diff --git a/app/src/main/assets/bitcoin.js b/app/src/main/assets/bitcoin.js index c35e90c5f..37782b591 100755 --- a/app/src/main/assets/bitcoin.js +++ b/app/src/main/assets/bitcoin.js @@ -1,2 +1,2 @@ /*! For license information please see bitcoin-lib.js.LICENSE.txt */ -(()=>{var t={242:(t,e,r)=>{"use strict";var n=r(1048).Buffer,i=r(4261),o=r(4500),s=r(9688);function a(t){var e=Object.create(null);return t&&Object.keys(t).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}})),e.default=t,Object.freeze(e)}var u=a(i);const f="Expected Private",c="Expected Point",h="Expected Tweak",p="Expected Signature",l="Expected Extra Data (32 bytes)",d="Expected Scalar";u.utils.hmacSha256Sync=(t,...e)=>o.hmac(s.sha256,t,u.utils.concatBytes(...e)),u.utils.sha256Sync=(...t)=>s.sha256(u.utils.concatBytes(...t));const y=u.utils._normalizePrivateKey,w=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65]),g=new Uint8Array(32),b=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,69,81,35,25,80,183,95,196,64,45,161,114,47,201,186,238]);function _(t,e){for(let r=0;r<32;++r)if(t[r]!==e[r])return t[r]=0)}function v(t){return t instanceof Uint8Array&&64===t.length&&_(t.subarray(0,32),w)<0&&_(t.subarray(32,64),w)<0}function S(t){return t instanceof Uint8Array&&32===t.length}function T(t){return void 0===t||t instanceof Uint8Array&&32===t.length}function I(t){if("string"!=typeof t)throw new TypeError("hexToNumber: expected string, got "+typeof t);return BigInt(`0x${t}`)}function k(t){let e;if("bigint"==typeof t)e=t;else if("number"==typeof t&&Number.isSafeInteger(t)&&t>=0)e=BigInt(t);else if("string"==typeof t){if(64!==t.length)throw new Error("Expected 32 bytes of private scalar");e=I(t)}else{if(!(t instanceof Uint8Array))throw new TypeError("Expected valid private scalar");if(32!==t.length)throw new Error("Expected 32 bytes of private scalar");r=t,e=I(u.utils.bytesToHex(r))}var r;if(e<0)throw new Error("Expected private scalar >= 0");return e}const P=(t,e,r)=>{const n=u.Point.fromHex(t),i=k(e),o=u.Point.BASE.multiplyAndAddUnsafe(n,i,BigInt(1));if(!o)throw new Error("Tweaked point at infinity");return o.toRawBytes(r)};function A(t,e){return void 0===t?void 0===e||U(e):!!t}function O(t){try{return t()}catch(t){return null}}function B(t,e){if(32===t.length!==e)return!1;try{return!!u.Point.fromHex(t)}catch(t){return!1}}function x(t){return B(t,!1)}function U(t){return B(t,!1)&&33===t.length}function R(t){return u.utils.isValidPrivateKey(t)}function N(t){return B(t,!0)}function L(t){if(!x(t))throw new Error(c);return t.slice(1,33)}function C(t,e){if(!R(t))throw new Error(f);return O((()=>u.getPublicKey(t,A(e))))}e.isPoint=x,e.isPointCompressed=U,e.isPrivate=R,e.isXOnlyPoint=N,e.pointAdd=function(t,e,r){if(!x(t)||!x(e))throw new Error(c);return O((()=>{const n=u.Point.fromHex(t),i=u.Point.fromHex(e);return n.equals(i.negate())?null:n.add(i).toRawBytes(A(r,t))}))},e.pointAddScalar=function(t,e,r){if(!x(t))throw new Error(c);if(!E(e))throw new Error(h);return O((()=>P(t,e,A(r,t))))},e.pointCompress=function(t,e){if(!x(t))throw new Error(c);return u.Point.fromHex(t).toRawBytes(A(e,t))},e.pointFromScalar=C,e.pointMultiply=function(t,e,r){if(!x(t))throw new Error(c);if(!E(e))throw new Error(h);return O((()=>((t,e,r)=>{const n=u.Point.fromHex(t),i="string"==typeof e?e:u.utils.bytesToHex(e),o=BigInt(`0x${i}`);return n.multiply(o).toRawBytes(r)})(t,e,A(r,t))))},e.privateAdd=function(t,e){if(!1===R(t))throw new Error(f);if(!1===E(e))throw new Error(h);return O((()=>((t,e)=>{const r=y(t),n=k(e),i=u.utils._bigintTo32Bytes(u.utils.mod(r+n,u.CURVE.n));return u.utils.isValidPrivateKey(i)?i:null})(t,e)))},e.privateNegate=function(t){if(!1===R(t))throw new Error(f);return(t=>{const e=y(t),r=u.utils._bigintTo32Bytes(u.CURVE.n-e);return u.utils.isValidPrivateKey(r)?r:null})(t)},e.privateSub=function(t,e){if(!1===R(t))throw new Error(f);if(!1===E(e))throw new Error(h);return O((()=>((t,e)=>{const r=y(t),n=k(e),i=u.utils._bigintTo32Bytes(u.utils.mod(r-n,u.CURVE.n));return u.utils.isValidPrivateKey(i)?i:null})(t,e)))},e.recover=function(t,e,r,n){if(!S(t))throw new Error("Expected Hash");if(!v(e)||!function(t){return!(m(t.subarray(0,32))||m(t.subarray(32,64)))}(e))throw new Error(p);if(2&r&&!function(t){return t instanceof Uint8Array&&64===t.length&&_(t.subarray(0,32),b)<0}(e))throw new Error("Bad Recovery Id");if(!N(e.subarray(0,32)))throw new Error(p);return u.recoverPublicKey(t,e,r,A(n))},e.sign=function(t,e,r){if(!R(e))throw new Error(f);if(!S(t))throw new Error(d);if(!T(r))throw new Error(l);return u.signSync(t,e,{der:!1,extraEntropy:r})},e.signRecoverable=function(t,e,r){if(!R(e))throw new Error(f);if(!S(t))throw new Error(d);if(!T(r))throw new Error(l);const[n,i]=u.signSync(t,e,{der:!1,extraEntropy:r,recovered:!0});return{signature:n,recoveryId:i}},e.signSchnorr=function(t,e,r=n.alloc(32,0)){if(!R(e))throw new Error(f);if(!S(t))throw new Error(d);if(!T(r))throw new Error(l);return u.schnorr.signSync(t,e,r)},e.verify=function(t,e,r,n){if(!x(e))throw new Error(c);if(!v(r))throw new Error(p);if(!S(t))throw new Error(d);return u.verify(r,t,e,{strict:n})},e.verifySchnorr=function(t,e,r){if(!N(e))throw new Error(c);if(!v(r))throw new Error(p);if(!S(t))throw new Error(d);return u.schnorr.verifySync(r,t,e)},e.xOnlyPointAddTweak=function(t,e){if(!N(t))throw new Error(c);if(!E(e))throw new Error(h);return O((()=>{const r=P(t,e,!0);return{parity:r[0]%2==1?1:0,xOnlyPubkey:r.slice(1)}}))},e.xOnlyPointFromPoint=L,e.xOnlyPointFromScalar=function(t){if(!R(t))throw new Error(f);return L(C(t))}},8460:(t,e)=>{"use strict";function r(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function n(t){if("boolean"!=typeof t)throw new Error(`boolean expected, not ${t}`)}function i(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name}function o(t,...e){if(!i(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function s(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");r(t.outputLen),r(t.blockLen)}function a(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function u(t,e){o(t);const r=e.outputLen;if(t.length{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.HashMD=e.Maj=e.Chi=void 0;const n=r(8460),i=r(9074);e.Chi=(t,e,r)=>t&e^~t&r,e.Maj=(t,e,r)=>t&e^t&r^e&r;class o extends i.Hash{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,i.createView)(this.buffer)}update(t){(0,n.exists)(this);const{view:e,buffer:r,blockLen:o}=this,s=(t=(0,i.toBytes)(t)).length;for(let n=0;no-a&&(this.process(r,0),a=0);for(let t=a;t>i&o),a=Number(r&o),u=n?4:0,f=n?0:4;t.setUint32(e+u,s,n),t.setUint32(e+f,a,n)}(r,o-8,BigInt(8*this.length),s),this.process(r,0);const u=(0,i.createView)(t),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=f/4,h=this.get();if(c>h.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.crypto=void 0,e.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0},4500:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const n=r(8460),i=r(9074);class o extends i.Hash{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,(0,n.hash)(t);const r=(0,i.toBytes)(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,s=new Uint8Array(o);s.set(r.length>o?t.create().update(r).digest():r);for(let t=0;tnew o(t,e).update(r).digest(),e.hmac.create=(t,e)=>new o(t,e)},71:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ripemd160=e.RIPEMD160=void 0;const n=r(6423),i=r(9074),o=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),s=new Uint8Array(new Array(16).fill(0).map(((t,e)=>e)));let a=[s],u=[s.map((t=>(9*t+5)%16))];for(let t=0;t<4;t++)for(let e of[a,u])e.push(e[t].map((t=>o[t])));const f=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map((t=>new Uint8Array(t))),c=a.map(((t,e)=>t.map((t=>f[e][t])))),h=u.map(((t,e)=>t.map((t=>f[e][t])))),p=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),l=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function d(t,e,r,n){return 0===t?e^r^n:1===t?e&r|~e&n:2===t?(e|~r)^n:3===t?e&n|r&~n:e^(r|~n)}const y=new Uint32Array(16);class w extends n.HashMD{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:e,h2:r,h3:n,h4:i}=this;return[t,e,r,n,i]}set(t,e,r,n,i){this.h0=0|t,this.h1=0|e,this.h2=0|r,this.h3=0|n,this.h4=0|i}process(t,e){for(let r=0;r<16;r++,e+=4)y[r]=t.getUint32(e,!0);let r=0|this.h0,n=r,o=0|this.h1,s=o,f=0|this.h2,w=f,g=0|this.h3,b=g,_=0|this.h4,m=_;for(let t=0;t<5;t++){const e=4-t,E=p[t],v=l[t],S=a[t],T=u[t],I=c[t],k=h[t];for(let e=0;e<16;e++){const n=(0,i.rotl)(r+d(t,o,f,g)+y[S[e]]+E,I[e])+_|0;r=_,_=g,g=0|(0,i.rotl)(f,10),f=o,o=n}for(let t=0;t<16;t++){const r=(0,i.rotl)(n+d(e,s,w,b)+y[T[t]]+v,k[t])+m|0;n=m,m=b,b=0|(0,i.rotl)(w,10),w=s,s=r}}this.set(this.h1+f+b|0,this.h2+g+m|0,this.h3+_+n|0,this.h4+r+s|0,this.h0+o+w|0)}roundClean(){y.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}e.RIPEMD160=w,e.ripemd160=(0,i.wrapConstructor)((()=>new w))},874:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.sha1=e.SHA1=void 0;const n=r(6423),i=r(9074),o=new Uint32Array([1732584193,4023233417,2562383102,271733878,3285377520]),s=new Uint32Array(80);class a extends n.HashMD{constructor(){super(64,20,8,!1),this.A=0|o[0],this.B=0|o[1],this.C=0|o[2],this.D=0|o[3],this.E=0|o[4]}get(){const{A:t,B:e,C:r,D:n,E:i}=this;return[t,e,r,n,i]}set(t,e,r,n,i){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i}process(t,e){for(let r=0;r<16;r++,e+=4)s[r]=t.getUint32(e,!1);for(let t=16;t<80;t++)s[t]=(0,i.rotl)(s[t-3]^s[t-8]^s[t-14]^s[t-16],1);let{A:r,B:o,C:a,D:u,E:f}=this;for(let t=0;t<80;t++){let e,c;t<20?(e=(0,n.Chi)(o,a,u),c=1518500249):t<40?(e=o^a^u,c=1859775393):t<60?(e=(0,n.Maj)(o,a,u),c=2400959708):(e=o^a^u,c=3395469782);const h=(0,i.rotl)(r,5)+e+f+c+s[t]|0;f=u,u=a,a=(0,i.rotl)(o,30),o=r,r=h}r=r+this.A|0,o=o+this.B|0,a=a+this.C|0,u=u+this.D|0,f=f+this.E|0,this.set(r,o,a,u,f)}roundClean(){s.fill(0)}destroy(){this.set(0,0,0,0,0),this.buffer.fill(0)}}e.SHA1=a,e.sha1=(0,i.wrapConstructor)((()=>new a))},9688:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.sha224=e.sha256=e.SHA256=void 0;const n=r(6423),i=r(9074),o=new Uint32Array([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]),s=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);class u extends n.HashMD{constructor(){super(64,32,8,!1),this.A=0|s[0],this.B=0|s[1],this.C=0|s[2],this.D=0|s[3],this.E=0|s[4],this.F=0|s[5],this.G=0|s[6],this.H=0|s[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[t,e,r,n,i,o,s,a]}set(t,e,r,n,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)a[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=a[t-15],r=a[t-2],n=(0,i.rotr)(e,7)^(0,i.rotr)(e,18)^e>>>3,o=(0,i.rotr)(r,17)^(0,i.rotr)(r,19)^r>>>10;a[t]=o+a[t-7]+n+a[t-16]|0}let{A:r,B:s,C:u,D:f,E:c,F:h,G:p,H:l}=this;for(let t=0;t<64;t++){const e=l+((0,i.rotr)(c,6)^(0,i.rotr)(c,11)^(0,i.rotr)(c,25))+(0,n.Chi)(c,h,p)+o[t]+a[t]|0,d=((0,i.rotr)(r,2)^(0,i.rotr)(r,13)^(0,i.rotr)(r,22))+(0,n.Maj)(r,s,u)|0;l=p,p=h,h=c,c=f+e|0,f=u,u=s,s=r,r=e+d|0}r=r+this.A|0,s=s+this.B|0,u=u+this.C|0,f=f+this.D|0,c=c+this.E|0,h=h+this.F|0,p=p+this.G|0,l=l+this.H|0,this.set(r,s,u,f,c,h,p,l)}roundClean(){a.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}e.SHA256=u;class f extends u{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}e.sha256=(0,i.wrapConstructor)((()=>new u)),e.sha224=(0,i.wrapConstructor)((()=>new f))},9074:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Hash=e.nextTick=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=void 0,e.isBytes=function(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name},e.byteSwap32=function(t){for(let r=0;r=0&&tt().update(f(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e},e.wrapConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(f(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.wrapXOFConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(f(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.randomBytes=function(t=32){if(n.crypto&&"function"==typeof n.crypto.getRandomValues)return n.crypto.getRandomValues(new Uint8Array(t));if(n.crypto&&"function"==typeof n.crypto.randomBytes)return n.crypto.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")};const n=r(6910),i=r(8460);e.u8=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength),e.u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),e.createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),e.rotr=(t,e)=>t<<32-e|t>>>e,e.rotl=(t,e)=>t<>>32-e>>>0,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],e.byteSwap=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255,e.byteSwapIfBE=e.isLE?t=>t:t=>(0,e.byteSwap)(t);const o=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0"))),s={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function a(t){return t>=s._0&&t<=s._9?t-s._0:t>=s._A&&t<=s._F?t-(s._A-10):t>=s._a&&t<=s._f?t-(s._a-10):void 0}function u(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}function f(t){return"string"==typeof t&&(t=u(t)),(0,i.bytes)(t),t}e.nextTick=async()=>{},e.Hash=class{clone(){return this._cloneInto()}};const c={}.toString},4261:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.utils=e.schnorr=e.verify=e.signSync=e.sign=e.getSharedSecret=e.recoverPublicKey=e.getPublicKey=e.Signature=e.Point=e.CURVE=void 0;const n=r(2028),i=BigInt(0),o=BigInt(1),s=BigInt(2),a=BigInt(3),u=BigInt(8),f=Object.freeze({a:i,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:o,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")});e.CURVE=f;const c=(t,e)=>(t+e/s)/e,h={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(t){const{n:e}=f,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-o*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=r,a=BigInt("0x100000000000000000000000000000000"),u=c(s*t,e),h=c(-n*t,e);let p=D(t-u*r-h*i,e),l=D(-u*n-h*s,e);const d=p>a,y=l>a;if(d&&(p=e-p),y&&(l=e-l),p>a||l>a)throw new Error("splitScalarEndo: Endomorphism failed, k="+t);return{k1neg:d,k1:p,k2neg:y,k2:l}}},p=32,l=32,d=p+1,y=2*p+1;function w(t){const{a:e,b:r}=f,n=D(t*t),i=D(n*t);return D(i+e*t+r)}const g=f.a===i;class b extends Error{constructor(t){super(t)}}function _(t){if(!(t instanceof m))throw new TypeError("JacobianPoint expected")}class m{constructor(t,e,r){this.x=t,this.y=e,this.z=r}static fromAffine(t){if(!(t instanceof S))throw new TypeError("JacobianPoint#fromAffine: expected Point");return t.equals(S.ZERO)?m.ZERO:new m(t.x,t.y,o)}static toAffineBatch(t){const e=function(t,e=f.P){const r=new Array(t.length),n=F(t.reduce(((t,n,o)=>n===i?t:(r[o]=t,D(t*n,e))),o),e);return t.reduceRight(((t,n,o)=>n===i?t:(r[o]=D(t*r[o],e),D(t*n,e))),n),r}(t.map((t=>t.z)));return t.map(((t,r)=>t.toAffine(e[r])))}static normalizeZ(t){return m.toAffineBatch(t).map(m.fromAffine)}equals(t){_(t);const{x:e,y:r,z:n}=this,{x:i,y:o,z:s}=t,a=D(n*n),u=D(s*s),f=D(e*u),c=D(i*a),h=D(D(r*s)*u),p=D(D(o*n)*a);return f===c&&h===p}negate(){return new m(this.x,D(-this.y),this.z)}double(){const{x:t,y:e,z:r}=this,n=D(t*t),i=D(e*e),o=D(i*i),f=t+i,c=D(s*(D(f*f)-n-o)),h=D(a*n),p=D(h*h),l=D(p-s*c),d=D(h*(c-l)-u*o),y=D(s*e*r);return new m(l,d,y)}add(t){_(t);const{x:e,y:r,z:n}=this,{x:o,y:a,z:u}=t;if(o===i||a===i)return this;if(e===i||r===i)return t;const f=D(n*n),c=D(u*u),h=D(e*c),p=D(o*f),l=D(D(r*u)*c),d=D(D(a*n)*f),y=D(p-h),w=D(d-l);if(y===i)return w===i?this.double():m.ZERO;const g=D(y*y),b=D(y*g),E=D(h*g),v=D(w*w-b-s*E),S=D(w*(E-v)-l*b),T=D(n*u*y);return new m(v,S,T)}subtract(t){return this.add(t.negate())}multiplyUnsafe(t){const e=m.ZERO;if("bigint"==typeof t&&t===i)return e;let r=M(t);if(r===o)return this;if(!g){let t=e,n=this;for(;r>i;)r&o&&(t=t.add(n)),n=n.double(),r>>=o;return t}let{k1neg:n,k1:s,k2neg:a,k2:u}=h.splitScalar(r),f=e,c=e,p=this;for(;s>i||u>i;)s&o&&(f=f.add(p)),u&o&&(c=c.add(p)),p=p.double(),s>>=o,u>>=o;return n&&(f=f.negate()),a&&(c=c.negate()),c=new m(D(c.x*h.beta),c.y,c.z),f.add(c)}precomputeWindow(t){const e=g?128/t+1:256/t+1,r=[];let n=this,i=n;for(let o=0;o>=h,a>u&&(a-=c,t+=o);const p=r,l=r+Math.abs(a)-1,d=e%2!=0,y=a<0;0===a?s=s.add(E(d,n[p])):i=i.add(E(y,n[l]))}return{p:i,f:s}}multiply(t,e){let r,n,i=M(t);if(g){const{k1neg:t,k1:o,k2neg:s,k2:a}=h.splitScalar(i);let{p:u,f}=this.wNAF(o,e),{p:c,f:p}=this.wNAF(a,e);u=E(t,u),c=E(s,c),c=new m(D(c.x*h.beta),c.y,c.z),r=u.add(c),n=f.add(p)}else{const{p:t,f:o}=this.wNAF(i,e);r=t,n=o}return m.normalizeZ([r,n])[0]}toAffine(t){const{x:e,y:r,z:n}=this,i=this.equals(m.ZERO);null==t&&(t=i?u:F(n));const s=t,a=D(s*s),f=D(a*s),c=D(e*a),h=D(r*f),p=D(n*s);if(i)return S.ZERO;if(p!==o)throw new Error("invZ was invalid");return new S(c,h)}}function E(t,e){const r=e.negate();return t?r:e}m.BASE=new m(f.Gx,f.Gy,o),m.ZERO=new m(i,o,i);const v=new WeakMap;class S{constructor(t,e){this.x=t,this.y=e}_setWindowSize(t){this._WINDOW_SIZE=t,v.delete(this)}hasEvenY(){return this.y%s===i}static fromCompressedHex(t){const e=32===t.length,r=C(e?t:t.subarray(1));if(!X(r))throw new Error("Point is not on curve");let n=function(t){const{P:e}=f,r=BigInt(6),n=BigInt(11),i=BigInt(22),o=BigInt(23),u=BigInt(44),c=BigInt(88),h=t*t*t%e,p=h*h*t%e,l=j(p,a)*p%e,d=j(l,a)*p%e,y=j(d,s)*h%e,w=j(y,n)*y%e,g=j(w,i)*w%e,b=j(g,u)*g%e,_=j(b,c)*b%e,m=j(_,u)*g%e,E=j(m,a)*p%e,v=j(E,o)*w%e,S=j(v,r)*h%e,T=j(S,s);if(T*T%e!==t)throw new Error("Cannot find square root");return T}(w(r));const i=(n&o)===o;e?i&&(n=D(-n)):!(1&~t[0])!==i&&(n=D(-n));const u=new S(r,n);return u.assertValidity(),u}static fromUncompressedHex(t){const e=C(t.subarray(1,p+1)),r=C(t.subarray(p+1,2*p+1)),n=new S(e,r);return n.assertValidity(),n}static fromHex(t){const e=H(t),r=e.length,n=e[0];if(r===p)return this.fromCompressedHex(e);if(r===d&&(2===n||3===n))return this.fromCompressedHex(e);if(r===y&&4===n)return this.fromUncompressedHex(e);throw new Error(`Point.fromHex: received invalid point. Expected 32-${d} compressed bytes or ${y} uncompressed bytes, not ${r}`)}static fromPrivateKey(t){return S.BASE.multiply(z(t))}static fromSignature(t,e,r){const{r:n,s:i}=J(e);if(![0,1,2,3].includes(r))throw new Error("Cannot recover: invalid recovery bit");const o=K(H(t)),{n:s}=f,a=2===r||3===r?n+s:n,u=F(a,s),c=D(-o*u,s),h=D(i*u,s),p=1&r?"03":"02",l=S.fromHex(p+x(a)),d=S.BASE.multiplyAndAddUnsafe(l,c,h);if(!d)throw new Error("Cannot recover signature: point at infinify");return d.assertValidity(),d}toRawBytes(t=!1){return L(this.toHex(t))}toHex(t=!1){const e=x(this.x);return t?`${this.hasEvenY()?"02":"03"}${e}`:`04${e}${x(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const t="Point is not on elliptic curve",{x:e,y:r}=this;if(!X(e)||!X(r))throw new Error(t);const n=D(r*r);if(D(n-w(e))!==i)throw new Error(t)}equals(t){return this.x===t.x&&this.y===t.y}negate(){return new S(this.x,D(-this.y))}double(){return m.fromAffine(this).double().toAffine()}add(t){return m.fromAffine(this).add(m.fromAffine(t)).toAffine()}subtract(t){return this.add(t.negate())}multiply(t){return m.fromAffine(this).multiply(t,this).toAffine()}multiplyAndAddUnsafe(t,e,r){const n=m.fromAffine(this),s=e===i||e===o||this!==S.BASE?n.multiplyUnsafe(e):n.multiply(e),a=m.fromAffine(t).multiplyUnsafe(r),u=s.add(a);return u.equals(m.ZERO)?void 0:u.toAffine()}}function T(t){return Number.parseInt(t[0],16)>=8?"00"+t:t}function I(t){if(t.length<2||2!==t[0])throw new Error(`Invalid signature integer tag: ${O(t)}`);const e=t[1],r=t.subarray(2,e+2);if(!e||r.length!==e)throw new Error("Invalid signature integer: wrong length");if(0===r[0]&&r[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:C(r),left:t.subarray(e+2)}}e.Point=S,S.BASE=new S(f.Gx,f.Gy),S.ZERO=new S(i,i);class k{constructor(t,e){this.r=t,this.s=e,this.assertValidity()}static fromCompact(t){const e=t instanceof Uint8Array,r="Signature.fromCompact";if("string"!=typeof t&&!e)throw new TypeError(`${r}: Expected string or Uint8Array`);const n=e?O(t):t;if(128!==n.length)throw new Error(`${r}: Expected 64-byte hex`);return new k(N(n.slice(0,64)),N(n.slice(64,128)))}static fromDER(t){const e=t instanceof Uint8Array;if("string"!=typeof t&&!e)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r,s:n}=function(t){if(t.length<2||48!=t[0])throw new Error(`Invalid signature tag: ${O(t)}`);if(t[1]!==t.length-2)throw new Error("Invalid signature: incorrect length");const{data:e,left:r}=I(t.subarray(2)),{data:n,left:i}=I(r);if(i.length)throw new Error(`Invalid signature: left bytes after parsing: ${O(i)}`);return{r:e,s:n}}(e?t:L(t));return new k(r,n)}static fromHex(t){return this.fromDER(t)}assertValidity(){const{r:t,s:e}=this;if(!q(t))throw new Error("Invalid Signature: r must be 0 < r < n");if(!q(e))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const t=f.n>>o;return this.s>t}normalizeS(){return this.hasHighS()?new k(this.r,D(-this.s,f.n)):this}toDERRawBytes(){return L(this.toDERHex())}toDERHex(){const t=T(R(this.s)),e=T(R(this.r)),r=t.length/2,n=e.length/2,i=R(r),o=R(n);return`30${R(n+r+4)}02${o}${e}02${i}${t}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return L(this.toCompactHex())}toCompactHex(){return x(this.r)+x(this.s)}}function P(...t){if(!t.every((t=>t instanceof Uint8Array)))throw new Error("Uint8Array list expected");if(1===t.length)return t[0];const e=t.reduce(((t,e)=>t+e.length),0),r=new Uint8Array(e);for(let e=0,n=0;ee.toString(16).padStart(2,"0")));function O(t){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");let e="";for(let r=0;r0)return BigInt(t);if("bigint"==typeof t&&q(t))return t;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function D(t,e=f.P){const r=t%e;return r>=i?r:e+r}function j(t,e){const{P:r}=f;let n=t;for(;e-- >i;)n*=n,n%=r;return n}function F(t,e=f.P){if(t===i||e<=i)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=D(t,e),n=e,s=i,a=o,u=o,c=i;for(;r!==i;){const t=n/r,e=n%r,i=s-u*t,o=a-c*t;n=r,r=e,s=u,a=c,u=i,c=o}if(n!==o)throw new Error("invert: does not exist");return D(s,e)}function K(t,e=!1){const r=function(t){const e=8*t.length-8*l,r=C(t);return e>0?r>>BigInt(e):r}(t);if(e)return r;const{n}=f;return r>=n?r-n:r}let V,W;class G{constructor(t,e){if(this.hashLen=t,this.qByteLen=e,"number"!=typeof t||t<2)throw new Error("hashLen must be a number");if("number"!=typeof e||e<2)throw new Error("qByteLen must be a number");this.v=new Uint8Array(t).fill(1),this.k=new Uint8Array(t).fill(0),this.counter=0}hmac(...t){return e.utils.hmacSha256(this.k,...t)}hmacSync(...t){return W(this.k,...t)}checkSync(){if("function"!=typeof W)throw new b("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}async reseed(t=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),t),this.v=await this.hmac(this.v),0!==t.length&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),t),this.v=await this.hmac(this.v))}reseedSync(t=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),t),this.v=this.hmacSync(this.v),0!==t.length&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),t),this.v=this.hmacSync(this.v))}async generate(){this.incr();let t=0;const e=[];for(;t0)e=BigInt(t);else if("string"==typeof t){if(t.length!==2*l)throw new Error("Expected 32 bytes of private key");e=N(t)}else{if(!(t instanceof Uint8Array))throw new TypeError("Expected valid private key");if(t.length!==l)throw new Error("Expected 32 bytes of private key");e=C(t)}if(!q(e))throw new Error("Expected private key: 0 < key < n");return e}function Y(t){return t instanceof S?(t.assertValidity(),t):S.fromHex(t)}function J(t){if(t instanceof k)return t.assertValidity(),t;try{return k.fromDER(t)}catch(e){return k.fromCompact(t)}}function Q(t){const e=t instanceof Uint8Array,r="string"==typeof t,n=(e||r)&&t.length;return e?n===d||n===y:r?n===2*d||n===2*y:t instanceof S}function Z(t){return C(t.length>p?t.slice(0,p):t)}function tt(t){const e=Z(t),r=D(e,f.n);return et(r{t=H(t);const e=l+8;if(t.length1024)throw new Error("Expected valid bytes of private key as per FIPS 186");return U(D(C(t),f.n-o)+o)},randomBytes:(t=32)=>{if(pt.web)return pt.web.getRandomValues(new Uint8Array(t));if(pt.node){const{randomBytes:e}=pt.node;return Uint8Array.from(e(t))}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>e.utils.hashToPrivateKey(e.utils.randomBytes(l+8)),precompute(t=8,e=S.BASE){const r=e===S.BASE?e:new S(e.x,e.y);return r._setWindowSize(t),r.multiply(a),r},sha256:async(...t)=>{if(pt.web){const e=await pt.web.subtle.digest("SHA-256",P(...t));return new Uint8Array(e)}if(pt.node){const{createHash:e}=pt.node,r=e("sha256");return t.forEach((t=>r.update(t))),Uint8Array.from(r.digest())}throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(t,...e)=>{if(pt.web){const r=await pt.web.subtle.importKey("raw",t,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),n=P(...e),i=await pt.web.subtle.sign("HMAC",r,n);return new Uint8Array(i)}if(pt.node){const{createHmac:r}=pt.node,n=r("sha256",t);return e.forEach((t=>n.update(t))),Uint8Array.from(n.digest())}throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(t,...r)=>{let n=dt[t];if(void 0===n){const r=await e.utils.sha256(Uint8Array.from(t,(t=>t.charCodeAt(0))));n=P(r,r),dt[t]=n}return e.utils.sha256(n,...r)},taggedHashSync:(t,...e)=>{if("function"!=typeof V)throw new b("sha256Sync is undefined, you need to set it");let r=dt[t];if(void 0===r){const e=V(Uint8Array.from(t,(t=>t.charCodeAt(0))));r=P(e,e),dt[t]=r}return V(r,...e)},_JacobianPoint:m},Object.defineProperties(e.utils,{sha256Sync:{configurable:!1,get:()=>V,set(t){V||(V=t)}},hmacSha256Sync:{configurable:!1,get:()=>W,set(t){W||(W=t)}}})},7991:(t,e)=>{"use strict";e.byteLength=function(t){var e=a(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,o=a(t),s=o[0],u=o[1],f=new i(function(t,e,r){return 3*(e+r)/4-r}(0,s,u)),c=0,h=u>0?s-4:s;for(r=0;r>16&255,f[c++]=e>>8&255,f[c++]=255&e;return 2===u&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,f[c++]=255&e),1===u&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,f[c++]=e>>8&255,f[c++]=255&e),f},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],s=16383,a=0,f=n-i;af?f:a+s));return 1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),o.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)r[s]=o[s],n[o.charCodeAt(s)]=s;function a(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function u(t,e,n){for(var i,o,s=[],a=e;a>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return s.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},6586:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.bech32m=e.bech32=void 0;const r="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n={};for(let t=0;t<32;t++){const e=r.charAt(t);n[e]=t}function i(t){const e=t>>25;return(33554431&t)<<5^996825010&-(1&e)^642813549&-(e>>1&1)^513874426&-(e>>2&1)^1027748829&-(e>>3&1)^705979059&-(e>>4&1)}function o(t){let e=1;for(let r=0;r126)return"Invalid prefix ("+t+")";e=i(e)^n>>5}e=i(e);for(let r=0;r=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<=e)return"Excess padding";if(i<r)return"Exceeds length limit";const s=t.toLowerCase(),a=t.toUpperCase();if(t!==s&&t!==a)return"Mixed-case string "+t;const u=(t=s).lastIndexOf("1");if(-1===u)return"No separator character for "+t;if(0===u)return"Missing prefix for "+t;const f=t.slice(0,u),c=t.slice(u+1);if(c.length<6)return"Data too short";let h=o(f);if("string"==typeof h)return h;const p=[];for(let t=0;t=c.length||p.push(r)}return h!==e?"Invalid checksum for "+t:{prefix:f,words:p}}return e="bech32"===t?1:734539939,{decodeUnsafe:function(t,e){const r=s(t,e);if("object"==typeof r)return r},decode:function(t,e){const r=s(t,e);if("object"==typeof r)return r;throw new Error(r)},encode:function(t,n,s){if(s=s||90,t.length+7+n.length>s)throw new TypeError("Exceeds length limit");let a=o(t=t.toLowerCase());if("string"==typeof a)throw new Error(a);let u=t+"1";for(let t=0;t>5)throw new Error("Non 5-bit word");a=i(a)^e,u+=r.charAt(e)}for(let t=0;t<6;++t)a=i(a);a^=e;for(let t=0;t<6;++t)u+=r.charAt(a>>5*(5-t)&31);return u},toWords:a,fromWordsUnsafe:u,fromWords:f}}e.bech32=c("bech32"),e.bech32m=c("bech32m")},1048:(t,e,r)=>{"use strict";const n=r(7991),i=r(9318),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=u,e.SlowBuffer=function(t){return+t!=t&&(t=0),u.alloc(+t)},e.INSPECT_MAX_BYTES=50;const s=2147483647;function a(t){if(t>s)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return h(t)}return f(t,e,r)}function f(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=a(r);const i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(z(t,Uint8Array)){const e=new Uint8Array(t);return l(e.buffer,e.byteOffset,e.byteLength)}return p(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(z(t,ArrayBuffer)||t&&z(t.buffer,ArrayBuffer))return l(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(z(t,SharedArrayBuffer)||t&&z(t.buffer,SharedArrayBuffer)))return l(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const i=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=a(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||Y(t.length)?a(0):p(t):"Buffer"===t.type&&Array.isArray(t.data)?p(t.data):void 0}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function c(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function h(t){return c(t),a(t<0?0:0|d(t))}function p(t){const e=t.length<0?0:0|d(t.length),r=a(e);for(let n=0;n=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||z(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return X(t).length;default:if(i)return n?-1:q(t).length;e=(""+e).toLowerCase(),i=!0}}function w(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return B(this,e,r);case"utf8":case"utf-8":return k(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return O(this,e,r);case"base64":return I(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function g(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function b(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),Y(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:_(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):_(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function _(t,e,r,n,i){let o,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function f(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){let n=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){let r=!0;for(let n=0;ni&&(n=i):n=i;const o=e.length;let s;for(n>o/2&&(n=o/2),s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function I(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function k(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i239?4:e>223?3:e>191?2:1;if(i+s<=r){let r,n,a,u;switch(s){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(o=u));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:r=t[i+1],n=t[i+2],a=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&a,u>65535&&u<1114112&&(o=u))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return function(t){const e=t.length;if(e<=P)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i)}i+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;er&&(t+=" ... "),""},o&&(u.prototype[o]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,i){if(z(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0);const a=Math.min(o,s),f=this.slice(n,i),c=t.slice(e,r);for(let t=0;t>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return m(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return v(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const P=4096;function A(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;in)&&(r=n);let i="";for(let n=e;nr)throw new RangeError("Trying to access beyond buffer length")}function R(t,e,r,n,i,o){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function N(t,e,r,n,i){K(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,r}function L(t,e,r,n,i){K(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s>>=8,t[r+2]=s,s>>=8,t[r+1]=s,s>>=8,t[r]=s,r+8}function C(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function H(t,e,r,n,o){return e=+e,r>>>=0,o||C(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,o){return e=+e,r>>>=0,o||C(t,0,r,8),i.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||U(t,e,this.length);let n=this[t],i=1,o=0;for(;++o>>=0,e>>>=0,r||U(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||U(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||U(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||U(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||U(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||U(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Q((function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<>>=0,e>>>=0,r||U(t,e,this.length);let n=this[t],i=1,o=0;for(;++o=i&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||U(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},u.prototype.readInt8=function(t,e){return t>>>=0,e||U(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||U(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||U(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||U(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||U(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Q((function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||W(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<>>=0,e||U(t,4,this.length),i.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||U(t,4,this.length),i.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||U(t,8,this.length),i.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||U(t,8,this.length),i.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||R(this,t,e,r,Math.pow(2,8*r)-1,0);let i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n||R(this,t,e,r,Math.pow(2,8*r)-1,0);let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Q((function(t,e=0){return N(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Q((function(t,e=0){return L(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);R(this,t,e,r,n-1,-n)}let i=0,o=1,s=0;for(this[e]=255&t;++i>>=0,!n){const n=Math.pow(2,8*r-1);R(this,t,e,r,n-1,-n)}let i=r-1,o=1,s=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/o|0)-s&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||R(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Q((function(t,e=0){return N(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Q((function(t,e=0){return L(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return H(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return H(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function K(t,e,r,n,i,o){if(t>r||t3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(o+1)}${n}`:`>= -(2${n} ** ${8*(o+1)-1}${n}) and < 2 ** ${8*(o+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new D.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,r){V(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||W(e,t.length-(r+1))}(n,i,o)}function V(t,e){if("number"!=typeof t)throw new D.ERR_INVALID_ARG_TYPE(e,"number",t)}function W(t,e,r){if(Math.floor(t)!==t)throw V(t,r),new D.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new D.ERR_BUFFER_OUT_OF_BOUNDS;throw new D.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}j("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),j("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),j("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=F(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=F(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n}),RangeError);const G=/[^+/0-9A-Za-z-_]/g;function q(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let s=0;s55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function X(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(G,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function $(t,e,r,n){let i;for(i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function z(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Y(t){return t!=t}const J=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function Q(t){return"undefined"==typeof BigInt?Z:t}function Z(){throw new Error("BigInt not supported")}},7589:(t,e,r)=>{var n=r(5636).Buffer,i=r(1983).Transform,o=r(8888).I;function s(t){i.call(this),this.hashMode="string"==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}r(5615)(s,i),s.prototype.update=function(t,e,r){"string"==typeof t&&(t=n.from(t,e));var i=this._update(t);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)},s.prototype.setAutoPadding=function(){},s.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},s.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},s.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},s.prototype._transform=function(t,e,r){var n;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(t){n=t}finally{r(n)}},s.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(t){e=t}t(e)},s.prototype._finalOrDigest=function(t){var e=this.__final()||n.alloc(0);return t&&(e=this._toString(e,t,!0)),e},s.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new o(e),this._encoding=e),this._encoding!==e)throw new Error("can't switch encodings");var n=this._decoder.write(t);return r&&(n+=this._decoder.end()),n},t.exports=s},3257:(t,e,r)=>{"use strict";var n=r(5615),i=r(3275),o=r(5586),s=r(3229),a=r(7589);function u(t){a.call(this,"digest"),this._hash=t}n(u,a),u.prototype._update=function(t){this._hash.update(t)},u.prototype._final=function(){return this._hash.digest()},t.exports=function(t){return"md5"===(t=t.toLowerCase())?new i:"rmd160"===t||"ripemd160"===t?new o:new u(s(t))}},46:t=>{"use strict";var e,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};e=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var i=Number.isNaN||function(t){return t!=t};function o(){o.init.call(this)}t.exports=o,t.exports.once=function(t,e){return new Promise((function(r,n){function i(r){t.removeListener(e,o),n(r)}function o(){"function"==typeof t.removeListener&&t.removeListener("error",i),r([].slice.call(arguments))}y(t,e,o,{once:!0}),"error"!==e&&function(t,e){"function"==typeof t.on&&y(t,"error",e,{once:!0})}(t,i)}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function u(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function f(t,e,r,n){var i,o,s,f;if(a(r),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),s=o[e]),void 0===s)s=o[e]=r,++t._eventsCount;else if("function"==typeof s?s=o[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(i=u(t))>0&&s.length>i&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=s.length,f=c,console&&console.warn&&console.warn(f)}return t}function c(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=c.bind(n);return i.listener=r,n.wrapFn=i,i}function p(t,e,r){var n=t._events;if(void 0===n)return[];var i=n[e];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(t){for(var e=new Array(t.length),r=0;r0&&(s=e[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var u=o[t];if(void 0===u)return!1;if("function"==typeof u)n(u,this,e);else{var f=u.length,c=d(u,f);for(r=0;r=0;o--)if(r[o]===e||r[o].listener===e){s=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(t,e){for(;e+1=0;n--)this.removeListener(t,e[n]);return this},o.prototype.listeners=function(t){return p(this,t,!0)},o.prototype.rawListeners=function(t){return p(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):l.call(t,e)},o.prototype.listenerCount=l,o.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}},1848:(t,e,r)=>{"use strict";var n=r(5636).Buffer,i=r(4156).Transform;function o(t){i.call(this),this._block=n.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}r(5615)(o,i),o.prototype._transform=function(t,e,r){var n=null;try{this.update(t,e)}catch(t){n=t}r(n)},o.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)},o.prototype.update=function(t,e){if(function(t){if(!n.isBuffer(t)&&"string"!=typeof t)throw new TypeError("Data must be a string or a buffer")}(t),this._finalized)throw new Error("Digest already called");n.isBuffer(t)||(t=n.from(t,e));for(var r=this._block,i=0;this._blockOffset+t.length-i>=this._blockSize;){for(var o=this._blockOffset;o0;++s)this._length[s]+=a,(a=this._length[s]/4294967296|0)>0&&(this._length[s]-=4294967296*a);return this},o.prototype._update=function(){throw new Error("_update is not implemented")},o.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e},o.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=o},9318:(t,e)=>{e.read=function(t,e,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,c=-7,h=r?i-1:0,p=r?-1:1,l=t[e+h];for(h+=p,o=l&(1<<-c)-1,l>>=-c,c+=a;c>0;o=256*o+t[e+h],h+=p,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=n;c>0;s=256*s+t[e+h],h+=p,c-=8);if(0===o)o=1-f;else{if(o===u)return s?NaN:1/0*(l?-1:1);s+=Math.pow(2,n),o-=f}return(l?-1:1)*s*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var s,a,u,f=8*o-i-1,c=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,l=n?0:o-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+h>=1?p/u:p*Math.pow(2,1-h))*u>=2&&(s++,u/=2),s+h>=c?(a=0,s=c):s+h>=1?(a=(e*u-1)*Math.pow(2,i),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[r+l]=255&a,l+=d,a/=256,i-=8);for(s=s<0;t[r+l]=255&s,l+=d,s/=256,f-=8);t[r+l-d]|=128*y}},5615:t=>{"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},3275:(t,e,r)=>{"use strict";var n=r(5615),i=r(1848),o=r(5636).Buffer,s=new Array(16);function a(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function u(t,e){return t<>>32-e}function f(t,e,r,n,i,o,s){return u(t+(e&r|~e&n)+i+o|0,s)+e|0}function c(t,e,r,n,i,o,s){return u(t+(e&n|r&~n)+i+o|0,s)+e|0}function h(t,e,r,n,i,o,s){return u(t+(e^r^n)+i+o|0,s)+e|0}function p(t,e,r,n,i,o,s){return u(t+(r^(e|~n))+i+o|0,s)+e|0}n(a,i),a.prototype._update=function(){for(var t=s,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);var r=this._a,n=this._b,i=this._c,o=this._d;r=f(r,n,i,o,t[0],3614090360,7),o=f(o,r,n,i,t[1],3905402710,12),i=f(i,o,r,n,t[2],606105819,17),n=f(n,i,o,r,t[3],3250441966,22),r=f(r,n,i,o,t[4],4118548399,7),o=f(o,r,n,i,t[5],1200080426,12),i=f(i,o,r,n,t[6],2821735955,17),n=f(n,i,o,r,t[7],4249261313,22),r=f(r,n,i,o,t[8],1770035416,7),o=f(o,r,n,i,t[9],2336552879,12),i=f(i,o,r,n,t[10],4294925233,17),n=f(n,i,o,r,t[11],2304563134,22),r=f(r,n,i,o,t[12],1804603682,7),o=f(o,r,n,i,t[13],4254626195,12),i=f(i,o,r,n,t[14],2792965006,17),r=c(r,n=f(n,i,o,r,t[15],1236535329,22),i,o,t[1],4129170786,5),o=c(o,r,n,i,t[6],3225465664,9),i=c(i,o,r,n,t[11],643717713,14),n=c(n,i,o,r,t[0],3921069994,20),r=c(r,n,i,o,t[5],3593408605,5),o=c(o,r,n,i,t[10],38016083,9),i=c(i,o,r,n,t[15],3634488961,14),n=c(n,i,o,r,t[4],3889429448,20),r=c(r,n,i,o,t[9],568446438,5),o=c(o,r,n,i,t[14],3275163606,9),i=c(i,o,r,n,t[3],4107603335,14),n=c(n,i,o,r,t[8],1163531501,20),r=c(r,n,i,o,t[13],2850285829,5),o=c(o,r,n,i,t[2],4243563512,9),i=c(i,o,r,n,t[7],1735328473,14),r=h(r,n=c(n,i,o,r,t[12],2368359562,20),i,o,t[5],4294588738,4),o=h(o,r,n,i,t[8],2272392833,11),i=h(i,o,r,n,t[11],1839030562,16),n=h(n,i,o,r,t[14],4259657740,23),r=h(r,n,i,o,t[1],2763975236,4),o=h(o,r,n,i,t[4],1272893353,11),i=h(i,o,r,n,t[7],4139469664,16),n=h(n,i,o,r,t[10],3200236656,23),r=h(r,n,i,o,t[13],681279174,4),o=h(o,r,n,i,t[0],3936430074,11),i=h(i,o,r,n,t[3],3572445317,16),n=h(n,i,o,r,t[6],76029189,23),r=h(r,n,i,o,t[9],3654602809,4),o=h(o,r,n,i,t[12],3873151461,11),i=h(i,o,r,n,t[15],530742520,16),r=p(r,n=h(n,i,o,r,t[2],3299628645,23),i,o,t[0],4096336452,6),o=p(o,r,n,i,t[7],1126891415,10),i=p(i,o,r,n,t[14],2878612391,15),n=p(n,i,o,r,t[5],4237533241,21),r=p(r,n,i,o,t[12],1700485571,6),o=p(o,r,n,i,t[3],2399980690,10),i=p(i,o,r,n,t[10],4293915773,15),n=p(n,i,o,r,t[1],2240044497,21),r=p(r,n,i,o,t[8],1873313359,6),o=p(o,r,n,i,t[15],4264355552,10),i=p(i,o,r,n,t[6],2734768916,15),n=p(n,i,o,r,t[13],1309151649,21),r=p(r,n,i,o,t[4],4149444226,6),o=p(o,r,n,i,t[11],3174756917,10),i=p(i,o,r,n,t[2],718787259,15),n=p(n,i,o,r,t[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+o|0},a.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=o.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t},t.exports=a},2644:(t,e,r)=>{"use strict";var n=65536,i=r(5636).Buffer,o=r.g.crypto||r.g.msCrypto;o&&o.getRandomValues?t.exports=function(t,e){if(t>4294967295)throw new RangeError("requested too many random bytes");var r=i.allocUnsafe(t);if(t>0)if(t>n)for(var s=0;s{"use strict";var e={};function r(t,r,n){n||(n=Error);var i=function(t){var e,n;function i(e,n,i){return t.call(this,function(t,e,n){return"string"==typeof r?r:r(t,e,n)}(e,n,i))||this}return n=t,(e=i).prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n,i}(n);i.prototype.name=n.name,i.prototype.code=t,e[t]=i}function n(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map((function(t){return String(t)})),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}r("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),r("ERR_INVALID_ARG_TYPE",(function(t,e,r){var i,o,s,a,u;if("string"==typeof e&&(o="not ",e.substr(0,4)===o)?(i="must not be",e=e.replace(/^not /,"")):i="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-9,r)===e}(t," argument"))s="The ".concat(t," ").concat(i," ").concat(n(e,"type"));else{var f=("number"!=typeof u&&(u=0),u+1>(a=t).length||-1===a.indexOf(".",u)?"argument":"property");s='The "'.concat(t,'" ').concat(f," ").concat(i," ").concat(n(e,"type"))}return s+". Received type ".concat(typeof r)}),TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.F=e},1265:(t,e,r)=>{"use strict";var n=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};t.exports=f;var i=r(8199),o=r(5291);r(5615)(f,i);for(var s=n(o.prototype),a=0;a{"use strict";t.exports=i;var n=r(9415);function i(t){if(!(this instanceof i))return new i(t);n.call(this,t)}r(5615)(i,n),i.prototype._transform=function(t,e,r){r(null,t)}},8199:(t,e,r)=>{"use strict";var n;t.exports=T,T.ReadableState=S,r(46).EventEmitter;var i,o=function(t,e){return t.listeners(e).length},s=r(4856),a=r(1048).Buffer,u=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},f=r(3951);i=f&&f.debuglog?f.debuglog("stream"):function(){};var c,h,p,l=r(82),d=r(6527),y=r(9952).getHighWaterMark,w=r(5699).F,g=w.ERR_INVALID_ARG_TYPE,b=w.ERR_STREAM_PUSH_AFTER_EOF,_=w.ERR_METHOD_NOT_IMPLEMENTED,m=w.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(5615)(T,s);var E=d.errorOrDestroy,v=["error","close","destroy","pause","resume"];function S(t,e,i){n=n||r(1265),t=t||{},"boolean"!=typeof i&&(i=e instanceof n),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=y(this,t,"readableHighWaterMark",i),this.buffer=new l,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(c||(c=r(8888).I),this.decoder=new c(t.encoding),this.encoding=t.encoding)}function T(t){if(n=n||r(1265),!(this instanceof T))return new T(t);var e=this instanceof n;this._readableState=new S(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),s.call(this)}function I(t,e,r,n,o){i("readableAddChunk",e);var s,f=t._readableState;if(null===e)f.reading=!1,function(t,e){if(i("onEofChunk"),!e.ended){if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?O(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,B(t)))}}(t,f);else if(o||(s=function(t,e){var r,n;return n=e,a.isBuffer(n)||n instanceof u||"string"==typeof e||void 0===e||t.objectMode||(r=new g("chunk",["string","Buffer","Uint8Array"],e)),r}(f,e)),s)E(t,s);else if(f.objectMode||e&&e.length>0)if("string"==typeof e||f.objectMode||Object.getPrototypeOf(e)===a.prototype||(e=function(t){return a.from(t)}(e)),n)f.endEmitted?E(t,new m):k(t,f,e,!0);else if(f.ended)E(t,new b);else{if(f.destroyed)return!1;f.reading=!1,f.decoder&&!r?(e=f.decoder.write(e),f.objectMode||0!==e.length?k(t,f,e,!1):x(t,f)):k(t,f,e,!1)}else n||(f.reading=!1,x(t,f));return!f.ended&&(f.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=P?t=P:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function O(t){var e=t._readableState;i("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(i("emitReadable",e.flowing),e.emittedReadable=!0,process.nextTick(B,t))}function B(t){var e=t._readableState;i("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,C(t)}function x(t,e){e.readingMore||(e.readingMore=!0,process.nextTick(U,t,e))}function U(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function N(t){i("readable nexttick read 0"),t.read(0)}function L(t,e){i("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),C(t),e.flowing&&!e.reading&&t.read(0)}function C(t){var e=t._readableState;for(i("flow",e.flowing);e.flowing&&null!==t.read(););}function H(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function M(t){var e=t._readableState;i("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,process.nextTick(D,e,t))}function D(t,e){if(i("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function j(t,e){for(var r=0,n=t.length;r=e.highWaterMark:e.length>0)||e.ended))return i("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?M(this):O(this),null;if(0===(t=A(t,e))&&e.ended)return 0===e.length&&M(this),null;var n,o=e.needReadable;return i("need readable",o),(0===e.length||e.length-t0?H(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&M(this)),null!==n&&this.emit("data",n),n},T.prototype._read=function(t){E(this,new _("_read()"))},T.prototype.pipe=function(t,e){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=t;break;case 1:n.pipes=[n.pipes,t];break;default:n.pipes.push(t)}n.pipesCount+=1,i("pipe count=%d opts=%j",n.pipesCount,e);var s=e&&!1===e.end||t===process.stdout||t===process.stderr?d:a;function a(){i("onend"),t.end()}n.endEmitted?process.nextTick(s):r.once("end",s),t.on("unpipe",(function e(o,s){i("onunpipe"),o===r&&s&&!1===s.hasUnpiped&&(s.hasUnpiped=!0,i("cleanup"),t.removeListener("close",p),t.removeListener("finish",l),t.removeListener("drain",u),t.removeListener("error",h),t.removeListener("unpipe",e),r.removeListener("end",a),r.removeListener("end",d),r.removeListener("data",c),f=!0,!n.awaitDrain||t._writableState&&!t._writableState.needDrain||u())}));var u=function(t){return function(){var e=t._readableState;i("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&o(t,"data")&&(e.flowing=!0,C(t))}}(r);t.on("drain",u);var f=!1;function c(e){i("ondata");var o=t.write(e);i("dest.write",o),!1===o&&((1===n.pipesCount&&n.pipes===t||n.pipesCount>1&&-1!==j(n.pipes,t))&&!f&&(i("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function h(e){i("onerror",e),d(),t.removeListener("error",h),0===o(t,"error")&&E(t,e)}function p(){t.removeListener("finish",l),d()}function l(){i("onfinish"),t.removeListener("close",p),d()}function d(){i("unpipe"),r.unpipe(t)}return r.on("data",c),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",h),t.once("close",p),t.once("finish",l),t.emit("pipe",r),n.flowing||(i("pipe resume"),r.resume()),t},T.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r)),this;if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o0,!1!==n.flowing&&this.resume()):"readable"===t&&(n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,i("on readable",n.length,n.reading),n.length?O(this):n.reading||process.nextTick(N,this))),r},T.prototype.addListener=T.prototype.on,T.prototype.removeListener=function(t,e){var r=s.prototype.removeListener.call(this,t,e);return"readable"===t&&process.nextTick(R,this),r},T.prototype.removeAllListeners=function(t){var e=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||process.nextTick(R,this),e},T.prototype.resume=function(){var t=this._readableState;return t.flowing||(i("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,process.nextTick(L,t,e))}(this,t)),t.paused=!1,this},T.prototype.pause=function(){return i("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(i("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},T.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var o in t.on("end",(function(){if(i("wrapped end"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(o){i("wrapped data"),r.decoder&&(o=r.decoder.write(o)),r.objectMode&&null==o||(r.objectMode||o&&o.length)&&(e.push(o)||(n=!0,t.pause()))})),t)void 0===this[o]&&"function"==typeof t[o]&&(this[o]=function(e){return function(){return t[e].apply(t,arguments)}}(o));for(var s=0;s{"use strict";t.exports=c;var n=r(5699).F,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,s=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=n.ERR_TRANSFORM_WITH_LENGTH_0,u=r(1265);function f(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=e&&this.push(e),n(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length{"use strict";function n(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e){var r=t.entry;for(t.entry=null;r;){var n=r.callback;e.pendingcb--,n(undefined),r=r.next}e.corkedRequestsFree.next=t}(e,t)}}var i;t.exports=T,T.WritableState=S;var o,s={deprecate:r(6732)},a=r(4856),u=r(1048).Buffer,f=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},c=r(6527),h=r(9952).getHighWaterMark,p=r(5699).F,l=p.ERR_INVALID_ARG_TYPE,d=p.ERR_METHOD_NOT_IMPLEMENTED,y=p.ERR_MULTIPLE_CALLBACK,w=p.ERR_STREAM_CANNOT_PIPE,g=p.ERR_STREAM_DESTROYED,b=p.ERR_STREAM_NULL_VALUES,_=p.ERR_STREAM_WRITE_AFTER_END,m=p.ERR_UNKNOWN_ENCODING,E=c.errorOrDestroy;function v(){}function S(t,e,o){i=i||r(1265),t=t||{},"boolean"!=typeof o&&(o=e instanceof i),this.objectMode=!!t.objectMode,o&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=h(this,t,"writableHighWaterMark",o),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===t.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,i=r.writecb;if("function"!=typeof i)throw new y;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,i){--e.pendingcb,r?(process.nextTick(i,n),process.nextTick(B,t,e),t._writableState.errorEmitted=!0,E(t,n)):(i(n),t._writableState.errorEmitted=!0,E(t,n),B(t,e))}(t,r,n,e,i);else{var o=A(r)||t.destroyed;o||r.corked||r.bufferProcessing||!r.bufferedRequest||P(t,r),n?process.nextTick(k,t,r,o,i):k(t,r,o,i)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new n(this)}function T(t){var e=this instanceof(i=i||r(1265));if(!e&&!o.call(T,this))return new T(t);this._writableState=new S(t,this,e),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),a.call(this)}function I(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new g("write")):r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function k(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),B(t,e)}function P(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var i=e.bufferedRequestCount,o=new Array(i),s=e.corkedRequestsFree;s.entry=r;for(var a=0,u=!0;r;)o[a]=r,r.isBuf||(u=!1),r=r.next,a+=1;o.allBuffers=u,I(t,e,!0,e.length,o,"",s.finish),e.pendingcb++,e.lastBufferedRequest=null,s.next?(e.corkedRequestsFree=s.next,s.next=null):e.corkedRequestsFree=new n(e),e.bufferedRequestCount=0}else{for(;r;){var f=r.chunk,c=r.encoding,h=r.callback;if(I(t,e,!1,e.objectMode?1:f.length,f,c,h),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function A(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function O(t,e){t._final((function(r){e.pendingcb--,r&&E(t,r),e.prefinished=!0,t.emit("prefinish"),B(t,e)}))}function B(t,e){var r=A(e);if(r&&(function(t,e){e.prefinished||e.finalCalled||("function"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit("prefinish")):(e.pendingcb++,e.finalCalled=!0,process.nextTick(O,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var n=t._readableState;(!n||n.autoDestroy&&n.endEmitted)&&t.destroy()}return r}r(5615)(T,a),S.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(S.prototype,"buffer",{get:s.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(o=Function.prototype[Symbol.hasInstance],Object.defineProperty(T,Symbol.hasInstance,{value:function(t){return!!o.call(this,t)||this===T&&t&&t._writableState instanceof S}})):o=function(t){return t instanceof this},T.prototype.pipe=function(){E(this,new w)},T.prototype.write=function(t,e,r){var n,i=this._writableState,o=!1,s=!i.objectMode&&(n=t,u.isBuffer(n)||n instanceof f);return s&&!u.isBuffer(t)&&(t=function(t){return u.from(t)}(t)),"function"==typeof e&&(r=e,e=null),s?e="buffer":e||(e=i.defaultEncoding),"function"!=typeof r&&(r=v),i.ending?function(t,e){var r=new _;E(t,r),process.nextTick(e,r)}(this,r):(s||function(t,e,r,n){var i;return null===r?i=new b:"string"==typeof r||e.objectMode||(i=new l("chunk",["string","Buffer"],r)),!i||(E(t,i),process.nextTick(n,i),!1)}(this,i,t,r))&&(i.pendingcb++,o=function(t,e,r,n,i,o){if(!r){var s=function(t,e,r){return t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=u.from(e,r)),e}(e,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=e.objectMode?1:n.length;e.length+=a;var f=e.length-1))throw new m(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(T.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(T.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),T.prototype._write=function(t,e,r){r(new d("_write()"))},T.prototype._writev=null,T.prototype.end=function(t,e,r){var n=this._writableState;return"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||function(t,e,r){e.ending=!0,B(t,e),r&&(e.finished?process.nextTick(r):t.once("finish",r)),e.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(T.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),T.prototype.destroy=c.destroy,T.prototype._undestroy=c.undestroy,T.prototype._destroy=function(t,e){e(t)}},534:(t,e,r)=>{"use strict";var n;function i(t,e,r){return(e=function(t){var e=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var o=r(4869),s=Symbol("lastResolve"),a=Symbol("lastReject"),u=Symbol("error"),f=Symbol("ended"),c=Symbol("lastPromise"),h=Symbol("handlePromise"),p=Symbol("stream");function l(t,e){return{value:t,done:e}}function d(t){var e=t[s];if(null!==e){var r=t[p].read();null!==r&&(t[c]=null,t[s]=null,t[a]=null,e(l(r,!1)))}}function y(t){process.nextTick(d,t)}var w=Object.getPrototypeOf((function(){})),g=Object.setPrototypeOf((i(n={get stream(){return this[p]},next:function(){var t=this,e=this[u];if(null!==e)return Promise.reject(e);if(this[f])return Promise.resolve(l(void 0,!0));if(this[p].destroyed)return new Promise((function(e,r){process.nextTick((function(){t[u]?r(t[u]):e(l(void 0,!0))}))}));var r,n=this[c];if(n)r=new Promise(function(t,e){return function(r,n){t.then((function(){e[f]?r(l(void 0,!0)):e[h](r,n)}),n)}}(n,this));else{var i=this[p].read();if(null!==i)return Promise.resolve(l(i,!1));r=new Promise(this[h])}return this[c]=r,r}},Symbol.asyncIterator,(function(){return this})),i(n,"return",(function(){var t=this;return new Promise((function(e,r){t[p].destroy(null,(function(t){t?r(t):e(l(void 0,!0))}))}))})),n),w);t.exports=function(t){var e,r=Object.create(g,(i(e={},p,{value:t,writable:!0}),i(e,s,{value:null,writable:!0}),i(e,a,{value:null,writable:!0}),i(e,u,{value:null,writable:!0}),i(e,f,{value:t._readableState.endEmitted,writable:!0}),i(e,h,{value:function(t,e){var n=r[p].read();n?(r[c]=null,r[s]=null,r[a]=null,t(l(n,!1))):(r[s]=t,r[a]=e)},writable:!0}),e));return r[c]=null,o(t,(function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=r[a];return null!==e&&(r[c]=null,r[s]=null,r[a]=null,e(t)),void(r[u]=t)}var n=r[s];null!==n&&(r[c]=null,r[s]=null,r[a]=null,n(l(void 0,!0))),r[f]=!0})),t.on("readable",y.bind(null,r)),r}},82:(t,e,r)=>{"use strict";function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function i(t){for(var e=1;e0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r}},{key:"concat",value:function(t){if(0===this.length)return u.alloc(0);for(var e,r,n,i=u.allocUnsafe(t>>>0),o=this.head,s=0;o;)e=o.data,r=i,n=s,u.prototype.copy.call(e,r,n),s+=o.data.length,o=o.next;return i}},{key:"consume",value:function(t,e){var r;return ti.length?i.length:t;if(o===i.length?n+=i:n+=i.slice(0,t),0==(t-=o)){o===i.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(t){var e=u.allocUnsafe(t),r=this.head,n=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var i=r.data,o=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,o),0==(t-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,e}},{key:c,value:function(t,e){return f(this,i(i({},e),{},{depth:0,customInspect:!1}))}}])&&s(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}()},6527:t=>{"use strict";function e(t,e){n(t,e),r(t)}function r(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function n(t,e){t.emit("error",e)}t.exports={destroy:function(t,i){var o=this,s=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;return s||a?(i?i(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(n,this,t)):process.nextTick(n,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!i&&t?o._writableState?o._writableState.errorEmitted?process.nextTick(r,o):(o._writableState.errorEmitted=!0,process.nextTick(e,o,t)):process.nextTick(e,o,t):i?(process.nextTick(r,o),i(t)):process.nextTick(r,o)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(t,e){var r=t._readableState,n=t._writableState;r&&r.autoDestroy||n&&n.autoDestroy?t.destroy(e):t.emit("error",e)}}},4869:(t,e,r)=>{"use strict";var n=r(5699).F.ERR_STREAM_PREMATURE_CLOSE;function i(){}t.exports=function t(e,r,o){if("function"==typeof r)return t(e,null,r);r||(r={}),o=function(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,n=new Array(r),i=0;i{t.exports=function(){throw new Error("Readable.from is not available in the browser")}},6815:(t,e,r)=>{"use strict";var n,i=r(5699).F,o=i.ERR_MISSING_ARGS,s=i.ERR_STREAM_DESTROYED;function a(t){if(t)throw t}function u(t){t()}function f(t,e){return t.pipe(e)}t.exports=function(){for(var t=arguments.length,e=new Array(t),i=0;i0,(function(t){c||(c=t),t&&p.forEach(u),o||(p.forEach(u),h(c))}))}));return e.reduce(f)}},9952:(t,e,r)=>{"use strict";var n=r(5699).F.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,r,i){var o=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new n(i?r:"highWaterMark",o);return Math.floor(o)}return t.objectMode?16:16384}}},4856:(t,e,r)=>{t.exports=r(46).EventEmitter},4156:(t,e,r)=>{(e=t.exports=r(8199)).Stream=e,e.Readable=e,e.Writable=r(5291),e.Duplex=r(1265),e.Transform=r(9415),e.PassThrough=r(4421),e.finished=r(4869),e.pipeline=r(6815)},5586:(t,e,r)=>{"use strict";var n=r(1048).Buffer,i=r(5615),o=r(1848),s=new Array(16),a=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],u=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],f=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],c=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],h=[0,1518500249,1859775393,2400959708,2840853838],p=[1352829926,1548603684,1836072691,2053994217,0];function l(){o.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function d(t,e){return t<>>32-e}function y(t,e,r,n,i,o,s,a){return d(t+(e^r^n)+o+s|0,a)+i|0}function w(t,e,r,n,i,o,s,a){return d(t+(e&r|~e&n)+o+s|0,a)+i|0}function g(t,e,r,n,i,o,s,a){return d(t+((e|~r)^n)+o+s|0,a)+i|0}function b(t,e,r,n,i,o,s,a){return d(t+(e&n|r&~n)+o+s|0,a)+i|0}function _(t,e,r,n,i,o,s,a){return d(t+(e^(r|~n))+o+s|0,a)+i|0}i(l,o),l.prototype._update=function(){for(var t=s,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);for(var r=0|this._a,n=0|this._b,i=0|this._c,o=0|this._d,l=0|this._e,m=0|this._a,E=0|this._b,v=0|this._c,S=0|this._d,T=0|this._e,I=0;I<80;I+=1){var k,P;I<16?(k=y(r,n,i,o,l,t[a[I]],h[0],f[I]),P=_(m,E,v,S,T,t[u[I]],p[0],c[I])):I<32?(k=w(r,n,i,o,l,t[a[I]],h[1],f[I]),P=b(m,E,v,S,T,t[u[I]],p[1],c[I])):I<48?(k=g(r,n,i,o,l,t[a[I]],h[2],f[I]),P=g(m,E,v,S,T,t[u[I]],p[2],c[I])):I<64?(k=b(r,n,i,o,l,t[a[I]],h[3],f[I]),P=w(m,E,v,S,T,t[u[I]],p[3],c[I])):(k=_(r,n,i,o,l,t[a[I]],h[4],f[I]),P=y(m,E,v,S,T,t[u[I]],p[4],c[I])),r=l,l=o,o=d(i,10),i=n,n=k,m=T,T=S,S=d(v,10),v=E,E=P}var A=this._b+i+S|0;this._b=this._c+o+T|0,this._c=this._d+l+m|0,this._d=this._e+r+E|0,this._e=this._a+n+v|0,this._a=A},l.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=n.alloc?n.alloc(20):new n(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t},t.exports=l},5636:(t,e,r)=>{var n=r(1048),i=n.Buffer;function o(t,e){for(var r in t)e[r]=t[r]}function s(t,e,r){return i(t,e,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(o(n,e),e.Buffer=s),s.prototype=Object.create(i.prototype),o(i,s),s.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return i(t,e,r)},s.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=i(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},s.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i(t)},s.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},1229:(t,e,r)=>{var n=r(5636).Buffer;function i(t,e){this._block=n.alloc(t),this._finalSize=e,this._blockSize=t,this._len=0}i.prototype.update=function(t,e){"string"==typeof t&&(e=e||"utf8",t=n.from(t,e));for(var r=this._block,i=this._blockSize,o=t.length,s=this._len,a=0;a=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return t?o.toString(t):o},i.prototype._update=function(){throw new Error("_update must be implemented by subclass")},t.exports=i},3229:(t,e,r)=>{var n=t.exports=function(t){t=t.toLowerCase();var e=n[t];if(!e)throw new Error(t+" is not supported (we accept pull requests)");return new e};n.sha=r(3675),n.sha1=r(8980),n.sha224=r(947),n.sha256=r(2826),n.sha384=r(9922),n.sha512=r(3699)},3675:(t,e,r)=>{var n=r(5615),i=r(1229),o=r(5636).Buffer,s=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function u(){this.init(),this._w=a,i.call(this,64,56)}function f(t){return t<<30|t>>>2}function c(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,u=0|this._e,h=0;h<16;++h)r[h]=t.readInt32BE(4*h);for(;h<80;++h)r[h]=r[h-3]^r[h-8]^r[h-14]^r[h-16];for(var p=0;p<80;++p){var l=~~(p/20),d=0|((e=n)<<5|e>>>27)+c(l,i,o,a)+u+r[p]+s[l];u=a,a=o,o=f(i),i=n,n=d}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var t=o.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},t.exports=u},8980:(t,e,r)=>{var n=r(5615),i=r(1229),o=r(5636).Buffer,s=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function u(){this.init(),this._w=a,i.call(this,64,56)}function f(t){return t<<5|t>>>27}function c(t){return t<<30|t>>>2}function h(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,u=0|this._e,p=0;p<16;++p)r[p]=t.readInt32BE(4*p);for(;p<80;++p)r[p]=(e=r[p-3]^r[p-8]^r[p-14]^r[p-16])<<1|e>>>31;for(var l=0;l<80;++l){var d=~~(l/20),y=f(n)+h(d,i,o,a)+u+r[l]+s[d]|0;u=a,a=o,o=c(i),i=n,n=y}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var t=o.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},t.exports=u},947:(t,e,r)=>{var n=r(5615),i=r(2826),o=r(1229),s=r(5636).Buffer,a=new Array(64);function u(){this.init(),this._w=a,o.call(this,64,56)}n(u,i),u.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},u.prototype._hash=function(){var t=s.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},t.exports=u},2826:(t,e,r)=>{var n=r(5615),i=r(1229),o=r(5636).Buffer,s=[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],a=new Array(64);function u(){this.init(),this._w=a,i.call(this,64,56)}function f(t,e,r){return r^t&(e^r)}function c(t,e,r){return t&e|r&(t|e)}function h(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function p(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function l(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}n(u,i),u.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},u.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,u=0|this._e,d=0|this._f,y=0|this._g,w=0|this._h,g=0;g<16;++g)r[g]=t.readInt32BE(4*g);for(;g<64;++g)r[g]=0|(((e=r[g-2])>>>17|e<<15)^(e>>>19|e<<13)^e>>>10)+r[g-7]+l(r[g-15])+r[g-16];for(var b=0;b<64;++b){var _=w+p(u)+f(u,d,y)+s[b]+r[b]|0,m=h(n)+c(n,i,o)|0;w=y,y=d,d=u,u=a+_|0,a=o,o=i,i=n,n=_+m|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=u+this._e|0,this._f=d+this._f|0,this._g=y+this._g|0,this._h=w+this._h|0},u.prototype._hash=function(){var t=o.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},t.exports=u},9922:(t,e,r)=>{var n=r(5615),i=r(3699),o=r(1229),s=r(5636).Buffer,a=new Array(160);function u(){this.init(),this._w=a,o.call(this,128,112)}n(u,i),u.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},u.prototype._hash=function(){var t=s.allocUnsafe(48);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t},t.exports=u},3699:(t,e,r)=>{var n=r(5615),i=r(1229),o=r(5636).Buffer,s=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],a=new Array(160);function u(){this.init(),this._w=a,i.call(this,128,112)}function f(t,e,r){return r^t&(e^r)}function c(t,e,r){return t&e|r&(t|e)}function h(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function p(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function l(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function d(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function y(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function w(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function g(t,e){return t>>>0>>0?1:0}n(u,i),u.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},u.prototype._update=function(t){for(var e=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,o=0|this._dh,a=0|this._eh,u=0|this._fh,b=0|this._gh,_=0|this._hh,m=0|this._al,E=0|this._bl,v=0|this._cl,S=0|this._dl,T=0|this._el,I=0|this._fl,k=0|this._gl,P=0|this._hl,A=0;A<32;A+=2)e[A]=t.readInt32BE(4*A),e[A+1]=t.readInt32BE(4*A+4);for(;A<160;A+=2){var O=e[A-30],B=e[A-30+1],x=l(O,B),U=d(B,O),R=y(O=e[A-4],B=e[A-4+1]),N=w(B,O),L=e[A-14],C=e[A-14+1],H=e[A-32],M=e[A-32+1],D=U+C|0,j=x+L+g(D,U)|0;j=(j=j+R+g(D=D+N|0,N)|0)+H+g(D=D+M|0,M)|0,e[A]=j,e[A+1]=D}for(var F=0;F<160;F+=2){j=e[F],D=e[F+1];var K=c(r,n,i),V=c(m,E,v),W=h(r,m),G=h(m,r),q=p(a,T),X=p(T,a),$=s[F],z=s[F+1],Y=f(a,u,b),J=f(T,I,k),Q=P+X|0,Z=_+q+g(Q,P)|0;Z=(Z=(Z=Z+Y+g(Q=Q+J|0,J)|0)+$+g(Q=Q+z|0,z)|0)+j+g(Q=Q+D|0,D)|0;var tt=G+V|0,et=W+K+g(tt,G)|0;_=b,P=k,b=u,k=I,u=a,I=T,a=o+Z+g(T=S+Q|0,S)|0,o=i,S=v,i=n,v=E,n=r,E=m,r=Z+et+g(m=Q+tt|0,Q)|0}this._al=this._al+m|0,this._bl=this._bl+E|0,this._cl=this._cl+v|0,this._dl=this._dl+S|0,this._el=this._el+T|0,this._fl=this._fl+I|0,this._gl=this._gl+k|0,this._hl=this._hl+P|0,this._ah=this._ah+r+g(this._al,m)|0,this._bh=this._bh+n+g(this._bl,E)|0,this._ch=this._ch+i+g(this._cl,v)|0,this._dh=this._dh+o+g(this._dl,S)|0,this._eh=this._eh+a+g(this._el,T)|0,this._fh=this._fh+u+g(this._fl,I)|0,this._gh=this._gh+b+g(this._gl,k)|0,this._hh=this._hh+_+g(this._hl,P)|0},u.prototype._hash=function(){var t=o.allocUnsafe(64);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},t.exports=u},1983:(t,e,r)=>{t.exports=i;var n=r(46).EventEmitter;function i(){n.call(this)}r(5615)(i,n),i.Readable=r(8199),i.Writable=r(5291),i.Duplex=r(1265),i.Transform=r(9415),i.PassThrough=r(4421),i.finished=r(4869),i.pipeline=r(6815),i.Stream=i,i.prototype.pipe=function(t,e){var r=this;function i(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),t.on("drain",o),t._isStdio||e&&!1===e.end||(r.on("end",a),r.on("close",u));var s=!1;function a(){s||(s=!0,t.end())}function u(){s||(s=!0,"function"==typeof t.destroy&&t.destroy())}function f(t){if(c(),0===n.listenerCount(this,"error"))throw t}function c(){r.removeListener("data",i),t.removeListener("drain",o),r.removeListener("end",a),r.removeListener("close",u),r.removeListener("error",f),t.removeListener("error",f),r.removeListener("end",c),r.removeListener("close",c),t.removeListener("close",c)}return r.on("error",f),t.on("error",f),r.on("end",c),r.on("close",c),t.on("close",c),t.emit("pipe",r),t}},8888:(t,e,r)=>{"use strict";var n=r(5636).Buffer,i=n.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(n.isEncoding===i||!i(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=u,this.end=f,e=4;break;case"utf8":this.fillLast=a,e=4;break;case"base64":this.text=c,this.end=h,e=3;break;default:return this.write=p,void(this.end=l)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(e)}function s(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function a(t){var e=this.lastTotal-this.lastNeed,r=function(t,e){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function u(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function f(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function c(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function h(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function p(t){return t.toString(this.encoding)}function l(t){return t&&t.length?this.write(t):""}e.I=o,o.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0?(i>0&&(t.lastNeed=i-1),i):--n=0?(i>0&&(t.lastNeed=i-2),i):--n=0?(i>0&&(2===i?i=0:t.lastNeed=i-3),i):0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},o.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},4322:(t,e,r)=>{var n=r(2890);function i(t){return t.name||t.toString().match(/function (.*?)\s*\(/)[1]}function o(t){return n.Nil(t)?"":i(t.constructor)}function s(t,e){Error.captureStackTrace&&Error.captureStackTrace(t,e)}function a(t){return n.Function(t)?t.toJSON?t.toJSON():i(t):n.Array(t)?"Array":t&&n.Object(t)?"Object":void 0!==t?t:""}function u(t,e,r){var i=function(t){return n.Function(t)?"":n.String(t)?JSON.stringify(t):t&&n.Object(t)?"":t}(e);return"Expected "+a(t)+", got"+(""!==r?" "+r:"")+(""!==i?" "+i:"")}function f(t,e,r){r=r||o(e),this.message=u(t,e,r),s(this,f),this.__type=t,this.__value=e,this.__valueTypeName=r}function c(t,e,r,n,i){t?(i=i||o(n),this.message=function(t,e,r,n,i){var o='" of type ';return"key"===e&&(o='" with key type '),u('property "'+a(r)+o+a(t),n,i)}(t,r,e,n,i)):this.message='Unexpected property "'+e+'"',s(this,f),this.__label=r,this.__property=e,this.__type=t,this.__value=n,this.__valueTypeName=i}f.prototype=Object.create(Error.prototype),f.prototype.constructor=f,c.prototype=Object.create(Error.prototype),c.prototype.constructor=f,t.exports={TfTypeError:f,TfPropertyTypeError:c,tfCustomError:function(t,e){return new f(t,{},e)},tfSubError:function(t,e,r){return t instanceof c?(e=e+"."+t.__property,t=new c(t.__type,e,t.__label,t.__value,t.__valueTypeName)):t instanceof f&&(t=new c(t.__type,e,r,t.__value,t.__valueTypeName)),s(t),t},tfJSON:a,getValueTypeName:o}},315:(t,e,r)=>{var n=r(1048).Buffer,i=r(2890),o=r(4322);function s(t){return n.isBuffer(t)}function a(t){return"string"==typeof t&&/^([0-9a-f]{2})+$/i.test(t)}function u(t,e){var r=t.toJSON();function n(n){if(!t(n))return!1;if(n.length===e)return!0;throw o.tfCustomError(r+"(Length: "+e+")",r+"(Length: "+n.length+")")}return n.toJSON=function(){return r},n}var f=u.bind(null,i.Array),c=u.bind(null,s),h=u.bind(null,a),p=u.bind(null,i.String),l=Math.pow(2,53)-1,d={ArrayN:f,Buffer:s,BufferN:c,Finite:function(t){return"number"==typeof t&&isFinite(t)},Hex:a,HexN:h,Int8:function(t){return t<<24>>24===t},Int16:function(t){return t<<16>>16===t},Int32:function(t){return(0|t)===t},Int53:function(t){return"number"==typeof t&&t>=-l&&t<=l&&Math.floor(t)===t},Range:function(t,e,r){function n(n,i){return r(n,i)&&n>t&&n>>0===t},UInt53:function(t){return"number"==typeof t&&t>=0&&t<=l&&Math.floor(t)===t}};for(var y in d)d[y].toJSON=function(t){return t}.bind(null,y);t.exports=d},973:(t,e,r)=>{var n=r(4322),i=r(2890),o=n.tfJSON,s=n.TfTypeError,a=n.TfPropertyTypeError,u=n.tfSubError,f=n.getValueTypeName,c={arrayOf:function(t,e){function r(r,n){return!!i.Array(r)&&!i.Nil(r)&&!(void 0!==e.minLength&&r.lengthe.maxLength)&&(void 0===e.length||r.length===e.length)&&r.every((function(e,r){try{return p(t,e,n)}catch(t){throw u(t,r)}}))}return t=h(t),e=e||{},r.toJSON=function(){var r="["+o(t)+"]";return void 0!==e.length?r+="{"+e.length+"}":void 0===e.minLength&&void 0===e.maxLength||(r+="{"+(void 0===e.minLength?0:e.minLength)+","+(void 0===e.maxLength?1/0:e.maxLength)+"}"),r},r},maybe:function t(e){function r(r,n){return i.Nil(r)||e(r,n,t)}return e=h(e),r.toJSON=function(){return"?"+o(e)},r},map:function(t,e){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var o in r){try{e&&p(e,o,n)}catch(t){throw u(t,o,"key")}try{var s=r[o];p(t,s,n)}catch(t){throw u(t,o)}}return!0}return t=h(t),e&&(e=h(e)),r.toJSON=e?function(){return"{"+o(e)+": "+o(t)+"}"}:function(){return"{"+o(t)+"}"},r},object:function(t){var e={};for(var r in t)e[r]=h(t[r]);function n(t,r){if(!i.Object(t))return!1;if(i.Nil(t))return!1;var n;try{for(n in e)p(e[n],t[n],r)}catch(t){throw u(t,n)}if(r)for(n in t)if(!e[n])throw new a(void 0,n);return!0}return n.toJSON=function(){return o(e)},n},anyOf:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return t.some((function(t){try{return p(t,e,r)}catch(t){return!1}}))}return e.toJSON=function(){return t.map(o).join("|")},e},allOf:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return t.every((function(t){try{return p(t,e,r)}catch(t){return!1}}))}return e.toJSON=function(){return t.map(o).join(" & ")},e},quacksLike:function(t){function e(e){return t===f(e)}return e.toJSON=function(){return t},e},tuple:function(){var t=[].slice.call(arguments).map(h);function e(e,r){return!i.Nil(e)&&!i.Nil(e.length)&&(!r||e.length===t.length)&&t.every((function(t,n){try{return p(t,e[n],r)}catch(t){throw u(t,n)}}))}return e.toJSON=function(){return"("+t.map(o).join(", ")+")"},e},value:function(t){function e(e){return e===t}return e.toJSON=function(){return t},e}};function h(t){if(i.String(t))return"?"===t[0]?c.maybe(t.slice(1)):i[t]||c.quacksLike(t);if(t&&i.Object(t)){if(i.Array(t)){if(1!==t.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return c.arrayOf(t[0])}return c.object(t)}return i.Function(t)?t:c.value(t)}function p(t,e,r,n){if(i.Function(t)){if(t(e,r))return!0;throw new s(n||t,e)}return p(h(t),e,r)}for(var l in c.oneOf=c.anyOf,i)p[l]=i[l];for(l in c)p[l]=c[l];var d=r(315);for(l in d)p[l]=d[l];p.compile=h,p.TfTypeError=s,p.TfPropertyTypeError=a,t.exports=p},2890:t=>{var e={Array:function(t){return null!=t&&t.constructor===Array},Boolean:function(t){return"boolean"==typeof t},Function:function(t){return"function"==typeof t},Nil:function(t){return null==t},Number:function(t){return"number"==typeof t},Object:function(t){return"object"==typeof t},String:function(t){return"string"==typeof t},"":function(){return!0}};for(var r in e.Null=e.Nil,e)e[r].toJSON=function(t){return t}.bind(null,r);t.exports=e},6732:(t,e,r)=>{function n(t){try{if(!r.g.localStorage)return!1}catch(t){return!1}var e=r.g.localStorage[t];return null!=e&&"true"===String(e).toLowerCase()}t.exports=function(t,e){if(n("noDeprecation"))return t;var r=!1;return function(){if(!r){if(n("throwDeprecation"))throw new Error(e);n("traceDeprecation")?console.trace(e):console.warn(e),r=!0}return t.apply(this,arguments)}}},5364:t=>{"use strict";t.exports=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,f=new Uint8Array(o);t[r];){var c=e[t.charCodeAt(r)];if(255===c)return;for(var h=0,p=o-1;(0!==c||h>>0,f[p]=c%256>>>0,c=c/256>>>0;if(0!==c)throw new Error("Non-zero carry");i=h,r++}for(var l=o-i;l!==o&&0===f[l];)l++;for(var d=new Uint8Array(n+(o-l)),y=n;l!==o;)d[y++]=f[l++];return d}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===e.length)return"";for(var r=0,n=0,i=0,o=e.length;i!==o&&0===e[i];)i++,r++;for(var u=(o-i)*f+1>>>0,c=new Uint8Array(u);i!==o;){for(var h=e[i],p=0,l=u-1;(0!==h||p>>0,c[l]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");n=p,i++}for(var d=u-n;d!==u&&0===c[d];)d++;for(var y=a.repeat(r);d{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(1457);function i(t,e,r){return n=>{if(t.has(n))return;const i=r.filter((t=>t.key.toString("hex")===n))[0];e.push(i),t.add(n)}}function o(t){return t.globalMap.unsignedTx}function s(t){const e=new Set;return t.forEach((t=>{const r=t.key.toString("hex");if(e.has(r))throw new Error("Combine: KeyValue Map keys should be unique");e.add(r)})),e}e.combine=function(t){const e=t[0],r=n.psbtToKeyVals(e),a=t.slice(1);if(0===a.length)throw new Error("Combine: Nothing to combine");const u=o(e);if(void 0===u)throw new Error("Combine: Self missing transaction");const f=s(r.globalKeyVals),c=r.inputKeyVals.map(s),h=r.outputKeyVals.map(s);for(const t of a){const e=o(t);if(void 0===e||!e.toBuffer().equals(u.toBuffer()))throw new Error("Combine: One of the Psbts does not have the same transaction.");const a=n.psbtToKeyVals(t);s(a.globalKeyVals).forEach(i(f,r.globalKeyVals,a.globalKeyVals)),a.inputKeyVals.map(s).forEach(((t,e)=>t.forEach(i(c[e],r.inputKeyVals[e],a.inputKeyVals[e])))),a.outputKeyVals.map(s).forEach(((t,e)=>t.forEach(i(h[e],r.outputKeyVals[e],a.outputKeyVals[e]))))}return n.psbtFromKeyVals(u,{globalMapKeyVals:r.globalKeyVals,inputKeyVals:r.inputKeyVals,outputKeyVals:r.outputKeyVals})}},4834:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);e.decode=function(t){if(t.key[0]!==i.GlobalTypes.GLOBAL_XPUB)throw new Error("Decode Error: could not decode globalXpub with key 0x"+t.key.toString("hex"));if(79!==t.key.length||![2,3].includes(t.key[46]))throw new Error("Decode Error: globalXpub has invalid extended pubkey in key 0x"+t.key.toString("hex"));if(t.value.length/4%1!=0)throw new Error("Decode Error: Global GLOBAL_XPUB value length should be multiple of 4");const e=t.key.slice(1),r={masterFingerprint:t.value.slice(0,4),extendedPubkey:e,path:"m"};for(const e of(n=t.value.length/4-1,[...Array(n).keys()])){const n=t.value.readUInt32LE(4*e+4),i=!!(2147483648&n),o=2147483647&n;r.path+="/"+o.toString(10)+(i?"'":"")}var n;return r},e.encode=function(t){const e=n.from([i.GlobalTypes.GLOBAL_XPUB]),r=n.concat([e,t.extendedPubkey]),o=t.path.split("/"),s=n.allocUnsafe(4*o.length);t.masterFingerprint.copy(s,0);let a=4;return o.slice(1).forEach((t=>{const e="'"===t.slice(-1);let r=2147483647&parseInt(e?t.slice(0,-1):t,10);e&&(r+=2147483648),s.writeUInt32LE(r,a),a+=4})),{key:r,value:s}},e.expected="{ masterFingerprint: Buffer; extendedPubkey: Buffer; path: string; }",e.check=function(t){const e=t.extendedPubkey,r=t.masterFingerprint,i=t.path;return n.isBuffer(e)&&78===e.length&&[2,3].indexOf(e[45])>-1&&n.isBuffer(r)&&4===r.length&&"string"==typeof i&&!!i.match(/^m(\/\d+'?)*$/)},e.canAddToArray=function(t,e,r){const n=e.extendedPubkey.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.extendedPubkey.equals(e.extendedPubkey))).length)}},4213:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);e.encode=function(t){return{key:n.from([i.GlobalTypes.UNSIGNED_TX]),value:t.toBuffer()}}},2706:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(9080),i=r(4834),o=r(4213),s=r(6605),a=r(1795),u=r(4431),f=r(6907),c=r(5949),h=r(9344),p=r(2760),l=r(1695),d=r(8454),y=r(9034),w=r(2926),g=r(7851),b=r(7545),_=r(2412),m=r(4307),E=r(7636),v=r(2223),S=r(5578),T={unsignedTx:o,globalXpub:i,checkPubkey:_.makeChecker([])};e.globals=T;const I={nonWitnessUtxo:u,partialSig:f,sighashType:h,finalScriptSig:s,finalScriptWitness:a,porCommitment:c,witnessUtxo:w,bip32Derivation:b.makeConverter(n.InputTypes.BIP32_DERIVATION),redeemScript:m.makeConverter(n.InputTypes.REDEEM_SCRIPT),witnessScript:S.makeConverter(n.InputTypes.WITNESS_SCRIPT),checkPubkey:_.makeChecker([n.InputTypes.PARTIAL_SIG,n.InputTypes.BIP32_DERIVATION]),tapKeySig:p,tapScriptSig:y,tapLeafScript:l,tapBip32Derivation:E.makeConverter(n.InputTypes.TAP_BIP32_DERIVATION),tapInternalKey:v.makeConverter(n.InputTypes.TAP_INTERNAL_KEY),tapMerkleRoot:d};e.inputs=I;const k={bip32Derivation:b.makeConverter(n.OutputTypes.BIP32_DERIVATION),redeemScript:m.makeConverter(n.OutputTypes.REDEEM_SCRIPT),witnessScript:S.makeConverter(n.OutputTypes.WITNESS_SCRIPT),checkPubkey:_.makeChecker([n.OutputTypes.BIP32_DERIVATION]),tapBip32Derivation:E.makeConverter(n.OutputTypes.TAP_BIP32_DERIVATION),tapTree:g,tapInternalKey:v.makeConverter(n.OutputTypes.TAP_INTERNAL_KEY)};e.outputs=k},6605:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);e.decode=function(t){if(t.key[0]!==i.InputTypes.FINAL_SCRIPTSIG)throw new Error("Decode Error: could not decode finalScriptSig with key 0x"+t.key.toString("hex"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.FINAL_SCRIPTSIG]),value:t}},e.expected="Buffer",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.finalScriptSig}},1795:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);e.decode=function(t){if(t.key[0]!==i.InputTypes.FINAL_SCRIPTWITNESS)throw new Error("Decode Error: could not decode finalScriptWitness with key 0x"+t.key.toString("hex"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.FINAL_SCRIPTWITNESS]),value:t}},e.expected="Buffer",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.finalScriptWitness}},4431:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);e.decode=function(t){if(t.key[0]!==i.InputTypes.NON_WITNESS_UTXO)throw new Error("Decode Error: could not decode nonWitnessUtxo with key 0x"+t.key.toString("hex"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.NON_WITNESS_UTXO]),value:t}},e.expected="Buffer",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.nonWitnessUtxo}},6907:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);e.decode=function(t){if(t.key[0]!==i.InputTypes.PARTIAL_SIG)throw new Error("Decode Error: could not decode partialSig with key 0x"+t.key.toString("hex"));if(34!==t.key.length&&66!==t.key.length||![2,3,4].includes(t.key[1]))throw new Error("Decode Error: partialSig has invalid pubkey in key 0x"+t.key.toString("hex"));return{pubkey:t.key.slice(1),signature:t.value}},e.encode=function(t){const e=n.from([i.InputTypes.PARTIAL_SIG]);return{key:n.concat([e,t.pubkey]),value:t.signature}},e.expected="{ pubkey: Buffer; signature: Buffer; }",e.check=function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.signature)&&[33,65].includes(t.pubkey.length)&&[2,3,4].includes(t.pubkey[0])&&function(t){if(!n.isBuffer(t)||t.length<9)return!1;if(48!==t[0])return!1;if(t.length!==t[1]+3)return!1;if(2!==t[2])return!1;const e=t[3];if(e>33||e<1)return!1;if(2!==t[3+e+1])return!1;const r=t[3+e+2];return!(r>33||r<1)&&t.length===3+e+2+r+2}(t.signature)},e.canAddToArray=function(t,e,r){const n=e.pubkey.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.pubkey.equals(e.pubkey))).length)}},5949:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);e.decode=function(t){if(t.key[0]!==i.InputTypes.POR_COMMITMENT)throw new Error("Decode Error: could not decode porCommitment with key 0x"+t.key.toString("hex"));return t.value.toString("utf8")},e.encode=function(t){return{key:n.from([i.InputTypes.POR_COMMITMENT]),value:n.from(t,"utf8")}},e.expected="string",e.check=function(t){return"string"==typeof t},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.porCommitment}},9344:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);e.decode=function(t){if(t.key[0]!==i.InputTypes.SIGHASH_TYPE)throw new Error("Decode Error: could not decode sighashType with key 0x"+t.key.toString("hex"));return t.value.readUInt32LE(0)},e.encode=function(t){const e=n.from([i.InputTypes.SIGHASH_TYPE]),r=n.allocUnsafe(4);return r.writeUInt32LE(t,0),{key:e,value:r}},e.expected="number",e.check=function(t){return"number"==typeof t},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.sighashType}},2760:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);function o(t){return n.isBuffer(t)&&(64===t.length||65===t.length)}e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_KEY_SIG||1!==t.key.length)throw new Error("Decode Error: could not decode tapKeySig with key 0x"+t.key.toString("hex"));if(!o(t.value))throw new Error("Decode Error: tapKeySig not a valid 64-65-byte BIP340 signature");return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.TAP_KEY_SIG]),value:t}},e.expected="Buffer",e.check=o,e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapKeySig}},1695:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_LEAF_SCRIPT)throw new Error("Decode Error: could not decode tapLeafScript with key 0x"+t.key.toString("hex"));if((t.key.length-2)%32!=0)throw new Error("Decode Error: tapLeafScript has invalid control block in key 0x"+t.key.toString("hex"));const e=t.value[t.value.length-1];if((254&t.key[1])!==e)throw new Error("Decode Error: tapLeafScript bad leaf version in key 0x"+t.key.toString("hex"));const r=t.value.slice(0,-1);return{controlBlock:t.key.slice(1),script:r,leafVersion:e}},e.encode=function(t){const e=n.from([i.InputTypes.TAP_LEAF_SCRIPT]),r=n.from([t.leafVersion]);return{key:n.concat([e,t.controlBlock]),value:n.concat([t.script,r])}},e.expected="{ controlBlock: Buffer; leafVersion: number, script: Buffer; }",e.check=function(t){return n.isBuffer(t.controlBlock)&&(t.controlBlock.length-1)%32==0&&(254&t.controlBlock[0])===t.leafVersion&&n.isBuffer(t.script)},e.canAddToArray=function(t,e,r){const n=e.controlBlock.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.controlBlock.equals(e.controlBlock))).length)}},8454:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);function o(t){return n.isBuffer(t)&&32===t.length}e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_MERKLE_ROOT||1!==t.key.length)throw new Error("Decode Error: could not decode tapMerkleRoot with key 0x"+t.key.toString("hex"));if(!o(t.value))throw new Error("Decode Error: tapMerkleRoot not a 32-byte hash");return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.TAP_MERKLE_ROOT]),value:t}},e.expected="Buffer",e.check=o,e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapMerkleRoot}},9034:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_SCRIPT_SIG)throw new Error("Decode Error: could not decode tapScriptSig with key 0x"+t.key.toString("hex"));if(65!==t.key.length)throw new Error("Decode Error: tapScriptSig has invalid key 0x"+t.key.toString("hex"));if(64!==t.value.length&&65!==t.value.length)throw new Error("Decode Error: tapScriptSig has invalid signature in key 0x"+t.key.toString("hex"));return{pubkey:t.key.slice(1,33),leafHash:t.key.slice(33),signature:t.value}},e.encode=function(t){const e=n.from([i.InputTypes.TAP_SCRIPT_SIG]);return{key:n.concat([e,t.pubkey,t.leafHash]),value:t.signature}},e.expected="{ pubkey: Buffer; leafHash: Buffer; signature: Buffer; }",e.check=function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.leafHash)&&n.isBuffer(t.signature)&&32===t.pubkey.length&&32===t.leafHash.length&&(64===t.signature.length||65===t.signature.length)},e.canAddToArray=function(t,e,r){const n=e.pubkey.toString("hex")+e.leafHash.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.pubkey.equals(e.pubkey)&&t.leafHash.equals(e.leafHash))).length)}},2926:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080),o=r(8133),s=r(394);e.decode=function(t){if(t.key[0]!==i.InputTypes.WITNESS_UTXO)throw new Error("Decode Error: could not decode witnessUtxo with key 0x"+t.key.toString("hex"));const e=o.readUInt64LE(t.value,0);let r=8;const n=s.decode(t.value,r);r+=s.encodingLength(n);const a=t.value.slice(r);if(a.length!==n)throw new Error("Decode Error: WITNESS_UTXO script is not proper length");return{script:a,value:e}},e.encode=function(t){const{script:e,value:r}=t,a=s.encodingLength(e.length),u=n.allocUnsafe(8+a+e.length);return o.writeUInt64LE(u,r,0),s.encode(e.length,u,8),e.copy(u,8+a),{key:n.from([i.InputTypes.WITNESS_UTXO]),value:u}},e.expected="{ script: Buffer; value: number; }",e.check=function(t){return n.isBuffer(t.script)&&"number"==typeof t.value},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.witnessUtxo}},7851:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080),o=r(394);e.decode=function(t){if(t.key[0]!==i.OutputTypes.TAP_TREE||1!==t.key.length)throw new Error("Decode Error: could not decode tapTree with key 0x"+t.key.toString("hex"));let e=0;const r=[];for(;e[n.of(t.depth,t.leafVersion),o.encode(t.script.length),t.script])));return{key:e,value:n.concat(r)}},e.expected="{ leaves: [{ depth: number; leafVersion: number, script: Buffer; }] }",e.check=function(t){return Array.isArray(t.leaves)&&t.leaves.every((t=>t.depth>=0&&t.depth<=128&&(254&t.leafVersion)===t.leafVersion&&n.isBuffer(t.script)))},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapTree}},7545:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=t=>33===t.length&&[2,3].includes(t[0])||65===t.length&&4===t[0];e.makeConverter=function(t,e=i){return{decode:function(r){if(r.key[0]!==t)throw new Error("Decode Error: could not decode bip32Derivation with key 0x"+r.key.toString("hex"));const n=r.key.slice(1);if(!e(n))throw new Error("Decode Error: bip32Derivation has invalid pubkey in key 0x"+r.key.toString("hex"));if(r.value.length/4%1!=0)throw new Error("Decode Error: Input BIP32_DERIVATION value length should be multiple of 4");const i={masterFingerprint:r.value.slice(0,4),pubkey:n,path:"m"};for(const t of(o=r.value.length/4-1,[...Array(o).keys()])){const e=r.value.readUInt32LE(4*t+4),n=!!(2147483648&e),o=2147483647&e;i.path+="/"+o.toString(10)+(n?"'":"")}var o;return i},encode:function(e){const r=n.from([t]),i=n.concat([r,e.pubkey]),o=e.path.split("/"),s=n.allocUnsafe(4*o.length);e.masterFingerprint.copy(s,0);let a=4;return o.slice(1).forEach((t=>{const e="'"===t.slice(-1);let r=2147483647&parseInt(e?t.slice(0,-1):t,10);e&&(r+=2147483648),s.writeUInt32LE(r,a),a+=4})),{key:i,value:s}},check:function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.masterFingerprint)&&"string"==typeof t.path&&e(t.pubkey)&&4===t.masterFingerprint.length},expected:"{ masterFingerprint: Buffer; pubkey: Buffer; path: string; }",canAddToArray:function(t,e,r){const n=e.pubkey.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.pubkey.equals(e.pubkey))).length)}}}},2412:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.makeChecker=function(t){return function(e){let r;if(t.includes(e.key[0])&&(r=e.key.slice(1),33!==r.length&&65!==r.length||![2,3,4].includes(r[0])))throw new Error("Format Error: invalid pubkey in key 0x"+e.key.toString("hex"));return r}}},4307:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.makeConverter=function(t){return{decode:function(e){if(e.key[0]!==t)throw new Error("Decode Error: could not decode redeemScript with key 0x"+e.key.toString("hex"));return e.value},encode:function(e){return{key:n.from([t]),value:e}},check:function(t){return n.isBuffer(t)},expected:"Buffer",canAdd:function(t,e){return!!t&&!!e&&void 0===t.redeemScript}}}},7636:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(394),o=r(7545),s=t=>32===t.length;e.makeConverter=function(t){const e=o.makeConverter(t,s);return{decode:function(t){const r=i.decode(t.value),n=i.encodingLength(r),o=e.decode({key:t.key,value:t.value.slice(n+32*r)}),s=new Array(r);for(let e=0,i=n;en.isBuffer(t)&&32===t.length))&&e.check(t)},expected:"{ masterFingerprint: Buffer; pubkey: Buffer; path: string; leafHashes: Buffer[]; }",canAddToArray:e.canAddToArray}}},2223:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.makeConverter=function(t){return{decode:function(e){if(e.key[0]!==t||1!==e.key.length)throw new Error("Decode Error: could not decode tapInternalKey with key 0x"+e.key.toString("hex"));if(32!==e.value.length)throw new Error("Decode Error: tapInternalKey not a 32-byte x-only pubkey");return e.value},encode:function(e){return{key:n.from([t]),value:e}},check:function(t){return n.isBuffer(t)&&32===t.length},expected:"Buffer",canAdd:function(t,e){return!!t&&!!e&&void 0===t.tapInternalKey}}}},5578:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.makeConverter=function(t){return{decode:function(e){if(e.key[0]!==t)throw new Error("Decode Error: could not decode witnessScript with key 0x"+e.key.toString("hex"));return e.value},encode:function(e){return{key:n.from([t]),value:e}},check:function(t){return n.isBuffer(t)},expected:"Buffer",canAdd:function(t,e){return!!t&&!!e&&void 0===t.witnessScript}}}},8133:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(394);function o(t){const e=t.key.length,r=t.value.length,o=i.encodingLength(e),s=i.encodingLength(r),a=n.allocUnsafe(o+e+s+r);return i.encode(e,a,0),t.key.copy(a,o),i.encode(r,a,o+e),t.value.copy(a,o+e+s),a}function s(t,e){if("number"!=typeof t)throw new Error("cannot write a non-number as a number");if(t<0)throw new Error("specified a negative value for writing an unsigned value");if(t>e)throw new Error("RangeError: value out of range");if(Math.floor(t)!==t)throw new Error("value has a fractional component")}e.range=t=>[...Array(t).keys()],e.reverseBuffer=function(t){if(t.length<1)return t;let e=t.length-1,r=0;for(let n=0;n{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=9007199254740991;function o(t){if(t<0||t>i||t%1!=0)throw new RangeError("value out of range")}function s(t){return o(t),t<253?1:t<=65535?3:t<=4294967295?5:9}e.encode=function t(e,r,i){if(o(e),r||(r=n.allocUnsafe(s(e))),!n.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return i||(i=0),e<253?(r.writeUInt8(e,i),Object.assign(t,{bytes:1})):e<=65535?(r.writeUInt8(253,i),r.writeUInt16LE(e,i+1),Object.assign(t,{bytes:3})):e<=4294967295?(r.writeUInt8(254,i),r.writeUInt32LE(e,i+1),Object.assign(t,{bytes:5})):(r.writeUInt8(255,i),r.writeUInt32LE(e>>>0,i+1),r.writeUInt32LE(e/4294967296|0,i+5),Object.assign(t,{bytes:9})),r},e.decode=function t(e,r){if(!n.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");r||(r=0);const i=e.readUInt8(r);if(i<253)return Object.assign(t,{bytes:1}),i;if(253===i)return Object.assign(t,{bytes:3}),e.readUInt16LE(r+1);if(254===i)return Object.assign(t,{bytes:5}),e.readUInt32LE(r+1);{Object.assign(t,{bytes:9});const n=e.readUInt32LE(r+1),i=4294967296*e.readUInt32LE(r+5)+n;return o(i),i}},e.encodingLength=s},6263:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(2706),o=r(8133),s=r(394),a=r(9080);function u(t,e,r){if(!e.equals(n.from([r])))throw new Error(`Format Error: Invalid ${t} key: ${e.toString("hex")}`)}function f(t,{globalMapKeyVals:e,inputKeyVals:r,outputKeyVals:n}){const s={unsignedTx:t};let f=0;for(const t of e)switch(t.key[0]){case a.GlobalTypes.UNSIGNED_TX:if(u("global",t.key,a.GlobalTypes.UNSIGNED_TX),f>0)throw new Error("Format Error: GlobalMap has multiple UNSIGNED_TX");f++;break;case a.GlobalTypes.GLOBAL_XPUB:void 0===s.globalXpub&&(s.globalXpub=[]),s.globalXpub.push(i.globals.globalXpub.decode(t));break;default:s.unknownKeyVals||(s.unknownKeyVals=[]),s.unknownKeyVals.push(t)}const c=r.length,h=n.length,p=[],l=[];for(const t of o.range(c)){const e={};for(const n of r[t])switch(i.inputs.checkPubkey(n),n.key[0]){case a.InputTypes.NON_WITNESS_UTXO:if(u("input",n.key,a.InputTypes.NON_WITNESS_UTXO),void 0!==e.nonWitnessUtxo)throw new Error("Format Error: Input has multiple NON_WITNESS_UTXO");e.nonWitnessUtxo=i.inputs.nonWitnessUtxo.decode(n);break;case a.InputTypes.WITNESS_UTXO:if(u("input",n.key,a.InputTypes.WITNESS_UTXO),void 0!==e.witnessUtxo)throw new Error("Format Error: Input has multiple WITNESS_UTXO");e.witnessUtxo=i.inputs.witnessUtxo.decode(n);break;case a.InputTypes.PARTIAL_SIG:void 0===e.partialSig&&(e.partialSig=[]),e.partialSig.push(i.inputs.partialSig.decode(n));break;case a.InputTypes.SIGHASH_TYPE:if(u("input",n.key,a.InputTypes.SIGHASH_TYPE),void 0!==e.sighashType)throw new Error("Format Error: Input has multiple SIGHASH_TYPE");e.sighashType=i.inputs.sighashType.decode(n);break;case a.InputTypes.REDEEM_SCRIPT:if(u("input",n.key,a.InputTypes.REDEEM_SCRIPT),void 0!==e.redeemScript)throw new Error("Format Error: Input has multiple REDEEM_SCRIPT");e.redeemScript=i.inputs.redeemScript.decode(n);break;case a.InputTypes.WITNESS_SCRIPT:if(u("input",n.key,a.InputTypes.WITNESS_SCRIPT),void 0!==e.witnessScript)throw new Error("Format Error: Input has multiple WITNESS_SCRIPT");e.witnessScript=i.inputs.witnessScript.decode(n);break;case a.InputTypes.BIP32_DERIVATION:void 0===e.bip32Derivation&&(e.bip32Derivation=[]),e.bip32Derivation.push(i.inputs.bip32Derivation.decode(n));break;case a.InputTypes.FINAL_SCRIPTSIG:u("input",n.key,a.InputTypes.FINAL_SCRIPTSIG),e.finalScriptSig=i.inputs.finalScriptSig.decode(n);break;case a.InputTypes.FINAL_SCRIPTWITNESS:u("input",n.key,a.InputTypes.FINAL_SCRIPTWITNESS),e.finalScriptWitness=i.inputs.finalScriptWitness.decode(n);break;case a.InputTypes.POR_COMMITMENT:u("input",n.key,a.InputTypes.POR_COMMITMENT),e.porCommitment=i.inputs.porCommitment.decode(n);break;case a.InputTypes.TAP_KEY_SIG:u("input",n.key,a.InputTypes.TAP_KEY_SIG),e.tapKeySig=i.inputs.tapKeySig.decode(n);break;case a.InputTypes.TAP_SCRIPT_SIG:void 0===e.tapScriptSig&&(e.tapScriptSig=[]),e.tapScriptSig.push(i.inputs.tapScriptSig.decode(n));break;case a.InputTypes.TAP_LEAF_SCRIPT:void 0===e.tapLeafScript&&(e.tapLeafScript=[]),e.tapLeafScript.push(i.inputs.tapLeafScript.decode(n));break;case a.InputTypes.TAP_BIP32_DERIVATION:void 0===e.tapBip32Derivation&&(e.tapBip32Derivation=[]),e.tapBip32Derivation.push(i.inputs.tapBip32Derivation.decode(n));break;case a.InputTypes.TAP_INTERNAL_KEY:u("input",n.key,a.InputTypes.TAP_INTERNAL_KEY),e.tapInternalKey=i.inputs.tapInternalKey.decode(n);break;case a.InputTypes.TAP_MERKLE_ROOT:u("input",n.key,a.InputTypes.TAP_MERKLE_ROOT),e.tapMerkleRoot=i.inputs.tapMerkleRoot.decode(n);break;default:e.unknownKeyVals||(e.unknownKeyVals=[]),e.unknownKeyVals.push(n)}p.push(e)}for(const t of o.range(h)){const e={};for(const r of n[t])switch(i.outputs.checkPubkey(r),r.key[0]){case a.OutputTypes.REDEEM_SCRIPT:if(u("output",r.key,a.OutputTypes.REDEEM_SCRIPT),void 0!==e.redeemScript)throw new Error("Format Error: Output has multiple REDEEM_SCRIPT");e.redeemScript=i.outputs.redeemScript.decode(r);break;case a.OutputTypes.WITNESS_SCRIPT:if(u("output",r.key,a.OutputTypes.WITNESS_SCRIPT),void 0!==e.witnessScript)throw new Error("Format Error: Output has multiple WITNESS_SCRIPT");e.witnessScript=i.outputs.witnessScript.decode(r);break;case a.OutputTypes.BIP32_DERIVATION:void 0===e.bip32Derivation&&(e.bip32Derivation=[]),e.bip32Derivation.push(i.outputs.bip32Derivation.decode(r));break;case a.OutputTypes.TAP_INTERNAL_KEY:u("output",r.key,a.OutputTypes.TAP_INTERNAL_KEY),e.tapInternalKey=i.outputs.tapInternalKey.decode(r);break;case a.OutputTypes.TAP_TREE:u("output",r.key,a.OutputTypes.TAP_TREE),e.tapTree=i.outputs.tapTree.decode(r);break;case a.OutputTypes.TAP_BIP32_DERIVATION:void 0===e.tapBip32Derivation&&(e.tapBip32Derivation=[]),e.tapBip32Derivation.push(i.outputs.tapBip32Derivation.decode(r));break;default:e.unknownKeyVals||(e.unknownKeyVals=[]),e.unknownKeyVals.push(r)}l.push(e)}return{globalMap:s,inputs:p,outputs:l}}e.psbtFromBuffer=function(t,e){let r=0;function n(){const e=s.decode(t,r);r+=s.encodingLength(e);const n=t.slice(r,r+e);return r+=e,n}function i(){return{key:n(),value:n()}}function u(){if(r>=t.length)throw new Error("Format Error: Unexpected End of PSBT");const e=0===t.readUInt8(r);return e&&r++,e}if(1886610036!==function(){const e=t.readUInt32BE(r);return r+=4,e}())throw new Error("Format Error: Invalid Magic Number");if(255!==function(){const e=t.readUInt8(r);return r+=1,e}())throw new Error("Format Error: Magic Number must be followed by 0xff separator");const c=[],h={};for(;!u();){const t=i(),e=t.key.toString("hex");if(h[e])throw new Error("Format Error: Keys must be unique for global keymap: key "+e);h[e]=1,c.push(t)}const p=c.filter((t=>t.key[0]===a.GlobalTypes.UNSIGNED_TX));if(1!==p.length)throw new Error("Format Error: Only one UNSIGNED_TX allowed");const l=e(p[0].value),{inputCount:d,outputCount:y}=l.getInputOutputCounts(),w=[],g=[];for(const t of o.range(d)){const e={},r=[];for(;!u();){const n=i(),o=n.key.toString("hex");if(e[o])throw new Error("Format Error: Keys must be unique for each input: input index "+t+" key "+o);e[o]=1,r.push(n)}w.push(r)}for(const t of o.range(y)){const e={},r=[];for(;!u();){const n=i(),o=n.key.toString("hex");if(e[o])throw new Error("Format Error: Keys must be unique for each output: output index "+t+" key "+o);e[o]=1,r.push(n)}g.push(r)}return f(l,{globalMapKeyVals:c,inputKeyVals:w,outputKeyVals:g})},e.checkKeyBuffer=u,e.psbtFromKeyVals=f},1457:(t,e,r)=>{"use strict";function n(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}Object.defineProperty(e,"__esModule",{value:!0}),n(r(6263)),n(r(238))},238:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(2706),o=r(8133);e.psbtToBuffer=function({globalMap:t,inputs:e,outputs:r}){const{globalKeyVals:i,inputKeyVals:s,outputKeyVals:a}=u({globalMap:t,inputs:e,outputs:r}),f=o.keyValsToBuffer(i),c=t=>0===t.length?[n.from([0])]:t.map(o.keyValsToBuffer),h=c(s),p=c(a),l=n.allocUnsafe(5);return l.writeUIntBE(482972169471,0,5),n.concat([l,f].concat(h,p))};const s=(t,e)=>t.key.compare(e.key);function a(t,e){const r=new Set,n=Object.entries(t).reduce(((t,[n,i])=>{if("unknownKeyVals"===n)return t;const o=e[n];if(void 0===o)return t;const s=(Array.isArray(i)?i:[i]).map(o.encode);return s.map((t=>t.key.toString("hex"))).forEach((t=>{if(r.has(t))throw new Error("Serialize Error: Duplicate key: "+t);r.add(t)})),t.concat(s)}),[]),i=t.unknownKeyVals?t.unknownKeyVals.filter((t=>!r.has(t.key.toString("hex")))):[];return n.concat(i).sort(s)}function u({globalMap:t,inputs:e,outputs:r}){return{globalKeyVals:a(t,i.globals),inputKeyVals:e.map((t=>a(t,i.inputs))),outputKeyVals:r.map((t=>a(t,i.outputs)))}}e.psbtToKeyVals=u},1614:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(4863),o=r(1457),s=r(9080),a=r(5080);e.Psbt=class{constructor(t){this.inputs=[],this.outputs=[],this.globalMap={unsignedTx:t}}static fromBase64(t,e){const r=n.from(t,"base64");return this.fromBuffer(r,e)}static fromHex(t,e){const r=n.from(t,"hex");return this.fromBuffer(r,e)}static fromBuffer(t,e){const r=o.psbtFromBuffer(t,e),n=new this(r.globalMap.unsignedTx);return Object.assign(n,r),n}toBase64(){return this.toBuffer().toString("base64")}toHex(){return this.toBuffer().toString("hex")}toBuffer(){return o.psbtToBuffer(this)}updateGlobal(t){return a.updateGlobal(t,this.globalMap),this}updateInput(t,e){const r=a.checkForInput(this.inputs,t);return a.updateInput(e,r),this}updateOutput(t,e){const r=a.checkForOutput(this.outputs,t);return a.updateOutput(e,r),this}addUnknownKeyValToGlobal(t){return a.checkHasKey(t,this.globalMap.unknownKeyVals,a.getEnumLength(s.GlobalTypes)),this.globalMap.unknownKeyVals||(this.globalMap.unknownKeyVals=[]),this.globalMap.unknownKeyVals.push(t),this}addUnknownKeyValToInput(t,e){const r=a.checkForInput(this.inputs,t);return a.checkHasKey(e,r.unknownKeyVals,a.getEnumLength(s.InputTypes)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(e),this}addUnknownKeyValToOutput(t,e){const r=a.checkForOutput(this.outputs,t);return a.checkHasKey(e,r.unknownKeyVals,a.getEnumLength(s.OutputTypes)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(e),this}addInput(t){this.globalMap.unsignedTx.addInput(t),this.inputs.push({unknownKeyVals:[]});const e=t.unknownKeyVals||[],r=this.inputs.length-1;if(!Array.isArray(e))throw new Error("unknownKeyVals must be an Array");return e.forEach((t=>this.addUnknownKeyValToInput(r,t))),a.addInputAttributes(this.inputs,t),this}addOutput(t){this.globalMap.unsignedTx.addOutput(t),this.outputs.push({unknownKeyVals:[]});const e=t.unknownKeyVals||[],r=this.outputs.length-1;if(!Array.isArray(e))throw new Error("unknownKeyVals must be an Array");return e.forEach((t=>this.addUnknownKeyValToOutput(r,t))),a.addOutputAttributes(this.outputs,t),this}clearFinalizedInput(t){const e=a.checkForInput(this.inputs,t);a.inputCheckUncleanFinalized(t,e);for(const t of Object.keys(e))["witnessUtxo","nonWitnessUtxo","finalScriptSig","finalScriptWitness","unknownKeyVals"].includes(t)||delete e[t];return this}combine(...t){const e=i.combine([this].concat(t));return Object.assign(this,e),this}getTransaction(){return this.globalMap.unsignedTx.toBuffer()}}},9080:(t,e)=>{"use strict";var r,n,i;Object.defineProperty(e,"__esModule",{value:!0}),(i=e.GlobalTypes||(e.GlobalTypes={}))[i.UNSIGNED_TX=0]="UNSIGNED_TX",i[i.GLOBAL_XPUB=1]="GLOBAL_XPUB",e.GLOBAL_TYPE_NAMES=["unsignedTx","globalXpub"],(n=e.InputTypes||(e.InputTypes={}))[n.NON_WITNESS_UTXO=0]="NON_WITNESS_UTXO",n[n.WITNESS_UTXO=1]="WITNESS_UTXO",n[n.PARTIAL_SIG=2]="PARTIAL_SIG",n[n.SIGHASH_TYPE=3]="SIGHASH_TYPE",n[n.REDEEM_SCRIPT=4]="REDEEM_SCRIPT",n[n.WITNESS_SCRIPT=5]="WITNESS_SCRIPT",n[n.BIP32_DERIVATION=6]="BIP32_DERIVATION",n[n.FINAL_SCRIPTSIG=7]="FINAL_SCRIPTSIG",n[n.FINAL_SCRIPTWITNESS=8]="FINAL_SCRIPTWITNESS",n[n.POR_COMMITMENT=9]="POR_COMMITMENT",n[n.TAP_KEY_SIG=19]="TAP_KEY_SIG",n[n.TAP_SCRIPT_SIG=20]="TAP_SCRIPT_SIG",n[n.TAP_LEAF_SCRIPT=21]="TAP_LEAF_SCRIPT",n[n.TAP_BIP32_DERIVATION=22]="TAP_BIP32_DERIVATION",n[n.TAP_INTERNAL_KEY=23]="TAP_INTERNAL_KEY",n[n.TAP_MERKLE_ROOT=24]="TAP_MERKLE_ROOT",e.INPUT_TYPE_NAMES=["nonWitnessUtxo","witnessUtxo","partialSig","sighashType","redeemScript","witnessScript","bip32Derivation","finalScriptSig","finalScriptWitness","porCommitment","tapKeySig","tapScriptSig","tapLeafScript","tapBip32Derivation","tapInternalKey","tapMerkleRoot"],(r=e.OutputTypes||(e.OutputTypes={}))[r.REDEEM_SCRIPT=0]="REDEEM_SCRIPT",r[r.WITNESS_SCRIPT=1]="WITNESS_SCRIPT",r[r.BIP32_DERIVATION=2]="BIP32_DERIVATION",r[r.TAP_INTERNAL_KEY=5]="TAP_INTERNAL_KEY",r[r.TAP_TREE=6]="TAP_TREE",r[r.TAP_BIP32_DERIVATION=7]="TAP_BIP32_DERIVATION",e.OUTPUT_TYPE_NAMES=["redeemScript","witnessScript","bip32Derivation","tapInternalKey","tapTree","tapBip32Derivation"]},5080:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(2706);function o(t,e){const r=t[e];if(void 0===r)throw new Error(`No input #${e}`);return r}function s(t,e){const r=t[e];if(void 0===r)throw new Error(`No output #${e}`);return r}function a(t,e,r,n){throw new Error(`Data for ${t} key ${e} is incorrect: Expected ${r} and got ${JSON.stringify(n)}`)}function u(t){return(e,r)=>{for(const n of Object.keys(e)){const o=e[n],{canAdd:s,canAddToArray:u,check:f,expected:c}=i[t+"s"][n]||{};if(f)if(u){if(!Array.isArray(o)||r[n]&&!Array.isArray(r[n]))throw new Error(`Key type ${n} must be an array`);o.every(f)||a(t,n,c,o);const e=r[n]||[],i=new Set;if(!o.every((t=>u(e,t,i))))throw new Error("Can not add duplicate data to array");r[n]=e.concat(o)}else{if(f(o)||a(t,n,c,o),!s(r,o))throw new Error(`Can not add duplicate data to ${t}`);r[n]=o}}}}e.checkForInput=o,e.checkForOutput=s,e.checkHasKey=function(t,e,r){if(t.key[0]e.key.equals(t.key))).length)throw new Error(`Duplicate Key: ${t.key.toString("hex")}`)},e.getEnumLength=function(t){let e=0;return Object.keys(t).forEach((t=>{Number(isNaN(Number(t)))&&e++})),e},e.inputCheckUncleanFinalized=function(t,e){let r=!1;if(e.nonWitnessUtxo||e.witnessUtxo){const t=!!e.redeemScript,n=!!e.witnessScript,i=!t||!!e.finalScriptSig,o=!n||!!e.finalScriptWitness,s=!!e.finalScriptSig||!!e.finalScriptWitness;r=i&&o&&s}if(!1===r)throw new Error(`Input #${t} has too much or too little data to clean`)},e.updateGlobal=u("global"),e.updateInput=u("input"),e.updateOutput=u("output"),e.addInputAttributes=function(t,r){const n=o(t,t.length-1);e.updateInput(r,n)},e.addOutputAttributes=function(t,r){const n=s(t,t.length-1);e.updateOutput(r,n)},e.defaultVersionSetter=function(t,e){if(!n.isBuffer(e)||e.length<4)throw new Error("Set Version: Invalid Transaction");return e.writeUInt32LE(t,0),e},e.defaultLocktimeSetter=function(t,e){if(!n.isBuffer(e)||e.length<4)throw new Error("Set Locktime: Invalid Transaction");return e.writeUInt32LE(t,e.length-4),e}},57:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.toOutputScript=e.fromOutputScript=e.toBech32=e.toBase58Check=e.fromBech32=e.fromBase58Check=void 0;const i=r(622),o=r(885),s=r(7038),a=r(8116),u=r(6586),f=r(1889),c="WARNING: Sending to a future segwit version address can lead to loss of funds. End users MUST be warned carefully in the GUI and asked if they wish to proceed with caution. Wallets should verify the segwit version from the output of fromBech32, then decide when it is safe to use which version of segwit.";function h(t){const e=n.from(f.decode(t));if(e.length<21)throw new TypeError(t+" is too short");if(e.length>21)throw new TypeError(t+" is too long");return{version:e.readUInt8(0),hash:e.slice(1)}}function p(t){let e,r;try{e=u.bech32.decode(t)}catch(t){}if(e){if(r=e.words[0],0!==r)throw new TypeError(t+" uses wrong encoding")}else if(e=u.bech32m.decode(t),r=e.words[0],0===r)throw new TypeError(t+" uses wrong encoding");const i=u.bech32.fromWords(e.words.slice(1));return{version:r,prefix:e.prefix,data:n.from(i)}}function l(t,e,r){const n=u.bech32.toWords(t);return n.unshift(e),0===e?u.bech32.encode(r,n):u.bech32m.encode(r,n)}e.fromBase58Check=h,e.fromBech32=p,e.toBase58Check=function(t,e){(0,a.typeforce)((0,a.tuple)(a.Hash160bit,a.UInt8),arguments);const r=n.allocUnsafe(21);return r.writeUInt8(e,0),t.copy(r,1),f.encode(r)},e.toBech32=l,e.fromOutputScript=function(t,e){e=e||i.bitcoin;try{return o.p2pkh({output:t,network:e}).address}catch(t){}try{return o.p2sh({output:t,network:e}).address}catch(t){}try{return o.p2wpkh({output:t,network:e}).address}catch(t){}try{return o.p2wsh({output:t,network:e}).address}catch(t){}try{return o.p2tr({output:t,network:e}).address}catch(t){}try{return function(t,e){const r=t.slice(2);if(r.length<2||r.length>40)throw new TypeError("Invalid program length for segwit address");const n=t[0]-80;if(n<2||n>16)throw new TypeError("Invalid version for segwit address");if(t[1]!==r.length)throw new TypeError("Invalid script for segwit address");return console.warn(c),l(r,n,e.bech32)}(t,e)}catch(t){}throw new Error(s.toASM(t)+" has no matching Address")},e.toOutputScript=function(t,e){let r,n;e=e||i.bitcoin;try{r=h(t)}catch(t){}if(r){if(r.version===e.pubKeyHash)return o.p2pkh({hash:r.hash}).output;if(r.version===e.scriptHash)return o.p2sh({hash:r.hash}).output}else{try{n=p(t)}catch(t){}if(n){if(n.prefix!==e.bech32)throw new Error(t+" has an invalid prefix");if(0===n.version){if(20===n.data.length)return o.p2wpkh({hash:n.data}).output;if(32===n.data.length)return o.p2wsh({hash:n.data}).output}else if(1===n.version){if(32===n.data.length)return o.p2tr({pubkey:n.data}).output}else if(n.version>=2&&n.version<=16&&n.data.length>=2&&n.data.length<=40)return console.warn(c),s.compile([n.version+80,n.data])}}throw new Error(t+" has no matching Script")}},3966:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.encode=e.decode=e.check=void 0,e.check=function(t){if(t.length<8)return!1;if(t.length>72)return!1;if(48!==t[0])return!1;if(t[1]!==t.length-2)return!1;if(2!==t[2])return!1;const e=t[3];if(0===e)return!1;if(5+e>=t.length)return!1;if(2!==t[4+e])return!1;const r=t[5+e];return!(0===r||6+e+r!==t.length||128&t[4]||e>1&&0===t[4]&&!(128&t[5])||128&t[e+6]||r>1&&0===t[e+6]&&!(128&t[e+7]))},e.decode=function(t){if(t.length<8)throw new Error("DER sequence length is too short");if(t.length>72)throw new Error("DER sequence length is too long");if(48!==t[0])throw new Error("Expected DER sequence");if(t[1]!==t.length-2)throw new Error("DER sequence length is invalid");if(2!==t[2])throw new Error("Expected DER integer");const e=t[3];if(0===e)throw new Error("R length is zero");if(5+e>=t.length)throw new Error("R length is too long");if(2!==t[4+e])throw new Error("Expected DER integer (2)");const r=t[5+e];if(0===r)throw new Error("S length is zero");if(6+e+r!==t.length)throw new Error("S length is invalid");if(128&t[4])throw new Error("R value is negative");if(e>1&&0===t[4]&&!(128&t[5]))throw new Error("R value excessively padded");if(128&t[e+6])throw new Error("S value is negative");if(r>1&&0===t[e+6]&&!(128&t[e+7]))throw new Error("S value excessively padded");return{r:t.slice(4,4+e),s:t.slice(6+e)}},e.encode=function(t,e){const r=t.length,i=e.length;if(0===r)throw new Error("R length is zero");if(0===i)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(i>33)throw new Error("S length is too long");if(128&t[0])throw new Error("R value is negative");if(128&e[0])throw new Error("S value is negative");if(r>1&&0===t[0]&&!(128&t[1]))throw new Error("R value excessively padded");if(i>1&&0===e[0]&&!(128&e[1]))throw new Error("S value excessively padded");const o=n.allocUnsafe(6+r+i);return o[0]=48,o[1]=o.length-2,o[2]=2,o[3]=t.length,t.copy(o,4),o[4+r]=2,o[5+r]=e.length,e.copy(o,6+r),o}},1696:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.Block=void 0;const i=r(606),o=r(1944),s=r(1015),a=r(2021),u=r(8116),{typeforce:f}=u,c=new TypeError("Cannot compute merkle root for zero transactions"),h=new TypeError("Cannot compute witness commit for non-segwit block");class p{constructor(){this.version=1,this.prevHash=void 0,this.merkleRoot=void 0,this.timestamp=0,this.witnessCommit=void 0,this.bits=0,this.nonce=0,this.transactions=void 0}static fromBuffer(t){if(t.length<80)throw new Error("Buffer too small (< 80 bytes)");const e=new i.BufferReader(t),r=new p;if(r.version=e.readInt32(),r.prevHash=e.readSlice(32),r.merkleRoot=e.readSlice(32),r.timestamp=e.readUInt32(),r.bits=e.readUInt32(),r.nonce=e.readUInt32(),80===t.length)return r;const n=()=>{const t=a.Transaction.fromBuffer(e.buffer.slice(e.offset),!0);return e.offset+=t.byteLength(),t},o=e.readVarInt();r.transactions=[];for(let t=0;t>24)-3,r=8388607&t,i=n.alloc(32,0);return i.writeUIntBE(r,29-e,3),i}static calculateMerkleRoot(t,e){if(f([{getHash:u.Function}],t),0===t.length)throw c;if(e&&!l(t))throw h;const r=t.map((t=>t.getHash(e))),i=(0,s.fastMerkleRoot)(r,o.hash256);return e?o.hash256(n.concat([i,t[0].ins[0].witness[0]])):i}getWitnessCommit(){if(!l(this.transactions))return null;const t=this.transactions[0].outs.filter((t=>t.script.slice(0,6).equals(n.from("6a24aa21a9ed","hex")))).map((t=>t.script.slice(6,38)));if(0===t.length)return null;const e=t[t.length-1];return e instanceof n&&32===e.length?e:null}hasWitnessCommit(){return this.witnessCommit instanceof n&&32===this.witnessCommit.length||null!==this.getWitnessCommit()}hasWitness(){return(t=this.transactions)instanceof Array&&t.some((t=>"object"==typeof t&&t.ins instanceof Array&&t.ins.some((t=>"object"==typeof t&&t.witness instanceof Array&&t.witness.length>0))));var t}weight(){return 3*this.byteLength(!1,!1)+this.byteLength(!1,!0)}byteLength(t,e=!0){return t||!this.transactions?80:80+i.varuint.encodingLength(this.transactions.length)+this.transactions.reduce(((t,r)=>t+r.byteLength(e)),0)}getHash(){return o.hash256(this.toBuffer(!0))}getId(){return(0,i.reverseBuffer)(this.getHash()).toString("hex")}getUTCDate(){const t=new Date(0);return t.setUTCSeconds(this.timestamp),t}toBuffer(t){const e=n.allocUnsafe(this.byteLength(t)),r=new i.BufferWriter(e);return r.writeInt32(this.version),r.writeSlice(this.prevHash),r.writeSlice(this.merkleRoot),r.writeUInt32(this.timestamp),r.writeUInt32(this.bits),r.writeUInt32(this.nonce),t||!this.transactions||(i.varuint.encode(this.transactions.length,e,r.offset),r.offset+=i.varuint.encode.bytes,this.transactions.forEach((t=>{const n=t.byteLength();t.toBuffer(e,r.offset),r.offset+=n}))),e}toHex(t){return this.toBuffer(t).toString("hex")}checkTxRoots(){const t=this.hasWitnessCommit();return!(!t&&this.hasWitness())&&this.__checkMerkleRoot()&&(!t||this.__checkWitnessCommit())}checkProofOfWork(){const t=(0,i.reverseBuffer)(this.getHash()),e=p.calculateTarget(this.bits);return t.compare(e)<=0}__checkMerkleRoot(){if(!this.transactions)throw c;const t=p.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(t)}__checkWitnessCommit(){if(!this.transactions)throw c;if(!this.hasWitnessCommit())throw h;const t=p.calculateMerkleRoot(this.transactions,!0);return 0===this.witnessCommit.compare(t)}}function l(t){return t instanceof Array&&t[0]&&t[0].ins&&t[0].ins instanceof Array&&t[0].ins[0]&&t[0].ins[0].witness&&t[0].ins[0].witness instanceof Array&&t[0].ins[0].witness.length>0}e.Block=p},606:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.BufferReader=e.BufferWriter=e.cloneBuffer=e.reverseBuffer=e.writeUInt64LE=e.readUInt64LE=e.varuint=void 0;const i=r(8116),{typeforce:o}=i,s=r(8469);function a(t,e){if("number"!=typeof t)throw new Error("cannot write a non-number as a number");if(t<0)throw new Error("specified a negative value for writing an unsigned value");if(t>e)throw new Error("RangeError: value out of range");if(Math.floor(t)!==t)throw new Error("value has a fractional component")}function u(t,e){const r=t.readUInt32LE(e);let n=t.readUInt32LE(e+4);return n*=4294967296,a(n+r,9007199254740991),n+r}function f(t,e,r){return a(e,9007199254740991),t.writeInt32LE(-1&e,r),t.writeUInt32LE(Math.floor(e/4294967296),r+4),r+8}e.varuint=s,e.readUInt64LE=u,e.writeUInt64LE=f,e.reverseBuffer=function(t){if(t.length<1)return t;let e=t.length-1,r=0;for(let n=0;nthis.writeVarSlice(t)))}end(){if(this.buffer.length===this.offset)return this.buffer;throw new Error(`buffer size ${this.buffer.length}, offset ${this.offset}`)}}e.BufferWriter=c,e.BufferReader=class{constructor(t,e=0){this.buffer=t,this.offset=e,o(i.tuple(i.Buffer,i.UInt32),[t,e])}readUInt8(){const t=this.buffer.readUInt8(this.offset);return this.offset++,t}readInt32(){const t=this.buffer.readInt32LE(this.offset);return this.offset+=4,t}readUInt32(){const t=this.buffer.readUInt32LE(this.offset);return this.offset+=4,t}readUInt64(){const t=u(this.buffer,this.offset);return this.offset+=8,t}readVarInt(){const t=s.decode(this.buffer,this.offset);return this.offset+=s.decode.bytes,t}readSlice(t){if(this.buffer.length{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.taggedHash=e.TAGGED_HASH_PREFIXES=e.TAGS=e.hash256=e.hash160=e.sha256=e.sha1=e.ripemd160=void 0;const i=r(71),o=r(874),s=r(9688);function a(t){return n.from((0,s.sha256)(Uint8Array.from(t)))}e.ripemd160=function(t){return n.from((0,i.ripemd160)(Uint8Array.from(t)))},e.sha1=function(t){return n.from((0,o.sha1)(Uint8Array.from(t)))},e.sha256=a,e.hash160=function(t){return n.from((0,i.ripemd160)((0,s.sha256)(Uint8Array.from(t))))},e.hash256=function(t){return n.from((0,s.sha256)((0,s.sha256)(Uint8Array.from(t))))},e.TAGS=["BIP0340/challenge","BIP0340/aux","BIP0340/nonce","TapLeaf","TapBranch","TapSighash","TapTweak","KeyAgg list","KeyAgg coefficient"],e.TAGGED_HASH_PREFIXES={"BIP0340/challenge":n.from([123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124,123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124]),"BIP0340/aux":n.from([241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144,241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144]),"BIP0340/nonce":n.from([7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47,7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47]),TapLeaf:n.from([174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238,174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238]),TapBranch:n.from([25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21,25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21]),TapSighash:n.from([244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49,244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49]),TapTweak:n.from([232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233,232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233]),"KeyAgg list":n.from([72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240,72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240]),"KeyAgg coefficient":n.from([191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129,191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129])},e.taggedHash=function(t,r){return a(n.concat([e.TAGGED_HASH_PREFIXES[t],r]))}},916:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.getEccLib=e.initEccLib=void 0;const i={};e.initEccLib=function(t){t?t!==i.eccLib&&(function(t){s("function"==typeof t.isXOnlyPoint),s(t.isXOnlyPoint(o("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),s(t.isXOnlyPoint(o("fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e"))),s(t.isXOnlyPoint(o("f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"))),s(t.isXOnlyPoint(o("0000000000000000000000000000000000000000000000000000000000000001"))),s(!t.isXOnlyPoint(o("0000000000000000000000000000000000000000000000000000000000000000"))),s(!t.isXOnlyPoint(o("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"))),s("function"==typeof t.xOnlyPointAddTweak),a.forEach((e=>{const r=t.xOnlyPointAddTweak(o(e.pubkey),o(e.tweak));null===e.result?s(null===r):(s(null!==r),s(r.parity===e.parity),s(n.from(r.xOnlyPubkey).equals(o(e.result))))}))}(t),i.eccLib=t):i.eccLib=t},e.getEccLib=function(){if(!i.eccLib)throw new Error("No ECC Library provided. You must call initEccLib() with a valid TinySecp256k1Interface instance");return i.eccLib};const o=t=>n.from(t,"hex");function s(t){if(!t)throw new Error("ecc library invalid")}const a=[{pubkey:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",tweak:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140",parity:-1,result:null},{pubkey:"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b",tweak:"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac",parity:1,result:"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"},{pubkey:"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991",tweak:"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47",parity:0,result:"9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"}]},1757:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.initEccLib=e.Transaction=e.opcodes=e.Psbt=e.Block=e.script=e.payments=e.networks=e.crypto=e.address=void 0;const n=r(57);e.address=n;const i=r(1944);e.crypto=i;const o=r(622);e.networks=o;const s=r(885);e.payments=s;const a=r(7038);e.script=a;var u=r(1696);Object.defineProperty(e,"Block",{enumerable:!0,get:function(){return u.Block}});var f=r(9646);Object.defineProperty(e,"Psbt",{enumerable:!0,get:function(){return f.Psbt}});var c=r(8417);Object.defineProperty(e,"opcodes",{enumerable:!0,get:function(){return c.OPS}});var h=r(2021);Object.defineProperty(e,"Transaction",{enumerable:!0,get:function(){return h.Transaction}});var p=r(916);Object.defineProperty(e,"initEccLib",{enumerable:!0,get:function(){return p.initEccLib}})},1015:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.fastMerkleRoot=void 0,e.fastMerkleRoot=function(t,e){if(!Array.isArray(t))throw TypeError("Expected values Array");if("function"!=typeof e)throw TypeError("Expected digest Function");let r=t.length;const i=t.concat();for(;r>1;){let t=0;for(let o=0;o{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.testnet=e.regtest=e.bitcoin=void 0,e.bitcoin={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},e.regtest={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bcrt",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},e.testnet={messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239}},8417:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.REVERSE_OPS=e.OPS=void 0;const r={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_CHECKSIGADD:186,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255};e.OPS=r;const n={};e.REVERSE_OPS=n;for(const t of Object.keys(r))n[r[t]]=t},2218:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.tweakKey=e.tapTweakHash=e.tapleafHash=e.findScriptPath=e.toHashTree=e.rootHashFromPath=e.MAX_TAPTREE_DEPTH=e.LEAF_VERSION_TAPSCRIPT=void 0;const n=r(1048),i=r(916),o=r(1944),s=r(606),a=r(8116);function u(t){const r=t.version||e.LEAF_VERSION_TAPSCRIPT;return o.taggedHash("TapLeaf",n.Buffer.concat([n.Buffer.from([r]),h(t.output)]))}function f(t,e){return o.taggedHash("TapTweak",n.Buffer.concat(e?[t,e]:[t]))}function c(t,e){return o.taggedHash("TapBranch",n.Buffer.concat([t,e]))}function h(t){const e=s.varuint.encodingLength(t.length),r=n.Buffer.allocUnsafe(e);return s.varuint.encode(t.length,r),n.Buffer.concat([r,t])}e.LEAF_VERSION_TAPSCRIPT=192,e.MAX_TAPTREE_DEPTH=128,e.rootHashFromPath=function(t,e){if(t.length<33)throw new TypeError(`The control-block length is too small. Got ${t.length}, expected min 33.`);const r=(t.length-33)/32;let n=e;for(let e=0;et.hash.compare(e.hash)));const[n,i]=r;return{hash:c(n.hash,i.hash),left:n,right:i}},e.findScriptPath=function t(e,r){if("left"in(n=e)&&"right"in n){const n=t(e.left,r);if(void 0!==n)return[...n,e.right.hash];const i=t(e.right,r);if(void 0!==i)return[...i,e.left.hash]}else if(e.hash.equals(r))return[];var n},e.tapleafHash=u,e.tapTweakHash=f,e.tweakKey=function(t,e){if(!n.Buffer.isBuffer(t))return null;if(32!==t.length)return null;if(e&&32!==e.length)return null;const r=f(t,e),o=(0,i.getEccLib)().xOnlyPointAddTweak(t,r);return o&&null!==o.xOnlyPubkey?{parity:o.parity,x:n.Buffer.from(o.xOnlyPubkey)}:null}},5472:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.p2data=void 0;const n=r(622),i=r(7038),o=r(8116),s=r(7883),a=i.OPS;e.p2data=function(t,e){if(!t.data&&!t.output)throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),(0,o.typeforce)({network:o.typeforce.maybe(o.typeforce.Object),output:o.typeforce.maybe(o.typeforce.Buffer),data:o.typeforce.maybe(o.typeforce.arrayOf(o.typeforce.Buffer))},t);const r={name:"embed",network:t.network||n.bitcoin};if(s.prop(r,"output",(()=>{if(t.data)return i.compile([a.OP_RETURN].concat(t.data))})),s.prop(r,"data",(()=>{if(t.output)return i.decompile(t.output).slice(1)})),e.validate&&t.output){const e=i.decompile(t.output);if(e[0]!==a.OP_RETURN)throw new TypeError("Output is invalid");if(!e.slice(1).every(o.typeforce.Buffer))throw new TypeError("Output is invalid");if(t.data&&!(0,o.stacksEqual)(t.data,r.data))throw new TypeError("Data mismatch")}return Object.assign(r,t)}},885:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.p2tr=e.p2wsh=e.p2wpkh=e.p2sh=e.p2pkh=e.p2pk=e.p2ms=e.embed=void 0;const n=r(5472);Object.defineProperty(e,"embed",{enumerable:!0,get:function(){return n.p2data}});const i=r(1395);Object.defineProperty(e,"p2ms",{enumerable:!0,get:function(){return i.p2ms}});const o=r(4930);Object.defineProperty(e,"p2pk",{enumerable:!0,get:function(){return o.p2pk}});const s=r(3504);Object.defineProperty(e,"p2pkh",{enumerable:!0,get:function(){return s.p2pkh}});const a=r(8368);Object.defineProperty(e,"p2sh",{enumerable:!0,get:function(){return a.p2sh}});const u=r(7027);Object.defineProperty(e,"p2wpkh",{enumerable:!0,get:function(){return u.p2wpkh}});const f=r(9041);Object.defineProperty(e,"p2wsh",{enumerable:!0,get:function(){return f.p2wsh}});const c=r(5501);Object.defineProperty(e,"p2tr",{enumerable:!0,get:function(){return c.p2tr}})},7883:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.value=e.prop=void 0,e.prop=function(t,e,r){Object.defineProperty(t,e,{configurable:!0,enumerable:!0,get(){const t=r.call(this);return this[e]=t,t},set(t){Object.defineProperty(this,e,{configurable:!0,enumerable:!0,value:t,writable:!0})}})},e.value=function(t){let e;return()=>(void 0!==e||(e=t()),e)}},1395:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.p2ms=void 0;const n=r(622),i=r(7038),o=r(8116),s=r(7883),a=i.OPS,u=a.OP_RESERVED;e.p2ms=function(t,e){if(!(t.input||t.output||t.pubkeys&&void 0!==t.m||t.signatures))throw new TypeError("Not enough data");function r(t){return i.isCanonicalScriptSignature(t)||void 0!==(e.allowIncomplete&&t===a.OP_0)}e=Object.assign({validate:!0},e||{}),(0,o.typeforce)({network:o.typeforce.maybe(o.typeforce.Object),m:o.typeforce.maybe(o.typeforce.Number),n:o.typeforce.maybe(o.typeforce.Number),output:o.typeforce.maybe(o.typeforce.Buffer),pubkeys:o.typeforce.maybe(o.typeforce.arrayOf(o.isPoint)),signatures:o.typeforce.maybe(o.typeforce.arrayOf(r)),input:o.typeforce.maybe(o.typeforce.Buffer)},t);const f={network:t.network||n.bitcoin};let c=[],h=!1;function p(t){h||(h=!0,c=i.decompile(t),f.m=c[0]-u,f.n=c[c.length-2]-u,f.pubkeys=c.slice(1,-2))}if(s.prop(f,"output",(()=>{if(t.m&&f.n&&t.pubkeys)return i.compile([].concat(u+t.m,t.pubkeys,u+f.n,a.OP_CHECKMULTISIG))})),s.prop(f,"m",(()=>{if(f.output)return p(f.output),f.m})),s.prop(f,"n",(()=>{if(f.pubkeys)return f.pubkeys.length})),s.prop(f,"pubkeys",(()=>{if(t.output)return p(t.output),f.pubkeys})),s.prop(f,"signatures",(()=>{if(t.input)return i.decompile(t.input).slice(1)})),s.prop(f,"input",(()=>{if(t.signatures)return i.compile([a.OP_0].concat(t.signatures))})),s.prop(f,"witness",(()=>{if(f.input)return[]})),s.prop(f,"name",(()=>{if(f.m&&f.n)return`p2ms(${f.m} of ${f.n})`})),e.validate){if(t.output){if(p(t.output),!o.typeforce.Number(c[0]))throw new TypeError("Output is invalid");if(!o.typeforce.Number(c[c.length-2]))throw new TypeError("Output is invalid");if(c[c.length-1]!==a.OP_CHECKMULTISIG)throw new TypeError("Output is invalid");if(f.m<=0||f.n>16||f.m>f.n||f.n!==c.length-3)throw new TypeError("Output is invalid");if(!f.pubkeys.every((t=>(0,o.isPoint)(t))))throw new TypeError("Output is invalid");if(void 0!==t.m&&t.m!==f.m)throw new TypeError("m mismatch");if(void 0!==t.n&&t.n!==f.n)throw new TypeError("n mismatch");if(t.pubkeys&&!(0,o.stacksEqual)(t.pubkeys,f.pubkeys))throw new TypeError("Pubkeys mismatch")}if(t.pubkeys){if(void 0!==t.n&&t.n!==t.pubkeys.length)throw new TypeError("Pubkey count mismatch");if(f.n=t.pubkeys.length,f.nf.m)throw new TypeError("Too many signatures provided")}if(t.input){if(t.input[0]!==a.OP_0)throw new TypeError("Input is invalid");if(0===f.signatures.length||!f.signatures.every(r))throw new TypeError("Input has invalid signature(s)");if(t.signatures&&!(0,o.stacksEqual)(t.signatures,f.signatures))throw new TypeError("Signature mismatch");if(void 0!==t.m&&t.m!==t.signatures.length)throw new TypeError("Signature count mismatch")}}return Object.assign(f,t)}},4930:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.p2pk=void 0;const n=r(622),i=r(7038),o=r(8116),s=r(7883),a=i.OPS;e.p2pk=function(t,e){if(!(t.input||t.output||t.pubkey||t.input||t.signature))throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),(0,o.typeforce)({network:o.typeforce.maybe(o.typeforce.Object),output:o.typeforce.maybe(o.typeforce.Buffer),pubkey:o.typeforce.maybe(o.isPoint),signature:o.typeforce.maybe(i.isCanonicalScriptSignature),input:o.typeforce.maybe(o.typeforce.Buffer)},t);const r=s.value((()=>i.decompile(t.input))),u={name:"p2pk",network:t.network||n.bitcoin};if(s.prop(u,"output",(()=>{if(t.pubkey)return i.compile([t.pubkey,a.OP_CHECKSIG])})),s.prop(u,"pubkey",(()=>{if(t.output)return t.output.slice(1,-1)})),s.prop(u,"signature",(()=>{if(t.input)return r()[0]})),s.prop(u,"input",(()=>{if(t.signature)return i.compile([t.signature])})),s.prop(u,"witness",(()=>{if(u.input)return[]})),e.validate){if(t.output){if(t.output[t.output.length-1]!==a.OP_CHECKSIG)throw new TypeError("Output is invalid");if(!(0,o.isPoint)(u.pubkey))throw new TypeError("Output pubkey is invalid");if(t.pubkey&&!t.pubkey.equals(u.pubkey))throw new TypeError("Pubkey mismatch")}if(t.signature&&t.input&&!t.input.equals(u.input))throw new TypeError("Signature mismatch");if(t.input){if(1!==r().length)throw new TypeError("Input is invalid");if(!i.isCanonicalScriptSignature(u.signature))throw new TypeError("Input has invalid signature")}}return Object.assign(u,t)}},3504:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.p2pkh=void 0;const i=r(1944),o=r(622),s=r(7038),a=r(8116),u=r(7883),f=r(1889),c=s.OPS;e.p2pkh=function(t,e){if(!(t.address||t.hash||t.output||t.pubkey||t.input))throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),(0,a.typeforce)({network:a.typeforce.maybe(a.typeforce.Object),address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(20)),output:a.typeforce.maybe(a.typeforce.BufferN(25)),pubkey:a.typeforce.maybe(a.isPoint),signature:a.typeforce.maybe(s.isCanonicalScriptSignature),input:a.typeforce.maybe(a.typeforce.Buffer)},t);const r=u.value((()=>{const e=n.from(f.decode(t.address));return{version:e.readUInt8(0),hash:e.slice(1)}})),h=u.value((()=>s.decompile(t.input))),p=t.network||o.bitcoin,l={name:"p2pkh",network:p};if(u.prop(l,"address",(()=>{if(!l.hash)return;const t=n.allocUnsafe(21);return t.writeUInt8(p.pubKeyHash,0),l.hash.copy(t,1),f.encode(t)})),u.prop(l,"hash",(()=>t.output?t.output.slice(3,23):t.address?r().hash:t.pubkey||l.pubkey?i.hash160(t.pubkey||l.pubkey):void 0)),u.prop(l,"output",(()=>{if(l.hash)return s.compile([c.OP_DUP,c.OP_HASH160,l.hash,c.OP_EQUALVERIFY,c.OP_CHECKSIG])})),u.prop(l,"pubkey",(()=>{if(t.input)return h()[1]})),u.prop(l,"signature",(()=>{if(t.input)return h()[0]})),u.prop(l,"input",(()=>{if(t.pubkey&&t.signature)return s.compile([t.signature,t.pubkey])})),u.prop(l,"witness",(()=>{if(l.input)return[]})),e.validate){let e=n.from([]);if(t.address){if(r().version!==p.pubKeyHash)throw new TypeError("Invalid version or Network mismatch");if(20!==r().hash.length)throw new TypeError("Invalid address");e=r().hash}if(t.hash){if(e.length>0&&!e.equals(t.hash))throw new TypeError("Hash mismatch");e=t.hash}if(t.output){if(25!==t.output.length||t.output[0]!==c.OP_DUP||t.output[1]!==c.OP_HASH160||20!==t.output[2]||t.output[23]!==c.OP_EQUALVERIFY||t.output[24]!==c.OP_CHECKSIG)throw new TypeError("Output is invalid");const r=t.output.slice(3,23);if(e.length>0&&!e.equals(r))throw new TypeError("Hash mismatch");e=r}if(t.pubkey){const r=i.hash160(t.pubkey);if(e.length>0&&!e.equals(r))throw new TypeError("Hash mismatch");e=r}if(t.input){const r=h();if(2!==r.length)throw new TypeError("Input is invalid");if(!s.isCanonicalScriptSignature(r[0]))throw new TypeError("Input has invalid signature");if(!(0,a.isPoint)(r[1]))throw new TypeError("Input has invalid pubkey");if(t.signature&&!t.signature.equals(r[0]))throw new TypeError("Signature mismatch");if(t.pubkey&&!t.pubkey.equals(r[1]))throw new TypeError("Pubkey mismatch");const n=i.hash160(r[1]);if(e.length>0&&!e.equals(n))throw new TypeError("Hash mismatch")}}return Object.assign(l,t)}},8368:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.p2sh=void 0;const i=r(1944),o=r(622),s=r(7038),a=r(8116),u=r(7883),f=r(1889),c=s.OPS;e.p2sh=function(t,e){if(!(t.address||t.hash||t.output||t.redeem||t.input))throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),(0,a.typeforce)({network:a.typeforce.maybe(a.typeforce.Object),address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(20)),output:a.typeforce.maybe(a.typeforce.BufferN(23)),redeem:a.typeforce.maybe({network:a.typeforce.maybe(a.typeforce.Object),output:a.typeforce.maybe(a.typeforce.Buffer),input:a.typeforce.maybe(a.typeforce.Buffer),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))}),input:a.typeforce.maybe(a.typeforce.Buffer),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))},t);let r=t.network;r||(r=t.redeem&&t.redeem.network||o.bitcoin);const h={network:r},p=u.value((()=>{const e=n.from(f.decode(t.address));return{version:e.readUInt8(0),hash:e.slice(1)}})),l=u.value((()=>s.decompile(t.input))),d=u.value((()=>{const e=l(),i=e[e.length-1];return{network:r,output:i===c.OP_FALSE?n.from([]):i,input:s.compile(e.slice(0,-1)),witness:t.witness||[]}}));if(u.prop(h,"address",(()=>{if(!h.hash)return;const t=n.allocUnsafe(21);return t.writeUInt8(h.network.scriptHash,0),h.hash.copy(t,1),f.encode(t)})),u.prop(h,"hash",(()=>t.output?t.output.slice(2,22):t.address?p().hash:h.redeem&&h.redeem.output?i.hash160(h.redeem.output):void 0)),u.prop(h,"output",(()=>{if(h.hash)return s.compile([c.OP_HASH160,h.hash,c.OP_EQUAL])})),u.prop(h,"redeem",(()=>{if(t.input)return d()})),u.prop(h,"input",(()=>{if(t.redeem&&t.redeem.input&&t.redeem.output)return s.compile([].concat(s.decompile(t.redeem.input),t.redeem.output))})),u.prop(h,"witness",(()=>h.redeem&&h.redeem.witness?h.redeem.witness:h.input?[]:void 0)),u.prop(h,"name",(()=>{const t=["p2sh"];return void 0!==h.redeem&&void 0!==h.redeem.name&&t.push(h.redeem.name),t.join("-")})),e.validate){let e=n.from([]);if(t.address){if(p().version!==r.scriptHash)throw new TypeError("Invalid version or Network mismatch");if(20!==p().hash.length)throw new TypeError("Invalid address");e=p().hash}if(t.hash){if(e.length>0&&!e.equals(t.hash))throw new TypeError("Hash mismatch");e=t.hash}if(t.output){if(23!==t.output.length||t.output[0]!==c.OP_HASH160||20!==t.output[1]||t.output[22]!==c.OP_EQUAL)throw new TypeError("Output is invalid");const r=t.output.slice(2,22);if(e.length>0&&!e.equals(r))throw new TypeError("Hash mismatch");e=r}const o=t=>{if(t.output){const r=s.decompile(t.output);if(!r||r.length<1)throw new TypeError("Redeem.output too short");if(t.output.byteLength>520)throw new TypeError("Redeem.output unspendable if larger than 520 bytes");if(s.countNonPushOnlyOPs(r)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const n=i.hash160(t.output);if(e.length>0&&!e.equals(n))throw new TypeError("Hash mismatch");e=n}if(t.input){const e=t.input.length>0,r=t.witness&&t.witness.length>0;if(!e&&!r)throw new TypeError("Empty input");if(e&&r)throw new TypeError("Input and witness provided");if(e){const e=s.decompile(t.input);if(!s.isPushOnly(e))throw new TypeError("Non push-only scriptSig")}}};if(t.input){const t=l();if(!t||t.length<1)throw new TypeError("Input too short");if(!n.isBuffer(d().output))throw new TypeError("Input is invalid");o(d())}if(t.redeem){if(t.redeem.network&&t.redeem.network!==r)throw new TypeError("Network mismatch");if(t.input){const e=d();if(t.redeem.output&&!t.redeem.output.equals(e.output))throw new TypeError("Redeem.output mismatch");if(t.redeem.input&&!t.redeem.input.equals(e.input))throw new TypeError("Redeem.input mismatch")}o(t.redeem)}if(t.witness&&t.redeem&&t.redeem.witness&&!(0,a.stacksEqual)(t.redeem.witness,t.witness))throw new TypeError("Witness and redeem.witness mismatch")}return Object.assign(h,t)}},5501:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.p2tr=void 0;const n=r(1048),i=r(622),o=r(7038),s=r(8116),a=r(916),u=r(2218),f=r(7883),c=r(6586),h=r(57),p=o.OPS;e.p2tr=function(t,e){if(!(t.address||t.output||t.pubkey||t.internalPubkey||t.witness&&t.witness.length>1))throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),(0,s.typeforce)({address:s.typeforce.maybe(s.typeforce.String),input:s.typeforce.maybe(s.typeforce.BufferN(0)),network:s.typeforce.maybe(s.typeforce.Object),output:s.typeforce.maybe(s.typeforce.BufferN(34)),internalPubkey:s.typeforce.maybe(s.typeforce.BufferN(32)),hash:s.typeforce.maybe(s.typeforce.BufferN(32)),pubkey:s.typeforce.maybe(s.typeforce.BufferN(32)),signature:s.typeforce.maybe(s.typeforce.anyOf(s.typeforce.BufferN(64),s.typeforce.BufferN(65))),witness:s.typeforce.maybe(s.typeforce.arrayOf(s.typeforce.Buffer)),scriptTree:s.typeforce.maybe(s.isTaptree),redeem:s.typeforce.maybe({output:s.typeforce.maybe(s.typeforce.Buffer),redeemVersion:s.typeforce.maybe(s.typeforce.Number),witness:s.typeforce.maybe(s.typeforce.arrayOf(s.typeforce.Buffer))}),redeemVersion:s.typeforce.maybe(s.typeforce.Number)},t);const r=f.value((()=>(0,h.fromBech32)(t.address))),l=f.value((()=>{if(t.witness&&t.witness.length)return t.witness.length>=2&&80===t.witness[t.witness.length-1][0]?t.witness.slice(0,-1):t.witness.slice()})),d=f.value((()=>t.scriptTree?(0,u.toHashTree)(t.scriptTree):t.hash?{hash:t.hash}:void 0)),y=t.network||i.bitcoin,w={name:"p2tr",network:y};if(f.prop(w,"address",(()=>{if(!w.pubkey)return;const t=c.bech32m.toWords(w.pubkey);return t.unshift(1),c.bech32m.encode(y.bech32,t)})),f.prop(w,"hash",(()=>{const t=d();if(t)return t.hash;const e=l();if(e&&e.length>1){const t=e[e.length-1],r=t[0]&s.TAPLEAF_VERSION_MASK,n=e[e.length-2],i=(0,u.tapleafHash)({output:n,version:r});return(0,u.rootHashFromPath)(t,i)}return null})),f.prop(w,"output",(()=>{if(w.pubkey)return o.compile([p.OP_1,w.pubkey])})),f.prop(w,"redeemVersion",(()=>t.redeemVersion?t.redeemVersion:t.redeem&&void 0!==t.redeem.redeemVersion&&null!==t.redeem.redeemVersion?t.redeem.redeemVersion:u.LEAF_VERSION_TAPSCRIPT)),f.prop(w,"redeem",(()=>{const t=l();if(t&&!(t.length<2))return{output:t[t.length-2],witness:t.slice(0,-2),redeemVersion:t[t.length-1][0]&s.TAPLEAF_VERSION_MASK}})),f.prop(w,"pubkey",(()=>{if(t.pubkey)return t.pubkey;if(t.output)return t.output.slice(2);if(t.address)return r().data;if(w.internalPubkey){const t=(0,u.tweakKey)(w.internalPubkey,w.hash);if(t)return t.x}})),f.prop(w,"internalPubkey",(()=>{if(t.internalPubkey)return t.internalPubkey;const e=l();return e&&e.length>1?e[e.length-1].slice(1,33):void 0})),f.prop(w,"signature",(()=>{if(t.signature)return t.signature;const e=l();return e&&1===e.length?e[0]:void 0})),f.prop(w,"witness",(()=>{if(t.witness)return t.witness;const e=d();if(e&&t.redeem&&t.redeem.output&&t.internalPubkey){const r=(0,u.tapleafHash)({output:t.redeem.output,version:w.redeemVersion}),i=(0,u.findScriptPath)(e,r);if(!i)return;const o=(0,u.tweakKey)(t.internalPubkey,e.hash);if(!o)return;const s=n.Buffer.concat([n.Buffer.from([w.redeemVersion|o.parity]),t.internalPubkey].concat(i));return[t.redeem.output,s]}return t.signature?[t.signature]:void 0})),e.validate){let e=n.Buffer.from([]);if(t.address){if(y&&y.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(1!==r().version)throw new TypeError("Invalid address version");if(32!==r().data.length)throw new TypeError("Invalid address data");e=r().data}if(t.pubkey){if(e.length>0&&!e.equals(t.pubkey))throw new TypeError("Pubkey mismatch");e=t.pubkey}if(t.output){if(34!==t.output.length||t.output[0]!==p.OP_1||32!==t.output[1])throw new TypeError("Output is invalid");if(e.length>0&&!e.equals(t.output.slice(2)))throw new TypeError("Pubkey mismatch");e=t.output.slice(2)}if(t.internalPubkey){const r=(0,u.tweakKey)(t.internalPubkey,w.hash);if(e.length>0&&!e.equals(r.x))throw new TypeError("Pubkey mismatch");e=r.x}if(e&&e.length&&!(0,a.getEccLib)().isXOnlyPoint(e))throw new TypeError("Invalid pubkey for p2tr");const i=d();if(t.hash&&i&&!t.hash.equals(i.hash))throw new TypeError("Hash mismatch");if(t.redeem&&t.redeem.output&&i){const e=(0,u.tapleafHash)({output:t.redeem.output,version:w.redeemVersion});if(!(0,u.findScriptPath)(i,e))throw new TypeError("Redeem script not in tree")}const f=l();if(t.redeem&&w.redeem){if(t.redeem.redeemVersion&&t.redeem.redeemVersion!==w.redeem.redeemVersion)throw new TypeError("Redeem.redeemVersion and witness mismatch");if(t.redeem.output){if(0===o.decompile(t.redeem.output).length)throw new TypeError("Redeem.output is invalid");if(w.redeem.output&&!t.redeem.output.equals(w.redeem.output))throw new TypeError("Redeem.output and witness mismatch")}if(t.redeem.witness&&w.redeem.witness&&!(0,s.stacksEqual)(t.redeem.witness,w.redeem.witness))throw new TypeError("Redeem.witness and witness mismatch")}if(f&&f.length)if(1===f.length){if(t.signature&&!t.signature.equals(f[0]))throw new TypeError("Signature mismatch")}else{const r=f[f.length-1];if(r.length<33)throw new TypeError(`The control-block length is too small. Got ${r.length}, expected min 33.`);if((r.length-33)%32!=0)throw new TypeError(`The control-block length of ${r.length} is incorrect!`);const n=(r.length-33)/32;if(n>128)throw new TypeError(`The script path is too long. Got ${n}, expected max 128.`);const i=r.slice(1,33);if(t.internalPubkey&&!t.internalPubkey.equals(i))throw new TypeError("Internal pubkey mismatch");if(!(0,a.getEccLib)().isXOnlyPoint(i))throw new TypeError("Invalid internalPubkey for p2tr witness");const o=r[0]&s.TAPLEAF_VERSION_MASK,c=f[f.length-2],h=(0,u.tapleafHash)({output:c,version:o}),p=(0,u.rootHashFromPath)(r,h),l=(0,u.tweakKey)(i,p);if(!l)throw new TypeError("Invalid outputKey for p2tr witness");if(e.length&&!e.equals(l.x))throw new TypeError("Pubkey mismatch for p2tr witness");if(l.parity!==(1&r[0]))throw new Error("Incorrect parity")}}return Object.assign(w,t)}},7027:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.p2wpkh=void 0;const i=r(1944),o=r(622),s=r(7038),a=r(8116),u=r(7883),f=r(6586),c=s.OPS,h=n.alloc(0);e.p2wpkh=function(t,e){if(!(t.address||t.hash||t.output||t.pubkey||t.witness))throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),(0,a.typeforce)({address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(20)),input:a.typeforce.maybe(a.typeforce.BufferN(0)),network:a.typeforce.maybe(a.typeforce.Object),output:a.typeforce.maybe(a.typeforce.BufferN(22)),pubkey:a.typeforce.maybe(a.isPoint),signature:a.typeforce.maybe(s.isCanonicalScriptSignature),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))},t);const r=u.value((()=>{const e=f.bech32.decode(t.address),r=e.words.shift(),i=f.bech32.fromWords(e.words);return{version:r,prefix:e.prefix,data:n.from(i)}})),p=t.network||o.bitcoin,l={name:"p2wpkh",network:p};if(u.prop(l,"address",(()=>{if(!l.hash)return;const t=f.bech32.toWords(l.hash);return t.unshift(0),f.bech32.encode(p.bech32,t)})),u.prop(l,"hash",(()=>t.output?t.output.slice(2,22):t.address?r().data:t.pubkey||l.pubkey?i.hash160(t.pubkey||l.pubkey):void 0)),u.prop(l,"output",(()=>{if(l.hash)return s.compile([c.OP_0,l.hash])})),u.prop(l,"pubkey",(()=>t.pubkey?t.pubkey:t.witness?t.witness[1]:void 0)),u.prop(l,"signature",(()=>{if(t.witness)return t.witness[0]})),u.prop(l,"input",(()=>{if(l.witness)return h})),u.prop(l,"witness",(()=>{if(t.pubkey&&t.signature)return[t.signature,t.pubkey]})),e.validate){let e=n.from([]);if(t.address){if(p&&p.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(0!==r().version)throw new TypeError("Invalid address version");if(20!==r().data.length)throw new TypeError("Invalid address data");e=r().data}if(t.hash){if(e.length>0&&!e.equals(t.hash))throw new TypeError("Hash mismatch");e=t.hash}if(t.output){if(22!==t.output.length||t.output[0]!==c.OP_0||20!==t.output[1])throw new TypeError("Output is invalid");if(e.length>0&&!e.equals(t.output.slice(2)))throw new TypeError("Hash mismatch");e=t.output.slice(2)}if(t.pubkey){const r=i.hash160(t.pubkey);if(e.length>0&&!e.equals(r))throw new TypeError("Hash mismatch");if(e=r,!(0,a.isPoint)(t.pubkey)||33!==t.pubkey.length)throw new TypeError("Invalid pubkey for p2wpkh")}if(t.witness){if(2!==t.witness.length)throw new TypeError("Witness is invalid");if(!s.isCanonicalScriptSignature(t.witness[0]))throw new TypeError("Witness has invalid signature");if(!(0,a.isPoint)(t.witness[1])||33!==t.witness[1].length)throw new TypeError("Witness has invalid pubkey");if(t.signature&&!t.signature.equals(t.witness[0]))throw new TypeError("Signature mismatch");if(t.pubkey&&!t.pubkey.equals(t.witness[1]))throw new TypeError("Pubkey mismatch");const r=i.hash160(t.witness[1]);if(e.length>0&&!e.equals(r))throw new TypeError("Hash mismatch")}}return Object.assign(l,t)}},9041:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.p2wsh=void 0;const i=r(1944),o=r(622),s=r(7038),a=r(8116),u=r(7883),f=r(6586),c=s.OPS,h=n.alloc(0);function p(t){return!(!n.isBuffer(t)||65!==t.length||4!==t[0]||!(0,a.isPoint)(t))}e.p2wsh=function(t,e){if(!(t.address||t.hash||t.output||t.redeem||t.witness))throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),(0,a.typeforce)({network:a.typeforce.maybe(a.typeforce.Object),address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(32)),output:a.typeforce.maybe(a.typeforce.BufferN(34)),redeem:a.typeforce.maybe({input:a.typeforce.maybe(a.typeforce.Buffer),network:a.typeforce.maybe(a.typeforce.Object),output:a.typeforce.maybe(a.typeforce.Buffer),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))}),input:a.typeforce.maybe(a.typeforce.BufferN(0)),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))},t);const r=u.value((()=>{const e=f.bech32.decode(t.address),r=e.words.shift(),i=f.bech32.fromWords(e.words);return{version:r,prefix:e.prefix,data:n.from(i)}})),l=u.value((()=>s.decompile(t.redeem.input)));let d=t.network;d||(d=t.redeem&&t.redeem.network||o.bitcoin);const y={network:d};if(u.prop(y,"address",(()=>{if(!y.hash)return;const t=f.bech32.toWords(y.hash);return t.unshift(0),f.bech32.encode(d.bech32,t)})),u.prop(y,"hash",(()=>t.output?t.output.slice(2):t.address?r().data:y.redeem&&y.redeem.output?i.sha256(y.redeem.output):void 0)),u.prop(y,"output",(()=>{if(y.hash)return s.compile([c.OP_0,y.hash])})),u.prop(y,"redeem",(()=>{if(t.witness)return{output:t.witness[t.witness.length-1],input:h,witness:t.witness.slice(0,-1)}})),u.prop(y,"input",(()=>{if(y.witness)return h})),u.prop(y,"witness",(()=>{if(t.redeem&&t.redeem.input&&t.redeem.input.length>0&&t.redeem.output&&t.redeem.output.length>0){const e=s.toStack(l());return y.redeem=Object.assign({witness:e},t.redeem),y.redeem.input=h,[].concat(e,t.redeem.output)}if(t.redeem&&t.redeem.output&&t.redeem.witness)return[].concat(t.redeem.witness,t.redeem.output)})),u.prop(y,"name",(()=>{const t=["p2wsh"];return void 0!==y.redeem&&void 0!==y.redeem.name&&t.push(y.redeem.name),t.join("-")})),e.validate){let e=n.from([]);if(t.address){if(r().prefix!==d.bech32)throw new TypeError("Invalid prefix or Network mismatch");if(0!==r().version)throw new TypeError("Invalid address version");if(32!==r().data.length)throw new TypeError("Invalid address data");e=r().data}if(t.hash){if(e.length>0&&!e.equals(t.hash))throw new TypeError("Hash mismatch");e=t.hash}if(t.output){if(34!==t.output.length||t.output[0]!==c.OP_0||32!==t.output[1])throw new TypeError("Output is invalid");const r=t.output.slice(2);if(e.length>0&&!e.equals(r))throw new TypeError("Hash mismatch");e=r}if(t.redeem){if(t.redeem.network&&t.redeem.network!==d)throw new TypeError("Network mismatch");if(t.redeem.input&&t.redeem.input.length>0&&t.redeem.witness&&t.redeem.witness.length>0)throw new TypeError("Ambiguous witness source");if(t.redeem.output){const r=s.decompile(t.redeem.output);if(!r||r.length<1)throw new TypeError("Redeem.output is invalid");if(t.redeem.output.byteLength>3600)throw new TypeError("Redeem.output unspendable if larger than 3600 bytes");if(s.countNonPushOnlyOPs(r)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const n=i.sha256(t.redeem.output);if(e.length>0&&!e.equals(n))throw new TypeError("Hash mismatch");e=n}if(t.redeem.input&&!s.isPushOnly(l()))throw new TypeError("Non push-only scriptSig");if(t.witness&&t.redeem.witness&&!(0,a.stacksEqual)(t.witness,t.redeem.witness))throw new TypeError("Witness and redeem.witness mismatch");if(t.redeem.input&&l().some(p)||t.redeem.output&&(s.decompile(t.redeem.output)||[]).some(p))throw new TypeError("redeem.input or redeem.output contains uncompressed pubkey")}if(t.witness&&t.witness.length>0){const e=t.witness[t.witness.length-1];if(t.redeem&&t.redeem.output&&!t.redeem.output.equals(e))throw new TypeError("Witness and redeem.output mismatch");if(t.witness.some(p)||(s.decompile(e)||[]).some(p))throw new TypeError("Witness contains uncompressed pubkey")}}return Object.assign(y,t)}},9646:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.Psbt=void 0;const i=r(1614),o=r(394),s=r(5080),a=r(57),u=r(606),f=r(622),c=r(885),h=r(2218),p=r(7038),l=r(2021),d=r(477),y=r(4929),w={network:f.bitcoin,maximumFeeRate:5e3};class g{static fromBase64(t,e={}){const r=n.from(t,"base64");return this.fromBuffer(r,e)}static fromHex(t,e={}){const r=n.from(t,"hex");return this.fromBuffer(r,e)}static fromBuffer(t,e={}){const r=i.Psbt.fromBuffer(t,b),n=new g(e,r);var o,s;return o=n.__CACHE.__TX,s=n.__CACHE,o.ins.forEach((t=>{P(s,t)})),n}constructor(t={},e=new i.Psbt(new _)){this.data=e,this.opts=Object.assign({},w,t),this.__CACHE={__NON_WITNESS_UTXO_TX_CACHE:[],__NON_WITNESS_UTXO_BUF_CACHE:[],__TX_IN_CACHE:{},__TX:this.data.globalMap.unsignedTx.tx,__UNSAFE_SIGN_NONSEGWIT:!1},0===this.data.inputs.length&&this.setVersion(2);const r=(t,e,r,n)=>Object.defineProperty(t,e,{enumerable:r,writable:n});r(this,"__CACHE",!1,!0),r(this,"opts",!1,!0)}get inputCount(){return this.data.inputs.length}get version(){return this.__CACHE.__TX.version}set version(t){this.setVersion(t)}get locktime(){return this.__CACHE.__TX.locktime}set locktime(t){this.setLocktime(t)}get txInputs(){return this.__CACHE.__TX.ins.map((t=>({hash:(0,u.cloneBuffer)(t.hash),index:t.index,sequence:t.sequence})))}get txOutputs(){return this.__CACHE.__TX.outs.map((t=>{let e;try{e=(0,a.fromOutputScript)(t.script,this.opts.network)}catch(t){}return{script:(0,u.cloneBuffer)(t.script),value:t.value,address:e}}))}combine(...t){return this.data.combine(...t.map((t=>t.data))),this}clone(){const t=g.fromBuffer(this.data.toBuffer());return t.opts=JSON.parse(JSON.stringify(this.opts)),t}setMaximumFeeRate(t){T(t),this.opts.maximumFeeRate=t}setVersion(t){T(t),I(this.data.inputs,"setVersion");const e=this.__CACHE;return e.__TX.version=t,e.__EXTRACTED_TX=void 0,this}setLocktime(t){T(t),I(this.data.inputs,"setLocktime");const e=this.__CACHE;return e.__TX.locktime=t,e.__EXTRACTED_TX=void 0,this}setInputSequence(t,e){T(e),I(this.data.inputs,"setInputSequence");const r=this.__CACHE;if(r.__TX.ins.length<=t)throw new Error("Input index too high");return r.__TX.ins[t].sequence=e,r.__EXTRACTED_TX=void 0,this}addInputs(t){return t.forEach((t=>this.addInput(t))),this}addInput(t){if(arguments.length>1||!t||void 0===t.hash||void 0===t.index)throw new Error("Invalid arguments for Psbt.addInput. Requires single object with at least [hash] and [index]");(0,d.checkTaprootInputFields)(t,t,"addInput"),I(this.data.inputs,"addInput"),t.witnessScript&&$(t.witnessScript);const e=this.__CACHE;this.data.addInput(t),P(e,e.__TX.ins[e.__TX.ins.length-1]);const r=this.data.inputs.length-1,n=this.data.inputs[r];return n.nonWitnessUtxo&&F(this.__CACHE,n,r),e.__FEE=void 0,e.__FEE_RATE=void 0,e.__EXTRACTED_TX=void 0,this}addOutputs(t){return t.forEach((t=>this.addOutput(t))),this}addOutput(t){if(arguments.length>1||!t||void 0===t.value||void 0===t.address&&void 0===t.script)throw new Error("Invalid arguments for Psbt.addOutput. Requires single object with at least [script or address] and [value]");I(this.data.inputs,"addOutput");const{address:e}=t;if("string"==typeof e){const{network:r}=this.opts,n=(0,a.toOutputScript)(e,r);t=Object.assign({},t,{script:n})}(0,d.checkTaprootOutputFields)(t,t,"addOutput");const r=this.__CACHE;return this.data.addOutput(t),r.__FEE=void 0,r.__FEE_RATE=void 0,r.__EXTRACTED_TX=void 0,this}extractTransaction(t){if(!this.data.inputs.every(v))throw new Error("Not finalized");const e=this.__CACHE;if(t||function(t,e,r){const n=e.__FEE_RATE||t.getFeeRate(),i=e.__EXTRACTED_TX.virtualSize(),o=n*i;if(n>=r.maximumFeeRate)throw new Error(`Warning: You are paying around ${(o/1e8).toFixed(8)} in fees, which is ${n} satoshi per byte for a transaction with a VSize of ${i} bytes (segwit counted as 0.25 byte per byte). Use setMaximumFeeRate method to raise your threshold, or pass true to the first arg of extractTransaction.`)}(this,e,this.opts),e.__EXTRACTED_TX)return e.__EXTRACTED_TX;const r=e.__TX.clone();return K(this.data.inputs,r,e,!0),r}getFeeRate(){return x("__FEE_RATE","fee rate",this.data.inputs,this.__CACHE)}getFee(){return x("__FEE","fee",this.data.inputs,this.__CACHE)}finalizeAllInputs(){return(0,s.checkForInput)(this.data.inputs,0),Y(this.data.inputs.length).forEach((t=>this.finalizeInput(t))),this}finalizeInput(t,e){const r=(0,s.checkForInput)(this.data.inputs,t);return(0,d.isTaprootInput)(r)?this._finalizeTaprootInput(t,r,void 0,e):this._finalizeInput(t,r,e)}finalizeTaprootInput(t,e,r=d.tapScriptFinalizer){const n=(0,s.checkForInput)(this.data.inputs,t);if((0,d.isTaprootInput)(n))return this._finalizeTaprootInput(t,n,e,r);throw new Error(`Cannot finalize input #${t}. Not Taproot.`)}_finalizeInput(t,e,r=U){const{script:n,isP2SH:i,isP2WSH:o,isSegwit:s}=function(t,e,r){const n=r.__TX,i={script:null,isSegwit:!1,isP2SH:!1,isP2WSH:!1};if(i.isP2SH=!!e.redeemScript,i.isP2WSH=!!e.witnessScript,e.witnessScript)i.script=e.witnessScript;else if(e.redeemScript)i.script=e.redeemScript;else if(e.nonWitnessUtxo){const o=V(r,e,t),s=n.ins[t].index;i.script=o.outs[s].script}else e.witnessUtxo&&(i.script=e.witnessUtxo.script);return(e.witnessScript||(0,y.isP2WPKH)(i.script))&&(i.isSegwit=!0),i}(t,e,this.__CACHE);if(!n)throw new Error(`No script found for input #${t}`);!function(t){if(!t.sighashType||!t.partialSig)return;const{partialSig:e,sighashType:r}=t;e.forEach((t=>{const{hashType:e}=p.signature.decode(t.signature);if(r!==e)throw new Error("Signature sighash does not match input sighash type")}))}(e);const{finalScriptSig:a,finalScriptWitness:u}=r(t,e,n,s,i,o);if(a&&this.data.updateInput(t,{finalScriptSig:a}),u&&this.data.updateInput(t,{finalScriptWitness:u}),!a&&!u)throw new Error(`Unknown error finalizing input #${t}`);return this.data.clearFinalizedInput(t),this}_finalizeTaprootInput(t,e,r,n=d.tapScriptFinalizer){if(!e.witnessUtxo)throw new Error(`Cannot finalize input #${t}. Missing withness utxo.`);if(e.tapKeySig){const r=c.p2tr({output:e.witnessUtxo.script,signature:e.tapKeySig}),n=(0,y.witnessStackToScriptWitness)(r.witness);this.data.updateInput(t,{finalScriptWitness:n})}else{const{finalScriptWitness:i}=n(t,e,r);this.data.updateInput(t,{finalScriptWitness:i})}return this.data.clearFinalizedInput(t),this}getInputType(t){const e=(0,s.checkForInput)(this.data.inputs,t),r=X(W(t,e,this.__CACHE),t,"input",e.redeemScript||function(t){if(!t)return;const e=p.decompile(t);if(!e)return;const r=e[e.length-1];var i;if(n.isBuffer(r)&&!q(r)&&(i=r,!p.isCanonicalScriptSignature(i))&&p.decompile(r))return r}(e.finalScriptSig),e.witnessScript||function(t){if(!t)return;const e=j(t),r=e[e.length-1];return!q(r)&&p.decompile(r)?r:void 0}(e.finalScriptWitness));return("raw"===r.type?"":r.type+"-")+z(r.meaningfulScript)}inputHasPubkey(t,e){return function(t,e,r,n){const i=W(r,e,n),{meaningfulScript:o}=X(i,r,"input",e.redeemScript,e.witnessScript);return(0,y.pubkeyInScript)(t,o)}(e,(0,s.checkForInput)(this.data.inputs,t),t,this.__CACHE)}inputHasHDKey(t,e){const r=(0,s.checkForInput)(this.data.inputs,t),n=S(e);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}outputHasPubkey(t,e){return function(t,e,r,n){const i=n.__TX.outs[r].script,{meaningfulScript:o}=X(i,r,"output",e.redeemScript,e.witnessScript);return(0,y.pubkeyInScript)(t,o)}(e,(0,s.checkForOutput)(this.data.outputs,t),t,this.__CACHE)}outputHasHDKey(t,e){const r=(0,s.checkForOutput)(this.data.outputs,t),n=S(e);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}validateSignaturesOfAllInputs(t){return(0,s.checkForInput)(this.data.inputs,0),Y(this.data.inputs.length).map((e=>this.validateSignaturesOfInput(e,t))).reduce(((t,e)=>!0===e&&t),!0)}validateSignaturesOfInput(t,e,r){const n=this.data.inputs[t];return(0,d.isTaprootInput)(n)?this.validateSignaturesOfTaprootInput(t,e,r):this._validateSignaturesOfInput(t,e,r)}_validateSignaturesOfInput(t,e,r){const n=this.data.inputs[t],i=(n||{}).partialSig;if(!n||!i||i.length<1)throw new Error("No signatures to validate");if("function"!=typeof e)throw new Error("Need validator function to validate signatures");const o=r?i.filter((t=>t.pubkey.equals(r))):i;if(o.length<1)throw new Error("No signatures for this pubkey");const s=[];let a,u,f;for(const r of o){const i=p.signature.decode(r.signature),{hash:o,script:c}=f!==i.hashType?N(t,Object.assign({},n,{sighashType:i.hashType}),this.__CACHE,!0):{hash:a,script:u};f=i.hashType,a=o,u=c,k(r.pubkey,c,"verify"),s.push(e(r.pubkey,o,i.signature))}return s.every((t=>!0===t))}validateSignaturesOfTaprootInput(t,e,r){const n=this.data.inputs[t],i=(n||{}).tapKeySig,o=(n||{}).tapScriptSig;if(!n&&!i&&(!o||o.length))throw new Error("No signatures to validate");if("function"!=typeof e)throw new Error("Need validator function to validate signatures");const s=(r=r&&(0,d.toXOnly)(r))?H(t,n,this.data.inputs,r,this.__CACHE):function(t,e,r,n){const i=[];if(e.tapInternalKey){const r=L(t,e,n);r&&i.push(r)}if(e.tapScriptSig){const t=e.tapScriptSig.map((t=>t.pubkey));i.push(...t)}return i.map((i=>H(t,e,r,i,n))).flat()}(t,n,this.data.inputs,this.__CACHE);if(!s.length)throw new Error("No signatures for this pubkey");const a=s.find((t=>!t.leafHash));let u=0;if(i&&a){if(!e(a.pubkey,a.hash,C(i)))return!1;u++}if(o)for(const t of o){const r=s.find((e=>t.pubkey.equals(e.pubkey)));if(r){if(!e(t.pubkey,r.hash,C(t.signature)))return!1;u++}}return u>0}signAllInputsHD(t,e=[l.Transaction.SIGHASH_ALL]){if(!t||!t.publicKey||!t.fingerprint)throw new Error("Need HDSigner to sign input");const r=[];for(const n of Y(this.data.inputs.length))try{this.signInputHD(n,t,e),r.push(!0)}catch(t){r.push(!1)}if(r.every((t=>!1===t)))throw new Error("No inputs were signed");return this}signAllInputsHDAsync(t,e=[l.Transaction.SIGHASH_ALL]){return new Promise(((r,n)=>{if(!t||!t.publicKey||!t.fingerprint)return n(new Error("Need HDSigner to sign input"));const i=[],o=[];for(const r of Y(this.data.inputs.length))o.push(this.signInputHDAsync(r,t,e).then((()=>{i.push(!0)}),(()=>{i.push(!1)})));return Promise.all(o).then((()=>{if(i.every((t=>!1===t)))return n(new Error("No inputs were signed"));r()}))}))}signInputHD(t,e,r=[l.Transaction.SIGHASH_ALL]){if(!e||!e.publicKey||!e.fingerprint)throw new Error("Need HDSigner to sign input");return D(t,this.data.inputs,e).forEach((e=>this.signInput(t,e,r))),this}signInputHDAsync(t,e,r=[l.Transaction.SIGHASH_ALL]){return new Promise(((n,i)=>{if(!e||!e.publicKey||!e.fingerprint)return i(new Error("Need HDSigner to sign input"));const o=D(t,this.data.inputs,e).map((e=>this.signInputAsync(t,e,r)));return Promise.all(o).then((()=>{n()})).catch(i)}))}signAllInputs(t,e){if(!t||!t.publicKey)throw new Error("Need Signer to sign input");const r=[];for(const n of Y(this.data.inputs.length))try{this.signInput(n,t,e),r.push(!0)}catch(t){r.push(!1)}if(r.every((t=>!1===t)))throw new Error("No inputs were signed");return this}signAllInputsAsync(t,e){return new Promise(((r,n)=>{if(!t||!t.publicKey)return n(new Error("Need Signer to sign input"));const i=[],o=[];for(const[r]of this.data.inputs.entries())o.push(this.signInputAsync(r,t,e).then((()=>{i.push(!0)}),(()=>{i.push(!1)})));return Promise.all(o).then((()=>{if(i.every((t=>!1===t)))return n(new Error("No inputs were signed"));r()}))}))}signInput(t,e,r){if(!e||!e.publicKey)throw new Error("Need Signer to sign input");const n=(0,s.checkForInput)(this.data.inputs,t);return(0,d.isTaprootInput)(n)?this._signTaprootInput(t,n,e,void 0,r):this._signInput(t,e,r)}signTaprootInput(t,e,r,n){if(!e||!e.publicKey)throw new Error("Need Signer to sign input");const i=(0,s.checkForInput)(this.data.inputs,t);if((0,d.isTaprootInput)(i))return this._signTaprootInput(t,i,e,r,n);throw new Error(`Input #${t} is not of type Taproot.`)}_signInput(t,e,r=[l.Transaction.SIGHASH_ALL]){const{hash:n,sighashType:i}=R(this.data.inputs,t,e.publicKey,this.__CACHE,r),o=[{pubkey:e.publicKey,signature:p.signature.encode(e.sign(n),i)}];return this.data.updateInput(t,{partialSig:o}),this}_signTaprootInput(t,e,r,n,i=[l.Transaction.SIGHASH_DEFAULT]){const o=this.checkTaprootHashesForSig(t,e,r,n,i),s=o.filter((t=>!t.leafHash)).map((t=>(0,d.serializeTaprootSignature)(r.signSchnorr(t.hash),e.sighashType)))[0],a=o.filter((t=>!!t.leafHash)).map((t=>({pubkey:(0,d.toXOnly)(r.publicKey),signature:(0,d.serializeTaprootSignature)(r.signSchnorr(t.hash),e.sighashType),leafHash:t.leafHash})));return s&&this.data.updateInput(t,{tapKeySig:s}),a.length&&this.data.updateInput(t,{tapScriptSig:a}),this}signInputAsync(t,e,r){return Promise.resolve().then((()=>{if(!e||!e.publicKey)throw new Error("Need Signer to sign input");const n=(0,s.checkForInput)(this.data.inputs,t);return(0,d.isTaprootInput)(n)?this._signTaprootInputAsync(t,n,e,void 0,r):this._signInputAsync(t,e,r)}))}signTaprootInputAsync(t,e,r,n){return Promise.resolve().then((()=>{if(!e||!e.publicKey)throw new Error("Need Signer to sign input");const i=(0,s.checkForInput)(this.data.inputs,t);if((0,d.isTaprootInput)(i))return this._signTaprootInputAsync(t,i,e,r,n);throw new Error(`Input #${t} is not of type Taproot.`)}))}_signInputAsync(t,e,r=[l.Transaction.SIGHASH_ALL]){const{hash:n,sighashType:i}=R(this.data.inputs,t,e.publicKey,this.__CACHE,r);return Promise.resolve(e.sign(n)).then((r=>{const n=[{pubkey:e.publicKey,signature:p.signature.encode(r,i)}];this.data.updateInput(t,{partialSig:n})}))}async _signTaprootInputAsync(t,e,r,n,i=[l.Transaction.SIGHASH_DEFAULT]){const o=this.checkTaprootHashesForSig(t,e,r,n,i),s=[],a=o.filter((t=>!t.leafHash))[0];if(a){const t=Promise.resolve(r.signSchnorr(a.hash)).then((t=>({tapKeySig:(0,d.serializeTaprootSignature)(t,e.sighashType)})));s.push(t)}const u=o.filter((t=>!!t.leafHash));if(u.length){const t=u.map((t=>Promise.resolve(r.signSchnorr(t.hash)).then((n=>({tapScriptSig:[{pubkey:(0,d.toXOnly)(r.publicKey),signature:(0,d.serializeTaprootSignature)(n,e.sighashType),leafHash:t.leafHash}]})))));s.push(...t)}return Promise.all(s).then((e=>{e.forEach((e=>this.data.updateInput(t,e)))}))}checkTaprootHashesForSig(t,e,r,n,i){if("function"!=typeof r.signSchnorr)throw new Error(`Need Schnorr Signer to sign taproot input #${t}.`);const o=H(t,e,this.data.inputs,r.publicKey,this.__CACHE,n,i);if(!o||!o.length)throw new Error(`Can not sign for input #${t} with the key ${r.publicKey.toString("hex")}`);return o}toBuffer(){return m(this.__CACHE),this.data.toBuffer()}toHex(){return m(this.__CACHE),this.data.toHex()}toBase64(){return m(this.__CACHE),this.data.toBase64()}updateGlobal(t){return this.data.updateGlobal(t),this}updateInput(t,e){return e.witnessScript&&$(e.witnessScript),(0,d.checkTaprootInputFields)(this.data.inputs[t],e,"updateInput"),this.data.updateInput(t,e),e.nonWitnessUtxo&&F(this.__CACHE,this.data.inputs[t],t),this}updateOutput(t,e){const r=this.data.outputs[t];return(0,d.checkTaprootOutputFields)(r,e,"updateOutput"),this.data.updateOutput(t,e),this}addUnknownKeyValToGlobal(t){return this.data.addUnknownKeyValToGlobal(t),this}addUnknownKeyValToInput(t,e){return this.data.addUnknownKeyValToInput(t,e),this}addUnknownKeyValToOutput(t,e){return this.data.addUnknownKeyValToOutput(t,e),this}clearFinalizedInput(t){return this.data.clearFinalizedInput(t),this}}e.Psbt=g;const b=t=>new _(t);class _{constructor(t=n.from([2,0,0,0,0,0,0,0,0,0])){this.tx=l.Transaction.fromBuffer(t),function(t){if(!t.ins.every((t=>t.script&&0===t.script.length&&t.witness&&0===t.witness.length)))throw new Error("Format Error: Transaction ScriptSigs are not empty")}(this.tx),Object.defineProperty(this,"tx",{enumerable:!1,writable:!0})}getInputOutputCounts(){return{inputCount:this.tx.ins.length,outputCount:this.tx.outs.length}}addInput(t){if(void 0===t.hash||void 0===t.index||!n.isBuffer(t.hash)&&"string"!=typeof t.hash||"number"!=typeof t.index)throw new Error("Error adding input.");const e="string"==typeof t.hash?(0,u.reverseBuffer)(n.from(t.hash,"hex")):t.hash;this.tx.addInput(e,t.index,t.sequence)}addOutput(t){if(void 0===t.script||void 0===t.value||!n.isBuffer(t.script)||"number"!=typeof t.value)throw new Error("Error adding output.");this.tx.addOutput(t.script,t.value)}toBuffer(){return this.tx.toBuffer()}}function m(t){if(!1!==t.__UNSAFE_SIGN_NONSEGWIT)throw new Error("Not BIP174 compliant, can not export")}function E(t,e,r){if(!e)return!1;let n;if(n=r?r.map((t=>{const r=function(t){if(65===t.length){const e=1&t[64],r=t.slice(0,33);return r[0]=2|e,r}return t.slice()}(t);return e.find((t=>t.pubkey.equals(r)))})).filter((t=>!!t)):e,n.length>t)throw new Error("Too many signatures");return n.length===t}function v(t){return!!t.finalScriptSig||!!t.finalScriptWitness}function S(t){return e=>!!e.masterFingerprint.equals(t.fingerprint)&&!!t.derivePath(e.path).publicKey.equals(e.pubkey)}function T(t){if("number"!=typeof t||t!==Math.floor(t)||t>4294967295||t<0)throw new Error("Invalid 32 bit integer")}function I(t,e){t.forEach((t=>{if((0,d.isTaprootInput)(t)?(0,d.checkTaprootInputForSigs)(t,e):(0,y.checkInputForSig)(t,e))throw new Error("Can not modify transaction, signatures exist.")}))}function k(t,e,r){if(!(0,y.pubkeyInScript)(t,e))throw new Error(`Can not ${r} for this input with the key ${t.toString("hex")}`)}function P(t,e){const r=(0,u.reverseBuffer)(n.from(e.hash)).toString("hex")+":"+e.index;if(t.__TX_IN_CACHE[r])throw new Error("Duplicate input detected.");t.__TX_IN_CACHE[r]=1}function A(t,e){return(r,n,i,o)=>{const s=t({redeem:{output:i}}).output;if(!n.equals(s))throw new Error(`${e} for ${o} #${r} doesn't match the scriptPubKey in the prevout`)}}const O=A(c.p2sh,"Redeem script"),B=A(c.p2wsh,"Witness script");function x(t,e,r,n){if(!r.every(v))throw new Error(`PSBT must be finalized to calculate ${e}`);if("__FEE_RATE"===t&&n.__FEE_RATE)return n.__FEE_RATE;if("__FEE"===t&&n.__FEE)return n.__FEE;let i,o=!0;return n.__EXTRACTED_TX?(i=n.__EXTRACTED_TX,o=!1):i=n.__TX.clone(),K(r,i,n,o),"__FEE_RATE"===t?n.__FEE_RATE:"__FEE"===t?n.__FEE:void 0}function U(t,e,r,n,i,o){const s=z(r);if(!function(t,e,r){switch(r){case"pubkey":case"pubkeyhash":case"witnesspubkeyhash":return E(1,t.partialSig);case"multisig":const r=c.p2ms({output:e});return E(r.m,t.partialSig,r.pubkeys);default:return!1}}(e,r,s))throw new Error(`Can not finalize input #${t}`);return function(t,e,r,n,i,o){let s,a;const u=function(t,e,r){let n;switch(e){case"multisig":const e=function(t,e){return c.p2ms({output:t}).pubkeys.map((t=>(e.filter((e=>e.pubkey.equals(t)))[0]||{}).signature)).filter((t=>!!t))}(t,r);n=c.p2ms({output:t,signatures:e});break;case"pubkey":n=c.p2pk({output:t,signature:r[0].signature});break;case"pubkeyhash":n=c.p2pkh({output:t,pubkey:r[0].pubkey,signature:r[0].signature});break;case"witnesspubkeyhash":n=c.p2wpkh({output:t,pubkey:r[0].pubkey,signature:r[0].signature})}return n}(t,e,r),f=o?c.p2wsh({redeem:u}):null,h=i?c.p2sh({redeem:f||u}):null;return n?(a=f?(0,y.witnessStackToScriptWitness)(f.witness):(0,y.witnessStackToScriptWitness)(u.witness),h&&(s=h.input)):s=h?h.input:u.input,{finalScriptSig:s,finalScriptWitness:a}}(r,s,e.partialSig,n,i,o)}function R(t,e,r,n,i){const o=(0,s.checkForInput)(t,e),{hash:a,sighashType:u,script:f}=N(e,o,n,!1,i);return k(r,f,"sign"),{hash:a,sighashType:u}}function N(t,e,r,n,i){const o=r.__TX,s=e.sighashType||l.Transaction.SIGHASH_ALL;let a,u;if(M(s,i),e.nonWitnessUtxo){const n=V(r,e,t),i=o.ins[t].hash,s=n.getHash();if(!i.equals(s))throw new Error(`Non-witness UTXO hash for input #${t} doesn't match the hash specified in the prevout`);const a=o.ins[t].index;u=n.outs[a]}else{if(!e.witnessUtxo)throw new Error("Need a Utxo input item for signing");u=e.witnessUtxo}const{meaningfulScript:f,type:h}=X(u.script,t,"input",e.redeemScript,e.witnessScript);if(["p2sh-p2wsh","p2wsh"].indexOf(h)>=0)a=o.hashForWitnessV0(t,f,u.value,s);else if((0,y.isP2WPKH)(f)){const e=c.p2pkh({hash:f.slice(2)}).output;a=o.hashForWitnessV0(t,e,u.value,s)}else{if(void 0===e.nonWitnessUtxo&&!1===r.__UNSAFE_SIGN_NONSEGWIT)throw new Error(`Input #${t} has witnessUtxo but non-segwit script: ${f.toString("hex")}`);n||!1===r.__UNSAFE_SIGN_NONSEGWIT||console.warn("Warning: Signing non-segwit inputs without the full parent transaction means there is a chance that a miner could feed you incorrect information to trick you into paying large fees. This behavior is the same as Psbt's predecessor (TransactionBuilder - now removed) when signing non-segwit scripts. You are not able to export this Psbt with toBuffer|toBase64|toHex since it is not BIP174 compliant.\n*********************\nPROCEED WITH CAUTION!\n*********************"),a=o.hashForSignature(t,f,s)}return{script:f,sighashType:s,hash:a}}function L(t,e,r){const{script:n}=G(t,e,r);return(0,y.isP2TR)(n)?n.subarray(2,34):null}function C(t){return 64===t.length?t:t.subarray(0,64)}function H(t,e,r,i,o,s,a){const u=o.__TX,f=e.sighashType||l.Transaction.SIGHASH_DEFAULT;M(f,a);const c=r.map(((t,e)=>G(e,t,o))),p=c.map((t=>t.script)),w=c.map((t=>t.value)),g=[];if(e.tapInternalKey&&!s){const r=L(t,e,o)||n.from([]);if((0,d.toXOnly)(i).equals(r)){const e=u.hashForWitnessV1(t,p,w,f);g.push({pubkey:i,hash:e})}}const b=(e.tapLeafScript||[]).filter((t=>(0,y.pubkeyInScript)(i,t.script))).map((t=>{const e=(0,h.tapleafHash)({output:t.script,version:t.leafVersion});return Object.assign({hash:e},t)})).filter((t=>!s||s.equals(t.hash))).map((e=>{const r=u.hashForWitnessV1(t,p,w,f,e.hash);return{pubkey:i,hash:r,leafHash:e.hash}}));return g.concat(b)}function M(t,e){if(e&&e.indexOf(t)<0){const e=function(t){let e=t&l.Transaction.SIGHASH_ANYONECANPAY?"SIGHASH_ANYONECANPAY | ":"";switch(31&t){case l.Transaction.SIGHASH_ALL:e+="SIGHASH_ALL";break;case l.Transaction.SIGHASH_SINGLE:e+="SIGHASH_SINGLE";break;case l.Transaction.SIGHASH_NONE:e+="SIGHASH_NONE"}return e}(t);throw new Error(`Sighash type is not allowed. Retry the sign method passing the sighashTypes array of whitelisted types. Sighash type: ${e}`)}}function D(t,e,r){const n=(0,s.checkForInput)(e,t);if(!n.bip32Derivation||0===n.bip32Derivation.length)throw new Error("Need bip32Derivation to sign with HD");const i=n.bip32Derivation.map((t=>t.masterFingerprint.equals(r.fingerprint)?t:void 0)).filter((t=>!!t));if(0===i.length)throw new Error("Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint");return i.map((t=>{const e=r.derivePath(t.path);if(!t.pubkey.equals(e.publicKey))throw new Error("pubkey did not match bip32Derivation");return e}))}function j(t){let e=0;function r(){const r=o.decode(t,e);return e+=o.decode.bytes,r}return function(){const n=r(),i=[];for(let s=0;s{if(n&&t.finalScriptSig&&(e.ins[o].script=t.finalScriptSig),n&&t.finalScriptWitness&&(e.ins[o].witness=j(t.finalScriptWitness)),t.witnessUtxo)i+=t.witnessUtxo.value;else if(t.nonWitnessUtxo){const n=V(r,t,o),s=e.ins[o].index,a=n.outs[s];i+=a.value}}));const o=e.outs.reduce(((t,e)=>t+e.value),0),s=i-o;if(s<0)throw new Error("Outputs are spending more than Inputs");const a=e.virtualSize();r.__FEE=s,r.__EXTRACTED_TX=e,r.__FEE_RATE=Math.floor(s/a)}function V(t,e,r){const n=t.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||F(t,e,r),n[r]}function W(t,e,r){const{script:n}=G(t,e,r);return n}function G(t,e,r){if(void 0!==e.witnessUtxo)return{script:e.witnessUtxo.script,value:e.witnessUtxo.value};if(void 0!==e.nonWitnessUtxo){const n=V(r,e,t).outs[r.__TX.ins[t].index];return{script:n.script,value:n.value}}throw new Error("Can't find pubkey in input without Utxo data")}function q(t){return 33===t.length&&p.isCanonicalPubKey(t)}function X(t,e,r,n,i){const o=(0,y.isP2SHScript)(t),s=o&&n&&(0,y.isP2WSHScript)(n),a=(0,y.isP2WSHScript)(t);if(o&&void 0===n)throw new Error("scriptPubkey is P2SH but redeemScript missing");if((a||s)&&void 0===i)throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");let u;return s?(u=i,O(e,t,n,r),B(e,n,i,r),$(u)):a?(u=i,B(e,t,i,r),$(u)):o?(u=n,O(e,t,n,r)):u=t,{meaningfulScript:u,type:s?"p2sh-p2wsh":o?"p2sh":a?"p2wsh":"raw"}}function $(t){if((0,y.isP2WPKH)(t)||(0,y.isP2SHScript)(t))throw new Error("P2WPKH or P2SH can not be contained within P2WSH")}function z(t){return(0,y.isP2WPKH)(t)?"witnesspubkeyhash":(0,y.isP2PKH)(t)?"pubkeyhash":(0,y.isP2MS)(t)?"multisig":(0,y.isP2PK)(t)?"pubkey":"nonstandard"}function Y(t){return[...Array(t).keys()]}},477:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.checkTaprootInputForSigs=e.tapTreeFromList=e.tapTreeToList=e.tweakInternalPubKey=e.checkTaprootOutputFields=e.checkTaprootInputFields=e.isTaprootOutput=e.isTaprootInput=e.serializeTaprootSignature=e.tapScriptFinalizer=e.toXOnly=void 0;const i=r(8116),o=r(2021),s=r(4929),a=r(2218),u=r(885),f=r(4929);function c(t){return t&&!!(t.tapInternalKey||t.tapMerkleRoot||t.tapLeafScript&&t.tapLeafScript.length||t.tapBip32Derivation&&t.tapBip32Derivation.length||t.witnessUtxo&&(0,s.isP2TR)(t.witnessUtxo.script))}function h(t,e){return t&&!!(t.tapInternalKey||t.tapTree||t.tapBip32Derivation&&t.tapBip32Derivation.length||e&&(0,s.isP2TR)(e))}function p(t=[]){return 1===t.length&&0===t[0].depth?{output:t[0].script,version:t[0].leafVersion}:function(t){let e;for(const r of t)if(e=y(r,e),!e)throw new Error("No room left to insert tapleaf in tree");return e}(t)}function l(t){return{signature:t.slice(0,64),hashType:t.slice(64)[0]||o.Transaction.SIGHASH_DEFAULT}}function d(t,e=[],r=0){if(r>a.MAX_TAPTREE_DEPTH)throw new Error("Max taptree depth exceeded.");return t?(0,i.isTapleaf)(t)?(e.push({depth:r,leafVersion:t.version||a.LEAF_VERSION_TAPSCRIPT,script:t.output}),e):(t[0]&&d(t[0],e,r+1),t[1]&&d(t[1],e,r+1),e):[]}function y(t,e,r=0){if(r>a.MAX_TAPTREE_DEPTH)throw new Error("Max taptree depth exceeded.");if(t.depth===r)return e?void 0:{output:t.script,version:t.leafVersion};if((0,i.isTapleaf)(e))return;const n=y(t,e&&e[0],r+1);if(n)return[n,e&&e[1]];const o=y(t,e&&e[1],r+1);return o?[e&&e[0],o]:void 0}function w(t,e){if(!e)return!0;const r=(0,a.tapleafHash)({output:t.script,version:t.leafVersion});return(0,a.rootHashFromPath)(t.controlBlock,r).equals(e)}function g(t){return t&&!!(t.redeemScript||t.witnessScript||t.bip32Derivation&&t.bip32Derivation.length)}e.toXOnly=t=>32===t.length?t:t.slice(1,33),e.tapScriptFinalizer=function(t,e,r){const n=function(t,e,r){if(!t.tapScriptSig||!t.tapScriptSig.length)throw new Error(`Can not finalize taproot input #${e}. No tapleaf script signature provided.`);const n=(t.tapLeafScript||[]).sort(((t,e)=>t.controlBlock.length-e.controlBlock.length)).find((e=>function(t,e,r){const n=(0,a.tapleafHash)({output:t.script,version:t.leafVersion});return(!r||r.equals(n))&&void 0!==e.find((t=>t.leafHash.equals(n)))}(e,t.tapScriptSig,r)));if(!n)throw new Error(`Can not finalize taproot input #${e}. Signature for tapleaf script not found.`);return n}(e,t,r);try{const t=function(t,e){const r=(0,a.tapleafHash)({output:e.script,version:e.leafVersion});return(t.tapScriptSig||[]).filter((t=>t.leafHash.equals(r))).map((t=>function(t,e){return Object.assign({positionInScript:(0,s.pubkeyPositionInScript)(e.pubkey,t)},e)}(e.script,t))).sort(((t,e)=>e.positionInScript-t.positionInScript)).map((t=>t.signature))}(e,n),r=t.concat(n.script).concat(n.controlBlock);return{finalScriptWitness:(0,s.witnessStackToScriptWitness)(r)}}catch(e){throw new Error(`Can not finalize taproot input #${t}: ${e}`)}},e.serializeTaprootSignature=function(t,e){const r=e?n.from([e]):n.from([]);return n.concat([t,r])},e.isTaprootInput=c,e.isTaprootOutput=h,e.checkTaprootInputFields=function(t,e,r){!function(t,e,r){const n=c(t)&&g(e),i=g(t)&&c(e),o=t===e&&c(e)&&g(e);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}(t,e,r),function(t,e,r){if(e.tapMerkleRoot){const n=(e.tapLeafScript||[]).every((t=>w(t,e.tapMerkleRoot))),i=(t.tapLeafScript||[]).every((t=>w(t,e.tapMerkleRoot)));if(!n||!i)throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}else if(t.tapMerkleRoot&&!(e.tapLeafScript||[]).every((e=>w(e,t.tapMerkleRoot))))throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}(t,e,r)},e.checkTaprootOutputFields=function(t,e,r){!function(t,e,r){const n=h(t)&&g(e),i=g(t)&&h(e),o=t===e&&h(e)&&g(e);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}(t,e,r),function(t,e){if(!e.tapTree&&!e.tapInternalKey)return;const r=e.tapInternalKey||t.tapInternalKey,n=e.tapTree||t.tapTree;if(r){const{script:e}=t,i=function(t,e){const r=e&&p(e.leaves),{output:n}=(0,u.p2tr)({internalPubkey:t,scriptTree:r});return n}(r,n);if(e&&!e.equals(i))throw new Error("Error adding output. Script or address missmatch.")}}(t,e)},e.tweakInternalPubKey=function(t,e){const r=e.tapInternalKey,n=r&&(0,a.tweakKey)(r,e.tapMerkleRoot);if(!n)throw new Error(`Cannot tweak tap internal key for input #${t}. Public key: ${r&&r.toString("hex")}`);return n.x},e.tapTreeToList=function(t){if(!(0,i.isTaptree)(t))throw new Error("Cannot convert taptree to tapleaf list. Expecting a tapree structure.");return d(t)},e.tapTreeFromList=p,e.checkTaprootInputForSigs=function(t,e){return function(t){const e=[];if(t.tapKeySig&&e.push(t.tapKeySig),t.tapScriptSig&&e.push(...t.tapScriptSig.map((t=>t.signature))),!e.length){const r=function(t){if(!t)return;const e=t.slice(2);return 64===e.length||65===e.length?e:void 0}(t.finalScriptWitness);r&&e.push(r)}return e}(t).some((t=>(0,f.signatureBlocksAction)(t,l,e)))}},4929:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.signatureBlocksAction=e.checkInputForSig=e.pubkeyInScript=e.pubkeyPositionInScript=e.witnessStackToScriptWitness=e.isP2TR=e.isP2SHScript=e.isP2WSHScript=e.isP2WPKH=e.isP2PKH=e.isP2PK=e.isP2MS=void 0;const i=r(394),o=r(7038),s=r(2021),a=r(1944),u=r(885);function f(t){return e=>{try{return t({output:e}),!0}catch(t){return!1}}}function c(t,e){const r=(0,a.hash160)(t),n=t.slice(1,33),i=o.decompile(e);if(null===i)throw new Error("Unknown script error");return i.findIndex((e=>"number"!=typeof e&&(e.equals(t)||e.equals(r)||e.equals(n))))}function h(t,e,r){const{hashType:n}=e(t),i=[];switch(n&s.Transaction.SIGHASH_ANYONECANPAY&&i.push("addInput"),31&n){case s.Transaction.SIGHASH_ALL:break;case s.Transaction.SIGHASH_SINGLE:case s.Transaction.SIGHASH_NONE:i.push("addOutput"),i.push("setInputSequence")}return-1===i.indexOf(r)}e.isP2MS=f(u.p2ms),e.isP2PK=f(u.p2pk),e.isP2PKH=f(u.p2pkh),e.isP2WPKH=f(u.p2wpkh),e.isP2WSHScript=f(u.p2wsh),e.isP2SHScript=f(u.p2sh),e.isP2TR=f(u.p2tr),e.witnessStackToScriptWitness=function(t){let e=n.allocUnsafe(0);function r(t){const r=e.length,o=i.encodingLength(t);e=n.concat([e,n.allocUnsafe(o)]),i.encode(t,e,r)}var o;return r((o=t).length),o.forEach((function(t){r(t.length),function(t){e=n.concat([e,n.from(t)])}(t)})),e},e.pubkeyPositionInScript=c,e.pubkeyInScript=function(t,e){return-1!==c(t,e)},e.checkInputForSig=function(t,e){return function(t){let e=[];if(0===(t.partialSig||[]).length){if(!t.finalScriptSig&&!t.finalScriptWitness)return[];e=function(t){const e=t.finalScriptSig&&o.decompile(t.finalScriptSig)||[],r=t.finalScriptWitness&&o.decompile(t.finalScriptWitness)||[];return e.concat(r).filter((t=>n.isBuffer(t)&&o.isCanonicalScriptSignature(t))).map((t=>({signature:t})))}(t)}else e=t.partialSig;return e.map((t=>t.signature))}(t).some((t=>h(t,o.signature.decode,e)))},e.signatureBlocksAction=h},4344:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.decode=e.encode=e.encodingLength=void 0;const n=r(8417);function i(t){return tt.length)return null;i=t.readUInt8(e+1),o=2}else if(r===n.OPS.OP_PUSHDATA2){if(e+3>t.length)return null;i=t.readUInt16LE(e+1),o=3}else{if(e+5>t.length)return null;if(r!==n.OPS.OP_PUSHDATA4)throw new Error("Unexpected opcode");i=t.readUInt32LE(e+1),o=5}return{opcode:r,number:i,size:o}}},7038:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.signature=e.number=e.isCanonicalScriptSignature=e.isDefinedHashType=e.isCanonicalPubKey=e.toStack=e.fromASM=e.toASM=e.decompile=e.compile=e.countNonPushOnlyOPs=e.isPushOnly=e.OPS=void 0;const i=r(3966),o=r(8417);Object.defineProperty(e,"OPS",{enumerable:!0,get:function(){return o.OPS}});const s=r(4344),a=r(9464),u=r(1043),f=r(8116),{typeforce:c}=f,h=o.OPS.OP_RESERVED;function p(t){return f.Buffer(t)||function(t){return f.Number(t)&&(t===o.OPS.OP_0||t>=o.OPS.OP_1&&t<=o.OPS.OP_16||t===o.OPS.OP_1NEGATE)}(t)}function l(t){return f.Array(t)&&t.every(p)}function d(t){return 0===t.length?o.OPS.OP_0:1===t.length?t[0]>=1&&t[0]<=16?h+t[0]:129===t[0]?o.OPS.OP_1NEGATE:void 0:void 0}function y(t){return n.isBuffer(t)}function w(t){return n.isBuffer(t)}function g(t){if(y(t))return t;c(f.Array,t);const e=t.reduce(((t,e)=>w(e)?1===e.length&&void 0!==d(e)?t+1:t+s.encodingLength(e.length)+e.length:t+1),0),r=n.allocUnsafe(e);let i=0;if(t.forEach((t=>{if(w(t)){const e=d(t);if(void 0!==e)return r.writeUInt8(e,i),void(i+=1);i+=s.encode(r,t.length,i),t.copy(r,i),i+=t.length}else r.writeUInt8(t,i),i+=1})),i!==r.length)throw new Error("Could not decode chunks");return r}function b(t){if(e=t,f.Array(e))return t;var e;c(f.Buffer,t);const r=[];let n=0;for(;no.OPS.OP_0&&e<=o.OPS.OP_PUSHDATA4){const e=s.decode(t,n);if(null===e)return null;if(n+=e.size,n+e.number>t.length)return null;const i=t.slice(n,n+e.number);n+=e.number;const o=d(i);void 0!==o?r.push(o):r.push(i)}else r.push(e),n+=1}return r}function _(t){const e=-129&t;return e>0&&e<4}e.isPushOnly=l,e.countNonPushOnlyOPs=function(t){return t.length-t.filter(p).length},e.compile=g,e.decompile=b,e.toASM=function(t){if(y(t)&&(t=b(t)),!t)throw new Error("Could not convert invalid chunks to ASM");return t.map((t=>{if(w(t)){const e=d(t);if(void 0===e)return t.toString("hex");t=e}return o.REVERSE_OPS[t]})).join(" ")},e.fromASM=function(t){return c(f.String,t),g(t.split(" ").map((t=>void 0!==o.OPS[t]?o.OPS[t]:(c(f.Hex,t),n.from(t,"hex")))))},e.toStack=function(t){return t=b(t),c(l,t),t.map((t=>w(t)?t:t===o.OPS.OP_0?n.allocUnsafe(0):a.encode(t-h)))},e.isCanonicalPubKey=function(t){return f.isPoint(t)},e.isDefinedHashType=_,e.isCanonicalScriptSignature=function(t){return!!n.isBuffer(t)&&!!_(t[t.length-1])&&i.check(t.slice(0,-1))},e.number=a,e.signature=u},9464:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.encode=e.decode=void 0,e.decode=function(t,e,r){e=e||4,r=void 0===r||r;const n=t.length;if(0===n)return 0;if(n>e)throw new TypeError("Script number overflow");if(r&&!(127&t[n-1]||!(n<=1)&&128&t[n-2]))throw new Error("Non-minimally encoded script number");if(5===n){const e=t.readUInt32LE(0),r=t.readUInt8(4);return 128&r?-(4294967296*(-129&r)+e):4294967296*r+e}let i=0;for(let e=0;e2147483647?5:i>8388607?4:i>32767?3:i>127?2:i>0?1:0;var i;const o=n.allocUnsafe(r),s=t<0;for(let t=0;t>=8;return 128&o[r-1]?o.writeUInt8(s?128:0,r-1):s&&(o[r-1]|=128),o}},1043:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.encode=e.decode=void 0;const i=r(3966),o=r(7038),s=r(8116),{typeforce:a}=s,u=n.alloc(1,0);function f(t){let e=0;for(;0===t[e];)++e;return e===t.length?u:128&(t=t.slice(e))[0]?n.concat([u,t],1+t.length):t}function c(t){0===t[0]&&(t=t.slice(1));const e=n.alloc(32,0),r=Math.max(0,32-t.length);return t.copy(e,r),e}e.decode=function(t){const e=t.readUInt8(t.length-1);if(!(0,o.isDefinedHashType)(e))throw new Error("Invalid hashType "+e);const r=i.decode(t.slice(0,-1)),s=c(r.r),a=c(r.s);return{signature:n.concat([s,a],64),hashType:e}},e.encode=function(t,e){if(a({signature:s.BufferN(64),hashType:s.UInt8},{signature:t,hashType:e}),!(0,o.isDefinedHashType)(e))throw new Error("Invalid hashType "+e);const r=n.allocUnsafe(1);r.writeUInt8(e,0);const u=f(t.slice(0,32)),c=f(t.slice(32,64));return n.concat([i.encode(u,c),r])}},2021:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.Transaction=void 0;const i=r(606),o=r(1944),s=r(7038),a=r(7038),u=r(8116),{typeforce:f}=u;function c(t){const e=t.length;return i.varuint.encodingLength(e)+e}const h=n.allocUnsafe(0),p=[],l=n.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),d=n.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),y=n.from("ffffffffffffffff","hex"),w={script:h,valueBuffer:y};class g{constructor(){this.version=1,this.locktime=0,this.ins=[],this.outs=[]}static fromBuffer(t,e){const r=new i.BufferReader(t),n=new g;n.version=r.readInt32();const o=r.readUInt8(),s=r.readUInt8();let a=!1;o===g.ADVANCED_TRANSACTION_MARKER&&s===g.ADVANCED_TRANSACTION_FLAG?a=!0:r.offset-=2;const u=r.readVarInt();for(let t=0;t0!==t.witness.length))}weight(){return 3*this.byteLength(!1)+this.byteLength(!0)}virtualSize(){return Math.ceil(this.weight()/4)}byteLength(t=!0){const e=t&&this.hasWitnesses();return(e?10:8)+i.varuint.encodingLength(this.ins.length)+i.varuint.encodingLength(this.outs.length)+this.ins.reduce(((t,e)=>t+40+c(e.script)),0)+this.outs.reduce(((t,e)=>t+8+c(e.script)),0)+(e?this.ins.reduce(((t,e)=>t+function(t){const e=t.length;return i.varuint.encodingLength(e)+t.reduce(((t,e)=>t+c(e)),0)}(e.witness)),0):0)}clone(){const t=new g;return t.version=this.version,t.locktime=this.locktime,t.ins=this.ins.map((t=>({hash:t.hash,index:t.index,script:t.script,sequence:t.sequence,witness:t.witness}))),t.outs=this.outs.map((t=>({script:t.script,value:t.value}))),t}hashForSignature(t,e,r){if(f(u.tuple(u.UInt32,u.Buffer,u.Number),arguments),t>=this.ins.length)return d;const i=s.compile(s.decompile(e).filter((t=>t!==a.OPS.OP_CODESEPARATOR))),c=this.clone();if((31&r)===g.SIGHASH_NONE)c.outs=[],c.ins.forEach(((e,r)=>{r!==t&&(e.sequence=0)}));else if((31&r)===g.SIGHASH_SINGLE){if(t>=this.outs.length)return d;c.outs.length=t+1;for(let e=0;e{r!==t&&(e.sequence=0)}))}r&g.SIGHASH_ANYONECANPAY?(c.ins=[c.ins[t]],c.ins[0].script=i):(c.ins.forEach((t=>{t.script=h})),c.ins[t].script=i);const p=n.allocUnsafe(c.byteLength(!1)+4);return p.writeInt32LE(r,p.length-4),c.__toBuffer(p,0,!1),o.hash256(p)}hashForWitnessV1(t,e,r,s,a,p){if(f(u.tuple(u.UInt32,f.arrayOf(u.Buffer),f.arrayOf(u.Satoshi),u.UInt32),arguments),r.length!==this.ins.length||e.length!==this.ins.length)throw new Error("Must supply prevout script and value for all inputs");const l=s===g.SIGHASH_DEFAULT?g.SIGHASH_ALL:s&g.SIGHASH_OUTPUT_MASK,d=(s&g.SIGHASH_INPUT_MASK)===g.SIGHASH_ANYONECANPAY,y=l===g.SIGHASH_NONE,w=l===g.SIGHASH_SINGLE;let b=h,_=h,m=h,E=h,v=h;if(!d){let t=i.BufferWriter.withCapacity(36*this.ins.length);this.ins.forEach((e=>{t.writeSlice(e.hash),t.writeUInt32(e.index)})),b=o.sha256(t.end()),t=i.BufferWriter.withCapacity(8*this.ins.length),r.forEach((e=>t.writeUInt64(e))),_=o.sha256(t.end()),t=i.BufferWriter.withCapacity(e.map(c).reduce(((t,e)=>t+e))),e.forEach((e=>t.writeVarSlice(e))),m=o.sha256(t.end()),t=i.BufferWriter.withCapacity(4*this.ins.length),this.ins.forEach((e=>t.writeUInt32(e.sequence))),E=o.sha256(t.end())}if(y||w){if(w&&t8+c(t.script))).reduce(((t,e)=>t+e)),e=i.BufferWriter.withCapacity(t);this.outs.forEach((t=>{e.writeUInt64(t.value),e.writeVarSlice(t.script)})),v=o.sha256(e.end())}const S=(a?2:0)+(p?1:0),T=174-(d?49:0)-(y?32:0)+(p?32:0)+(a?37:0),I=i.BufferWriter.withCapacity(T);if(I.writeUInt8(s),I.writeInt32(this.version),I.writeUInt32(this.locktime),I.writeSlice(b),I.writeSlice(_),I.writeSlice(m),I.writeSlice(E),y||w||I.writeSlice(v),I.writeUInt8(S),d){const n=this.ins[t];I.writeSlice(n.hash),I.writeUInt32(n.index),I.writeUInt64(r[t]),I.writeVarSlice(e[t]),I.writeUInt32(n.sequence)}else I.writeUInt32(t);if(p){const t=i.BufferWriter.withCapacity(c(p));t.writeVarSlice(p),I.writeSlice(o.sha256(t.end()))}return w&&I.writeSlice(v),a&&(I.writeSlice(a),I.writeUInt8(0),I.writeUInt32(4294967295)),o.taggedHash("TapSighash",n.concat([n.from([0]),I.end()]))}hashForWitnessV0(t,e,r,s){f(u.tuple(u.UInt32,u.Buffer,u.Satoshi,u.UInt32),arguments);let a,h=n.from([]),p=l,d=l,y=l;if(s&g.SIGHASH_ANYONECANPAY||(h=n.allocUnsafe(36*this.ins.length),a=new i.BufferWriter(h,0),this.ins.forEach((t=>{a.writeSlice(t.hash),a.writeUInt32(t.index)})),d=o.hash256(h)),s&g.SIGHASH_ANYONECANPAY||(31&s)===g.SIGHASH_SINGLE||(31&s)===g.SIGHASH_NONE||(h=n.allocUnsafe(4*this.ins.length),a=new i.BufferWriter(h,0),this.ins.forEach((t=>{a.writeUInt32(t.sequence)})),y=o.hash256(h)),(31&s)!==g.SIGHASH_SINGLE&&(31&s)!==g.SIGHASH_NONE){const t=this.outs.reduce(((t,e)=>t+8+c(e.script)),0);h=n.allocUnsafe(t),a=new i.BufferWriter(h,0),this.outs.forEach((t=>{a.writeUInt64(t.value),a.writeVarSlice(t.script)})),p=o.hash256(h)}else if((31&s)===g.SIGHASH_SINGLE&&t{o.writeSlice(t.hash),o.writeUInt32(t.index),o.writeVarSlice(t.script),o.writeUInt32(t.sequence)})),o.writeVarInt(this.outs.length),this.outs.forEach((t=>{void 0!==t.value?o.writeUInt64(t.value):o.writeSlice(t.valueBuffer),o.writeVarSlice(t.script)})),s&&this.ins.forEach((t=>{o.writeVector(t.witness)})),o.writeUInt32(this.locktime),void 0!==e?t.slice(e,o.offset):t}}e.Transaction=g,g.DEFAULT_SEQUENCE=4294967295,g.SIGHASH_DEFAULT=0,g.SIGHASH_ALL=1,g.SIGHASH_NONE=2,g.SIGHASH_SINGLE=3,g.SIGHASH_ANYONECANPAY=128,g.SIGHASH_OUTPUT_MASK=3,g.SIGHASH_INPUT_MASK=128,g.ADVANCED_TRANSACTION_MARKER=0,g.ADVANCED_TRANSACTION_FLAG=1},8116:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.oneOf=e.Null=e.BufferN=e.Function=e.UInt32=e.UInt8=e.tuple=e.maybe=e.Hex=e.Buffer=e.String=e.Boolean=e.Array=e.Number=e.Hash256bit=e.Hash160bit=e.Buffer256bit=e.isTaptree=e.isTapleaf=e.TAPLEAF_VERSION_MASK=e.Satoshi=e.isPoint=e.stacksEqual=e.typeforce=void 0;const n=r(1048);e.typeforce=r(973);const i=n.Buffer.alloc(32,0),o=n.Buffer.from("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f","hex");function s(t){return!(!t||!("output"in t)||!n.Buffer.isBuffer(t.output)||void 0!==t.version&&(t.version&e.TAPLEAF_VERSION_MASK)!==t.version)}e.stacksEqual=function(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))},e.isPoint=function(t){if(!n.Buffer.isBuffer(t))return!1;if(t.length<33)return!1;const e=t[0],r=t.slice(1,33);if(0===r.compare(i))return!1;if(r.compare(o)>=0)return!1;if((2===e||3===e)&&33===t.length)return!0;const s=t.slice(33);return 0!==s.compare(i)&&!(s.compare(o)>=0)&&4===e&&65===t.length},e.Satoshi=function(t){return e.typeforce.UInt53(t)&&t<=21e14},e.TAPLEAF_VERSION_MASK=254,e.isTapleaf=s,e.isTaptree=function t(r){return(0,e.Array)(r)?2===r.length&&r.every((e=>t(e))):s(r)},e.Buffer256bit=e.typeforce.BufferN(32),e.Hash160bit=e.typeforce.BufferN(20),e.Hash256bit=e.typeforce.BufferN(32),e.Number=e.typeforce.Number,e.Array=e.typeforce.Array,e.Boolean=e.typeforce.Boolean,e.String=e.typeforce.String,e.Buffer=e.typeforce.Buffer,e.Hex=e.typeforce.Hex,e.maybe=e.typeforce.maybe,e.tuple=e.typeforce.tuple,e.UInt8=e.typeforce.UInt8,e.UInt32=e.typeforce.UInt32,e.Function=e.typeforce.Function,e.BufferN=e.typeforce.BufferN,e.Null=e.typeforce.Null,e.oneOf=e.typeforce.oneOf},6763:(t,e,r)=>{const n=r(5364);t.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},9204:(t,e,r)=>{"use strict";var n=r(6763);t.exports=function(t){function e(e){var r=e.slice(0,-4),n=e.slice(-4),i=t(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(e){var r=Uint8Array.from(e),i=t(r),o=r.length+4,s=new Uint8Array(o);return s.set(r,0),s.set(i.subarray(0,4),r.length),n.encode(s,o)},decode:function(t){var r=e(n.decode(t));if(!r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(t){var r=n.decodeUnsafe(t);if(r)return e(r)}}}},1889:(t,e,r)=>{"use strict";var{sha256:n}=r(9688),i=r(9204);t.exports=i((function(t){return n(n(t))}))},5170:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.ECPairFactory=e.networks=void 0;const i=r(5249);e.networks=i;const o=r(953),s=r(2644),a=r(7513),u=r(709),f=o.typeforce.maybe(o.typeforce.compile({compressed:o.maybe(o.Boolean),network:o.maybe(o.Network)}));e.ECPairFactory=function(t){function e(e,r){if(o.typeforce(o.Buffer256bit,e),!t.isPrivate(e))throw new TypeError("Private key not in range [1, n)");return o.typeforce(f,r),new c(e,void 0,r)}function r(e,r){return o.typeforce(t.isPoint,e),o.typeforce(f,r),new c(void 0,e,r)}(0,u.testEcc)(t);class c{__D;__Q;compressed;network;lowR;constructor(e,r,o){this.__D=e,this.__Q=r,this.lowR=!1,void 0===o&&(o={}),this.compressed=void 0===o.compressed||o.compressed,this.network=o.network||i.bitcoin,void 0!==r&&(this.__Q=n.from(t.pointCompress(r,this.compressed)))}get privateKey(){return this.__D}get publicKey(){if(!this.__Q){const e=t.pointFromScalar(this.__D,this.compressed);this.__Q=n.from(e)}return this.__Q}toWIF(){if(!this.__D)throw new Error("Missing private key");return a.encode(this.network.wif,this.__D,this.compressed)}tweak(t){return this.privateKey?this.tweakFromPrivateKey(t):this.tweakFromPublicKey(t)}sign(e,r){if(!this.__D)throw new Error("Missing private key");if(void 0===r&&(r=this.lowR),!1===r)return n.from(t.sign(e,this.__D));{let r=t.sign(e,this.__D);const i=n.alloc(32,0);let o=0;for(;r[0]>127;)o++,i.writeUIntLE(o,0,6),r=t.sign(e,this.__D,i);return n.from(r)}}signSchnorr(e){if(!this.privateKey)throw new Error("Missing private key");if(!t.signSchnorr)throw new Error("signSchnorr not supported by ecc library");return n.from(t.signSchnorr(e,this.privateKey))}verify(e,r){return t.verify(e,this.publicKey,r)}verifySchnorr(e,r){if(!t.verifySchnorr)throw new Error("verifySchnorr not supported by ecc library");return t.verifySchnorr(e,this.publicKey.subarray(1,33),r)}tweakFromPublicKey(e){const i=32===(o=this.publicKey).length?o:o.slice(1,33);var o;const s=t.xOnlyPointAddTweak(i,e);if(!s||null===s.xOnlyPubkey)throw new Error("Cannot tweak public key!");const a=n.from([0===s.parity?2:3]);return r(n.concat([a,s.xOnlyPubkey]),{network:this.network,compressed:this.compressed})}tweakFromPrivateKey(r){const i=3!==this.publicKey[0]&&(4!==this.publicKey[0]||1&~this.publicKey[64])?this.privateKey:t.privateNegate(this.privateKey),o=t.privateAdd(i,r);if(!o)throw new Error("Invalid tweaked private key!");return e(n.from(o),{network:this.network,compressed:this.compressed})}}return{isPoint:function(e){return t.isPoint(e)},fromPrivateKey:e,fromPublicKey:r,fromWIF:function(t,r){const n=a.decode(t),s=n.version;if(o.Array(r)){if(!(r=r.filter((t=>s===t.wif)).pop()))throw new Error("Unknown network version")}else if(r=r||i.bitcoin,s!==r.wif)throw new Error("Invalid network version");return e(n.privateKey,{compressed:n.compressed,network:r})},makeRandom:function(r){o.typeforce(f,r),void 0===r&&(r={});const n=r.rng||s;let i;do{i=n(32),o.typeforce(o.Buffer256bit,i)}while(!t.isPrivate(i));return e(i,r)}}}},8700:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.networks=e.ECPairFactory=e.default=void 0;var n=r(5170);Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n.ECPairFactory}}),Object.defineProperty(e,"ECPairFactory",{enumerable:!0,get:function(){return n.ECPairFactory}}),Object.defineProperty(e,"networks",{enumerable:!0,get:function(){return n.networks}})},5249:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.testnet=e.bitcoin=void 0,e.bitcoin={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},e.testnet={messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239}},709:(t,e,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.testEcc=void 0;const i=t=>n.from(t,"hex");function o(t){if(!t)throw new Error("ecc library invalid")}e.testEcc=function(t){o(t.isPoint(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(!t.isPoint(i("030000000000000000000000000000000000000000000000000000000000000005"))),o(t.isPrivate(i("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(t.isPrivate(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),o(!t.isPrivate(i("0000000000000000000000000000000000000000000000000000000000000000"))),o(!t.isPrivate(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"))),o(!t.isPrivate(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142"))),o(n.from(t.privateAdd(i("0000000000000000000000000000000000000000000000000000000000000001"),i("0000000000000000000000000000000000000000000000000000000000000000"))).equals(i("0000000000000000000000000000000000000000000000000000000000000001"))),o(null===t.privateAdd(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"),i("0000000000000000000000000000000000000000000000000000000000000003"))),o(n.from(t.privateAdd(i("e211078564db65c3ce7704f08262b1f38f1ef412ad15b5ac2d76657a63b2c500"),i("b51fbb69051255d1becbd683de5848242a89c229348dd72896a87ada94ae8665"))).equals(i("9730c2ee69edbb958d42db7460bafa18fef9d955325aec99044c81c8282b0a24"))),o(n.from(t.privateNegate(i("0000000000000000000000000000000000000000000000000000000000000001"))).equals(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),o(n.from(t.privateNegate(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"))).equals(i("0000000000000000000000000000000000000000000000000000000000000003"))),o(n.from(t.privateNegate(i("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(i("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792"))),o(n.from(t.pointCompress(i("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!0)).equals(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(n.from(t.pointCompress(i("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!1)).equals(i("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),o(n.from(t.pointCompress(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!0)).equals(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(n.from(t.pointCompress(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!1)).equals(i("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),o(n.from(t.pointFromScalar(i("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(i("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99"))),o(null===t.xOnlyPointAddTweak(i("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140")));let e=t.xOnlyPointAddTweak(i("1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b"),i("a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac"));o(n.from(e.xOnlyPubkey).equals(i("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"))&&1===e.parity),e=t.xOnlyPointAddTweak(i("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"),i("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47")),o(n.from(e.xOnlyPubkey).equals(i("9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"))&&0===e.parity),o(n.from(t.sign(i("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))).equals(i("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),o(t.verify(i("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),i("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),i("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),t.signSchnorr&&o(n.from(t.signSchnorr(i("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),i("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"),i("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906"))).equals(i("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7"))),t.verifySchnorr&&o(t.verifySchnorr(i("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),i("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"),i("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")))}},953:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.maybe=e.Boolean=e.Array=e.Buffer256bit=e.Network=e.typeforce=void 0,e.typeforce=r(973),e.Network=e.typeforce.compile({messagePrefix:e.typeforce.oneOf(e.typeforce.Buffer,e.typeforce.String),bip32:{public:e.typeforce.UInt32,private:e.typeforce.UInt32},pubKeyHash:e.typeforce.UInt8,scriptHash:e.typeforce.UInt8,wif:e.typeforce.UInt8}),e.Buffer256bit=e.typeforce.BufferN(32),e.Array=e.typeforce.Array,e.Boolean=e.typeforce.Boolean,e.maybe=e.typeforce.maybe},8469:(t,e,r)=>{"use strict";var n=r(5636).Buffer,i=9007199254740991;function o(t){if(t<0||t>i||t%1!=0)throw new RangeError("value out of range")}function s(t){return o(t),t<253?1:t<=65535?3:t<=4294967295?5:9}t.exports={encode:function t(e,r,i){if(o(e),r||(r=n.allocUnsafe(s(e))),!n.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return i||(i=0),e<253?(r.writeUInt8(e,i),t.bytes=1):e<=65535?(r.writeUInt8(253,i),r.writeUInt16LE(e,i+1),t.bytes=3):e<=4294967295?(r.writeUInt8(254,i),r.writeUInt32LE(e,i+1),t.bytes=5):(r.writeUInt8(255,i),r.writeUInt32LE(e>>>0,i+1),r.writeUInt32LE(e/4294967296|0,i+5),t.bytes=9),r},decode:function t(e,r){if(!n.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");r||(r=0);var i=e.readUInt8(r);if(i<253)return t.bytes=1,i;if(253===i)return t.bytes=3,e.readUInt16LE(r+1);if(254===i)return t.bytes=5,e.readUInt32LE(r+1);t.bytes=9;var s=e.readUInt32LE(r+1),a=4294967296*e.readUInt32LE(r+5)+s;return o(a),a},encodingLength:s}},7513:(t,e,r)=>{var n=r(1048).Buffer,i=r(7701);function o(t,e){if(void 0!==e&&t[0]!==e)throw new Error("Invalid network version");if(33===t.length)return{version:t[0],privateKey:t.slice(1,33),compressed:!1};if(34!==t.length)throw new Error("Invalid WIF length");if(1!==t[33])throw new Error("Invalid compression flag");return{version:t[0],privateKey:t.slice(1,33),compressed:!0}}function s(t,e,r){var i=new n(r?34:33);return i.writeUInt8(t,0),e.copy(i,1),r&&(i[33]=1),i}t.exports={decode:function(t,e){return o(i.decode(t),e)},decodeRaw:o,encode:function(t,e,r){return"number"==typeof t?i.encode(s(t,e,r)):i.encode(s(t.version,t.privateKey,t.compressed))},encodeRaw:s}},1448:(t,e,r)=>{"use strict";var n=r(5636).Buffer;t.exports=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r>>0,c=new Uint8Array(s);r>>0,c[l]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");o=p,r++}for(var d=s-o;d!==s&&0===c[d];)d++;var y=n.allocUnsafe(i+(s-d));y.fill(0,0,i);for(var w=i;d!==s;)y[w++]=c[d++];return y}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,s=e.length;o!==s&&0===e[o];)o++,r++;for(var f=(s-o)*c+1>>>0,h=new Uint8Array(f);o!==s;){for(var p=e[o],l=0,d=f-1;(0!==p||l>>0,h[d]=p%a>>>0,p=p/a>>>0;if(0!==p)throw new Error("Non-zero carry");i=l,o++}for(var y=f-i;y!==f&&0===h[y];)y++;for(var w=u.repeat(r);y{var n=r(1448);t.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},8016:(t,e,r)=>{"use strict";var n=r(3119),i=r(5636).Buffer;t.exports=function(t){function e(e){var r=e.slice(0,-4),n=e.slice(-4),i=t(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(e){var r=t(e);return n.encode(i.concat([e,r],e.length+4))},decode:function(t){var r=e(n.decode(t));if(!r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(t){var r=n.decodeUnsafe(t);if(r)return e(r)}}}},7701:(t,e,r)=>{"use strict";var n=r(3257),i=r(8016);t.exports=i((function(t){var e=n("sha256").update(t).digest();return n("sha256").update(e).digest()}))},2028:()=>{},3011:()=>{},3951:()=>{}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var o=e[n]={exports:{}};return t[n](o,o.exports,r),o.exports}r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}();var n=r(1048).Buffer,i=r(1757),o=r(8700),s=r(242),a=o.ECPairFactory(s),u=i.Psbt,f=i.payments,c=i.networks;function h(t,e){var r=e||"hex";return n.from(t,r)}function p(t){return a.fromPrivateKey(h(t,"hex"))}function l(t,e,r){var n="testnet"===r?c.testnet:c.bitcoin,i=h(t,"hex");return"p2pkh"===e?f.p2pkh({pubkey:i,network:n}):"p2sh"===e?f.p2sh({redeem:f.p2wpkh({pubkey:i,network:n})}):f.p2wpkh({pubkey:i,network:n})}void 0!==r.g&&(r.g.Psbt=u,r.g.payments=f,r.g.networks=c,r.g.getPayment=l,r.g.getAddress=function(t,e,r){return l(t,e,r).address},r.g.createTx=function(t,e,r,n){var i="testnet"===n?c.testnet:c.bitcoin,o=new u({network:i}),s=p(r);return o.addInputs(t),o.addOutputs(e),o.signAllInputs(s).finalizeAllInputs().extractTransaction().toHex()},r.g.aTb=h,r.g.k=p,r.g.m=function(t){var e=h(t,"utf8");return{script:f.embed({data:[e]}).output,value:0}})})(); \ No newline at end of file +(()=>{var e={242:(e,t,r)=>{"use strict";var n=r(1048).Buffer,i=r(4261),o=r(4500),s=r(9688);function a(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var f=a(i);const u="Expected Private",c="Expected Point",h="Expected Tweak",d="Expected Signature",l="Expected Extra Data (32 bytes)",p="Expected Scalar";f.utils.hmacSha256Sync=(e,...t)=>o.hmac(s.sha256,e,f.utils.concatBytes(...t)),f.utils.sha256Sync=(...e)=>s.sha256(f.utils.concatBytes(...e));const b=f.utils._normalizePrivateKey,y=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65]),g=new Uint8Array(32),w=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,69,81,35,25,80,183,95,196,64,45,161,114,47,201,186,238]);function m(e,t){for(let r=0;r<32;++r)if(e[r]!==t[r])return e[r]=0)}function E(e){return e instanceof Uint8Array&&64===e.length&&m(e.subarray(0,32),y)<0&&m(e.subarray(32,64),y)<0}function S(e){return e instanceof Uint8Array&&32===e.length}function I(e){return void 0===e||e instanceof Uint8Array&&32===e.length}function A(e){if("string"!=typeof e)throw new TypeError("hexToNumber: expected string, got "+typeof e);return BigInt(`0x${e}`)}function T(e){let t;if("bigint"==typeof e)t=e;else if("number"==typeof e&&Number.isSafeInteger(e)&&e>=0)t=BigInt(e);else if("string"==typeof e){if(64!==e.length)throw new Error("Expected 32 bytes of private scalar");t=A(e)}else{if(!(e instanceof Uint8Array))throw new TypeError("Expected valid private scalar");if(32!==e.length)throw new Error("Expected 32 bytes of private scalar");r=e,t=A(f.utils.bytesToHex(r))}var r;if(t<0)throw new Error("Expected private scalar >= 0");return t}const k=(e,t,r)=>{const n=f.Point.fromHex(e),i=T(t),o=f.Point.BASE.multiplyAndAddUnsafe(n,i,BigInt(1));if(!o)throw new Error("Tweaked point at infinity");return o.toRawBytes(r)};function P(e,t){return void 0===e?void 0===t||B(t):!!e}function O(e){try{return e()}catch(e){return null}}function M(e,t){if(32===e.length!==t)return!1;try{return!!f.Point.fromHex(e)}catch(e){return!1}}function x(e){return M(e,!1)}function B(e){return M(e,!1)&&33===e.length}function L(e){return f.utils.isValidPrivateKey(e)}function R(e){return M(e,!0)}function N(e){if(!x(e))throw new Error(c);return e.slice(1,33)}function U(e,t){if(!L(e))throw new Error(u);return O((()=>f.getPublicKey(e,P(t))))}t.isPoint=x,t.isPointCompressed=B,t.isPrivate=L,t.isXOnlyPoint=R,t.pointAdd=function(e,t,r){if(!x(e)||!x(t))throw new Error(c);return O((()=>{const n=f.Point.fromHex(e),i=f.Point.fromHex(t);return n.equals(i.negate())?null:n.add(i).toRawBytes(P(r,e))}))},t.pointAddScalar=function(e,t,r){if(!x(e))throw new Error(c);if(!_(t))throw new Error(h);return O((()=>k(e,t,P(r,e))))},t.pointCompress=function(e,t){if(!x(e))throw new Error(c);return f.Point.fromHex(e).toRawBytes(P(t,e))},t.pointFromScalar=U,t.pointMultiply=function(e,t,r){if(!x(e))throw new Error(c);if(!_(t))throw new Error(h);return O((()=>((e,t,r)=>{const n=f.Point.fromHex(e),i="string"==typeof t?t:f.utils.bytesToHex(t),o=BigInt(`0x${i}`);return n.multiply(o).toRawBytes(r)})(e,t,P(r,e))))},t.privateAdd=function(e,t){if(!1===L(e))throw new Error(u);if(!1===_(t))throw new Error(h);return O((()=>((e,t)=>{const r=b(e),n=T(t),i=f.utils._bigintTo32Bytes(f.utils.mod(r+n,f.CURVE.n));return f.utils.isValidPrivateKey(i)?i:null})(e,t)))},t.privateNegate=function(e){if(!1===L(e))throw new Error(u);return(e=>{const t=b(e),r=f.utils._bigintTo32Bytes(f.CURVE.n-t);return f.utils.isValidPrivateKey(r)?r:null})(e)},t.privateSub=function(e,t){if(!1===L(e))throw new Error(u);if(!1===_(t))throw new Error(h);return O((()=>((e,t)=>{const r=b(e),n=T(t),i=f.utils._bigintTo32Bytes(f.utils.mod(r-n,f.CURVE.n));return f.utils.isValidPrivateKey(i)?i:null})(e,t)))},t.recover=function(e,t,r,n){if(!S(e))throw new Error("Expected Hash");if(!E(t)||!function(e){return!(v(e.subarray(0,32))||v(e.subarray(32,64)))}(t))throw new Error(d);if(2&r&&!function(e){return e instanceof Uint8Array&&64===e.length&&m(e.subarray(0,32),w)<0}(t))throw new Error("Bad Recovery Id");if(!R(t.subarray(0,32)))throw new Error(d);return f.recoverPublicKey(e,t,r,P(n))},t.sign=function(e,t,r){if(!L(t))throw new Error(u);if(!S(e))throw new Error(p);if(!I(r))throw new Error(l);return f.signSync(e,t,{der:!1,extraEntropy:r})},t.signRecoverable=function(e,t,r){if(!L(t))throw new Error(u);if(!S(e))throw new Error(p);if(!I(r))throw new Error(l);const[n,i]=f.signSync(e,t,{der:!1,extraEntropy:r,recovered:!0});return{signature:n,recoveryId:i}},t.signSchnorr=function(e,t,r=n.alloc(32,0)){if(!L(t))throw new Error(u);if(!S(e))throw new Error(p);if(!I(r))throw new Error(l);return f.schnorr.signSync(e,t,r)},t.verify=function(e,t,r,n){if(!x(t))throw new Error(c);if(!E(r))throw new Error(d);if(!S(e))throw new Error(p);return f.verify(r,e,t,{strict:n})},t.verifySchnorr=function(e,t,r){if(!R(t))throw new Error(c);if(!E(r))throw new Error(d);if(!S(e))throw new Error(p);return f.schnorr.verifySync(r,e,t)},t.xOnlyPointAddTweak=function(e,t){if(!R(e))throw new Error(c);if(!_(t))throw new Error(h);return O((()=>{const r=k(e,t,!0);return{parity:r[0]%2==1?1:0,xOnlyPubkey:r.slice(1)}}))},t.xOnlyPointFromPoint=N,t.xOnlyPointFromScalar=function(e){if(!L(e))throw new Error(u);return N(U(e))}},8460:(e,t)=>{"use strict";function r(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function n(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}function i(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function o(e,...t){if(!i(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function s(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");r(e.outputLen),r(e.blockLen)}function a(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function f(e,t){o(e);const r=t.outputLen;if(e.length{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HashMD=t.Maj=t.Chi=void 0;const n=r(8460),i=r(9074);t.Chi=(e,t,r)=>e&t^~e&r,t.Maj=(e,t,r)=>e&t^e&r^t&r;class o extends i.Hash{constructor(e,t,r,n){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=(0,i.createView)(this.buffer)}update(e){(0,n.exists)(this);const{view:t,buffer:r,blockLen:o}=this,s=(e=(0,i.toBytes)(e)).length;for(let n=0;no-a&&(this.process(r,0),a=0);for(let e=a;e>i&o),a=Number(r&o),f=n?4:0,u=n?0:4;e.setUint32(t+f,s,n),e.setUint32(t+u,a,n)}(r,o-8,BigInt(8*this.length),s),this.process(r,0);const f=(0,i.createView)(e),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=u/4,h=this.get();if(c>h.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.crypto=void 0,t.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0},4500:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hmac=t.HMAC=void 0;const n=r(8460),i=r(9074);class o extends i.Hash{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,(0,n.hash)(e);const r=(0,i.toBytes)(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,s=new Uint8Array(o);s.set(r.length>o?e.create().update(r).digest():r);for(let e=0;enew o(e,t).update(r).digest(),t.hmac.create=(e,t)=>new o(e,t)},71:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ripemd160=t.RIPEMD160=void 0;const n=r(6423),i=r(9074),o=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),s=new Uint8Array(new Array(16).fill(0).map(((e,t)=>t)));let a=[s],f=[s.map((e=>(9*e+5)%16))];for(let e=0;e<4;e++)for(let t of[a,f])t.push(t[e].map((e=>o[e])));const u=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map((e=>new Uint8Array(e))),c=a.map(((e,t)=>e.map((e=>u[t][e])))),h=f.map(((e,t)=>e.map((e=>u[t][e])))),d=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),l=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function p(e,t,r,n){return 0===e?t^r^n:1===e?t&r|~t&n:2===e?(t|~r)^n:3===e?t&n|r&~n:t^(r|~n)}const b=new Uint32Array(16);class y extends n.HashMD{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:e,h1:t,h2:r,h3:n,h4:i}=this;return[e,t,r,n,i]}set(e,t,r,n,i){this.h0=0|e,this.h1=0|t,this.h2=0|r,this.h3=0|n,this.h4=0|i}process(e,t){for(let r=0;r<16;r++,t+=4)b[r]=e.getUint32(t,!0);let r=0|this.h0,n=r,o=0|this.h1,s=o,u=0|this.h2,y=u,g=0|this.h3,w=g,m=0|this.h4,v=m;for(let e=0;e<5;e++){const t=4-e,_=d[e],E=l[e],S=a[e],I=f[e],A=c[e],T=h[e];for(let t=0;t<16;t++){const n=(0,i.rotl)(r+p(e,o,u,g)+b[S[t]]+_,A[t])+m|0;r=m,m=g,g=0|(0,i.rotl)(u,10),u=o,o=n}for(let e=0;e<16;e++){const r=(0,i.rotl)(n+p(t,s,y,w)+b[I[e]]+E,T[e])+v|0;n=v,v=w,w=0|(0,i.rotl)(y,10),y=s,s=r}}this.set(this.h1+u+w|0,this.h2+g+v|0,this.h3+m+n|0,this.h4+r+s|0,this.h0+o+y|0)}roundClean(){b.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}t.RIPEMD160=y,t.ripemd160=(0,i.wrapConstructor)((()=>new y))},874:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sha1=t.SHA1=void 0;const n=r(6423),i=r(9074),o=new Uint32Array([1732584193,4023233417,2562383102,271733878,3285377520]),s=new Uint32Array(80);class a extends n.HashMD{constructor(){super(64,20,8,!1),this.A=0|o[0],this.B=0|o[1],this.C=0|o[2],this.D=0|o[3],this.E=0|o[4]}get(){const{A:e,B:t,C:r,D:n,E:i}=this;return[e,t,r,n,i]}set(e,t,r,n,i){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|i}process(e,t){for(let r=0;r<16;r++,t+=4)s[r]=e.getUint32(t,!1);for(let e=16;e<80;e++)s[e]=(0,i.rotl)(s[e-3]^s[e-8]^s[e-14]^s[e-16],1);let{A:r,B:o,C:a,D:f,E:u}=this;for(let e=0;e<80;e++){let t,c;e<20?(t=(0,n.Chi)(o,a,f),c=1518500249):e<40?(t=o^a^f,c=1859775393):e<60?(t=(0,n.Maj)(o,a,f),c=2400959708):(t=o^a^f,c=3395469782);const h=(0,i.rotl)(r,5)+t+u+c+s[e]|0;u=f,f=a,a=(0,i.rotl)(o,30),o=r,r=h}r=r+this.A|0,o=o+this.B|0,a=a+this.C|0,f=f+this.D|0,u=u+this.E|0,this.set(r,o,a,f,u)}roundClean(){s.fill(0)}destroy(){this.set(0,0,0,0,0),this.buffer.fill(0)}}t.SHA1=a,t.sha1=(0,i.wrapConstructor)((()=>new a))},9688:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sha224=t.sha256=t.SHA256=void 0;const n=r(6423),i=r(9074),o=new Uint32Array([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]),s=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);class f extends n.HashMD{constructor(){super(64,32,8,!1),this.A=0|s[0],this.B=0|s[1],this.C=0|s[2],this.D=0|s[3],this.E=0|s[4],this.F=0|s[5],this.G=0|s[6],this.H=0|s[7]}get(){const{A:e,B:t,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[e,t,r,n,i,o,s,a]}set(e,t,r,n,i,o,s,a){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(e,t){for(let r=0;r<16;r++,t+=4)a[r]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=a[e-15],r=a[e-2],n=(0,i.rotr)(t,7)^(0,i.rotr)(t,18)^t>>>3,o=(0,i.rotr)(r,17)^(0,i.rotr)(r,19)^r>>>10;a[e]=o+a[e-7]+n+a[e-16]|0}let{A:r,B:s,C:f,D:u,E:c,F:h,G:d,H:l}=this;for(let e=0;e<64;e++){const t=l+((0,i.rotr)(c,6)^(0,i.rotr)(c,11)^(0,i.rotr)(c,25))+(0,n.Chi)(c,h,d)+o[e]+a[e]|0,p=((0,i.rotr)(r,2)^(0,i.rotr)(r,13)^(0,i.rotr)(r,22))+(0,n.Maj)(r,s,f)|0;l=d,d=h,h=c,c=u+t|0,u=f,f=s,s=r,r=t+p|0}r=r+this.A|0,s=s+this.B|0,f=f+this.C|0,u=u+this.D|0,c=c+this.E|0,h=h+this.F|0,d=d+this.G|0,l=l+this.H|0,this.set(r,s,f,u,c,h,d,l)}roundClean(){a.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}t.SHA256=f;class u extends f{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}t.sha256=(0,i.wrapConstructor)((()=>new f)),t.sha224=(0,i.wrapConstructor)((()=>new u))},9074:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Hash=t.nextTick=t.byteSwapIfBE=t.byteSwap=t.isLE=t.rotl=t.rotr=t.createView=t.u32=t.u8=void 0,t.isBytes=function(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name},t.byteSwap32=function(e){for(let r=0;r=0&&ee().update(u(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t},t.wrapConstructorWithOpts=function(e){const t=(t,r)=>e(r).update(u(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t},t.wrapXOFConstructorWithOpts=function(e){const t=(t,r)=>e(r).update(u(t)).digest(),r=e({});return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t},t.randomBytes=function(e=32){if(n.crypto&&"function"==typeof n.crypto.getRandomValues)return n.crypto.getRandomValues(new Uint8Array(e));if(n.crypto&&"function"==typeof n.crypto.randomBytes)return n.crypto.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")};const n=r(6910),i=r(8460);t.u8=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),t.u32=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),t.createView=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),t.rotr=(e,t)=>e<<32-t|e>>>t,t.rotl=(e,t)=>e<>>32-t>>>0,t.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],t.byteSwap=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,t.byteSwapIfBE=t.isLE?e=>e:e=>(0,t.byteSwap)(e);const o=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0"))),s={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function a(e){return e>=s._0&&e<=s._9?e-s._0:e>=s._A&&e<=s._F?e-(s._A-10):e>=s._a&&e<=s._f?e-(s._a-10):void 0}function f(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function u(e){return"string"==typeof e&&(e=f(e)),(0,i.bytes)(e),e}t.nextTick=async()=>{},t.Hash=class{clone(){return this._cloneInto()}};const c={}.toString},4261:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.utils=t.schnorr=t.verify=t.signSync=t.sign=t.getSharedSecret=t.recoverPublicKey=t.getPublicKey=t.Signature=t.Point=t.CURVE=void 0;const n=r(2028),i=BigInt(0),o=BigInt(1),s=BigInt(2),a=BigInt(3),f=BigInt(8),u=Object.freeze({a:i,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:o,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")});t.CURVE=u;const c=(e,t)=>(e+t/s)/t,h={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(e){const{n:t}=u,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-o*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=r,a=BigInt("0x100000000000000000000000000000000"),f=c(s*e,t),h=c(-n*e,t);let d=D(e-f*r-h*i,t),l=D(-f*n-h*s,t);const p=d>a,b=l>a;if(p&&(d=t-d),b&&(l=t-l),d>a||l>a)throw new Error("splitScalarEndo: Endomorphism failed, k="+e);return{k1neg:p,k1:d,k2neg:b,k2:l}}},d=32,l=32,p=d+1,b=2*d+1;function y(e){const{a:t,b:r}=u,n=D(e*e),i=D(n*e);return D(i+t*e+r)}const g=u.a===i;class w extends Error{constructor(e){super(e)}}function m(e){if(!(e instanceof v))throw new TypeError("JacobianPoint expected")}class v{constructor(e,t,r){this.x=e,this.y=t,this.z=r}static fromAffine(e){if(!(e instanceof S))throw new TypeError("JacobianPoint#fromAffine: expected Point");return e.equals(S.ZERO)?v.ZERO:new v(e.x,e.y,o)}static toAffineBatch(e){const t=function(e,t=u.P){const r=new Array(e.length),n=V(e.reduce(((e,n,o)=>n===i?e:(r[o]=e,D(e*n,t))),o),t);return e.reduceRight(((e,n,o)=>n===i?e:(r[o]=D(e*r[o],t),D(e*n,t))),n),r}(e.map((e=>e.z)));return e.map(((e,r)=>e.toAffine(t[r])))}static normalizeZ(e){return v.toAffineBatch(e).map(v.fromAffine)}equals(e){m(e);const{x:t,y:r,z:n}=this,{x:i,y:o,z:s}=e,a=D(n*n),f=D(s*s),u=D(t*f),c=D(i*a),h=D(D(r*s)*f),d=D(D(o*n)*a);return u===c&&h===d}negate(){return new v(this.x,D(-this.y),this.z)}double(){const{x:e,y:t,z:r}=this,n=D(e*e),i=D(t*t),o=D(i*i),u=e+i,c=D(s*(D(u*u)-n-o)),h=D(a*n),d=D(h*h),l=D(d-s*c),p=D(h*(c-l)-f*o),b=D(s*t*r);return new v(l,p,b)}add(e){m(e);const{x:t,y:r,z:n}=this,{x:o,y:a,z:f}=e;if(o===i||a===i)return this;if(t===i||r===i)return e;const u=D(n*n),c=D(f*f),h=D(t*c),d=D(o*u),l=D(D(r*f)*c),p=D(D(a*n)*u),b=D(d-h),y=D(p-l);if(b===i)return y===i?this.double():v.ZERO;const g=D(b*b),w=D(b*g),_=D(h*g),E=D(y*y-w-s*_),S=D(y*(_-E)-l*w),I=D(n*f*b);return new v(E,S,I)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){const t=v.ZERO;if("bigint"==typeof e&&e===i)return t;let r=H(e);if(r===o)return this;if(!g){let e=t,n=this;for(;r>i;)r&o&&(e=e.add(n)),n=n.double(),r>>=o;return e}let{k1neg:n,k1:s,k2neg:a,k2:f}=h.splitScalar(r),u=t,c=t,d=this;for(;s>i||f>i;)s&o&&(u=u.add(d)),f&o&&(c=c.add(d)),d=d.double(),s>>=o,f>>=o;return n&&(u=u.negate()),a&&(c=c.negate()),c=new v(D(c.x*h.beta),c.y,c.z),u.add(c)}precomputeWindow(e){const t=g?128/e+1:256/e+1,r=[];let n=this,i=n;for(let o=0;o>=h,a>f&&(a-=c,e+=o);const d=r,l=r+Math.abs(a)-1,p=t%2!=0,b=a<0;0===a?s=s.add(_(p,n[d])):i=i.add(_(b,n[l]))}return{p:i,f:s}}multiply(e,t){let r,n,i=H(e);if(g){const{k1neg:e,k1:o,k2neg:s,k2:a}=h.splitScalar(i);let{p:f,f:u}=this.wNAF(o,t),{p:c,f:d}=this.wNAF(a,t);f=_(e,f),c=_(s,c),c=new v(D(c.x*h.beta),c.y,c.z),r=f.add(c),n=u.add(d)}else{const{p:e,f:o}=this.wNAF(i,t);r=e,n=o}return v.normalizeZ([r,n])[0]}toAffine(e){const{x:t,y:r,z:n}=this,i=this.equals(v.ZERO);null==e&&(e=i?f:V(n));const s=e,a=D(s*s),u=D(a*s),c=D(t*a),h=D(r*u),d=D(n*s);if(i)return S.ZERO;if(d!==o)throw new Error("invZ was invalid");return new S(c,h)}}function _(e,t){const r=t.negate();return e?r:t}v.BASE=new v(u.Gx,u.Gy,o),v.ZERO=new v(i,o,i);const E=new WeakMap;class S{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,E.delete(this)}hasEvenY(){return this.y%s===i}static fromCompressedHex(e){const t=32===e.length,r=U(t?e:e.subarray(1));if(!G(r))throw new Error("Point is not on curve");let n=function(e){const{P:t}=u,r=BigInt(6),n=BigInt(11),i=BigInt(22),o=BigInt(23),f=BigInt(44),c=BigInt(88),h=e*e*e%t,d=h*h*e%t,l=K(d,a)*d%t,p=K(l,a)*d%t,b=K(p,s)*h%t,y=K(b,n)*b%t,g=K(y,i)*y%t,w=K(g,f)*g%t,m=K(w,c)*w%t,v=K(m,f)*g%t,_=K(v,a)*d%t,E=K(_,o)*y%t,S=K(E,r)*h%t,I=K(S,s);if(I*I%t!==e)throw new Error("Cannot find square root");return I}(y(r));const i=(n&o)===o;t?i&&(n=D(-n)):!(1&~e[0])!==i&&(n=D(-n));const f=new S(r,n);return f.assertValidity(),f}static fromUncompressedHex(e){const t=U(e.subarray(1,d+1)),r=U(e.subarray(d+1,2*d+1)),n=new S(t,r);return n.assertValidity(),n}static fromHex(e){const t=C(e),r=t.length,n=t[0];if(r===d)return this.fromCompressedHex(t);if(r===p&&(2===n||3===n))return this.fromCompressedHex(t);if(r===b&&4===n)return this.fromUncompressedHex(t);throw new Error(`Point.fromHex: received invalid point. Expected 32-${p} compressed bytes or ${b} uncompressed bytes, not ${r}`)}static fromPrivateKey(e){return S.BASE.multiply(X(e))}static fromSignature(e,t,r){const{r:n,s:i}=Z(t);if(![0,1,2,3].includes(r))throw new Error("Cannot recover: invalid recovery bit");const o=j(C(e)),{n:s}=u,a=2===r||3===r?n+s:n,f=V(a,s),c=D(-o*f,s),h=D(i*f,s),d=1&r?"03":"02",l=S.fromHex(d+x(a)),p=S.BASE.multiplyAndAddUnsafe(l,c,h);if(!p)throw new Error("Cannot recover signature: point at infinify");return p.assertValidity(),p}toRawBytes(e=!1){return N(this.toHex(e))}toHex(e=!1){const t=x(this.x);return e?`${this.hasEvenY()?"02":"03"}${t}`:`04${t}${x(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const e="Point is not on elliptic curve",{x:t,y:r}=this;if(!G(t)||!G(r))throw new Error(e);const n=D(r*r);if(D(n-y(t))!==i)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new S(this.x,D(-this.y))}double(){return v.fromAffine(this).double().toAffine()}add(e){return v.fromAffine(this).add(v.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return v.fromAffine(this).multiply(e,this).toAffine()}multiplyAndAddUnsafe(e,t,r){const n=v.fromAffine(this),s=t===i||t===o||this!==S.BASE?n.multiplyUnsafe(t):n.multiply(t),a=v.fromAffine(e).multiplyUnsafe(r),f=s.add(a);return f.equals(v.ZERO)?void 0:f.toAffine()}}function I(e){return Number.parseInt(e[0],16)>=8?"00"+e:e}function A(e){if(e.length<2||2!==e[0])throw new Error(`Invalid signature integer tag: ${O(e)}`);const t=e[1],r=e.subarray(2,t+2);if(!t||r.length!==t)throw new Error("Invalid signature integer: wrong length");if(0===r[0]&&r[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:U(r),left:e.subarray(t+2)}}t.Point=S,S.BASE=new S(u.Gx,u.Gy),S.ZERO=new S(i,i);class T{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromCompact(e){const t=e instanceof Uint8Array,r="Signature.fromCompact";if("string"!=typeof e&&!t)throw new TypeError(`${r}: Expected string or Uint8Array`);const n=t?O(e):e;if(128!==n.length)throw new Error(`${r}: Expected 64-byte hex`);return new T(R(n.slice(0,64)),R(n.slice(64,128)))}static fromDER(e){const t=e instanceof Uint8Array;if("string"!=typeof e&&!t)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r,s:n}=function(e){if(e.length<2||48!=e[0])throw new Error(`Invalid signature tag: ${O(e)}`);if(e[1]!==e.length-2)throw new Error("Invalid signature: incorrect length");const{data:t,left:r}=A(e.subarray(2)),{data:n,left:i}=A(r);if(i.length)throw new Error(`Invalid signature: left bytes after parsing: ${O(i)}`);return{r:t,s:n}}(t?e:N(e));return new T(r,n)}static fromHex(e){return this.fromDER(e)}assertValidity(){const{r:e,s:t}=this;if(!z(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!z(t))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const e=u.n>>o;return this.s>e}normalizeS(){return this.hasHighS()?new T(this.r,D(-this.s,u.n)):this}toDERRawBytes(){return N(this.toDERHex())}toDERHex(){const e=I(L(this.s)),t=I(L(this.r)),r=e.length/2,n=t.length/2,i=L(r),o=L(n);return`30${L(n+r+4)}02${o}${t}02${i}${e}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return N(this.toCompactHex())}toCompactHex(){return x(this.r)+x(this.s)}}function k(...e){if(!e.every((e=>e instanceof Uint8Array)))throw new Error("Uint8Array list expected");if(1===e.length)return e[0];const t=e.reduce(((e,t)=>e+t.length),0),r=new Uint8Array(t);for(let t=0,n=0;tt.toString(16).padStart(2,"0")));function O(e){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");let t="";for(let r=0;r0)return BigInt(e);if("bigint"==typeof e&&z(e))return e;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function D(e,t=u.P){const r=e%t;return r>=i?r:t+r}function K(e,t){const{P:r}=u;let n=e;for(;t-- >i;)n*=n,n%=r;return n}function V(e,t=u.P){if(e===i||t<=i)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let r=D(e,t),n=t,s=i,a=o,f=o,c=i;for(;r!==i;){const e=n/r,t=n%r,i=s-f*e,o=a-c*e;n=r,r=t,s=f,a=c,f=i,c=o}if(n!==o)throw new Error("invert: does not exist");return D(s,t)}function j(e,t=!1){const r=function(e){const t=8*e.length-8*l,r=U(e);return t>0?r>>BigInt(t):r}(e);if(t)return r;const{n}=u;return r>=n?r-n:r}let F,q;class W{constructor(e,t){if(this.hashLen=e,this.qByteLen=t,"number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");this.v=new Uint8Array(e).fill(1),this.k=new Uint8Array(e).fill(0),this.counter=0}hmac(...e){return t.utils.hmacSha256(this.k,...e)}hmacSync(...e){return q(this.k,...e)}checkSync(){if("function"!=typeof q)throw new w("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}async reseed(e=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),e),this.v=await this.hmac(this.v),0!==e.length&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),e),this.v=await this.hmac(this.v))}reseedSync(e=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),e),this.v=this.hmacSync(this.v),0!==e.length&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),e),this.v=this.hmacSync(this.v))}async generate(){this.incr();let e=0;const t=[];for(;e0)t=BigInt(e);else if("string"==typeof e){if(e.length!==2*l)throw new Error("Expected 32 bytes of private key");t=R(e)}else{if(!(e instanceof Uint8Array))throw new TypeError("Expected valid private key");if(e.length!==l)throw new Error("Expected 32 bytes of private key");t=U(e)}if(!z(t))throw new Error("Expected private key: 0 < key < n");return t}function $(e){return e instanceof S?(e.assertValidity(),e):S.fromHex(e)}function Z(e){if(e instanceof T)return e.assertValidity(),e;try{return T.fromDER(e)}catch(t){return T.fromCompact(e)}}function J(e){const t=e instanceof Uint8Array,r="string"==typeof e,n=(t||r)&&e.length;return t?n===p||n===b:r?n===2*p||n===2*b:e instanceof S}function Q(e){return U(e.length>d?e.slice(0,d):e)}function ee(e){const t=Q(e),r=D(t,u.n);return te(r{e=C(e);const t=l+8;if(e.length1024)throw new Error("Expected valid bytes of private key as per FIPS 186");return B(D(U(e),u.n-o)+o)},randomBytes:(e=32)=>{if(de.web)return de.web.getRandomValues(new Uint8Array(e));if(de.node){const{randomBytes:t}=de.node;return Uint8Array.from(t(e))}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>t.utils.hashToPrivateKey(t.utils.randomBytes(l+8)),precompute(e=8,t=S.BASE){const r=t===S.BASE?t:new S(t.x,t.y);return r._setWindowSize(e),r.multiply(a),r},sha256:async(...e)=>{if(de.web){const t=await de.web.subtle.digest("SHA-256",k(...e));return new Uint8Array(t)}if(de.node){const{createHash:t}=de.node,r=t("sha256");return e.forEach((e=>r.update(e))),Uint8Array.from(r.digest())}throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(e,...t)=>{if(de.web){const r=await de.web.subtle.importKey("raw",e,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),n=k(...t),i=await de.web.subtle.sign("HMAC",r,n);return new Uint8Array(i)}if(de.node){const{createHmac:r}=de.node,n=r("sha256",e);return t.forEach((e=>n.update(e))),Uint8Array.from(n.digest())}throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(e,...r)=>{let n=pe[e];if(void 0===n){const r=await t.utils.sha256(Uint8Array.from(e,(e=>e.charCodeAt(0))));n=k(r,r),pe[e]=n}return t.utils.sha256(n,...r)},taggedHashSync:(e,...t)=>{if("function"!=typeof F)throw new w("sha256Sync is undefined, you need to set it");let r=pe[e];if(void 0===r){const t=F(Uint8Array.from(e,(e=>e.charCodeAt(0))));r=k(t,t),pe[e]=r}return F(r,...t)},_JacobianPoint:v},Object.defineProperties(t.utils,{sha256Sync:{configurable:!1,get:()=>F,set(e){F||(F=e)}},hmacSha256Sync:{configurable:!1,get:()=>q,set(e){q||(q=e)}}})},7403:e=>{"use strict";e.exports=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r>>0,u=new Uint8Array(o);e[r];){var c=t[e.charCodeAt(r)];if(255===c)return;for(var h=0,d=o-1;(0!==c||h>>0,u[d]=c%256>>>0,c=c/256>>>0;if(0!==c)throw new Error("Non-zero carry");i=h,r++}for(var l=o-i;l!==o&&0===u[l];)l++;for(var p=new Uint8Array(n+(o-l)),b=n;l!==o;)p[b++]=u[l++];return p}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,o=t.length;i!==o&&0===t[i];)i++,r++;for(var f=(o-i)*u+1>>>0,c=new Uint8Array(f);i!==o;){for(var h=t[i],d=0,l=f-1;(0!==h||d>>0,c[l]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=f-n;p!==f&&0===c[p];)p++;for(var b=a.repeat(r);p{"use strict";t.byteLength=function(e){var t=a(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,o=a(e),s=o[0],f=o[1],u=new i(function(e,t,r){return 3*(t+r)/4-r}(0,s,f)),c=0,h=f>0?s-4:s;for(r=0;r>16&255,u[c++]=t>>8&255,u[c++]=255&t;return 2===f&&(t=n[e.charCodeAt(r)]<<2|n[e.charCodeAt(r+1)]>>4,u[c++]=255&t),1===f&&(t=n[e.charCodeAt(r)]<<10|n[e.charCodeAt(r+1)]<<4|n[e.charCodeAt(r+2)]>>2,u[c++]=t>>8&255,u[c++]=255&t),u},t.fromByteArray=function(e){for(var t,n=e.length,i=n%3,o=[],s=16383,a=0,u=n-i;au?u:a+s));return 1===i?(t=e[n-1],o.push(r[t>>2]+r[t<<4&63]+"==")):2===i&&(t=(e[n-2]<<8)+e[n-1],o.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"=")),o.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)r[s]=o[s],n[o.charCodeAt(s)]=s;function a(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function f(e,t,n){for(var i,o,s=[],a=t;a>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return s.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},6586:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bech32m=t.bech32=void 0;const r="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n={};for(let e=0;e<32;e++){const t=r.charAt(e);n[t]=e}function i(e){const t=e>>25;return(33554431&e)<<5^996825010&-(1&t)^642813549&-(t>>1&1)^513874426&-(t>>2&1)^1027748829&-(t>>3&1)^705979059&-(t>>4&1)}function o(e){let t=1;for(let r=0;r126)return"Invalid prefix ("+e+")";t=i(t)^n>>5}t=i(t);for(let r=0;r=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<=t)return"Excess padding";if(i<r)return"Exceeds length limit";const s=e.toLowerCase(),a=e.toUpperCase();if(e!==s&&e!==a)return"Mixed-case string "+e;const f=(e=s).lastIndexOf("1");if(-1===f)return"No separator character for "+e;if(0===f)return"Missing prefix for "+e;const u=e.slice(0,f),c=e.slice(f+1);if(c.length<6)return"Data too short";let h=o(u);if("string"==typeof h)return h;const d=[];for(let e=0;e=c.length||d.push(r)}return h!==t?"Invalid checksum for "+e:{prefix:u,words:d}}return t="bech32"===e?1:734539939,{decodeUnsafe:function(e,t){const r=s(e,t);if("object"==typeof r)return r},decode:function(e,t){const r=s(e,t);if("object"==typeof r)return r;throw new Error(r)},encode:function(e,n,s){if(s=s||90,e.length+7+n.length>s)throw new TypeError("Exceeds length limit");let a=o(e=e.toLowerCase());if("string"==typeof a)throw new Error(a);let f=e+"1";for(let e=0;e>5)throw new Error("Non 5-bit word");a=i(a)^t,f+=r.charAt(t)}for(let e=0;e<6;++e)a=i(a);a^=t;for(let e=0;e<6;++e)f+=r.charAt(a>>5*(5-e)&31);return f},toWords:a,fromWordsUnsafe:f,fromWords:u}}t.bech32=c("bech32"),t.bech32m=c("bech32m")},3162:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(6808);function i(e,t,r){return n=>{if(e.has(n))return;const i=r.filter((e=>e.key.toString("hex")===n))[0];t.push(i),e.add(n)}}function o(e){return e.globalMap.unsignedTx}function s(e){const t=new Set;return e.forEach((e=>{const r=e.key.toString("hex");if(t.has(r))throw new Error("Combine: KeyValue Map keys should be unique");t.add(r)})),t}t.combine=function(e){const t=e[0],r=n.psbtToKeyVals(t),a=e.slice(1);if(0===a.length)throw new Error("Combine: Nothing to combine");const f=o(t);if(void 0===f)throw new Error("Combine: Self missing transaction");const u=s(r.globalKeyVals),c=r.inputKeyVals.map(s),h=r.outputKeyVals.map(s);for(const e of a){const t=o(e);if(void 0===t||!t.toBuffer().equals(f.toBuffer()))throw new Error("Combine: One of the Psbts does not have the same transaction.");const a=n.psbtToKeyVals(e);s(a.globalKeyVals).forEach(i(u,r.globalKeyVals,a.globalKeyVals)),a.inputKeyVals.map(s).forEach(((e,t)=>e.forEach(i(c[t],r.inputKeyVals[t],a.inputKeyVals[t])))),a.outputKeyVals.map(s).forEach(((e,t)=>e.forEach(i(h[t],r.outputKeyVals[t],a.outputKeyVals[t]))))}return n.psbtFromKeyVals(f,{globalMapKeyVals:r.globalKeyVals,inputKeyVals:r.inputKeyVals,outputKeyVals:r.outputKeyVals})}},9977:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0});const i=r(9889);t.decode=function(e){if(e.key[0]!==i.GlobalTypes.GLOBAL_XPUB)throw new Error("Decode Error: could not decode globalXpub with key 0x"+e.key.toString("hex"));if(79!==e.key.length||![2,3].includes(e.key[46]))throw new Error("Decode Error: globalXpub has invalid extended pubkey in key 0x"+e.key.toString("hex"));if(e.value.length/4%1!=0)throw new Error("Decode Error: Global GLOBAL_XPUB value length should be multiple of 4");const t=e.key.slice(1),r={masterFingerprint:e.value.slice(0,4),extendedPubkey:t,path:"m"};for(const t of(n=e.value.length/4-1,[...Array(n).keys()])){const n=e.value.readUInt32LE(4*t+4),i=!!(2147483648&n),o=2147483647&n;r.path+="/"+o.toString(10)+(i?"'":"")}var n;return r},t.encode=function(e){const t=n.from([i.GlobalTypes.GLOBAL_XPUB]),r=n.concat([t,e.extendedPubkey]),o=e.path.split("/"),s=n.allocUnsafe(4*o.length);e.masterFingerprint.copy(s,0);let a=4;return o.slice(1).forEach((e=>{const t="'"===e.slice(-1);let r=2147483647&parseInt(t?e.slice(0,-1):e,10);t&&(r+=2147483648),s.writeUInt32LE(r,a),a+=4})),{key:r,value:s}},t.expected="{ masterFingerprint: Buffer; extendedPubkey: Buffer; path: string; }",t.check=function(e){const t=e.extendedPubkey,r=e.masterFingerprint,i=e.path;return n.isBuffer(t)&&78===t.length&&[2,3].indexOf(t[45])>-1&&n.isBuffer(r)&&4===r.length&&"string"==typeof i&&!!i.match(/^m(\/\d+'?)*$/)},t.canAddToArray=function(e,t,r){const n=t.extendedPubkey.toString("hex");return!r.has(n)&&(r.add(n),0===e.filter((e=>e.extendedPubkey.equals(t.extendedPubkey))).length)}},3398:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0});const i=r(9889);t.encode=function(e){return{key:n.from([i.GlobalTypes.UNSIGNED_TX]),value:e.toBuffer()}}},6317:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(9889),i=r(9977),o=r(3398),s=r(7312),a=r(4042),f=r(8730),u=r(5098),c=r(4474),h=r(9175),d=r(7279),l=r(7544),p=r(241),b=r(3155),y=r(4709),g=r(9574),w=r(6896),m=r(437),v=r(5400),_=r(2751),E=r(9632),S=r(9079),I={unsignedTx:o,globalXpub:i,checkPubkey:m.makeChecker([])};t.globals=I;const A={nonWitnessUtxo:f,partialSig:u,sighashType:h,finalScriptSig:s,finalScriptWitness:a,porCommitment:c,witnessUtxo:y,bip32Derivation:w.makeConverter(n.InputTypes.BIP32_DERIVATION),redeemScript:v.makeConverter(n.InputTypes.REDEEM_SCRIPT),witnessScript:S.makeConverter(n.InputTypes.WITNESS_SCRIPT),checkPubkey:m.makeChecker([n.InputTypes.PARTIAL_SIG,n.InputTypes.BIP32_DERIVATION]),tapKeySig:d,tapScriptSig:b,tapLeafScript:l,tapBip32Derivation:_.makeConverter(n.InputTypes.TAP_BIP32_DERIVATION),tapInternalKey:E.makeConverter(n.InputTypes.TAP_INTERNAL_KEY),tapMerkleRoot:p};t.inputs=A;const T={bip32Derivation:w.makeConverter(n.OutputTypes.BIP32_DERIVATION),redeemScript:v.makeConverter(n.OutputTypes.REDEEM_SCRIPT),witnessScript:S.makeConverter(n.OutputTypes.WITNESS_SCRIPT),checkPubkey:m.makeChecker([n.OutputTypes.BIP32_DERIVATION]),tapBip32Derivation:_.makeConverter(n.OutputTypes.TAP_BIP32_DERIVATION),tapTree:g,tapInternalKey:E.makeConverter(n.OutputTypes.TAP_INTERNAL_KEY)};t.outputs=T},7312:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0});const i=r(9889);t.decode=function(e){if(e.key[0]!==i.InputTypes.FINAL_SCRIPTSIG)throw new Error("Decode Error: could not decode finalScriptSig with key 0x"+e.key.toString("hex"));return e.value},t.encode=function(e){return{key:n.from([i.InputTypes.FINAL_SCRIPTSIG]),value:e}},t.expected="Buffer",t.check=function(e){return n.isBuffer(e)},t.canAdd=function(e,t){return!!e&&!!t&&void 0===e.finalScriptSig}},4042:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0});const i=r(9889);t.decode=function(e){if(e.key[0]!==i.InputTypes.FINAL_SCRIPTWITNESS)throw new Error("Decode Error: could not decode finalScriptWitness with key 0x"+e.key.toString("hex"));return e.value},t.encode=function(e){return{key:n.from([i.InputTypes.FINAL_SCRIPTWITNESS]),value:e}},t.expected="Buffer",t.check=function(e){return n.isBuffer(e)},t.canAdd=function(e,t){return!!e&&!!t&&void 0===e.finalScriptWitness}},8730:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0});const i=r(9889);t.decode=function(e){if(e.key[0]!==i.InputTypes.NON_WITNESS_UTXO)throw new Error("Decode Error: could not decode nonWitnessUtxo with key 0x"+e.key.toString("hex"));return e.value},t.encode=function(e){return{key:n.from([i.InputTypes.NON_WITNESS_UTXO]),value:e}},t.expected="Buffer",t.check=function(e){return n.isBuffer(e)},t.canAdd=function(e,t){return!!e&&!!t&&void 0===e.nonWitnessUtxo}},5098:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0});const i=r(9889);t.decode=function(e){if(e.key[0]!==i.InputTypes.PARTIAL_SIG)throw new Error("Decode Error: could not decode partialSig with key 0x"+e.key.toString("hex"));if(34!==e.key.length&&66!==e.key.length||![2,3,4].includes(e.key[1]))throw new Error("Decode Error: partialSig has invalid pubkey in key 0x"+e.key.toString("hex"));return{pubkey:e.key.slice(1),signature:e.value}},t.encode=function(e){const t=n.from([i.InputTypes.PARTIAL_SIG]);return{key:n.concat([t,e.pubkey]),value:e.signature}},t.expected="{ pubkey: Buffer; signature: Buffer; }",t.check=function(e){return n.isBuffer(e.pubkey)&&n.isBuffer(e.signature)&&[33,65].includes(e.pubkey.length)&&[2,3,4].includes(e.pubkey[0])&&function(e){if(!n.isBuffer(e)||e.length<9)return!1;if(48!==e[0])return!1;if(e.length!==e[1]+3)return!1;if(2!==e[2])return!1;const t=e[3];if(t>33||t<1)return!1;if(2!==e[3+t+1])return!1;const r=e[3+t+2];return!(r>33||r<1)&&e.length===3+t+2+r+2}(e.signature)},t.canAddToArray=function(e,t,r){const n=t.pubkey.toString("hex");return!r.has(n)&&(r.add(n),0===e.filter((e=>e.pubkey.equals(t.pubkey))).length)}},4474:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0});const i=r(9889);t.decode=function(e){if(e.key[0]!==i.InputTypes.POR_COMMITMENT)throw new Error("Decode Error: could not decode porCommitment with key 0x"+e.key.toString("hex"));return e.value.toString("utf8")},t.encode=function(e){return{key:n.from([i.InputTypes.POR_COMMITMENT]),value:n.from(e,"utf8")}},t.expected="string",t.check=function(e){return"string"==typeof e},t.canAdd=function(e,t){return!!e&&!!t&&void 0===e.porCommitment}},9175:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0});const i=r(9889);t.decode=function(e){if(e.key[0]!==i.InputTypes.SIGHASH_TYPE)throw new Error("Decode Error: could not decode sighashType with key 0x"+e.key.toString("hex"));return e.value.readUInt32LE(0)},t.encode=function(e){const t=n.from([i.InputTypes.SIGHASH_TYPE]),r=n.allocUnsafe(4);return r.writeUInt32LE(e,0),{key:t,value:r}},t.expected="number",t.check=function(e){return"number"==typeof e},t.canAdd=function(e,t){return!!e&&!!t&&void 0===e.sighashType}},7279:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0});const i=r(9889);function o(e){return n.isBuffer(e)&&(64===e.length||65===e.length)}t.decode=function(e){if(e.key[0]!==i.InputTypes.TAP_KEY_SIG||1!==e.key.length)throw new Error("Decode Error: could not decode tapKeySig with key 0x"+e.key.toString("hex"));if(!o(e.value))throw new Error("Decode Error: tapKeySig not a valid 64-65-byte BIP340 signature");return e.value},t.encode=function(e){return{key:n.from([i.InputTypes.TAP_KEY_SIG]),value:e}},t.expected="Buffer",t.check=o,t.canAdd=function(e,t){return!!e&&!!t&&void 0===e.tapKeySig}},7544:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0});const i=r(9889);t.decode=function(e){if(e.key[0]!==i.InputTypes.TAP_LEAF_SCRIPT)throw new Error("Decode Error: could not decode tapLeafScript with key 0x"+e.key.toString("hex"));if((e.key.length-2)%32!=0)throw new Error("Decode Error: tapLeafScript has invalid control block in key 0x"+e.key.toString("hex"));const t=e.value[e.value.length-1];if((254&e.key[1])!==t)throw new Error("Decode Error: tapLeafScript bad leaf version in key 0x"+e.key.toString("hex"));const r=e.value.slice(0,-1);return{controlBlock:e.key.slice(1),script:r,leafVersion:t}},t.encode=function(e){const t=n.from([i.InputTypes.TAP_LEAF_SCRIPT]),r=n.from([e.leafVersion]);return{key:n.concat([t,e.controlBlock]),value:n.concat([e.script,r])}},t.expected="{ controlBlock: Buffer; leafVersion: number, script: Buffer; }",t.check=function(e){return n.isBuffer(e.controlBlock)&&(e.controlBlock.length-1)%32==0&&(254&e.controlBlock[0])===e.leafVersion&&n.isBuffer(e.script)},t.canAddToArray=function(e,t,r){const n=t.controlBlock.toString("hex");return!r.has(n)&&(r.add(n),0===e.filter((e=>e.controlBlock.equals(t.controlBlock))).length)}},241:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0});const i=r(9889);function o(e){return n.isBuffer(e)&&32===e.length}t.decode=function(e){if(e.key[0]!==i.InputTypes.TAP_MERKLE_ROOT||1!==e.key.length)throw new Error("Decode Error: could not decode tapMerkleRoot with key 0x"+e.key.toString("hex"));if(!o(e.value))throw new Error("Decode Error: tapMerkleRoot not a 32-byte hash");return e.value},t.encode=function(e){return{key:n.from([i.InputTypes.TAP_MERKLE_ROOT]),value:e}},t.expected="Buffer",t.check=o,t.canAdd=function(e,t){return!!e&&!!t&&void 0===e.tapMerkleRoot}},3155:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0});const i=r(9889);t.decode=function(e){if(e.key[0]!==i.InputTypes.TAP_SCRIPT_SIG)throw new Error("Decode Error: could not decode tapScriptSig with key 0x"+e.key.toString("hex"));if(65!==e.key.length)throw new Error("Decode Error: tapScriptSig has invalid key 0x"+e.key.toString("hex"));if(64!==e.value.length&&65!==e.value.length)throw new Error("Decode Error: tapScriptSig has invalid signature in key 0x"+e.key.toString("hex"));return{pubkey:e.key.slice(1,33),leafHash:e.key.slice(33),signature:e.value}},t.encode=function(e){const t=n.from([i.InputTypes.TAP_SCRIPT_SIG]);return{key:n.concat([t,e.pubkey,e.leafHash]),value:e.signature}},t.expected="{ pubkey: Buffer; leafHash: Buffer; signature: Buffer; }",t.check=function(e){return n.isBuffer(e.pubkey)&&n.isBuffer(e.leafHash)&&n.isBuffer(e.signature)&&32===e.pubkey.length&&32===e.leafHash.length&&(64===e.signature.length||65===e.signature.length)},t.canAddToArray=function(e,t,r){const n=t.pubkey.toString("hex")+t.leafHash.toString("hex");return!r.has(n)&&(r.add(n),0===e.filter((e=>e.pubkey.equals(t.pubkey)&&e.leafHash.equals(t.leafHash))).length)}},4709:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0});const i=r(9889),o=r(5962),s=r(2715);t.decode=function(e){if(e.key[0]!==i.InputTypes.WITNESS_UTXO)throw new Error("Decode Error: could not decode witnessUtxo with key 0x"+e.key.toString("hex"));const t=o.readUInt64LE(e.value,0);let r=8;const n=s.decode(e.value,r);r+=s.encodingLength(n);const a=e.value.slice(r);if(a.length!==n)throw new Error("Decode Error: WITNESS_UTXO script is not proper length");return{script:a,value:t}},t.encode=function(e){const{script:t,value:r}=e,a=s.encodingLength(t.length),f=n.allocUnsafe(8+a+t.length);return o.writeUInt64LE(f,r,0),s.encode(t.length,f,8),t.copy(f,8+a),{key:n.from([i.InputTypes.WITNESS_UTXO]),value:f}},t.expected="{ script: Buffer; value: number; }",t.check=function(e){return n.isBuffer(e.script)&&"number"==typeof e.value},t.canAdd=function(e,t){return!!e&&!!t&&void 0===e.witnessUtxo}},9574:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0});const i=r(9889),o=r(2715);t.decode=function(e){if(e.key[0]!==i.OutputTypes.TAP_TREE||1!==e.key.length)throw new Error("Decode Error: could not decode tapTree with key 0x"+e.key.toString("hex"));let t=0;const r=[];for(;t[n.of(e.depth,e.leafVersion),o.encode(e.script.length),e.script])));return{key:t,value:n.concat(r)}},t.expected="{ leaves: [{ depth: number; leafVersion: number, script: Buffer; }] }",t.check=function(e){return Array.isArray(e.leaves)&&e.leaves.every((e=>e.depth>=0&&e.depth<=128&&(254&e.leafVersion)===e.leafVersion&&n.isBuffer(e.script)))},t.canAdd=function(e,t){return!!e&&!!t&&void 0===e.tapTree}},6896:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0});const i=e=>33===e.length&&[2,3].includes(e[0])||65===e.length&&4===e[0];t.makeConverter=function(e,t=i){return{decode:function(r){if(r.key[0]!==e)throw new Error("Decode Error: could not decode bip32Derivation with key 0x"+r.key.toString("hex"));const n=r.key.slice(1);if(!t(n))throw new Error("Decode Error: bip32Derivation has invalid pubkey in key 0x"+r.key.toString("hex"));if(r.value.length/4%1!=0)throw new Error("Decode Error: Input BIP32_DERIVATION value length should be multiple of 4");const i={masterFingerprint:r.value.slice(0,4),pubkey:n,path:"m"};for(const e of(o=r.value.length/4-1,[...Array(o).keys()])){const t=r.value.readUInt32LE(4*e+4),n=!!(2147483648&t),o=2147483647&t;i.path+="/"+o.toString(10)+(n?"'":"")}var o;return i},encode:function(t){const r=n.from([e]),i=n.concat([r,t.pubkey]),o=t.path.split("/"),s=n.allocUnsafe(4*o.length);t.masterFingerprint.copy(s,0);let a=4;return o.slice(1).forEach((e=>{const t="'"===e.slice(-1);let r=2147483647&parseInt(t?e.slice(0,-1):e,10);t&&(r+=2147483648),s.writeUInt32LE(r,a),a+=4})),{key:i,value:s}},check:function(e){return n.isBuffer(e.pubkey)&&n.isBuffer(e.masterFingerprint)&&"string"==typeof e.path&&t(e.pubkey)&&4===e.masterFingerprint.length},expected:"{ masterFingerprint: Buffer; pubkey: Buffer; path: string; }",canAddToArray:function(e,t,r){const n=t.pubkey.toString("hex");return!r.has(n)&&(r.add(n),0===e.filter((e=>e.pubkey.equals(t.pubkey))).length)}}}},437:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.makeChecker=function(e){return function(t){let r;if(e.includes(t.key[0])&&(r=t.key.slice(1),33!==r.length&&65!==r.length||![2,3,4].includes(r[0])))throw new Error("Format Error: invalid pubkey in key 0x"+t.key.toString("hex"));return r}}},5400:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.makeConverter=function(e){return{decode:function(t){if(t.key[0]!==e)throw new Error("Decode Error: could not decode redeemScript with key 0x"+t.key.toString("hex"));return t.value},encode:function(t){return{key:n.from([e]),value:t}},check:function(e){return n.isBuffer(e)},expected:"Buffer",canAdd:function(e,t){return!!e&&!!t&&void 0===e.redeemScript}}}},2751:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0});const i=r(2715),o=r(6896),s=e=>32===e.length;t.makeConverter=function(e){const t=o.makeConverter(e,s);return{decode:function(e){const r=i.decode(e.value),n=i.encodingLength(r),o=t.decode({key:e.key,value:e.value.slice(n+32*r)}),s=new Array(r);for(let t=0,i=n;tn.isBuffer(e)&&32===e.length))&&t.check(e)},expected:"{ masterFingerprint: Buffer; pubkey: Buffer; path: string; leafHashes: Buffer[]; }",canAddToArray:t.canAddToArray}}},9632:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.makeConverter=function(e){return{decode:function(t){if(t.key[0]!==e||1!==t.key.length)throw new Error("Decode Error: could not decode tapInternalKey with key 0x"+t.key.toString("hex"));if(32!==t.value.length)throw new Error("Decode Error: tapInternalKey not a 32-byte x-only pubkey");return t.value},encode:function(t){return{key:n.from([e]),value:t}},check:function(e){return n.isBuffer(e)&&32===e.length},expected:"Buffer",canAdd:function(e,t){return!!e&&!!t&&void 0===e.tapInternalKey}}}},9079:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.makeConverter=function(e){return{decode:function(t){if(t.key[0]!==e)throw new Error("Decode Error: could not decode witnessScript with key 0x"+t.key.toString("hex"));return t.value},encode:function(t){return{key:n.from([e]),value:t}},check:function(e){return n.isBuffer(e)},expected:"Buffer",canAdd:function(e,t){return!!e&&!!t&&void 0===e.witnessScript}}}},5962:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0});const i=r(2715);function o(e){const t=e.key.length,r=e.value.length,o=i.encodingLength(t),s=i.encodingLength(r),a=n.allocUnsafe(o+t+s+r);return i.encode(t,a,0),e.key.copy(a,o),i.encode(r,a,o+t),e.value.copy(a,o+t+s),a}function s(e,t){if("number"!=typeof e)throw new Error("cannot write a non-number as a number");if(e<0)throw new Error("specified a negative value for writing an unsigned value");if(e>t)throw new Error("RangeError: value out of range");if(Math.floor(e)!==e)throw new Error("value has a fractional component")}t.range=e=>[...Array(e).keys()],t.reverseBuffer=function(e){if(e.length<1)return e;let t=e.length-1,r=0;for(let n=0;n{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0});const i=9007199254740991;function o(e){if(e<0||e>i||e%1!=0)throw new RangeError("value out of range")}function s(e){return o(e),e<253?1:e<=65535?3:e<=4294967295?5:9}t.encode=function e(t,r,i){if(o(t),r||(r=n.allocUnsafe(s(t))),!n.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return i||(i=0),t<253?(r.writeUInt8(t,i),Object.assign(e,{bytes:1})):t<=65535?(r.writeUInt8(253,i),r.writeUInt16LE(t,i+1),Object.assign(e,{bytes:3})):t<=4294967295?(r.writeUInt8(254,i),r.writeUInt32LE(t,i+1),Object.assign(e,{bytes:5})):(r.writeUInt8(255,i),r.writeUInt32LE(t>>>0,i+1),r.writeUInt32LE(t/4294967296|0,i+5),Object.assign(e,{bytes:9})),r},t.decode=function e(t,r){if(!n.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");r||(r=0);const i=t.readUInt8(r);if(i<253)return Object.assign(e,{bytes:1}),i;if(253===i)return Object.assign(e,{bytes:3}),t.readUInt16LE(r+1);if(254===i)return Object.assign(e,{bytes:5}),t.readUInt32LE(r+1);{Object.assign(e,{bytes:9});const n=t.readUInt32LE(r+1),i=4294967296*t.readUInt32LE(r+5)+n;return o(i),i}},t.encodingLength=s},4112:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0});const i=r(6317),o=r(5962),s=r(2715),a=r(9889);function f(e,t,r){if(!t.equals(n.from([r])))throw new Error(`Format Error: Invalid ${e} key: ${t.toString("hex")}`)}function u(e,{globalMapKeyVals:t,inputKeyVals:r,outputKeyVals:n}){const s={unsignedTx:e};let u=0;for(const e of t)switch(e.key[0]){case a.GlobalTypes.UNSIGNED_TX:if(f("global",e.key,a.GlobalTypes.UNSIGNED_TX),u>0)throw new Error("Format Error: GlobalMap has multiple UNSIGNED_TX");u++;break;case a.GlobalTypes.GLOBAL_XPUB:void 0===s.globalXpub&&(s.globalXpub=[]),s.globalXpub.push(i.globals.globalXpub.decode(e));break;default:s.unknownKeyVals||(s.unknownKeyVals=[]),s.unknownKeyVals.push(e)}const c=r.length,h=n.length,d=[],l=[];for(const e of o.range(c)){const t={};for(const n of r[e])switch(i.inputs.checkPubkey(n),n.key[0]){case a.InputTypes.NON_WITNESS_UTXO:if(f("input",n.key,a.InputTypes.NON_WITNESS_UTXO),void 0!==t.nonWitnessUtxo)throw new Error("Format Error: Input has multiple NON_WITNESS_UTXO");t.nonWitnessUtxo=i.inputs.nonWitnessUtxo.decode(n);break;case a.InputTypes.WITNESS_UTXO:if(f("input",n.key,a.InputTypes.WITNESS_UTXO),void 0!==t.witnessUtxo)throw new Error("Format Error: Input has multiple WITNESS_UTXO");t.witnessUtxo=i.inputs.witnessUtxo.decode(n);break;case a.InputTypes.PARTIAL_SIG:void 0===t.partialSig&&(t.partialSig=[]),t.partialSig.push(i.inputs.partialSig.decode(n));break;case a.InputTypes.SIGHASH_TYPE:if(f("input",n.key,a.InputTypes.SIGHASH_TYPE),void 0!==t.sighashType)throw new Error("Format Error: Input has multiple SIGHASH_TYPE");t.sighashType=i.inputs.sighashType.decode(n);break;case a.InputTypes.REDEEM_SCRIPT:if(f("input",n.key,a.InputTypes.REDEEM_SCRIPT),void 0!==t.redeemScript)throw new Error("Format Error: Input has multiple REDEEM_SCRIPT");t.redeemScript=i.inputs.redeemScript.decode(n);break;case a.InputTypes.WITNESS_SCRIPT:if(f("input",n.key,a.InputTypes.WITNESS_SCRIPT),void 0!==t.witnessScript)throw new Error("Format Error: Input has multiple WITNESS_SCRIPT");t.witnessScript=i.inputs.witnessScript.decode(n);break;case a.InputTypes.BIP32_DERIVATION:void 0===t.bip32Derivation&&(t.bip32Derivation=[]),t.bip32Derivation.push(i.inputs.bip32Derivation.decode(n));break;case a.InputTypes.FINAL_SCRIPTSIG:f("input",n.key,a.InputTypes.FINAL_SCRIPTSIG),t.finalScriptSig=i.inputs.finalScriptSig.decode(n);break;case a.InputTypes.FINAL_SCRIPTWITNESS:f("input",n.key,a.InputTypes.FINAL_SCRIPTWITNESS),t.finalScriptWitness=i.inputs.finalScriptWitness.decode(n);break;case a.InputTypes.POR_COMMITMENT:f("input",n.key,a.InputTypes.POR_COMMITMENT),t.porCommitment=i.inputs.porCommitment.decode(n);break;case a.InputTypes.TAP_KEY_SIG:f("input",n.key,a.InputTypes.TAP_KEY_SIG),t.tapKeySig=i.inputs.tapKeySig.decode(n);break;case a.InputTypes.TAP_SCRIPT_SIG:void 0===t.tapScriptSig&&(t.tapScriptSig=[]),t.tapScriptSig.push(i.inputs.tapScriptSig.decode(n));break;case a.InputTypes.TAP_LEAF_SCRIPT:void 0===t.tapLeafScript&&(t.tapLeafScript=[]),t.tapLeafScript.push(i.inputs.tapLeafScript.decode(n));break;case a.InputTypes.TAP_BIP32_DERIVATION:void 0===t.tapBip32Derivation&&(t.tapBip32Derivation=[]),t.tapBip32Derivation.push(i.inputs.tapBip32Derivation.decode(n));break;case a.InputTypes.TAP_INTERNAL_KEY:f("input",n.key,a.InputTypes.TAP_INTERNAL_KEY),t.tapInternalKey=i.inputs.tapInternalKey.decode(n);break;case a.InputTypes.TAP_MERKLE_ROOT:f("input",n.key,a.InputTypes.TAP_MERKLE_ROOT),t.tapMerkleRoot=i.inputs.tapMerkleRoot.decode(n);break;default:t.unknownKeyVals||(t.unknownKeyVals=[]),t.unknownKeyVals.push(n)}d.push(t)}for(const e of o.range(h)){const t={};for(const r of n[e])switch(i.outputs.checkPubkey(r),r.key[0]){case a.OutputTypes.REDEEM_SCRIPT:if(f("output",r.key,a.OutputTypes.REDEEM_SCRIPT),void 0!==t.redeemScript)throw new Error("Format Error: Output has multiple REDEEM_SCRIPT");t.redeemScript=i.outputs.redeemScript.decode(r);break;case a.OutputTypes.WITNESS_SCRIPT:if(f("output",r.key,a.OutputTypes.WITNESS_SCRIPT),void 0!==t.witnessScript)throw new Error("Format Error: Output has multiple WITNESS_SCRIPT");t.witnessScript=i.outputs.witnessScript.decode(r);break;case a.OutputTypes.BIP32_DERIVATION:void 0===t.bip32Derivation&&(t.bip32Derivation=[]),t.bip32Derivation.push(i.outputs.bip32Derivation.decode(r));break;case a.OutputTypes.TAP_INTERNAL_KEY:f("output",r.key,a.OutputTypes.TAP_INTERNAL_KEY),t.tapInternalKey=i.outputs.tapInternalKey.decode(r);break;case a.OutputTypes.TAP_TREE:f("output",r.key,a.OutputTypes.TAP_TREE),t.tapTree=i.outputs.tapTree.decode(r);break;case a.OutputTypes.TAP_BIP32_DERIVATION:void 0===t.tapBip32Derivation&&(t.tapBip32Derivation=[]),t.tapBip32Derivation.push(i.outputs.tapBip32Derivation.decode(r));break;default:t.unknownKeyVals||(t.unknownKeyVals=[]),t.unknownKeyVals.push(r)}l.push(t)}return{globalMap:s,inputs:d,outputs:l}}t.psbtFromBuffer=function(e,t){let r=0;function n(){const t=s.decode(e,r);r+=s.encodingLength(t);const n=e.slice(r,r+t);return r+=t,n}function i(){return{key:n(),value:n()}}function f(){if(r>=e.length)throw new Error("Format Error: Unexpected End of PSBT");const t=0===e.readUInt8(r);return t&&r++,t}if(1886610036!==function(){const t=e.readUInt32BE(r);return r+=4,t}())throw new Error("Format Error: Invalid Magic Number");if(255!==function(){const t=e.readUInt8(r);return r+=1,t}())throw new Error("Format Error: Magic Number must be followed by 0xff separator");const c=[],h={};for(;!f();){const e=i(),t=e.key.toString("hex");if(h[t])throw new Error("Format Error: Keys must be unique for global keymap: key "+t);h[t]=1,c.push(e)}const d=c.filter((e=>e.key[0]===a.GlobalTypes.UNSIGNED_TX));if(1!==d.length)throw new Error("Format Error: Only one UNSIGNED_TX allowed");const l=t(d[0].value),{inputCount:p,outputCount:b}=l.getInputOutputCounts(),y=[],g=[];for(const e of o.range(p)){const t={},r=[];for(;!f();){const n=i(),o=n.key.toString("hex");if(t[o])throw new Error("Format Error: Keys must be unique for each input: input index "+e+" key "+o);t[o]=1,r.push(n)}y.push(r)}for(const e of o.range(b)){const t={},r=[];for(;!f();){const n=i(),o=n.key.toString("hex");if(t[o])throw new Error("Format Error: Keys must be unique for each output: output index "+e+" key "+o);t[o]=1,r.push(n)}g.push(r)}return u(l,{globalMapKeyVals:c,inputKeyVals:y,outputKeyVals:g})},t.checkKeyBuffer=f,t.psbtFromKeyVals=u},6808:(e,t,r)=>{"use strict";function n(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}Object.defineProperty(t,"__esModule",{value:!0}),n(r(4112)),n(r(2673))},2673:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0});const i=r(6317),o=r(5962);t.psbtToBuffer=function({globalMap:e,inputs:t,outputs:r}){const{globalKeyVals:i,inputKeyVals:s,outputKeyVals:a}=f({globalMap:e,inputs:t,outputs:r}),u=o.keyValsToBuffer(i),c=e=>0===e.length?[n.from([0])]:e.map(o.keyValsToBuffer),h=c(s),d=c(a),l=n.allocUnsafe(5);return l.writeUIntBE(482972169471,0,5),n.concat([l,u].concat(h,d))};const s=(e,t)=>e.key.compare(t.key);function a(e,t){const r=new Set,n=Object.entries(e).reduce(((e,[n,i])=>{if("unknownKeyVals"===n)return e;const o=t[n];if(void 0===o)return e;const s=(Array.isArray(i)?i:[i]).map(o.encode);return s.map((e=>e.key.toString("hex"))).forEach((e=>{if(r.has(e))throw new Error("Serialize Error: Duplicate key: "+e);r.add(e)})),e.concat(s)}),[]),i=e.unknownKeyVals?e.unknownKeyVals.filter((e=>!r.has(e.key.toString("hex")))):[];return n.concat(i).sort(s)}function f({globalMap:e,inputs:t,outputs:r}){return{globalKeyVals:a(e,i.globals),inputKeyVals:t.map((e=>a(e,i.inputs))),outputKeyVals:r.map((e=>a(e,i.outputs)))}}t.psbtToKeyVals=f},7003:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0});const i=r(3162),o=r(6808),s=r(9889),a=r(2431);t.Psbt=class{constructor(e){this.inputs=[],this.outputs=[],this.globalMap={unsignedTx:e}}static fromBase64(e,t){const r=n.from(e,"base64");return this.fromBuffer(r,t)}static fromHex(e,t){const r=n.from(e,"hex");return this.fromBuffer(r,t)}static fromBuffer(e,t){const r=o.psbtFromBuffer(e,t),n=new this(r.globalMap.unsignedTx);return Object.assign(n,r),n}toBase64(){return this.toBuffer().toString("base64")}toHex(){return this.toBuffer().toString("hex")}toBuffer(){return o.psbtToBuffer(this)}updateGlobal(e){return a.updateGlobal(e,this.globalMap),this}updateInput(e,t){const r=a.checkForInput(this.inputs,e);return a.updateInput(t,r),this}updateOutput(e,t){const r=a.checkForOutput(this.outputs,e);return a.updateOutput(t,r),this}addUnknownKeyValToGlobal(e){return a.checkHasKey(e,this.globalMap.unknownKeyVals,a.getEnumLength(s.GlobalTypes)),this.globalMap.unknownKeyVals||(this.globalMap.unknownKeyVals=[]),this.globalMap.unknownKeyVals.push(e),this}addUnknownKeyValToInput(e,t){const r=a.checkForInput(this.inputs,e);return a.checkHasKey(t,r.unknownKeyVals,a.getEnumLength(s.InputTypes)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(t),this}addUnknownKeyValToOutput(e,t){const r=a.checkForOutput(this.outputs,e);return a.checkHasKey(t,r.unknownKeyVals,a.getEnumLength(s.OutputTypes)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(t),this}addInput(e){this.globalMap.unsignedTx.addInput(e),this.inputs.push({unknownKeyVals:[]});const t=e.unknownKeyVals||[],r=this.inputs.length-1;if(!Array.isArray(t))throw new Error("unknownKeyVals must be an Array");return t.forEach((e=>this.addUnknownKeyValToInput(r,e))),a.addInputAttributes(this.inputs,e),this}addOutput(e){this.globalMap.unsignedTx.addOutput(e),this.outputs.push({unknownKeyVals:[]});const t=e.unknownKeyVals||[],r=this.outputs.length-1;if(!Array.isArray(t))throw new Error("unknownKeyVals must be an Array");return t.forEach((e=>this.addUnknownKeyValToOutput(r,e))),a.addOutputAttributes(this.outputs,e),this}clearFinalizedInput(e){const t=a.checkForInput(this.inputs,e);a.inputCheckUncleanFinalized(e,t);for(const e of Object.keys(t))["witnessUtxo","nonWitnessUtxo","finalScriptSig","finalScriptWitness","unknownKeyVals"].includes(e)||delete t[e];return this}combine(...e){const t=i.combine([this].concat(e));return Object.assign(this,t),this}getTransaction(){return this.globalMap.unsignedTx.toBuffer()}}},9889:(e,t)=>{"use strict";var r,n,i;Object.defineProperty(t,"__esModule",{value:!0}),(i=t.GlobalTypes||(t.GlobalTypes={}))[i.UNSIGNED_TX=0]="UNSIGNED_TX",i[i.GLOBAL_XPUB=1]="GLOBAL_XPUB",t.GLOBAL_TYPE_NAMES=["unsignedTx","globalXpub"],(n=t.InputTypes||(t.InputTypes={}))[n.NON_WITNESS_UTXO=0]="NON_WITNESS_UTXO",n[n.WITNESS_UTXO=1]="WITNESS_UTXO",n[n.PARTIAL_SIG=2]="PARTIAL_SIG",n[n.SIGHASH_TYPE=3]="SIGHASH_TYPE",n[n.REDEEM_SCRIPT=4]="REDEEM_SCRIPT",n[n.WITNESS_SCRIPT=5]="WITNESS_SCRIPT",n[n.BIP32_DERIVATION=6]="BIP32_DERIVATION",n[n.FINAL_SCRIPTSIG=7]="FINAL_SCRIPTSIG",n[n.FINAL_SCRIPTWITNESS=8]="FINAL_SCRIPTWITNESS",n[n.POR_COMMITMENT=9]="POR_COMMITMENT",n[n.TAP_KEY_SIG=19]="TAP_KEY_SIG",n[n.TAP_SCRIPT_SIG=20]="TAP_SCRIPT_SIG",n[n.TAP_LEAF_SCRIPT=21]="TAP_LEAF_SCRIPT",n[n.TAP_BIP32_DERIVATION=22]="TAP_BIP32_DERIVATION",n[n.TAP_INTERNAL_KEY=23]="TAP_INTERNAL_KEY",n[n.TAP_MERKLE_ROOT=24]="TAP_MERKLE_ROOT",t.INPUT_TYPE_NAMES=["nonWitnessUtxo","witnessUtxo","partialSig","sighashType","redeemScript","witnessScript","bip32Derivation","finalScriptSig","finalScriptWitness","porCommitment","tapKeySig","tapScriptSig","tapLeafScript","tapBip32Derivation","tapInternalKey","tapMerkleRoot"],(r=t.OutputTypes||(t.OutputTypes={}))[r.REDEEM_SCRIPT=0]="REDEEM_SCRIPT",r[r.WITNESS_SCRIPT=1]="WITNESS_SCRIPT",r[r.BIP32_DERIVATION=2]="BIP32_DERIVATION",r[r.TAP_INTERNAL_KEY=5]="TAP_INTERNAL_KEY",r[r.TAP_TREE=6]="TAP_TREE",r[r.TAP_BIP32_DERIVATION=7]="TAP_BIP32_DERIVATION",t.OUTPUT_TYPE_NAMES=["redeemScript","witnessScript","bip32Derivation","tapInternalKey","tapTree","tapBip32Derivation"]},2431:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0});const i=r(6317);function o(e,t){const r=e[t];if(void 0===r)throw new Error(`No input #${t}`);return r}function s(e,t){const r=e[t];if(void 0===r)throw new Error(`No output #${t}`);return r}function a(e,t,r,n){throw new Error(`Data for ${e} key ${t} is incorrect: Expected ${r} and got ${JSON.stringify(n)}`)}function f(e){return(t,r)=>{for(const n of Object.keys(t)){const o=t[n],{canAdd:s,canAddToArray:f,check:u,expected:c}=i[e+"s"][n]||{};if(u)if(f){if(!Array.isArray(o)||r[n]&&!Array.isArray(r[n]))throw new Error(`Key type ${n} must be an array`);o.every(u)||a(e,n,c,o);const t=r[n]||[],i=new Set;if(!o.every((e=>f(t,e,i))))throw new Error("Can not add duplicate data to array");r[n]=t.concat(o)}else{if(u(o)||a(e,n,c,o),!s(r,o))throw new Error(`Can not add duplicate data to ${e}`);r[n]=o}}}}t.checkForInput=o,t.checkForOutput=s,t.checkHasKey=function(e,t,r){if(e.key[0]t.key.equals(e.key))).length)throw new Error(`Duplicate Key: ${e.key.toString("hex")}`)},t.getEnumLength=function(e){let t=0;return Object.keys(e).forEach((e=>{Number(isNaN(Number(e)))&&t++})),t},t.inputCheckUncleanFinalized=function(e,t){let r=!1;if(t.nonWitnessUtxo||t.witnessUtxo){const e=!!t.redeemScript,n=!!t.witnessScript,i=!e||!!t.finalScriptSig,o=!n||!!t.finalScriptWitness,s=!!t.finalScriptSig||!!t.finalScriptWitness;r=i&&o&&s}if(!1===r)throw new Error(`Input #${e} has too much or too little data to clean`)},t.updateGlobal=f("global"),t.updateInput=f("input"),t.updateOutput=f("output"),t.addInputAttributes=function(e,r){const n=o(e,e.length-1);t.updateInput(r,n)},t.addOutputAttributes=function(e,r){const n=s(e,e.length-1);t.updateOutput(r,n)},t.defaultVersionSetter=function(e,t){if(!n.isBuffer(t)||t.length<4)throw new Error("Set Version: Invalid Transaction");return t.writeUInt32LE(e,0),t},t.defaultLocktimeSetter=function(e,t){if(!n.isBuffer(t)||t.length<4)throw new Error("Set Locktime: Invalid Transaction");return t.writeUInt32LE(e,t.length-4),t}},2115:function(e,t,r){"use strict";var n=r(1048).Buffer,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return o(t,e),t};Object.defineProperty(t,"__esModule",{value:!0});const a=r(2337),f=s(r(7612));class u{static hashMessage(e){const t=new a.Hash;t.update(this.TAG);const r=t.digest(),i=new a.Hash;return i.update(r),i.update(r),i.update(n.from(e)),i.digest()}static buildToSpendTx(e,t){const r=new f.Psbt;r.setVersion(0),r.setLocktime(0);const i=this.hashMessage(e),o=new Uint8Array([0,32]),s=new Uint8Array(o.length+i.length);return s.set(o),s.set(i,o.length),r.addInput({hash:"0".repeat(64),index:4294967295,sequence:0,finalScriptSig:n.from(s),witnessScript:n.from([])}),r.addOutput({value:0,script:t}),r.extractTransaction()}static buildToSignTx(e,t,r=!1,i=void 0){const o=new f.Psbt;return o.setVersion(0),o.setLocktime(0),o.addInput({hash:e,index:0,sequence:0,witnessUtxo:{script:t,value:0}}),r&&o.updateInput(0,{redeemScript:t}),i&&o.updateInput(0,{tapInternalKey:i}),o.addOutput({value:0,script:n.from([106])}),o}static encodeWitness(e){const t=e.data.inputs[0].finalScriptWitness;if(t)return t.toString("base64");throw new Error("Cannot encode empty witness stack.")}}u.TAG=n.from("BIP0322-signed-message"),t.default=u},1881:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=s(r(2115)),f=s(r(1075)),u=r(7373),c=o(r(7612)),h=s(r(242)),d=o(r(6989));t.default=class{static sign(e,t,r){let n=(0,f.default)(h.default).fromWIF(e,[c.networks.bitcoin,c.networks.testnet,c.networks.regtest]);if(!this.checkPubKeyCorrespondToAddress(n.publicKey,t))throw new Error(`Invalid private key provided for signing message for ${t}.`);if(u.Address.isP2PKH(t))return d.sign(r,n.privateKey,n.compressed);const i=u.Address.convertAdressToScriptPubkey(t),o=a.default.buildToSpendTx(r,i);let s;if(u.Address.isP2SH(t)){const e=c.payments.p2wpkh({hash:c.crypto.hash160(n.publicKey),network:u.Address.getNetworkFromAddess(t)}).output;s=a.default.buildToSignTx(o.getId(),e,!0)}else if(u.Address.isP2WPKH(t))s=a.default.buildToSignTx(o.getId(),i);else{const e=u.Key.toXOnly(n.publicKey);n=n.tweak(c.crypto.taggedHash("TapTweak",e)),s=a.default.buildToSignTx(o.getId(),i,!1,e),s.updateInput(0,{sighashType:c.Transaction.SIGHASH_ALL})}const l=s.signAllInputs(n,[c.Transaction.SIGHASH_ALL]).finalizeAllInputs();return a.default.encodeWitness(l)}static checkPubKeyCorrespondToAddress(e,t){let r;if(u.Address.isP2PKH(t))r=u.Address.convertPubKeyIntoAddress(e,"p2pkh");else if(u.Address.isP2SH(t))r=u.Address.convertPubKeyIntoAddress(e,"p2sh-p2wpkh");else if(u.Address.isP2WPKH(t))r=u.Address.convertPubKeyIntoAddress(e,"p2wpkh");else{if(!u.Address.isP2TR(t))throw new Error("Unable to sign BIP-322 message for unsupported address type.");r=u.Address.convertPubKeyIntoAddress(e,"p2tr")}return r.mainnet===t||r.testnet===t||r.regtest===t}}},6293:function(e,t,r){"use strict";var n=r(1048).Buffer,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return o(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const f=a(r(2115)),u=s(r(7612)),c=a(r(242)),h=r(7373),d=s(r(6989)),l=r(9145);t.default=class{static verifySignature(e,t,r,i=!1){if(!h.Address.isValidBitcoinAddress(e))throw new Error("Invalid Bitcoin address is provided.");if(h.Address.isP2PKH(e)||h.BIP137.isBIP137Signature(r))return this.verifyBIP137Signature(e,t,r,i);const o=h.Address.convertAdressToScriptPubkey(e),s=f.default.buildToSpendTx(t,o),a=f.default.buildToSignTx(s.getId(),o);a.updateInput(0,{finalScriptWitness:n.from(r,"base64")});const d=a.extractTransaction().ins[0].witness,p=d[0];if(h.Address.isP2WPKHWitness(d)){const t=d[1],{signature:r}=(0,l.decodeScriptSignature)(p),i=u.crypto.hash160(t);let s;if(h.Address.isP2SH(e)){s=this.getHashForSigP2SHInP2WPKH(a,i);const e=n.concat([n.from([0,20]),i]),t=u.crypto.hash160(e),r=o.subarray(2,-1);if(0!==n.compare(t,r))return!1}else{s=this.getHashForSigP2WPKH(a);const e=o.subarray(2);if(0!==n.compare(i,e))return!1}return c.default.verify(s,t,r)}if(h.Address.isP2TR(e)){if(!h.Address.isSingleKeyP2TRWitness(d))throw new Error("BIP-322 verification from script-spend P2TR is unsupported.");const e=o.subarray(2);let t,r;if(64===p.byteLength)t=this.getHashForSigP2TR(a,0),r=p;else{if(65!==p.byteLength)throw new Error("Invalid Schnorr signature provided.");t=this.getHashForSigP2TR(a,p[64]),r=p.subarray(0,-1)}return c.default.verifySchnorr(t,e,r)}throw new Error("Only P2WPKH, P2SH-P2WPKH, and single-key-spend P2TR BIP-322 verification is supported. Unsupported address is provided.")}static verifyBIP137Signature(e,t,r,n){if(n)return this.bitcoinMessageVerifyWrap(t,e,r);const i=h.BIP137.derivePubKey(t,r);let o,s;65===i.byteLength?(o=i,s=h.Key.compressPublicKey(i)):(o=h.Key.uncompressPublicKey(i),s=i);const a=h.Address.convertPubKeyIntoAddress(o,"p2pkh").mainnet,f=h.Address.convertPubKeyIntoAddress(s,"p2pkh").mainnet,u=h.Address.convertPubKeyIntoAddress(s,"p2sh-p2wpkh").mainnet,c=h.Address.convertPubKeyIntoAddress(s,"p2wpkh").mainnet;if(h.Address.isP2PKH(e)){const t=h.Address.convertPubKeyIntoAddress(o,"p2pkh"),r=h.Address.convertPubKeyIntoAddress(s,"p2pkh");if(t.mainnet!==e&&t.testnet!==e&&t.regtest!==e&&r.mainnet!==e&&r.testnet!==e&&r.regtest!==e)return!1}else if(h.Address.isP2SH(e)){const t=h.Address.convertPubKeyIntoAddress(s,"p2sh-p2wpkh");if(t.mainnet!==e&&t.testnet!==e&&t.regtest!==e)return!1}else if(h.Address.isP2WPKH(e)){const t=h.Address.convertPubKeyIntoAddress(s,"p2wpkh");if(t.mainnet!==e&&t.testnet!==e&&t.regtest!==e)return!1}else{const t=h.Address.convertPubKeyIntoAddress(s,"p2tr");if(t.mainnet!==e&&t.testnet!==e&&t.regtest!==e)return!1}return this.bitcoinMessageVerifyWrap(t,a,r)||this.bitcoinMessageVerifyWrap(t,f,r)||this.bitcoinMessageVerifyWrap(t,u,r)||this.bitcoinMessageVerifyWrap(t,c,r)}static bitcoinMessageVerifyWrap(e,t,r){try{return d.verify(e,t,r)}catch(e){return!1}}static getHashForSigP2WPKH(e){const t=u.payments.p2pkh({hash:e.data.inputs[0].witnessUtxo.script.subarray(2)}).output;return e.extractTransaction().hashForWitnessV0(0,t,0,u.Transaction.SIGHASH_ALL)}static getHashForSigP2SHInP2WPKH(e,t){const r=u.payments.p2pkh({hash:t}).output;return e.extractTransaction().hashForWitnessV0(0,r,0,u.Transaction.SIGHASH_ALL)}static getHashForSigP2TR(e,t){if(t!==u.Transaction.SIGHASH_DEFAULT&&t!==u.Transaction.SIGHASH_ALL)throw new Error("Invalid SIGHASH used in signature. Must be either SIGHASH_ALL or SIGHASH_DEFAULT.");return e.extractTransaction().hashForWitnessV1(0,[e.data.inputs[0].witnessUtxo.script],[0],t)}}},7904:(e,t,r)=>{"use strict";var n=r(1048).Buffer;function i(e){0===e[0]&&(e=e.slice(1));const t=n.alloc(32,0),r=Math.max(0,32-e.length);return e.copy(t,r),t}Object.defineProperty(t,"__esModule",{value:!0}),t.decodeScriptSignature=void 0,t.decodeScriptSignature=function(e){const t=e.readUInt8(e.length-1),r=-129&t;if(r<=0||r>=4)throw new Error("Invalid hashType "+t);const o=function(e){if(e.length<8)throw new Error("DER sequence length is too short");if(e.length>72)throw new Error("DER sequence length is too long");if(48!==e[0])throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(2!==e[2])throw new Error("Expected DER integer");const t=e[3];if(0===t)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(2!==e[4+t])throw new Error("Expected DER integer (2)");const r=e[5+t];if(0===r)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(128&e[4])throw new Error("R value is negative");if(t>1&&0===e[4]&&!(128&e[5]))throw new Error("R value excessively padded");if(128&e[t+6])throw new Error("S value is negative");if(r>1&&0===e[t+6]&&!(128&e[t+7]))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}}(e.slice(0,-1)),s=i(o.r),a=i(o.s);return{signature:n.concat([s,a],64),hashType:t}}},9145:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decodeScriptSignature=void 0;const n=r(7904);Object.defineProperty(t,"decodeScriptSignature",{enumerable:!0,get:function(){return n.decodeScriptSignature}})},7401:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=s(r(9118)),f=o(r(7612));t.default=class{static isP2PKH(e){return"1"===e[0]||"m"===e[0]||"n"===e[0]}static isP2SH(e){return"3"===e[0]||"2"===e[0]}static isP2WPKH(e){return!!/^(bc1q|tb1q|bcrt1q)/.test(e)&&22===this.convertAdressToScriptPubkey(e).byteLength}static isP2TR(e){return!!/^(bc1p|tb1p|bcrt1p)/.test(e)}static isP2WPKHWitness(e){return 2===e.length&&33===e[1].byteLength&&(2===e[1][0]||3===e[1][0])}static isSingleKeyP2TRWitness(e){return 1===e.length}static getNetworkFromAddess(e){if(/^(bc1q|bc1p|1|3)/.test(e))return f.networks.bitcoin;if(/^(tb1q|tb1p|2|m|n)/.test(e))return f.networks.testnet;if(/^(bcrt1q|bcrt1p)/.test(e))return f.networks.regtest;throw new Error("Unknown address type")}static convertAdressToScriptPubkey(e){if("1"===e[0]||"m"===e[0]||"n"===e[0])return f.payments.p2pkh({address:e,network:this.getNetworkFromAddess(e)}).output;if("3"===e[0]||"2"===e[0])return f.payments.p2sh({address:e,network:this.getNetworkFromAddess(e)}).output;if(/^(bc1q|tb1q|bcrt1q)/.test(e)){if(42===e.length||e.includes("bcrt1q")&&44===e.length)return f.payments.p2wpkh({address:e,network:this.getNetworkFromAddess(e)}).output;if(62===e.length||e.includes("bcrt1q")&&64===e.length)return f.payments.p2wsh({address:e,network:this.getNetworkFromAddess(e)}).output}else if(/^(bc1p|tb1p|bcrt1p)/.test(e)&&(62===e.length||e.includes("bcrt1p")&&64===e.length))return f.payments.p2tr({address:e,network:this.getNetworkFromAddess(e)}).output;throw new Error("Unknown address type")}static convertPubKeyIntoAddress(e,t){switch(t){case"p2pkh":return{mainnet:f.payments.p2pkh({pubkey:e,network:f.networks.bitcoin}).address,testnet:f.payments.p2pkh({pubkey:e,network:f.networks.testnet}).address,regtest:f.payments.p2pkh({pubkey:e,network:f.networks.regtest}).address};case"p2sh-p2wpkh":return{mainnet:f.payments.p2sh({redeem:f.payments.p2wpkh({pubkey:e,network:f.networks.bitcoin}),network:f.networks.bitcoin}).address,testnet:f.payments.p2sh({redeem:f.payments.p2wpkh({pubkey:e,network:f.networks.testnet}),network:f.networks.testnet}).address,regtest:f.payments.p2sh({redeem:f.payments.p2wpkh({pubkey:e,network:f.networks.regtest}),network:f.networks.regtest}).address};case"p2wpkh":return{mainnet:f.payments.p2wpkh({pubkey:e,network:f.networks.bitcoin}).address,testnet:f.payments.p2wpkh({pubkey:e,network:f.networks.testnet}).address,regtest:f.payments.p2wpkh({pubkey:e,network:f.networks.regtest}).address};case"p2tr":const t=a.default.toXOnly(e);return{mainnet:f.payments.p2tr({internalPubkey:t,network:f.networks.bitcoin}).address,testnet:f.payments.p2tr({internalPubkey:t,network:f.networks.testnet}).address,regtest:f.payments.p2tr({internalPubkey:t,network:f.networks.regtest}).address};default:throw new Error("Cannot convert public key into unsupported address type.")}}static isValidBitcoinAddress(e){try{return f.address.toOutputScript(e,f.networks.bitcoin),!0}catch(e){}try{return f.address.toOutputScript(e,f.networks.testnet),!0}catch(e){}try{return f.address.toOutputScript(e,f.networks.regtest),!0}catch(e){}return!1}}},4697:function(e,t,r){"use strict";var n=r(1048).Buffer,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return o(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const f=a(r(766)),u=s(r(6989));t.default=class{static isBIP137Signature(e){return 65===n.from(e,"base64").byteLength}static derivePubKey(e,t){const r=u.magicHash(e),i=this.decodeSignature(n.from(t,"base64"));return n.from(f.default.ecdsaRecover(i.signature,i.recovery,r,i.compressed))}static decodeSignature(e){if(65!==e.length)throw new Error("Invalid signature length");const t=e.readUInt8(0)-27;if(t>19||t<0)throw new Error("Invalid signature parameter");return{compressed:!!(12&t),recovery:3&t,signature:e.subarray(1)}}}},9118:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0});const i=r(3360);t.default=class{static toXOnly(e){if(32!==e.length&&33!==e.length)throw new Error("Invalid public key length");return n.from(32===e.length?e:e.subarray(1,33))}static compressPublicKey(e){const t=new i.ec("secp256k1");try{const r=t.keyFromPublic(n.from(e));return n.from(r.getPublic(!0,"array"))}catch(e){throw new Error("Fails to compress the provided public key. Please check if the provided key is a valid uncompressed public key.")}}static uncompressPublicKey(e){const t=new i.ec("secp256k1");try{const r=t.keyFromPublic(n.from(e));return n.from(r.getPublic(!1,"array"))}catch(e){throw new Error("Fails to uncompress the provided public key. Please check if the provided key is a valid compressed public key.")}}}},7243:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.default=class{static encode(e){if(e<253){const t=n.alloc(1);return t.writeUInt8(e),t}if(e<65536){const t=n.alloc(3);return t.writeUInt8(253),t.writeUInt16LE(e,1),t}if(e<4294967296){const t=n.alloc(5);return t.writeUInt8(254),t.writeUInt32LE(e,1),t}if(e<281474976710656){const t=n.alloc(9);return t.writeUInt8(255),t.writeUIntLE(e,1,6),t.writeUInt8(0,7),t.writeUInt8(0,8),t}throw new Error(`Integer too large: ${e}`)}static decode(e){if(0===e.byteLength)throw new Error("Empty buffer provided");const t=e.readUInt8();return 253===t?e.readUInt16LE(1):254===t?e.readUInt32LE(1):255===t?e.readUIntLE(1,6):t}}},6429:function(e,t,r){"use strict";var n=r(1048).Buffer,i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=i(r(7243));t.default=class{static encode(e){const t=o.default.encode(e.length);return n.concat([t,e])}static decode(e){const t=o.default.decode(e),r=o.default.encode(t).byteLength;return e.subarray(r,t+r)}}},414:function(e,t,r){"use strict";var n=r(1048).Buffer,i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=i(r(7243)),s=i(r(6429));t.default=class{static serialize(e){let t=o.default.encode(e.length);return e.forEach((e=>{t=n.concat([t,s.default.encode(n.from(e))])})),t.toString("base64")}static deserialize(e){let t,r=[];t="string"==typeof e?n.from(e,"base64"):e;const i=o.default.decode(t),a=o.default.encode(i).byteLength;t=t.subarray(a);for(let e=0;e{e.exports=r(8622)(r(5938))},5938:(e,t,r)=>{const n=new(0,r(3360).ec)("secp256k1"),i=n.curve,o=i.n.constructor;function s(e){const t=e[0];switch(t){case 2:case 3:return 33!==e.length?null:function(e,t){let r=new o(t);if(r.cmp(i.p)>=0)return null;r=r.toRed(i.red);let s=r.redSqr().redIMul(r).redIAdd(i.b).redSqrt();3===e!==s.isOdd()&&(s=s.redNeg());const a=r.redSqr().redIMul(r);return s.redSqr().redISub(a.redIAdd(i.b)).isZero()?n.keyPair({pub:{x:r,y:s}}):null}(t,e.subarray(1,33));case 4:case 6:case 7:return 65!==e.length?null:function(e,t,r){let s=new o(t),a=new o(r);if(s.cmp(i.p)>=0||a.cmp(i.p)>=0)return null;if(s=s.toRed(i.red),a=a.toRed(i.red),(6===e||7===e)&&a.isOdd()!==(7===e))return null;const f=s.redSqr().redIMul(s);return a.redSqr().redISub(f.redIAdd(i.b)).isZero()?n.keyPair({pub:{x:s,y:a}}):null}(t,e.subarray(1,33),e.subarray(33,65));default:return null}}function a(e,t){const r=t.encode(null,33===e.length);for(let t=0;t0,privateKeyVerify(e){const t=new o(e);return t.cmp(i.n)<0&&!t.isZero()?0:1},privateKeyNegate(e){const t=new o(e),r=i.n.sub(t).umod(i.n).toArrayLike(Uint8Array,"be",32);return e.set(r),0},privateKeyTweakAdd(e,t){const r=new o(t);if(r.cmp(i.n)>=0)return 1;if(r.iadd(new o(e)),r.cmp(i.n)>=0&&r.isub(i.n),r.isZero())return 1;const n=r.toArrayLike(Uint8Array,"be",32);return e.set(n),0},privateKeyTweakMul(e,t){let r=new o(t);if(r.cmp(i.n)>=0||r.isZero())return 1;r.imul(new o(e)),r.cmp(i.n)>=0&&(r=r.umod(i.n));const n=r.toArrayLike(Uint8Array,"be",32);return e.set(n),0},publicKeyVerify:e=>null===s(e)?1:0,publicKeyCreate(e,t){const r=new o(t);return r.cmp(i.n)>=0||r.isZero()?1:(a(e,n.keyFromPrivate(t).getPublic()),0)},publicKeyConvert(e,t){const r=s(t);return null===r?1:(a(e,r.getPublic()),0)},publicKeyNegate(e,t){const r=s(t);if(null===r)return 1;const n=r.getPublic();return n.y=n.y.redNeg(),a(e,n),0},publicKeyCombine(e,t){const r=new Array(t.length);for(let e=0;e=0)return 2;const f=n.getPublic().add(i.g.mul(r));return f.isInfinity()?2:(a(e,f),0)},publicKeyTweakMul(e,t,r){const n=s(t);return null===n?1:(r=new o(r)).cmp(i.n)>=0||r.isZero()?2:(a(e,n.getPublic().mul(r)),0)},signatureNormalize(e){const t=new o(e.subarray(0,32)),r=new o(e.subarray(32,64));return t.cmp(i.n)>=0||r.cmp(i.n)>=0?1:(1===r.cmp(n.nh)&&e.set(i.n.sub(r).toArrayLike(Uint8Array,"be",32),32),0)},signatureExport(e,t){const r=t.subarray(0,32),n=t.subarray(32,64);if(new o(r).cmp(i.n)>=0)return 1;if(new o(n).cmp(i.n)>=0)return 1;const{output:s}=e;let a=s.subarray(4,37);a[0]=0,a.set(r,1);let f=33,u=0;for(;f>1&&0===a[u]&&!(128&a[u+1]);--f,++u);if(a=a.subarray(u),128&a[0])return 1;if(f>1&&0===a[0]&&!(128&a[1]))return 1;let c=s.subarray(39,72);c[0]=0,c.set(n,1);let h=33,d=0;for(;h>1&&0===c[d]&&!(128&c[d+1]);--h,++d);return c=c.subarray(d),128&c[0]||h>1&&0===c[0]&&!(128&c[1])?1:(e.outputlen=6+f+h,s[0]=48,s[1]=e.outputlen-2,s[2]=2,s[3]=a.length,s.set(a,4),s[4+f]=2,s[5+f]=c.length,s.set(c,6+f),0)},signatureImport(e,t){if(t.length<8)return 1;if(t.length>72)return 1;if(48!==t[0])return 1;if(t[1]!==t.length-2)return 1;if(2!==t[2])return 1;const r=t[3];if(0===r)return 1;if(5+r>=t.length)return 1;if(2!==t[4+r])return 1;const n=t[5+r];if(0===n)return 1;if(6+r+n!==t.length)return 1;if(128&t[4])return 1;if(r>1&&0===t[4]&&!(128&t[5]))return 1;if(128&t[r+6])return 1;if(n>1&&0===t[r+6]&&!(128&t[r+7]))return 1;let s=t.subarray(4,4+r);if(33===s.length&&0===s[0]&&(s=s.subarray(1)),s.length>32)return 1;let a=t.subarray(6+r);if(33===a.length&&0===a[0]&&(a=a.slice(1)),a.length>32)throw new Error("S length is too long");let f=new o(s);f.cmp(i.n)>=0&&(f=new o(0));let u=new o(t.subarray(6+r));return u.cmp(i.n)>=0&&(u=new o(0)),e.set(f.toArrayLike(Uint8Array,"be",32),0),e.set(u.toArrayLike(Uint8Array,"be",32),32),0},ecdsaSign(e,t,r,s,a){if(a){const e=a;a=n=>{const i=e(t,r,null,s,n);if(!(i instanceof Uint8Array&&32===i.length))throw new Error("This is the way");return new o(i)}}const f=new o(r);if(f.cmp(i.n)>=0||f.isZero())return 1;let u;try{u=n.sign(t,r,{canonical:!0,k:a,pers:s})}catch(e){return 1}return e.signature.set(u.r.toArrayLike(Uint8Array,"be",32),0),e.signature.set(u.s.toArrayLike(Uint8Array,"be",32),32),e.recid=u.recoveryParam,0},ecdsaVerify(e,t,r){const a={r:e.subarray(0,32),s:e.subarray(32,64)},f=new o(a.r),u=new o(a.s);if(f.cmp(i.n)>=0||u.cmp(i.n)>=0)return 1;if(1===u.cmp(n.nh)||f.isZero()||u.isZero())return 3;const c=s(r);if(null===c)return 2;const h=c.getPublic();return n.verify(t,a,h)?0:3},ecdsaRecover(e,t,r,s){const f={r:t.slice(0,32),s:t.slice(32,64)},u=new o(f.r),c=new o(f.s);if(u.cmp(i.n)>=0||c.cmp(i.n)>=0)return 1;if(u.isZero()||c.isZero())return 2;let h;try{h=n.recoverPubKey(s,f,r)}catch(e){return 2}return a(e,h),0},ecdh(e,t,r,a,f,u,c){const h=s(t);if(null===h)return 1;const d=new o(r);if(d.cmp(i.n)>=0||d.isZero())return 2;const l=h.getPublic().mul(d);if(void 0===f){const t=l.encode(null,!0),r=n.hash().update(t).digest();for(let t=0;t<32;++t)e[t]=r[t]}else{u||(u=new Uint8Array(32));const t=l.getX().toArray("be",32);for(let e=0;e<32;++e)u[e]=t[e];c||(c=new Uint8Array(32));const r=l.getY().toArray("be",32);for(let e=0;e<32;++e)c[e]=r[e];const n=f(u,c,a);if(!(n instanceof Uint8Array&&n.length===e.length))return 2;e.set(n)}return 0}}},8622:e=>{const t="Impossible case. Please create issue.",r="The tweak was out of range or the resulted private key is invalid",n="The tweak was out of range or equal to zero",i="Public Key could not be parsed",o="Public Key serialization error",s="Signature could not be parsed";function a(e,t){if(!e)throw new Error(t)}function f(e,t,r){if(a(t instanceof Uint8Array,`Expected ${e} to be an Uint8Array`),void 0!==r)if(Array.isArray(r)){const n=`Expected ${e} to be an Uint8Array with length [${r.join(", ")}]`;a(r.includes(t.length),n)}else{const n=`Expected ${e} to be an Uint8Array with length ${r}`;a(t.length===r,n)}}function u(e){a("Boolean"===h(e),"Expected compressed to be a Boolean")}function c(e=e=>new Uint8Array(e),t){return"function"==typeof e&&(e=e(t)),f("output",e,t),e}function h(e){return Object.prototype.toString.call(e).slice(8,-1)}e.exports=e=>({contextRandomize(t){if(a(null===t||t instanceof Uint8Array,"Expected seed to be an Uint8Array or null"),null!==t&&f("seed",t,32),1===e.contextRandomize(t))throw new Error("Unknow error on context randomization")},privateKeyVerify:t=>(f("private key",t,32),0===e.privateKeyVerify(t)),privateKeyNegate(r){switch(f("private key",r,32),e.privateKeyNegate(r)){case 0:return r;case 1:throw new Error(t)}},privateKeyTweakAdd(t,n){switch(f("private key",t,32),f("tweak",n,32),e.privateKeyTweakAdd(t,n)){case 0:return t;case 1:throw new Error(r)}},privateKeyTweakMul(t,r){switch(f("private key",t,32),f("tweak",r,32),e.privateKeyTweakMul(t,r)){case 0:return t;case 1:throw new Error(n)}},publicKeyVerify:t=>(f("public key",t,[33,65]),0===e.publicKeyVerify(t)),publicKeyCreate(t,r=!0,n){switch(f("private key",t,32),u(r),n=c(n,r?33:65),e.publicKeyCreate(n,t)){case 0:return n;case 1:throw new Error("Private Key is invalid");case 2:throw new Error(o)}},publicKeyConvert(t,r=!0,n){switch(f("public key",t,[33,65]),u(r),n=c(n,r?33:65),e.publicKeyConvert(n,t)){case 0:return n;case 1:throw new Error(i);case 2:throw new Error(o)}},publicKeyNegate(r,n=!0,s){switch(f("public key",r,[33,65]),u(n),s=c(s,n?33:65),e.publicKeyNegate(s,r)){case 0:return s;case 1:throw new Error(i);case 2:throw new Error(t);case 3:throw new Error(o)}},publicKeyCombine(t,r=!0,n){a(Array.isArray(t),"Expected public keys to be an Array"),a(t.length>0,"Expected public keys array will have more than zero items");for(const e of t)f("public key",e,[33,65]);switch(u(r),n=c(n,r?33:65),e.publicKeyCombine(n,t)){case 0:return n;case 1:throw new Error(i);case 2:throw new Error("The sum of the public keys is not valid");case 3:throw new Error(o)}},publicKeyTweakAdd(t,n,o=!0,s){switch(f("public key",t,[33,65]),f("tweak",n,32),u(o),s=c(s,o?33:65),e.publicKeyTweakAdd(s,t,n)){case 0:return s;case 1:throw new Error(i);case 2:throw new Error(r)}},publicKeyTweakMul(t,r,o=!0,s){switch(f("public key",t,[33,65]),f("tweak",r,32),u(o),s=c(s,o?33:65),e.publicKeyTweakMul(s,t,r)){case 0:return s;case 1:throw new Error(i);case 2:throw new Error(n)}},signatureNormalize(t){switch(f("signature",t,64),e.signatureNormalize(t)){case 0:return t;case 1:throw new Error(s)}},signatureExport(r,n){f("signature",r,64);const i={output:n=c(n,72),outputlen:72};switch(e.signatureExport(i,r)){case 0:return n.slice(0,i.outputlen);case 1:throw new Error(s);case 2:throw new Error(t)}},signatureImport(r,n){switch(f("signature",r),n=c(n,64),e.signatureImport(n,r)){case 0:return n;case 1:throw new Error(s);case 2:throw new Error(t)}},ecdsaSign(r,n,i={},o){f("message",r,32),f("private key",n,32),a("Object"===h(i),"Expected options to be an Object"),void 0!==i.data&&f("options.data",i.data),void 0!==i.noncefn&&a("Function"===h(i.noncefn),"Expected options.noncefn to be a Function");const s={signature:o=c(o,64),recid:null};switch(e.ecdsaSign(s,r,n,i.data,i.noncefn)){case 0:return s;case 1:throw new Error("The nonce generation function failed, or the private key was invalid");case 2:throw new Error(t)}},ecdsaVerify(t,r,n){switch(f("signature",t,64),f("message",r,32),f("public key",n,[33,65]),e.ecdsaVerify(t,r,n)){case 0:return!0;case 3:return!1;case 1:throw new Error(s);case 2:throw new Error(i)}},ecdsaRecover(r,n,i,o=!0,d){switch(f("signature",r,64),a("Number"===h(n)&&n>=0&&n<=3,"Expected recovery id to be a Number within interval [0, 3]"),f("message",i,32),u(o),d=c(d,o?33:65),e.ecdsaRecover(d,r,n,i)){case 0:return d;case 1:throw new Error(s);case 2:throw new Error("Public key could not be recover");case 3:throw new Error(t)}},ecdh(t,r,n={},o){switch(f("public key",t,[33,65]),f("private key",r,32),a("Object"===h(n),"Expected options to be an Object"),void 0!==n.data&&f("options.data",n.data),void 0!==n.hashfn?(a("Function"===h(n.hashfn),"Expected options.hashfn to be a Function"),void 0!==n.xbuf&&f("options.xbuf",n.xbuf,32),void 0!==n.ybuf&&f("options.ybuf",n.ybuf,32),f("output",o)):o=c(o,32),e.ecdh(o,t,r,n.data,n.hashfn,n.xbuf,n.ybuf)){case 0:return o;case 1:throw new Error(i);case 2:throw new Error("Scalar was invalid (zero or overflow)")}}})},1821:(e,t,r)=>{var n=r(5636).Buffer;e.exports={check:function(e){if(e.length<8)return!1;if(e.length>72)return!1;if(48!==e[0])return!1;if(e[1]!==e.length-2)return!1;if(2!==e[2])return!1;var t=e[3];if(0===t)return!1;if(5+t>=e.length)return!1;if(2!==e[4+t])return!1;var r=e[5+t];return!(0===r||6+t+r!==e.length||128&e[4]||t>1&&0===e[4]&&!(128&e[5])||128&e[t+6]||r>1&&0===e[t+6]&&!(128&e[t+7]))},decode:function(e){if(e.length<8)throw new Error("DER sequence length is too short");if(e.length>72)throw new Error("DER sequence length is too long");if(48!==e[0])throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(2!==e[2])throw new Error("Expected DER integer");var t=e[3];if(0===t)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(2!==e[4+t])throw new Error("Expected DER integer (2)");var r=e[5+t];if(0===r)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(128&e[4])throw new Error("R value is negative");if(t>1&&0===e[4]&&!(128&e[5]))throw new Error("R value excessively padded");if(128&e[t+6])throw new Error("S value is negative");if(r>1&&0===e[t+6]&&!(128&e[t+7]))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}},encode:function(e,t){var r=e.length,i=t.length;if(0===r)throw new Error("R length is zero");if(0===i)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(i>33)throw new Error("S length is too long");if(128&e[0])throw new Error("R value is negative");if(128&t[0])throw new Error("S value is negative");if(r>1&&0===e[0]&&!(128&e[1]))throw new Error("R value excessively padded");if(i>1&&0===t[0]&&!(128&t[1]))throw new Error("S value excessively padded");var o=n.allocUnsafe(6+r+i);return o[0]=48,o[1]=o.length-2,o[2]=2,o[3]=e.length,e.copy(o,4),o[4+r]=2,o[5+r]=t.length,t.copy(o,6+r),o}}},4638:(e,t,r)=>{"use strict";r.r(t),r.d(t,{AddressType:()=>T,Network:()=>A,default:()=>M,getAddressInfo:()=>O,validate:()=>M});var n=function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r{const e=Array(256).fill(-1);for(let t=0;t<58;++t)e[i.charCodeAt(t)]=t})();var o,s,a,f=e=>{if(!e||"string"!=typeof e)throw new Error(`Expected base58 string but got “${e}”`);if(e.match(/[IOl0]/gmu))throw new Error(`Invalid base58 character “${e.match(/[IOl0]/gmu)}”`);const t=e.match(/^1+/gmu),r=t?t[0].length:0,n=(e.length-r)*(Math.log(58)/Math.log(256))+1>>>0;return new Uint8Array([...new Uint8Array(r),...e.match(/.{1}/gmu).map((e=>i.indexOf(e))).reduce(((e,t)=>e.map((e=>{const r=58*e+t;return t=r>>8,r}))),new Uint8Array(n)).reverse().filter((o=!1,e=>o=o||e))]);var o},u=(o=function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.bech32m=t.bech32=void 0;const r="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n={};for(let e=0;e<32;e++){const t=r.charAt(e);n[t]=e}function i(e){const t=e>>25;return(33554431&e)<<5^996825010&-(1&t)^642813549&-(t>>1&1)^513874426&-(t>>2&1)^1027748829&-(t>>3&1)^705979059&-(t>>4&1)}function o(e){let t=1;for(let r=0;r126)return"Invalid prefix ("+e+")";t=i(t)^n>>5}t=i(t);for(let r=0;r=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<=t)return"Excess padding";if(i<r)return"Exceeds length limit";const s=e.toLowerCase(),a=e.toUpperCase();if(e!==s&&e!==a)return"Mixed-case string "+e;const f=(e=s).lastIndexOf("1");if(-1===f)return"No separator character for "+e;if(0===f)return"Missing prefix for "+e;const u=e.slice(0,f),c=e.slice(f+1);if(c.length<6)return"Data too short";let h=o(u);if("string"==typeof h)return h;const d=[];for(let e=0;e=c.length||d.push(r)}return h!==t?"Invalid checksum for "+e:{prefix:u,words:d}}return t="bech32"===e?1:734539939,{decodeUnsafe:function(e,t){const r=s(e,t);if("object"==typeof r)return r},decode:function(e,t){const r=s(e,t);if("object"==typeof r)return r;throw new Error(r)},encode:function(e,n,s){if(s=s||90,e.length+7+n.length>s)throw new TypeError("Exceeds length limit");let a=o(e=e.toLowerCase());if("string"==typeof a)throw new Error(a);let f=e+"1";for(let e=0;e>5)throw new Error("Non 5-bit word");a=i(a)^t,f+=r.charAt(t)}for(let e=0;e<6;++e)a=i(a);a^=t;for(let e=0;e<6;++e)f+=r.charAt(a>>5*(5-e)&31);return f},toWords:a,fromWordsUnsafe:f,fromWords:u}}t.bech32=c("bech32"),t.bech32m=c("bech32m")},o(s={exports:{}},s.exports),s.exports);(a=u)&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")&&a.default;var c=u.bech32m,h=u.bech32;const d=[1116352408,1899447441,-1245643825,-373957723,961987163,1508970993,-1841331548,-1424204075,-670586216,310598401,607225278,1426881987,1925078388,-2132889090,-1680079193,-1046744716,-459576895,-272742522,264347078,604807628,770255983,1249150122,1555081692,1996064986,-1740746414,-1473132947,-1341970488,-1084653625,-958395405,-710438585,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,-2117940946,-1838011259,-1564481375,-1474664885,-1035236496,-949202525,-778901479,-694614492,-200395387,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,-2067236844,-1933114872,-1866530822,-1538233109,-1090935817,-965641998];class l{constructor(){this.A=1779033703,this.B=-1150833019,this.C=1013904242,this.D=-1521486534,this.E=1359893119,this.F=-1694144372,this.G=528734635,this.H=1541459225,this._size=0,this._sp=0,(!b||y>=8e3)&&(b=new ArrayBuffer(8e3),y=0),this._byte=new Uint8Array(b,y,80),this._word=new Int32Array(b,y,20),y+=80}update(e){if("string"==typeof e)return this._utf8(e);if(null==e)throw new TypeError("Invalid type: "+typeof e);const t=e.byteOffset,r=e.byteLength;let n=r/64|0,i=0;if(n&&!(3&t)&&!(this._size%64)){const r=new Int32Array(e.buffer,t,16*n);for(;n--;)this._int32(r,i>>2),i+=64;this._size+=i}if(1!==e.BYTES_PER_ELEMENT&&e.buffer){const n=new Uint8Array(e.buffer,t+i,r-i);return this._uint8(n)}return i===r?this:this._uint8(e,i)}_uint8(e,t){const{_byte:r,_word:n}=this,i=e.length;for(t|=0;t=64&&this._int32(n),this._size+=s-o}return this}_utf8(e){const{_byte:t,_word:r}=this,n=e.length;let i=this._sp;for(let o=0;o>>6,t[a++]=128|63&r):r<55296||r>57343?(t[a++]=224|r>>>12,t[a++]=128|r>>>6&63,t[a++]=128|63&r):i?(r=((1023&i)<<10)+(1023&r)+65536,t[a++]=240|r>>>18,t[a++]=128|r>>>12&63,t[a++]=128|r>>>6&63,t[a++]=128|63&r,i=0):i=r}a>=64&&(this._int32(r),r[0]=r[16]),this._size+=a-s}return this._sp=i,this}_int32(e,t){let{A:r,B:n,C:i,D:o,E:s,F:a,G:f,H:u}=this,c=0;for(t|=0;c<16;)p[c++]=w(e[t++]);for(c=16;c<64;c++)p[c]=I(p[c-2])+p[c-7]+S(p[c-15])+p[c-16]|0;for(c=0;c<64;c++){const e=u+E(s)+m(s,a,f)+d[c]+p[c]|0,t=_(r)+v(r,n,i)|0;u=f,f=a,a=s,s=o+e|0,o=i,i=n,n=r,r=e+t|0}this.A=r+this.A|0,this.B=n+this.B|0,this.C=i+this.C|0,this.D=o+this.D|0,this.E=s+this.E|0,this.F=a+this.F|0,this.G=f+this.G|0,this.H=u+this.H|0}digest(e){const{_byte:t,_word:r}=this;let n=this._size%64|0;for(t[n++]=128;3&n;)t[n++]=0;if(n>>=2,n>14){for(;n<16;)r[n++]=0;n=0,this._int32(r)}for(;n<16;)r[n++]=0;const i=8*this._size,o=(4294967295&i)>>>0,s=(i-o)/4294967296;return s&&(r[14]=w(s)),o&&(r[15]=w(o)),this._int32(r),"hex"===e?this._hex():this._bin()}_hex(){const{A:e,B:t,C:r,D:n,E:i,F:o,G:s,H:a}=this;return g(e)+g(t)+g(r)+g(n)+g(i)+g(o)+g(s)+g(a)}_bin(){const{A:e,B:t,C:r,D:n,E:i,F:o,G:s,H:a,_byte:f,_word:u}=this;return u[0]=w(e),u[1]=w(t),u[2]=w(r),u[3]=w(n),u[4]=w(i),u[5]=w(o),u[6]=w(s),u[7]=w(a),f.slice(0,32)}}const p=new Int32Array(64);let b,y=0;const g=e=>(e+4294967296).toString(16).substr(-8),w=254===new Uint8Array(new Uint16Array([65279]).buffer)[0]?e=>e:e=>e<<24&4278190080|e<<8&16711680|e>>8&65280|e>>24&255,m=(e,t,r)=>r^e&(t^r),v=(e,t,r)=>e&t|r&(e|t),_=e=>(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10),E=e=>(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7),S=e=>(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3,I=e=>(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10;var A,T,k=function(e){return(new l).update(e).digest()};!function(e){e.mainnet="mainnet",e.testnet="testnet",e.regtest="regtest"}(A||(A={})),function(e){e.p2pkh="p2pkh",e.p2sh="p2sh",e.p2wpkh="p2wpkh",e.p2wsh="p2wsh",e.p2tr="p2tr"}(T||(T={}));var P={0:{type:T.p2pkh,network:A.mainnet},111:{type:T.p2pkh,network:A.testnet},5:{type:T.p2sh,network:A.mainnet},196:{type:T.p2sh,network:A.testnet}},O=function(e){var t,r=e.substr(0,2).toLowerCase();if("bc"===r||"tb"===r)return function(e){var t;try{t=e.startsWith("bc1p")||e.startsWith("tb1p")||e.startsWith("bcrt1p")?c.decode(e):h.decode(e)}catch(e){throw new Error("Invalid address")}var r={bc:A.mainnet,tb:A.testnet,bcrt:A.regtest}[t.prefix];if(void 0===r)throw new Error("Invalid address");var n=t.words[0];if(n<0||n>16)throw new Error("Invalid address");return{bech32:!0,network:r,address:e,type:20===h.fromWords(t.words.slice(1)).length?T.p2wpkh:1===n?T.p2tr:T.p2wsh}}(e);try{t=f(e)}catch(e){throw new Error("Invalid address")}var i=t.length;if(25!==i)throw new Error("Invalid address");var o=t[0],s=t.slice(i-4,i),a=t.slice(0,i-4),u=k(k(a)).slice(0,4);if(s.some((function(e,t){return e!==u[t]})))throw new Error("Invalid address");if(!Object.keys(P).map(Number).includes(o))throw new Error("Invalid address");return n(n({},P[o]),{address:e,bech32:!1})},M=function(e,t){try{var r=O(e);return!t||t===r.network}catch(e){return!1}}},3348:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.toOutputScript=t.fromOutputScript=t.toBech32=t.toBase58Check=t.fromBech32=t.fromBase58Check=void 0;const i=r(2529),o=r(8614),s=r(4009),a=r(5593),f=r(6586),u=r(9848),c="WARNING: Sending to a future segwit version address can lead to loss of funds. End users MUST be warned carefully in the GUI and asked if they wish to proceed with caution. Wallets should verify the segwit version from the output of fromBech32, then decide when it is safe to use which version of segwit.";function h(e){const t=n.from(u.decode(e));if(t.length<21)throw new TypeError(e+" is too short");if(t.length>21)throw new TypeError(e+" is too long");return{version:t.readUInt8(0),hash:t.slice(1)}}function d(e){let t,r;try{t=f.bech32.decode(e)}catch(e){}if(t){if(r=t.words[0],0!==r)throw new TypeError(e+" uses wrong encoding")}else if(t=f.bech32m.decode(e),r=t.words[0],0===r)throw new TypeError(e+" uses wrong encoding");const i=f.bech32.fromWords(t.words.slice(1));return{version:r,prefix:t.prefix,data:n.from(i)}}function l(e,t,r){const n=f.bech32.toWords(e);return n.unshift(t),0===t?f.bech32.encode(r,n):f.bech32m.encode(r,n)}t.fromBase58Check=h,t.fromBech32=d,t.toBase58Check=function(e,t){(0,a.typeforce)((0,a.tuple)(a.Hash160bit,a.UInt8),arguments);const r=n.allocUnsafe(21);return r.writeUInt8(t,0),e.copy(r,1),u.encode(r)},t.toBech32=l,t.fromOutputScript=function(e,t){t=t||i.bitcoin;try{return o.p2pkh({output:e,network:t}).address}catch(e){}try{return o.p2sh({output:e,network:t}).address}catch(e){}try{return o.p2wpkh({output:e,network:t}).address}catch(e){}try{return o.p2wsh({output:e,network:t}).address}catch(e){}try{return o.p2tr({output:e,network:t}).address}catch(e){}try{return function(e,t){const r=e.slice(2);if(r.length<2||r.length>40)throw new TypeError("Invalid program length for segwit address");const n=e[0]-80;if(n<2||n>16)throw new TypeError("Invalid version for segwit address");if(e[1]!==r.length)throw new TypeError("Invalid script for segwit address");return console.warn(c),l(r,n,t.bech32)}(e,t)}catch(e){}throw new Error(s.toASM(e)+" has no matching Address")},t.toOutputScript=function(e,t){let r,n;t=t||i.bitcoin;try{r=h(e)}catch(e){}if(r){if(r.version===t.pubKeyHash)return o.p2pkh({hash:r.hash}).output;if(r.version===t.scriptHash)return o.p2sh({hash:r.hash}).output}else{try{n=d(e)}catch(e){}if(n){if(n.prefix!==t.bech32)throw new Error(e+" has an invalid prefix");if(0===n.version){if(20===n.data.length)return o.p2wpkh({hash:n.data}).output;if(32===n.data.length)return o.p2wsh({hash:n.data}).output}else if(1===n.version){if(32===n.data.length)return o.p2tr({pubkey:n.data}).output}else if(n.version>=2&&n.version<=16&&n.data.length>=2&&n.data.length<=40)return console.warn(c),s.compile([n.version+80,n.data])}}throw new Error(e+" has no matching Script")}},195:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.encode=t.decode=t.check=void 0,t.check=function(e){if(e.length<8)return!1;if(e.length>72)return!1;if(48!==e[0])return!1;if(e[1]!==e.length-2)return!1;if(2!==e[2])return!1;const t=e[3];if(0===t)return!1;if(5+t>=e.length)return!1;if(2!==e[4+t])return!1;const r=e[5+t];return!(0===r||6+t+r!==e.length||128&e[4]||t>1&&0===e[4]&&!(128&e[5])||128&e[t+6]||r>1&&0===e[t+6]&&!(128&e[t+7]))},t.decode=function(e){if(e.length<8)throw new Error("DER sequence length is too short");if(e.length>72)throw new Error("DER sequence length is too long");if(48!==e[0])throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(2!==e[2])throw new Error("Expected DER integer");const t=e[3];if(0===t)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(2!==e[4+t])throw new Error("Expected DER integer (2)");const r=e[5+t];if(0===r)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(128&e[4])throw new Error("R value is negative");if(t>1&&0===e[4]&&!(128&e[5]))throw new Error("R value excessively padded");if(128&e[t+6])throw new Error("S value is negative");if(r>1&&0===e[t+6]&&!(128&e[t+7]))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}},t.encode=function(e,t){const r=e.length,i=t.length;if(0===r)throw new Error("R length is zero");if(0===i)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(i>33)throw new Error("S length is too long");if(128&e[0])throw new Error("R value is negative");if(128&t[0])throw new Error("S value is negative");if(r>1&&0===e[0]&&!(128&e[1]))throw new Error("R value excessively padded");if(i>1&&0===t[0]&&!(128&t[1]))throw new Error("S value excessively padded");const o=n.allocUnsafe(6+r+i);return o[0]=48,o[1]=o.length-2,o[2]=2,o[3]=e.length,e.copy(o,4),o[4+r]=2,o[5+r]=t.length,t.copy(o,6+r),o}},1169:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.Block=void 0;const i=r(3831),o=r(6891),s=r(7992),a=r(5444),f=r(5593),{typeforce:u}=f,c=new TypeError("Cannot compute merkle root for zero transactions"),h=new TypeError("Cannot compute witness commit for non-segwit block");class d{constructor(){this.version=1,this.prevHash=void 0,this.merkleRoot=void 0,this.timestamp=0,this.witnessCommit=void 0,this.bits=0,this.nonce=0,this.transactions=void 0}static fromBuffer(e){if(e.length<80)throw new Error("Buffer too small (< 80 bytes)");const t=new i.BufferReader(e),r=new d;if(r.version=t.readInt32(),r.prevHash=t.readSlice(32),r.merkleRoot=t.readSlice(32),r.timestamp=t.readUInt32(),r.bits=t.readUInt32(),r.nonce=t.readUInt32(),80===e.length)return r;const n=()=>{const e=a.Transaction.fromBuffer(t.buffer.slice(t.offset),!0);return t.offset+=e.byteLength(),e},o=t.readVarInt();r.transactions=[];for(let e=0;e>24)-3,r=8388607&e,i=n.alloc(32,0);return i.writeUIntBE(r,29-t,3),i}static calculateMerkleRoot(e,t){if(u([{getHash:f.Function}],e),0===e.length)throw c;if(t&&!l(e))throw h;const r=e.map((e=>e.getHash(t))),i=(0,s.fastMerkleRoot)(r,o.hash256);return t?o.hash256(n.concat([i,e[0].ins[0].witness[0]])):i}getWitnessCommit(){if(!l(this.transactions))return null;const e=this.transactions[0].outs.filter((e=>e.script.slice(0,6).equals(n.from("6a24aa21a9ed","hex")))).map((e=>e.script.slice(6,38)));if(0===e.length)return null;const t=e[e.length-1];return t instanceof n&&32===t.length?t:null}hasWitnessCommit(){return this.witnessCommit instanceof n&&32===this.witnessCommit.length||null!==this.getWitnessCommit()}hasWitness(){return(e=this.transactions)instanceof Array&&e.some((e=>"object"==typeof e&&e.ins instanceof Array&&e.ins.some((e=>"object"==typeof e&&e.witness instanceof Array&&e.witness.length>0))));var e}weight(){return 3*this.byteLength(!1,!1)+this.byteLength(!1,!0)}byteLength(e,t=!0){return e||!this.transactions?80:80+i.varuint.encodingLength(this.transactions.length)+this.transactions.reduce(((e,r)=>e+r.byteLength(t)),0)}getHash(){return o.hash256(this.toBuffer(!0))}getId(){return(0,i.reverseBuffer)(this.getHash()).toString("hex")}getUTCDate(){const e=new Date(0);return e.setUTCSeconds(this.timestamp),e}toBuffer(e){const t=n.allocUnsafe(this.byteLength(e)),r=new i.BufferWriter(t);return r.writeInt32(this.version),r.writeSlice(this.prevHash),r.writeSlice(this.merkleRoot),r.writeUInt32(this.timestamp),r.writeUInt32(this.bits),r.writeUInt32(this.nonce),e||!this.transactions||(i.varuint.encode(this.transactions.length,t,r.offset),r.offset+=i.varuint.encode.bytes,this.transactions.forEach((e=>{const n=e.byteLength();e.toBuffer(t,r.offset),r.offset+=n}))),t}toHex(e){return this.toBuffer(e).toString("hex")}checkTxRoots(){const e=this.hasWitnessCommit();return!(!e&&this.hasWitness())&&this.__checkMerkleRoot()&&(!e||this.__checkWitnessCommit())}checkProofOfWork(){const e=(0,i.reverseBuffer)(this.getHash()),t=d.calculateTarget(this.bits);return e.compare(t)<=0}__checkMerkleRoot(){if(!this.transactions)throw c;const e=d.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(e)}__checkWitnessCommit(){if(!this.transactions)throw c;if(!this.hasWitnessCommit())throw h;const e=d.calculateMerkleRoot(this.transactions,!0);return 0===this.witnessCommit.compare(e)}}function l(e){return e instanceof Array&&e[0]&&e[0].ins&&e[0].ins instanceof Array&&e[0].ins[0]&&e[0].ins[0].witness&&e[0].ins[0].witness instanceof Array&&e[0].ins[0].witness.length>0}t.Block=d},3831:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.BufferReader=t.BufferWriter=t.cloneBuffer=t.reverseBuffer=t.writeUInt64LE=t.readUInt64LE=t.varuint=void 0;const i=r(5593),{typeforce:o}=i,s=r(7820);function a(e,t){if("number"!=typeof e)throw new Error("cannot write a non-number as a number");if(e<0)throw new Error("specified a negative value for writing an unsigned value");if(e>t)throw new Error("RangeError: value out of range");if(Math.floor(e)!==e)throw new Error("value has a fractional component")}function f(e,t){const r=e.readUInt32LE(t);let n=e.readUInt32LE(t+4);return n*=4294967296,a(n+r,9007199254740991),n+r}function u(e,t,r){return a(t,9007199254740991),e.writeInt32LE(-1&t,r),e.writeUInt32LE(Math.floor(t/4294967296),r+4),r+8}t.varuint=s,t.readUInt64LE=f,t.writeUInt64LE=u,t.reverseBuffer=function(e){if(e.length<1)return e;let t=e.length-1,r=0;for(let n=0;nthis.writeVarSlice(e)))}end(){if(this.buffer.length===this.offset)return this.buffer;throw new Error(`buffer size ${this.buffer.length}, offset ${this.offset}`)}}t.BufferWriter=c,t.BufferReader=class{constructor(e,t=0){this.buffer=e,this.offset=t,o(i.tuple(i.Buffer,i.UInt32),[e,t])}readUInt8(){const e=this.buffer.readUInt8(this.offset);return this.offset++,e}readInt32(){const e=this.buffer.readInt32LE(this.offset);return this.offset+=4,e}readUInt32(){const e=this.buffer.readUInt32LE(this.offset);return this.offset+=4,e}readUInt64(){const e=f(this.buffer,this.offset);return this.offset+=8,e}readVarInt(){const e=s.decode(this.buffer,this.offset);return this.offset+=s.decode.bytes,e}readSlice(e){if(this.buffer.length{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.taggedHash=t.TAGGED_HASH_PREFIXES=t.TAGS=t.hash256=t.hash160=t.sha256=t.sha1=t.ripemd160=void 0;const i=r(71),o=r(874),s=r(9688);function a(e){return n.from((0,s.sha256)(Uint8Array.from(e)))}t.ripemd160=function(e){return n.from((0,i.ripemd160)(Uint8Array.from(e)))},t.sha1=function(e){return n.from((0,o.sha1)(Uint8Array.from(e)))},t.sha256=a,t.hash160=function(e){return n.from((0,i.ripemd160)((0,s.sha256)(Uint8Array.from(e))))},t.hash256=function(e){return n.from((0,s.sha256)((0,s.sha256)(Uint8Array.from(e))))},t.TAGS=["BIP0340/challenge","BIP0340/aux","BIP0340/nonce","TapLeaf","TapBranch","TapSighash","TapTweak","KeyAgg list","KeyAgg coefficient"],t.TAGGED_HASH_PREFIXES={"BIP0340/challenge":n.from([123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124,123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124]),"BIP0340/aux":n.from([241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144,241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144]),"BIP0340/nonce":n.from([7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47,7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47]),TapLeaf:n.from([174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238,174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238]),TapBranch:n.from([25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21,25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21]),TapSighash:n.from([244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49,244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49]),TapTweak:n.from([232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233,232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233]),"KeyAgg list":n.from([72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240,72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240]),"KeyAgg coefficient":n.from([191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129,191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129])},t.taggedHash=function(e,r){return a(n.concat([t.TAGGED_HASH_PREFIXES[e],r]))}},6313:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.getEccLib=t.initEccLib=void 0;const i={};t.initEccLib=function(e){e?e!==i.eccLib&&(function(e){s("function"==typeof e.isXOnlyPoint),s(e.isXOnlyPoint(o("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),s(e.isXOnlyPoint(o("fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e"))),s(e.isXOnlyPoint(o("f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"))),s(e.isXOnlyPoint(o("0000000000000000000000000000000000000000000000000000000000000001"))),s(!e.isXOnlyPoint(o("0000000000000000000000000000000000000000000000000000000000000000"))),s(!e.isXOnlyPoint(o("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"))),s("function"==typeof e.xOnlyPointAddTweak),a.forEach((t=>{const r=e.xOnlyPointAddTweak(o(t.pubkey),o(t.tweak));null===t.result?s(null===r):(s(null!==r),s(r.parity===t.parity),s(n.from(r.xOnlyPubkey).equals(o(t.result))))}))}(e),i.eccLib=e):i.eccLib=e},t.getEccLib=function(){if(!i.eccLib)throw new Error("No ECC Library provided. You must call initEccLib() with a valid TinySecp256k1Interface instance");return i.eccLib};const o=e=>n.from(e,"hex");function s(e){if(!e)throw new Error("ecc library invalid")}const a=[{pubkey:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",tweak:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140",parity:-1,result:null},{pubkey:"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b",tweak:"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac",parity:1,result:"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"},{pubkey:"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991",tweak:"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47",parity:0,result:"9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"}]},7612:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.initEccLib=t.Transaction=t.opcodes=t.Psbt=t.Block=t.script=t.payments=t.networks=t.crypto=t.address=void 0;const n=r(3348);t.address=n;const i=r(6891);t.crypto=i;const o=r(2529);t.networks=o;const s=r(8614);t.payments=s;const a=r(4009);t.script=a;var f=r(1169);Object.defineProperty(t,"Block",{enumerable:!0,get:function(){return f.Block}});var u=r(6689);Object.defineProperty(t,"Psbt",{enumerable:!0,get:function(){return u.Psbt}});var c=r(8156);Object.defineProperty(t,"opcodes",{enumerable:!0,get:function(){return c.OPS}});var h=r(5444);Object.defineProperty(t,"Transaction",{enumerable:!0,get:function(){return h.Transaction}});var d=r(6313);Object.defineProperty(t,"initEccLib",{enumerable:!0,get:function(){return d.initEccLib}})},7992:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.fastMerkleRoot=void 0,t.fastMerkleRoot=function(e,t){if(!Array.isArray(e))throw TypeError("Expected values Array");if("function"!=typeof t)throw TypeError("Expected digest Function");let r=e.length;const i=e.concat();for(;r>1;){let e=0;for(let o=0;o{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.testnet=t.regtest=t.bitcoin=void 0,t.bitcoin={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},t.regtest={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bcrt",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},t.testnet={messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239}},8156:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.REVERSE_OPS=t.OPS=void 0;const r={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_CHECKSIGADD:186,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255};t.OPS=r;const n={};t.REVERSE_OPS=n;for(const e of Object.keys(r))n[r[e]]=e},5247:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tweakKey=t.tapTweakHash=t.tapleafHash=t.findScriptPath=t.toHashTree=t.rootHashFromPath=t.MAX_TAPTREE_DEPTH=t.LEAF_VERSION_TAPSCRIPT=void 0;const n=r(1048),i=r(6313),o=r(6891),s=r(3831),a=r(5593);function f(e){const r=e.version||t.LEAF_VERSION_TAPSCRIPT;return o.taggedHash("TapLeaf",n.Buffer.concat([n.Buffer.from([r]),h(e.output)]))}function u(e,t){return o.taggedHash("TapTweak",n.Buffer.concat(t?[e,t]:[e]))}function c(e,t){return o.taggedHash("TapBranch",n.Buffer.concat([e,t]))}function h(e){const t=s.varuint.encodingLength(e.length),r=n.Buffer.allocUnsafe(t);return s.varuint.encode(e.length,r),n.Buffer.concat([r,e])}t.LEAF_VERSION_TAPSCRIPT=192,t.MAX_TAPTREE_DEPTH=128,t.rootHashFromPath=function(e,t){if(e.length<33)throw new TypeError(`The control-block length is too small. Got ${e.length}, expected min 33.`);const r=(e.length-33)/32;let n=t;for(let t=0;te.hash.compare(t.hash)));const[n,i]=r;return{hash:c(n.hash,i.hash),left:n,right:i}},t.findScriptPath=function e(t,r){if("left"in(n=t)&&"right"in n){const n=e(t.left,r);if(void 0!==n)return[...n,t.right.hash];const i=e(t.right,r);if(void 0!==i)return[...i,t.left.hash]}else if(t.hash.equals(r))return[];var n},t.tapleafHash=f,t.tapTweakHash=u,t.tweakKey=function(e,t){if(!n.Buffer.isBuffer(e))return null;if(32!==e.length)return null;if(t&&32!==t.length)return null;const r=u(e,t),o=(0,i.getEccLib)().xOnlyPointAddTweak(e,r);return o&&null!==o.xOnlyPubkey?{parity:o.parity,x:n.Buffer.from(o.xOnlyPubkey)}:null}},271:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.p2data=void 0;const n=r(2529),i=r(4009),o=r(5593),s=r(9158),a=i.OPS;t.p2data=function(e,t){if(!e.data&&!e.output)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,o.typeforce)({network:o.typeforce.maybe(o.typeforce.Object),output:o.typeforce.maybe(o.typeforce.Buffer),data:o.typeforce.maybe(o.typeforce.arrayOf(o.typeforce.Buffer))},e);const r={name:"embed",network:e.network||n.bitcoin};if(s.prop(r,"output",(()=>{if(e.data)return i.compile([a.OP_RETURN].concat(e.data))})),s.prop(r,"data",(()=>{if(e.output)return i.decompile(e.output).slice(1)})),t.validate&&e.output){const t=i.decompile(e.output);if(t[0]!==a.OP_RETURN)throw new TypeError("Output is invalid");if(!t.slice(1).every(o.typeforce.Buffer))throw new TypeError("Output is invalid");if(e.data&&!(0,o.stacksEqual)(e.data,r.data))throw new TypeError("Data mismatch")}return Object.assign(r,e)}},8614:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.p2tr=t.p2wsh=t.p2wpkh=t.p2sh=t.p2pkh=t.p2pk=t.p2ms=t.embed=void 0;const n=r(271);Object.defineProperty(t,"embed",{enumerable:!0,get:function(){return n.p2data}});const i=r(2810);Object.defineProperty(t,"p2ms",{enumerable:!0,get:function(){return i.p2ms}});const o=r(5643);Object.defineProperty(t,"p2pk",{enumerable:!0,get:function(){return o.p2pk}});const s=r(9379);Object.defineProperty(t,"p2pkh",{enumerable:!0,get:function(){return s.p2pkh}});const a=r(2129);Object.defineProperty(t,"p2sh",{enumerable:!0,get:function(){return a.p2sh}});const f=r(7090);Object.defineProperty(t,"p2wpkh",{enumerable:!0,get:function(){return f.p2wpkh}});const u=r(2366);Object.defineProperty(t,"p2wsh",{enumerable:!0,get:function(){return u.p2wsh}});const c=r(1992);Object.defineProperty(t,"p2tr",{enumerable:!0,get:function(){return c.p2tr}})},9158:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.value=t.prop=void 0,t.prop=function(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){const e=r.call(this);return this[t]=e,e},set(e){Object.defineProperty(this,t,{configurable:!0,enumerable:!0,value:e,writable:!0})}})},t.value=function(e){let t;return()=>(void 0!==t||(t=e()),t)}},2810:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.p2ms=void 0;const n=r(2529),i=r(4009),o=r(5593),s=r(9158),a=i.OPS,f=a.OP_RESERVED;t.p2ms=function(e,t){if(!(e.input||e.output||e.pubkeys&&void 0!==e.m||e.signatures))throw new TypeError("Not enough data");function r(e){return i.isCanonicalScriptSignature(e)||void 0!==(t.allowIncomplete&&e===a.OP_0)}t=Object.assign({validate:!0},t||{}),(0,o.typeforce)({network:o.typeforce.maybe(o.typeforce.Object),m:o.typeforce.maybe(o.typeforce.Number),n:o.typeforce.maybe(o.typeforce.Number),output:o.typeforce.maybe(o.typeforce.Buffer),pubkeys:o.typeforce.maybe(o.typeforce.arrayOf(o.isPoint)),signatures:o.typeforce.maybe(o.typeforce.arrayOf(r)),input:o.typeforce.maybe(o.typeforce.Buffer)},e);const u={network:e.network||n.bitcoin};let c=[],h=!1;function d(e){h||(h=!0,c=i.decompile(e),u.m=c[0]-f,u.n=c[c.length-2]-f,u.pubkeys=c.slice(1,-2))}if(s.prop(u,"output",(()=>{if(e.m&&u.n&&e.pubkeys)return i.compile([].concat(f+e.m,e.pubkeys,f+u.n,a.OP_CHECKMULTISIG))})),s.prop(u,"m",(()=>{if(u.output)return d(u.output),u.m})),s.prop(u,"n",(()=>{if(u.pubkeys)return u.pubkeys.length})),s.prop(u,"pubkeys",(()=>{if(e.output)return d(e.output),u.pubkeys})),s.prop(u,"signatures",(()=>{if(e.input)return i.decompile(e.input).slice(1)})),s.prop(u,"input",(()=>{if(e.signatures)return i.compile([a.OP_0].concat(e.signatures))})),s.prop(u,"witness",(()=>{if(u.input)return[]})),s.prop(u,"name",(()=>{if(u.m&&u.n)return`p2ms(${u.m} of ${u.n})`})),t.validate){if(e.output){if(d(e.output),!o.typeforce.Number(c[0]))throw new TypeError("Output is invalid");if(!o.typeforce.Number(c[c.length-2]))throw new TypeError("Output is invalid");if(c[c.length-1]!==a.OP_CHECKMULTISIG)throw new TypeError("Output is invalid");if(u.m<=0||u.n>16||u.m>u.n||u.n!==c.length-3)throw new TypeError("Output is invalid");if(!u.pubkeys.every((e=>(0,o.isPoint)(e))))throw new TypeError("Output is invalid");if(void 0!==e.m&&e.m!==u.m)throw new TypeError("m mismatch");if(void 0!==e.n&&e.n!==u.n)throw new TypeError("n mismatch");if(e.pubkeys&&!(0,o.stacksEqual)(e.pubkeys,u.pubkeys))throw new TypeError("Pubkeys mismatch")}if(e.pubkeys){if(void 0!==e.n&&e.n!==e.pubkeys.length)throw new TypeError("Pubkey count mismatch");if(u.n=e.pubkeys.length,u.nu.m)throw new TypeError("Too many signatures provided")}if(e.input){if(e.input[0]!==a.OP_0)throw new TypeError("Input is invalid");if(0===u.signatures.length||!u.signatures.every(r))throw new TypeError("Input has invalid signature(s)");if(e.signatures&&!(0,o.stacksEqual)(e.signatures,u.signatures))throw new TypeError("Signature mismatch");if(void 0!==e.m&&e.m!==e.signatures.length)throw new TypeError("Signature count mismatch")}}return Object.assign(u,e)}},5643:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.p2pk=void 0;const n=r(2529),i=r(4009),o=r(5593),s=r(9158),a=i.OPS;t.p2pk=function(e,t){if(!(e.input||e.output||e.pubkey||e.input||e.signature))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,o.typeforce)({network:o.typeforce.maybe(o.typeforce.Object),output:o.typeforce.maybe(o.typeforce.Buffer),pubkey:o.typeforce.maybe(o.isPoint),signature:o.typeforce.maybe(i.isCanonicalScriptSignature),input:o.typeforce.maybe(o.typeforce.Buffer)},e);const r=s.value((()=>i.decompile(e.input))),f={name:"p2pk",network:e.network||n.bitcoin};if(s.prop(f,"output",(()=>{if(e.pubkey)return i.compile([e.pubkey,a.OP_CHECKSIG])})),s.prop(f,"pubkey",(()=>{if(e.output)return e.output.slice(1,-1)})),s.prop(f,"signature",(()=>{if(e.input)return r()[0]})),s.prop(f,"input",(()=>{if(e.signature)return i.compile([e.signature])})),s.prop(f,"witness",(()=>{if(f.input)return[]})),t.validate){if(e.output){if(e.output[e.output.length-1]!==a.OP_CHECKSIG)throw new TypeError("Output is invalid");if(!(0,o.isPoint)(f.pubkey))throw new TypeError("Output pubkey is invalid");if(e.pubkey&&!e.pubkey.equals(f.pubkey))throw new TypeError("Pubkey mismatch")}if(e.signature&&e.input&&!e.input.equals(f.input))throw new TypeError("Signature mismatch");if(e.input){if(1!==r().length)throw new TypeError("Input is invalid");if(!i.isCanonicalScriptSignature(f.signature))throw new TypeError("Input has invalid signature")}}return Object.assign(f,e)}},9379:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.p2pkh=void 0;const i=r(6891),o=r(2529),s=r(4009),a=r(5593),f=r(9158),u=r(9848),c=s.OPS;t.p2pkh=function(e,t){if(!(e.address||e.hash||e.output||e.pubkey||e.input))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,a.typeforce)({network:a.typeforce.maybe(a.typeforce.Object),address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(20)),output:a.typeforce.maybe(a.typeforce.BufferN(25)),pubkey:a.typeforce.maybe(a.isPoint),signature:a.typeforce.maybe(s.isCanonicalScriptSignature),input:a.typeforce.maybe(a.typeforce.Buffer)},e);const r=f.value((()=>{const t=n.from(u.decode(e.address));return{version:t.readUInt8(0),hash:t.slice(1)}})),h=f.value((()=>s.decompile(e.input))),d=e.network||o.bitcoin,l={name:"p2pkh",network:d};if(f.prop(l,"address",(()=>{if(!l.hash)return;const e=n.allocUnsafe(21);return e.writeUInt8(d.pubKeyHash,0),l.hash.copy(e,1),u.encode(e)})),f.prop(l,"hash",(()=>e.output?e.output.slice(3,23):e.address?r().hash:e.pubkey||l.pubkey?i.hash160(e.pubkey||l.pubkey):void 0)),f.prop(l,"output",(()=>{if(l.hash)return s.compile([c.OP_DUP,c.OP_HASH160,l.hash,c.OP_EQUALVERIFY,c.OP_CHECKSIG])})),f.prop(l,"pubkey",(()=>{if(e.input)return h()[1]})),f.prop(l,"signature",(()=>{if(e.input)return h()[0]})),f.prop(l,"input",(()=>{if(e.pubkey&&e.signature)return s.compile([e.signature,e.pubkey])})),f.prop(l,"witness",(()=>{if(l.input)return[]})),t.validate){let t=n.from([]);if(e.address){if(r().version!==d.pubKeyHash)throw new TypeError("Invalid version or Network mismatch");if(20!==r().hash.length)throw new TypeError("Invalid address");t=r().hash}if(e.hash){if(t.length>0&&!t.equals(e.hash))throw new TypeError("Hash mismatch");t=e.hash}if(e.output){if(25!==e.output.length||e.output[0]!==c.OP_DUP||e.output[1]!==c.OP_HASH160||20!==e.output[2]||e.output[23]!==c.OP_EQUALVERIFY||e.output[24]!==c.OP_CHECKSIG)throw new TypeError("Output is invalid");const r=e.output.slice(3,23);if(t.length>0&&!t.equals(r))throw new TypeError("Hash mismatch");t=r}if(e.pubkey){const r=i.hash160(e.pubkey);if(t.length>0&&!t.equals(r))throw new TypeError("Hash mismatch");t=r}if(e.input){const r=h();if(2!==r.length)throw new TypeError("Input is invalid");if(!s.isCanonicalScriptSignature(r[0]))throw new TypeError("Input has invalid signature");if(!(0,a.isPoint)(r[1]))throw new TypeError("Input has invalid pubkey");if(e.signature&&!e.signature.equals(r[0]))throw new TypeError("Signature mismatch");if(e.pubkey&&!e.pubkey.equals(r[1]))throw new TypeError("Pubkey mismatch");const n=i.hash160(r[1]);if(t.length>0&&!t.equals(n))throw new TypeError("Hash mismatch")}}return Object.assign(l,e)}},2129:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.p2sh=void 0;const i=r(6891),o=r(2529),s=r(4009),a=r(5593),f=r(9158),u=r(9848),c=s.OPS;t.p2sh=function(e,t){if(!(e.address||e.hash||e.output||e.redeem||e.input))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,a.typeforce)({network:a.typeforce.maybe(a.typeforce.Object),address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(20)),output:a.typeforce.maybe(a.typeforce.BufferN(23)),redeem:a.typeforce.maybe({network:a.typeforce.maybe(a.typeforce.Object),output:a.typeforce.maybe(a.typeforce.Buffer),input:a.typeforce.maybe(a.typeforce.Buffer),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))}),input:a.typeforce.maybe(a.typeforce.Buffer),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))},e);let r=e.network;r||(r=e.redeem&&e.redeem.network||o.bitcoin);const h={network:r},d=f.value((()=>{const t=n.from(u.decode(e.address));return{version:t.readUInt8(0),hash:t.slice(1)}})),l=f.value((()=>s.decompile(e.input))),p=f.value((()=>{const t=l(),i=t[t.length-1];return{network:r,output:i===c.OP_FALSE?n.from([]):i,input:s.compile(t.slice(0,-1)),witness:e.witness||[]}}));if(f.prop(h,"address",(()=>{if(!h.hash)return;const e=n.allocUnsafe(21);return e.writeUInt8(h.network.scriptHash,0),h.hash.copy(e,1),u.encode(e)})),f.prop(h,"hash",(()=>e.output?e.output.slice(2,22):e.address?d().hash:h.redeem&&h.redeem.output?i.hash160(h.redeem.output):void 0)),f.prop(h,"output",(()=>{if(h.hash)return s.compile([c.OP_HASH160,h.hash,c.OP_EQUAL])})),f.prop(h,"redeem",(()=>{if(e.input)return p()})),f.prop(h,"input",(()=>{if(e.redeem&&e.redeem.input&&e.redeem.output)return s.compile([].concat(s.decompile(e.redeem.input),e.redeem.output))})),f.prop(h,"witness",(()=>h.redeem&&h.redeem.witness?h.redeem.witness:h.input?[]:void 0)),f.prop(h,"name",(()=>{const e=["p2sh"];return void 0!==h.redeem&&void 0!==h.redeem.name&&e.push(h.redeem.name),e.join("-")})),t.validate){let t=n.from([]);if(e.address){if(d().version!==r.scriptHash)throw new TypeError("Invalid version or Network mismatch");if(20!==d().hash.length)throw new TypeError("Invalid address");t=d().hash}if(e.hash){if(t.length>0&&!t.equals(e.hash))throw new TypeError("Hash mismatch");t=e.hash}if(e.output){if(23!==e.output.length||e.output[0]!==c.OP_HASH160||20!==e.output[1]||e.output[22]!==c.OP_EQUAL)throw new TypeError("Output is invalid");const r=e.output.slice(2,22);if(t.length>0&&!t.equals(r))throw new TypeError("Hash mismatch");t=r}const o=e=>{if(e.output){const r=s.decompile(e.output);if(!r||r.length<1)throw new TypeError("Redeem.output too short");if(e.output.byteLength>520)throw new TypeError("Redeem.output unspendable if larger than 520 bytes");if(s.countNonPushOnlyOPs(r)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const n=i.hash160(e.output);if(t.length>0&&!t.equals(n))throw new TypeError("Hash mismatch");t=n}if(e.input){const t=e.input.length>0,r=e.witness&&e.witness.length>0;if(!t&&!r)throw new TypeError("Empty input");if(t&&r)throw new TypeError("Input and witness provided");if(t){const t=s.decompile(e.input);if(!s.isPushOnly(t))throw new TypeError("Non push-only scriptSig")}}};if(e.input){const e=l();if(!e||e.length<1)throw new TypeError("Input too short");if(!n.isBuffer(p().output))throw new TypeError("Input is invalid");o(p())}if(e.redeem){if(e.redeem.network&&e.redeem.network!==r)throw new TypeError("Network mismatch");if(e.input){const t=p();if(e.redeem.output&&!e.redeem.output.equals(t.output))throw new TypeError("Redeem.output mismatch");if(e.redeem.input&&!e.redeem.input.equals(t.input))throw new TypeError("Redeem.input mismatch")}o(e.redeem)}if(e.witness&&e.redeem&&e.redeem.witness&&!(0,a.stacksEqual)(e.redeem.witness,e.witness))throw new TypeError("Witness and redeem.witness mismatch")}return Object.assign(h,e)}},1992:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.p2tr=void 0;const n=r(1048),i=r(2529),o=r(4009),s=r(5593),a=r(6313),f=r(5247),u=r(9158),c=r(6586),h=r(3348),d=o.OPS;t.p2tr=function(e,t){if(!(e.address||e.output||e.pubkey||e.internalPubkey||e.witness&&e.witness.length>1))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,s.typeforce)({address:s.typeforce.maybe(s.typeforce.String),input:s.typeforce.maybe(s.typeforce.BufferN(0)),network:s.typeforce.maybe(s.typeforce.Object),output:s.typeforce.maybe(s.typeforce.BufferN(34)),internalPubkey:s.typeforce.maybe(s.typeforce.BufferN(32)),hash:s.typeforce.maybe(s.typeforce.BufferN(32)),pubkey:s.typeforce.maybe(s.typeforce.BufferN(32)),signature:s.typeforce.maybe(s.typeforce.anyOf(s.typeforce.BufferN(64),s.typeforce.BufferN(65))),witness:s.typeforce.maybe(s.typeforce.arrayOf(s.typeforce.Buffer)),scriptTree:s.typeforce.maybe(s.isTaptree),redeem:s.typeforce.maybe({output:s.typeforce.maybe(s.typeforce.Buffer),redeemVersion:s.typeforce.maybe(s.typeforce.Number),witness:s.typeforce.maybe(s.typeforce.arrayOf(s.typeforce.Buffer))}),redeemVersion:s.typeforce.maybe(s.typeforce.Number)},e);const r=u.value((()=>(0,h.fromBech32)(e.address))),l=u.value((()=>{if(e.witness&&e.witness.length)return e.witness.length>=2&&80===e.witness[e.witness.length-1][0]?e.witness.slice(0,-1):e.witness.slice()})),p=u.value((()=>e.scriptTree?(0,f.toHashTree)(e.scriptTree):e.hash?{hash:e.hash}:void 0)),b=e.network||i.bitcoin,y={name:"p2tr",network:b};if(u.prop(y,"address",(()=>{if(!y.pubkey)return;const e=c.bech32m.toWords(y.pubkey);return e.unshift(1),c.bech32m.encode(b.bech32,e)})),u.prop(y,"hash",(()=>{const e=p();if(e)return e.hash;const t=l();if(t&&t.length>1){const e=t[t.length-1],r=e[0]&s.TAPLEAF_VERSION_MASK,n=t[t.length-2],i=(0,f.tapleafHash)({output:n,version:r});return(0,f.rootHashFromPath)(e,i)}return null})),u.prop(y,"output",(()=>{if(y.pubkey)return o.compile([d.OP_1,y.pubkey])})),u.prop(y,"redeemVersion",(()=>e.redeemVersion?e.redeemVersion:e.redeem&&void 0!==e.redeem.redeemVersion&&null!==e.redeem.redeemVersion?e.redeem.redeemVersion:f.LEAF_VERSION_TAPSCRIPT)),u.prop(y,"redeem",(()=>{const e=l();if(e&&!(e.length<2))return{output:e[e.length-2],witness:e.slice(0,-2),redeemVersion:e[e.length-1][0]&s.TAPLEAF_VERSION_MASK}})),u.prop(y,"pubkey",(()=>{if(e.pubkey)return e.pubkey;if(e.output)return e.output.slice(2);if(e.address)return r().data;if(y.internalPubkey){const e=(0,f.tweakKey)(y.internalPubkey,y.hash);if(e)return e.x}})),u.prop(y,"internalPubkey",(()=>{if(e.internalPubkey)return e.internalPubkey;const t=l();return t&&t.length>1?t[t.length-1].slice(1,33):void 0})),u.prop(y,"signature",(()=>{if(e.signature)return e.signature;const t=l();return t&&1===t.length?t[0]:void 0})),u.prop(y,"witness",(()=>{if(e.witness)return e.witness;const t=p();if(t&&e.redeem&&e.redeem.output&&e.internalPubkey){const r=(0,f.tapleafHash)({output:e.redeem.output,version:y.redeemVersion}),i=(0,f.findScriptPath)(t,r);if(!i)return;const o=(0,f.tweakKey)(e.internalPubkey,t.hash);if(!o)return;const s=n.Buffer.concat([n.Buffer.from([y.redeemVersion|o.parity]),e.internalPubkey].concat(i));return[e.redeem.output,s]}return e.signature?[e.signature]:void 0})),t.validate){let t=n.Buffer.from([]);if(e.address){if(b&&b.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(1!==r().version)throw new TypeError("Invalid address version");if(32!==r().data.length)throw new TypeError("Invalid address data");t=r().data}if(e.pubkey){if(t.length>0&&!t.equals(e.pubkey))throw new TypeError("Pubkey mismatch");t=e.pubkey}if(e.output){if(34!==e.output.length||e.output[0]!==d.OP_1||32!==e.output[1])throw new TypeError("Output is invalid");if(t.length>0&&!t.equals(e.output.slice(2)))throw new TypeError("Pubkey mismatch");t=e.output.slice(2)}if(e.internalPubkey){const r=(0,f.tweakKey)(e.internalPubkey,y.hash);if(t.length>0&&!t.equals(r.x))throw new TypeError("Pubkey mismatch");t=r.x}if(t&&t.length&&!(0,a.getEccLib)().isXOnlyPoint(t))throw new TypeError("Invalid pubkey for p2tr");const i=p();if(e.hash&&i&&!e.hash.equals(i.hash))throw new TypeError("Hash mismatch");if(e.redeem&&e.redeem.output&&i){const t=(0,f.tapleafHash)({output:e.redeem.output,version:y.redeemVersion});if(!(0,f.findScriptPath)(i,t))throw new TypeError("Redeem script not in tree")}const u=l();if(e.redeem&&y.redeem){if(e.redeem.redeemVersion&&e.redeem.redeemVersion!==y.redeem.redeemVersion)throw new TypeError("Redeem.redeemVersion and witness mismatch");if(e.redeem.output){if(0===o.decompile(e.redeem.output).length)throw new TypeError("Redeem.output is invalid");if(y.redeem.output&&!e.redeem.output.equals(y.redeem.output))throw new TypeError("Redeem.output and witness mismatch")}if(e.redeem.witness&&y.redeem.witness&&!(0,s.stacksEqual)(e.redeem.witness,y.redeem.witness))throw new TypeError("Redeem.witness and witness mismatch")}if(u&&u.length)if(1===u.length){if(e.signature&&!e.signature.equals(u[0]))throw new TypeError("Signature mismatch")}else{const r=u[u.length-1];if(r.length<33)throw new TypeError(`The control-block length is too small. Got ${r.length}, expected min 33.`);if((r.length-33)%32!=0)throw new TypeError(`The control-block length of ${r.length} is incorrect!`);const n=(r.length-33)/32;if(n>128)throw new TypeError(`The script path is too long. Got ${n}, expected max 128.`);const i=r.slice(1,33);if(e.internalPubkey&&!e.internalPubkey.equals(i))throw new TypeError("Internal pubkey mismatch");if(!(0,a.getEccLib)().isXOnlyPoint(i))throw new TypeError("Invalid internalPubkey for p2tr witness");const o=r[0]&s.TAPLEAF_VERSION_MASK,c=u[u.length-2],h=(0,f.tapleafHash)({output:c,version:o}),d=(0,f.rootHashFromPath)(r,h),l=(0,f.tweakKey)(i,d);if(!l)throw new TypeError("Invalid outputKey for p2tr witness");if(t.length&&!t.equals(l.x))throw new TypeError("Pubkey mismatch for p2tr witness");if(l.parity!==(1&r[0]))throw new Error("Incorrect parity")}}return Object.assign(y,e)}},7090:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.p2wpkh=void 0;const i=r(6891),o=r(2529),s=r(4009),a=r(5593),f=r(9158),u=r(6586),c=s.OPS,h=n.alloc(0);t.p2wpkh=function(e,t){if(!(e.address||e.hash||e.output||e.pubkey||e.witness))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,a.typeforce)({address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(20)),input:a.typeforce.maybe(a.typeforce.BufferN(0)),network:a.typeforce.maybe(a.typeforce.Object),output:a.typeforce.maybe(a.typeforce.BufferN(22)),pubkey:a.typeforce.maybe(a.isPoint),signature:a.typeforce.maybe(s.isCanonicalScriptSignature),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))},e);const r=f.value((()=>{const t=u.bech32.decode(e.address),r=t.words.shift(),i=u.bech32.fromWords(t.words);return{version:r,prefix:t.prefix,data:n.from(i)}})),d=e.network||o.bitcoin,l={name:"p2wpkh",network:d};if(f.prop(l,"address",(()=>{if(!l.hash)return;const e=u.bech32.toWords(l.hash);return e.unshift(0),u.bech32.encode(d.bech32,e)})),f.prop(l,"hash",(()=>e.output?e.output.slice(2,22):e.address?r().data:e.pubkey||l.pubkey?i.hash160(e.pubkey||l.pubkey):void 0)),f.prop(l,"output",(()=>{if(l.hash)return s.compile([c.OP_0,l.hash])})),f.prop(l,"pubkey",(()=>e.pubkey?e.pubkey:e.witness?e.witness[1]:void 0)),f.prop(l,"signature",(()=>{if(e.witness)return e.witness[0]})),f.prop(l,"input",(()=>{if(l.witness)return h})),f.prop(l,"witness",(()=>{if(e.pubkey&&e.signature)return[e.signature,e.pubkey]})),t.validate){let t=n.from([]);if(e.address){if(d&&d.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(0!==r().version)throw new TypeError("Invalid address version");if(20!==r().data.length)throw new TypeError("Invalid address data");t=r().data}if(e.hash){if(t.length>0&&!t.equals(e.hash))throw new TypeError("Hash mismatch");t=e.hash}if(e.output){if(22!==e.output.length||e.output[0]!==c.OP_0||20!==e.output[1])throw new TypeError("Output is invalid");if(t.length>0&&!t.equals(e.output.slice(2)))throw new TypeError("Hash mismatch");t=e.output.slice(2)}if(e.pubkey){const r=i.hash160(e.pubkey);if(t.length>0&&!t.equals(r))throw new TypeError("Hash mismatch");if(t=r,!(0,a.isPoint)(e.pubkey)||33!==e.pubkey.length)throw new TypeError("Invalid pubkey for p2wpkh")}if(e.witness){if(2!==e.witness.length)throw new TypeError("Witness is invalid");if(!s.isCanonicalScriptSignature(e.witness[0]))throw new TypeError("Witness has invalid signature");if(!(0,a.isPoint)(e.witness[1])||33!==e.witness[1].length)throw new TypeError("Witness has invalid pubkey");if(e.signature&&!e.signature.equals(e.witness[0]))throw new TypeError("Signature mismatch");if(e.pubkey&&!e.pubkey.equals(e.witness[1]))throw new TypeError("Pubkey mismatch");const r=i.hash160(e.witness[1]);if(t.length>0&&!t.equals(r))throw new TypeError("Hash mismatch")}}return Object.assign(l,e)}},2366:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.p2wsh=void 0;const i=r(6891),o=r(2529),s=r(4009),a=r(5593),f=r(9158),u=r(6586),c=s.OPS,h=n.alloc(0);function d(e){return!(!n.isBuffer(e)||65!==e.length||4!==e[0]||!(0,a.isPoint)(e))}t.p2wsh=function(e,t){if(!(e.address||e.hash||e.output||e.redeem||e.witness))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),(0,a.typeforce)({network:a.typeforce.maybe(a.typeforce.Object),address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(32)),output:a.typeforce.maybe(a.typeforce.BufferN(34)),redeem:a.typeforce.maybe({input:a.typeforce.maybe(a.typeforce.Buffer),network:a.typeforce.maybe(a.typeforce.Object),output:a.typeforce.maybe(a.typeforce.Buffer),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))}),input:a.typeforce.maybe(a.typeforce.BufferN(0)),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))},e);const r=f.value((()=>{const t=u.bech32.decode(e.address),r=t.words.shift(),i=u.bech32.fromWords(t.words);return{version:r,prefix:t.prefix,data:n.from(i)}})),l=f.value((()=>s.decompile(e.redeem.input)));let p=e.network;p||(p=e.redeem&&e.redeem.network||o.bitcoin);const b={network:p};if(f.prop(b,"address",(()=>{if(!b.hash)return;const e=u.bech32.toWords(b.hash);return e.unshift(0),u.bech32.encode(p.bech32,e)})),f.prop(b,"hash",(()=>e.output?e.output.slice(2):e.address?r().data:b.redeem&&b.redeem.output?i.sha256(b.redeem.output):void 0)),f.prop(b,"output",(()=>{if(b.hash)return s.compile([c.OP_0,b.hash])})),f.prop(b,"redeem",(()=>{if(e.witness)return{output:e.witness[e.witness.length-1],input:h,witness:e.witness.slice(0,-1)}})),f.prop(b,"input",(()=>{if(b.witness)return h})),f.prop(b,"witness",(()=>{if(e.redeem&&e.redeem.input&&e.redeem.input.length>0&&e.redeem.output&&e.redeem.output.length>0){const t=s.toStack(l());return b.redeem=Object.assign({witness:t},e.redeem),b.redeem.input=h,[].concat(t,e.redeem.output)}if(e.redeem&&e.redeem.output&&e.redeem.witness)return[].concat(e.redeem.witness,e.redeem.output)})),f.prop(b,"name",(()=>{const e=["p2wsh"];return void 0!==b.redeem&&void 0!==b.redeem.name&&e.push(b.redeem.name),e.join("-")})),t.validate){let t=n.from([]);if(e.address){if(r().prefix!==p.bech32)throw new TypeError("Invalid prefix or Network mismatch");if(0!==r().version)throw new TypeError("Invalid address version");if(32!==r().data.length)throw new TypeError("Invalid address data");t=r().data}if(e.hash){if(t.length>0&&!t.equals(e.hash))throw new TypeError("Hash mismatch");t=e.hash}if(e.output){if(34!==e.output.length||e.output[0]!==c.OP_0||32!==e.output[1])throw new TypeError("Output is invalid");const r=e.output.slice(2);if(t.length>0&&!t.equals(r))throw new TypeError("Hash mismatch");t=r}if(e.redeem){if(e.redeem.network&&e.redeem.network!==p)throw new TypeError("Network mismatch");if(e.redeem.input&&e.redeem.input.length>0&&e.redeem.witness&&e.redeem.witness.length>0)throw new TypeError("Ambiguous witness source");if(e.redeem.output){const r=s.decompile(e.redeem.output);if(!r||r.length<1)throw new TypeError("Redeem.output is invalid");if(e.redeem.output.byteLength>3600)throw new TypeError("Redeem.output unspendable if larger than 3600 bytes");if(s.countNonPushOnlyOPs(r)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const n=i.sha256(e.redeem.output);if(t.length>0&&!t.equals(n))throw new TypeError("Hash mismatch");t=n}if(e.redeem.input&&!s.isPushOnly(l()))throw new TypeError("Non push-only scriptSig");if(e.witness&&e.redeem.witness&&!(0,a.stacksEqual)(e.witness,e.redeem.witness))throw new TypeError("Witness and redeem.witness mismatch");if(e.redeem.input&&l().some(d)||e.redeem.output&&(s.decompile(e.redeem.output)||[]).some(d))throw new TypeError("redeem.input or redeem.output contains uncompressed pubkey")}if(e.witness&&e.witness.length>0){const t=e.witness[e.witness.length-1];if(e.redeem&&e.redeem.output&&!e.redeem.output.equals(t))throw new TypeError("Witness and redeem.output mismatch");if(e.witness.some(d)||(s.decompile(t)||[]).some(d))throw new TypeError("Witness contains uncompressed pubkey")}}return Object.assign(b,e)}},6689:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.Psbt=void 0;const i=r(7003),o=r(2715),s=r(2431),a=r(3348),f=r(3831),u=r(2529),c=r(8614),h=r(5247),d=r(4009),l=r(5444),p=r(6412),b=r(8990),y={network:u.bitcoin,maximumFeeRate:5e3};class g{static fromBase64(e,t={}){const r=n.from(e,"base64");return this.fromBuffer(r,t)}static fromHex(e,t={}){const r=n.from(e,"hex");return this.fromBuffer(r,t)}static fromBuffer(e,t={}){const r=i.Psbt.fromBuffer(e,w),n=new g(t,r);var o,s;return o=n.__CACHE.__TX,s=n.__CACHE,o.ins.forEach((e=>{k(s,e)})),n}constructor(e={},t=new i.Psbt(new m)){this.data=t,this.opts=Object.assign({},y,e),this.__CACHE={__NON_WITNESS_UTXO_TX_CACHE:[],__NON_WITNESS_UTXO_BUF_CACHE:[],__TX_IN_CACHE:{},__TX:this.data.globalMap.unsignedTx.tx,__UNSAFE_SIGN_NONSEGWIT:!1},0===this.data.inputs.length&&this.setVersion(2);const r=(e,t,r,n)=>Object.defineProperty(e,t,{enumerable:r,writable:n});r(this,"__CACHE",!1,!0),r(this,"opts",!1,!0)}get inputCount(){return this.data.inputs.length}get version(){return this.__CACHE.__TX.version}set version(e){this.setVersion(e)}get locktime(){return this.__CACHE.__TX.locktime}set locktime(e){this.setLocktime(e)}get txInputs(){return this.__CACHE.__TX.ins.map((e=>({hash:(0,f.cloneBuffer)(e.hash),index:e.index,sequence:e.sequence})))}get txOutputs(){return this.__CACHE.__TX.outs.map((e=>{let t;try{t=(0,a.fromOutputScript)(e.script,this.opts.network)}catch(e){}return{script:(0,f.cloneBuffer)(e.script),value:e.value,address:t}}))}combine(...e){return this.data.combine(...e.map((e=>e.data))),this}clone(){const e=g.fromBuffer(this.data.toBuffer());return e.opts=JSON.parse(JSON.stringify(this.opts)),e}setMaximumFeeRate(e){I(e),this.opts.maximumFeeRate=e}setVersion(e){I(e),A(this.data.inputs,"setVersion");const t=this.__CACHE;return t.__TX.version=e,t.__EXTRACTED_TX=void 0,this}setLocktime(e){I(e),A(this.data.inputs,"setLocktime");const t=this.__CACHE;return t.__TX.locktime=e,t.__EXTRACTED_TX=void 0,this}setInputSequence(e,t){I(t),A(this.data.inputs,"setInputSequence");const r=this.__CACHE;if(r.__TX.ins.length<=e)throw new Error("Input index too high");return r.__TX.ins[e].sequence=t,r.__EXTRACTED_TX=void 0,this}addInputs(e){return e.forEach((e=>this.addInput(e))),this}addInput(e){if(arguments.length>1||!e||void 0===e.hash||void 0===e.index)throw new Error("Invalid arguments for Psbt.addInput. Requires single object with at least [hash] and [index]");(0,p.checkTaprootInputFields)(e,e,"addInput"),A(this.data.inputs,"addInput"),e.witnessScript&&Y(e.witnessScript);const t=this.__CACHE;this.data.addInput(e),k(t,t.__TX.ins[t.__TX.ins.length-1]);const r=this.data.inputs.length-1,n=this.data.inputs[r];return n.nonWitnessUtxo&&V(this.__CACHE,n,r),t.__FEE=void 0,t.__FEE_RATE=void 0,t.__EXTRACTED_TX=void 0,this}addOutputs(e){return e.forEach((e=>this.addOutput(e))),this}addOutput(e){if(arguments.length>1||!e||void 0===e.value||void 0===e.address&&void 0===e.script)throw new Error("Invalid arguments for Psbt.addOutput. Requires single object with at least [script or address] and [value]");A(this.data.inputs,"addOutput");const{address:t}=e;if("string"==typeof t){const{network:r}=this.opts,n=(0,a.toOutputScript)(t,r);e=Object.assign({},e,{script:n})}(0,p.checkTaprootOutputFields)(e,e,"addOutput");const r=this.__CACHE;return this.data.addOutput(e),r.__FEE=void 0,r.__FEE_RATE=void 0,r.__EXTRACTED_TX=void 0,this}extractTransaction(e){if(!this.data.inputs.every(E))throw new Error("Not finalized");const t=this.__CACHE;if(e||function(e,t,r){const n=t.__FEE_RATE||e.getFeeRate(),i=t.__EXTRACTED_TX.virtualSize(),o=n*i;if(n>=r.maximumFeeRate)throw new Error(`Warning: You are paying around ${(o/1e8).toFixed(8)} in fees, which is ${n} satoshi per byte for a transaction with a VSize of ${i} bytes (segwit counted as 0.25 byte per byte). Use setMaximumFeeRate method to raise your threshold, or pass true to the first arg of extractTransaction.`)}(this,t,this.opts),t.__EXTRACTED_TX)return t.__EXTRACTED_TX;const r=t.__TX.clone();return j(this.data.inputs,r,t,!0),r}getFeeRate(){return x("__FEE_RATE","fee rate",this.data.inputs,this.__CACHE)}getFee(){return x("__FEE","fee",this.data.inputs,this.__CACHE)}finalizeAllInputs(){return(0,s.checkForInput)(this.data.inputs,0),$(this.data.inputs.length).forEach((e=>this.finalizeInput(e))),this}finalizeInput(e,t){const r=(0,s.checkForInput)(this.data.inputs,e);return(0,p.isTaprootInput)(r)?this._finalizeTaprootInput(e,r,void 0,t):this._finalizeInput(e,r,t)}finalizeTaprootInput(e,t,r=p.tapScriptFinalizer){const n=(0,s.checkForInput)(this.data.inputs,e);if((0,p.isTaprootInput)(n))return this._finalizeTaprootInput(e,n,t,r);throw new Error(`Cannot finalize input #${e}. Not Taproot.`)}_finalizeInput(e,t,r=B){const{script:n,isP2SH:i,isP2WSH:o,isSegwit:s}=function(e,t,r){const n=r.__TX,i={script:null,isSegwit:!1,isP2SH:!1,isP2WSH:!1};if(i.isP2SH=!!t.redeemScript,i.isP2WSH=!!t.witnessScript,t.witnessScript)i.script=t.witnessScript;else if(t.redeemScript)i.script=t.redeemScript;else if(t.nonWitnessUtxo){const o=F(r,t,e),s=n.ins[e].index;i.script=o.outs[s].script}else t.witnessUtxo&&(i.script=t.witnessUtxo.script);return(t.witnessScript||(0,b.isP2WPKH)(i.script))&&(i.isSegwit=!0),i}(e,t,this.__CACHE);if(!n)throw new Error(`No script found for input #${e}`);!function(e){if(!e.sighashType||!e.partialSig)return;const{partialSig:t,sighashType:r}=e;t.forEach((e=>{const{hashType:t}=d.signature.decode(e.signature);if(r!==t)throw new Error("Signature sighash does not match input sighash type")}))}(t);const{finalScriptSig:a,finalScriptWitness:f}=r(e,t,n,s,i,o);if(a&&this.data.updateInput(e,{finalScriptSig:a}),f&&this.data.updateInput(e,{finalScriptWitness:f}),!a&&!f)throw new Error(`Unknown error finalizing input #${e}`);return this.data.clearFinalizedInput(e),this}_finalizeTaprootInput(e,t,r,n=p.tapScriptFinalizer){if(!t.witnessUtxo)throw new Error(`Cannot finalize input #${e}. Missing withness utxo.`);if(t.tapKeySig){const r=c.p2tr({output:t.witnessUtxo.script,signature:t.tapKeySig}),n=(0,b.witnessStackToScriptWitness)(r.witness);this.data.updateInput(e,{finalScriptWitness:n})}else{const{finalScriptWitness:i}=n(e,t,r);this.data.updateInput(e,{finalScriptWitness:i})}return this.data.clearFinalizedInput(e),this}getInputType(e){const t=(0,s.checkForInput)(this.data.inputs,e),r=G(q(e,t,this.__CACHE),e,"input",t.redeemScript||function(e){if(!e)return;const t=d.decompile(e);if(!t)return;const r=t[t.length-1];var i;if(n.isBuffer(r)&&!z(r)&&(i=r,!d.isCanonicalScriptSignature(i))&&d.decompile(r))return r}(t.finalScriptSig),t.witnessScript||function(e){if(!e)return;const t=K(e),r=t[t.length-1];return!z(r)&&d.decompile(r)?r:void 0}(t.finalScriptWitness));return("raw"===r.type?"":r.type+"-")+X(r.meaningfulScript)}inputHasPubkey(e,t){return function(e,t,r,n){const i=q(r,t,n),{meaningfulScript:o}=G(i,r,"input",t.redeemScript,t.witnessScript);return(0,b.pubkeyInScript)(e,o)}(t,(0,s.checkForInput)(this.data.inputs,e),e,this.__CACHE)}inputHasHDKey(e,t){const r=(0,s.checkForInput)(this.data.inputs,e),n=S(t);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}outputHasPubkey(e,t){return function(e,t,r,n){const i=n.__TX.outs[r].script,{meaningfulScript:o}=G(i,r,"output",t.redeemScript,t.witnessScript);return(0,b.pubkeyInScript)(e,o)}(t,(0,s.checkForOutput)(this.data.outputs,e),e,this.__CACHE)}outputHasHDKey(e,t){const r=(0,s.checkForOutput)(this.data.outputs,e),n=S(t);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}validateSignaturesOfAllInputs(e){return(0,s.checkForInput)(this.data.inputs,0),$(this.data.inputs.length).map((t=>this.validateSignaturesOfInput(t,e))).reduce(((e,t)=>!0===t&&e),!0)}validateSignaturesOfInput(e,t,r){const n=this.data.inputs[e];return(0,p.isTaprootInput)(n)?this.validateSignaturesOfTaprootInput(e,t,r):this._validateSignaturesOfInput(e,t,r)}_validateSignaturesOfInput(e,t,r){const n=this.data.inputs[e],i=(n||{}).partialSig;if(!n||!i||i.length<1)throw new Error("No signatures to validate");if("function"!=typeof t)throw new Error("Need validator function to validate signatures");const o=r?i.filter((e=>e.pubkey.equals(r))):i;if(o.length<1)throw new Error("No signatures for this pubkey");const s=[];let a,f,u;for(const r of o){const i=d.signature.decode(r.signature),{hash:o,script:c}=u!==i.hashType?R(e,Object.assign({},n,{sighashType:i.hashType}),this.__CACHE,!0):{hash:a,script:f};u=i.hashType,a=o,f=c,T(r.pubkey,c,"verify"),s.push(t(r.pubkey,o,i.signature))}return s.every((e=>!0===e))}validateSignaturesOfTaprootInput(e,t,r){const n=this.data.inputs[e],i=(n||{}).tapKeySig,o=(n||{}).tapScriptSig;if(!n&&!i&&(!o||o.length))throw new Error("No signatures to validate");if("function"!=typeof t)throw new Error("Need validator function to validate signatures");const s=(r=r&&(0,p.toXOnly)(r))?C(e,n,this.data.inputs,r,this.__CACHE):function(e,t,r,n){const i=[];if(t.tapInternalKey){const r=N(e,t,n);r&&i.push(r)}if(t.tapScriptSig){const e=t.tapScriptSig.map((e=>e.pubkey));i.push(...e)}return i.map((i=>C(e,t,r,i,n))).flat()}(e,n,this.data.inputs,this.__CACHE);if(!s.length)throw new Error("No signatures for this pubkey");const a=s.find((e=>!e.leafHash));let f=0;if(i&&a){if(!t(a.pubkey,a.hash,U(i)))return!1;f++}if(o)for(const e of o){const r=s.find((t=>e.pubkey.equals(t.pubkey)));if(r){if(!t(e.pubkey,r.hash,U(e.signature)))return!1;f++}}return f>0}signAllInputsHD(e,t=[l.Transaction.SIGHASH_ALL]){if(!e||!e.publicKey||!e.fingerprint)throw new Error("Need HDSigner to sign input");const r=[];for(const n of $(this.data.inputs.length))try{this.signInputHD(n,e,t),r.push(!0)}catch(e){r.push(!1)}if(r.every((e=>!1===e)))throw new Error("No inputs were signed");return this}signAllInputsHDAsync(e,t=[l.Transaction.SIGHASH_ALL]){return new Promise(((r,n)=>{if(!e||!e.publicKey||!e.fingerprint)return n(new Error("Need HDSigner to sign input"));const i=[],o=[];for(const r of $(this.data.inputs.length))o.push(this.signInputHDAsync(r,e,t).then((()=>{i.push(!0)}),(()=>{i.push(!1)})));return Promise.all(o).then((()=>{if(i.every((e=>!1===e)))return n(new Error("No inputs were signed"));r()}))}))}signInputHD(e,t,r=[l.Transaction.SIGHASH_ALL]){if(!t||!t.publicKey||!t.fingerprint)throw new Error("Need HDSigner to sign input");return D(e,this.data.inputs,t).forEach((t=>this.signInput(e,t,r))),this}signInputHDAsync(e,t,r=[l.Transaction.SIGHASH_ALL]){return new Promise(((n,i)=>{if(!t||!t.publicKey||!t.fingerprint)return i(new Error("Need HDSigner to sign input"));const o=D(e,this.data.inputs,t).map((t=>this.signInputAsync(e,t,r)));return Promise.all(o).then((()=>{n()})).catch(i)}))}signAllInputs(e,t){if(!e||!e.publicKey)throw new Error("Need Signer to sign input");const r=[];for(const n of $(this.data.inputs.length))try{this.signInput(n,e,t),r.push(!0)}catch(e){r.push(!1)}if(r.every((e=>!1===e)))throw new Error("No inputs were signed");return this}signAllInputsAsync(e,t){return new Promise(((r,n)=>{if(!e||!e.publicKey)return n(new Error("Need Signer to sign input"));const i=[],o=[];for(const[r]of this.data.inputs.entries())o.push(this.signInputAsync(r,e,t).then((()=>{i.push(!0)}),(()=>{i.push(!1)})));return Promise.all(o).then((()=>{if(i.every((e=>!1===e)))return n(new Error("No inputs were signed"));r()}))}))}signInput(e,t,r){if(!t||!t.publicKey)throw new Error("Need Signer to sign input");const n=(0,s.checkForInput)(this.data.inputs,e);return(0,p.isTaprootInput)(n)?this._signTaprootInput(e,n,t,void 0,r):this._signInput(e,t,r)}signTaprootInput(e,t,r,n){if(!t||!t.publicKey)throw new Error("Need Signer to sign input");const i=(0,s.checkForInput)(this.data.inputs,e);if((0,p.isTaprootInput)(i))return this._signTaprootInput(e,i,t,r,n);throw new Error(`Input #${e} is not of type Taproot.`)}_signInput(e,t,r=[l.Transaction.SIGHASH_ALL]){const{hash:n,sighashType:i}=L(this.data.inputs,e,t.publicKey,this.__CACHE,r),o=[{pubkey:t.publicKey,signature:d.signature.encode(t.sign(n),i)}];return this.data.updateInput(e,{partialSig:o}),this}_signTaprootInput(e,t,r,n,i=[l.Transaction.SIGHASH_DEFAULT]){const o=this.checkTaprootHashesForSig(e,t,r,n,i),s=o.filter((e=>!e.leafHash)).map((e=>(0,p.serializeTaprootSignature)(r.signSchnorr(e.hash),t.sighashType)))[0],a=o.filter((e=>!!e.leafHash)).map((e=>({pubkey:(0,p.toXOnly)(r.publicKey),signature:(0,p.serializeTaprootSignature)(r.signSchnorr(e.hash),t.sighashType),leafHash:e.leafHash})));return s&&this.data.updateInput(e,{tapKeySig:s}),a.length&&this.data.updateInput(e,{tapScriptSig:a}),this}signInputAsync(e,t,r){return Promise.resolve().then((()=>{if(!t||!t.publicKey)throw new Error("Need Signer to sign input");const n=(0,s.checkForInput)(this.data.inputs,e);return(0,p.isTaprootInput)(n)?this._signTaprootInputAsync(e,n,t,void 0,r):this._signInputAsync(e,t,r)}))}signTaprootInputAsync(e,t,r,n){return Promise.resolve().then((()=>{if(!t||!t.publicKey)throw new Error("Need Signer to sign input");const i=(0,s.checkForInput)(this.data.inputs,e);if((0,p.isTaprootInput)(i))return this._signTaprootInputAsync(e,i,t,r,n);throw new Error(`Input #${e} is not of type Taproot.`)}))}_signInputAsync(e,t,r=[l.Transaction.SIGHASH_ALL]){const{hash:n,sighashType:i}=L(this.data.inputs,e,t.publicKey,this.__CACHE,r);return Promise.resolve(t.sign(n)).then((r=>{const n=[{pubkey:t.publicKey,signature:d.signature.encode(r,i)}];this.data.updateInput(e,{partialSig:n})}))}async _signTaprootInputAsync(e,t,r,n,i=[l.Transaction.SIGHASH_DEFAULT]){const o=this.checkTaprootHashesForSig(e,t,r,n,i),s=[],a=o.filter((e=>!e.leafHash))[0];if(a){const e=Promise.resolve(r.signSchnorr(a.hash)).then((e=>({tapKeySig:(0,p.serializeTaprootSignature)(e,t.sighashType)})));s.push(e)}const f=o.filter((e=>!!e.leafHash));if(f.length){const e=f.map((e=>Promise.resolve(r.signSchnorr(e.hash)).then((n=>({tapScriptSig:[{pubkey:(0,p.toXOnly)(r.publicKey),signature:(0,p.serializeTaprootSignature)(n,t.sighashType),leafHash:e.leafHash}]})))));s.push(...e)}return Promise.all(s).then((t=>{t.forEach((t=>this.data.updateInput(e,t)))}))}checkTaprootHashesForSig(e,t,r,n,i){if("function"!=typeof r.signSchnorr)throw new Error(`Need Schnorr Signer to sign taproot input #${e}.`);const o=C(e,t,this.data.inputs,r.publicKey,this.__CACHE,n,i);if(!o||!o.length)throw new Error(`Can not sign for input #${e} with the key ${r.publicKey.toString("hex")}`);return o}toBuffer(){return v(this.__CACHE),this.data.toBuffer()}toHex(){return v(this.__CACHE),this.data.toHex()}toBase64(){return v(this.__CACHE),this.data.toBase64()}updateGlobal(e){return this.data.updateGlobal(e),this}updateInput(e,t){return t.witnessScript&&Y(t.witnessScript),(0,p.checkTaprootInputFields)(this.data.inputs[e],t,"updateInput"),this.data.updateInput(e,t),t.nonWitnessUtxo&&V(this.__CACHE,this.data.inputs[e],e),this}updateOutput(e,t){const r=this.data.outputs[e];return(0,p.checkTaprootOutputFields)(r,t,"updateOutput"),this.data.updateOutput(e,t),this}addUnknownKeyValToGlobal(e){return this.data.addUnknownKeyValToGlobal(e),this}addUnknownKeyValToInput(e,t){return this.data.addUnknownKeyValToInput(e,t),this}addUnknownKeyValToOutput(e,t){return this.data.addUnknownKeyValToOutput(e,t),this}clearFinalizedInput(e){return this.data.clearFinalizedInput(e),this}}t.Psbt=g;const w=e=>new m(e);class m{constructor(e=n.from([2,0,0,0,0,0,0,0,0,0])){this.tx=l.Transaction.fromBuffer(e),function(e){if(!e.ins.every((e=>e.script&&0===e.script.length&&e.witness&&0===e.witness.length)))throw new Error("Format Error: Transaction ScriptSigs are not empty")}(this.tx),Object.defineProperty(this,"tx",{enumerable:!1,writable:!0})}getInputOutputCounts(){return{inputCount:this.tx.ins.length,outputCount:this.tx.outs.length}}addInput(e){if(void 0===e.hash||void 0===e.index||!n.isBuffer(e.hash)&&"string"!=typeof e.hash||"number"!=typeof e.index)throw new Error("Error adding input.");const t="string"==typeof e.hash?(0,f.reverseBuffer)(n.from(e.hash,"hex")):e.hash;this.tx.addInput(t,e.index,e.sequence)}addOutput(e){if(void 0===e.script||void 0===e.value||!n.isBuffer(e.script)||"number"!=typeof e.value)throw new Error("Error adding output.");this.tx.addOutput(e.script,e.value)}toBuffer(){return this.tx.toBuffer()}}function v(e){if(!1!==e.__UNSAFE_SIGN_NONSEGWIT)throw new Error("Not BIP174 compliant, can not export")}function _(e,t,r){if(!t)return!1;let n;if(n=r?r.map((e=>{const r=function(e){if(65===e.length){const t=1&e[64],r=e.slice(0,33);return r[0]=2|t,r}return e.slice()}(e);return t.find((e=>e.pubkey.equals(r)))})).filter((e=>!!e)):t,n.length>e)throw new Error("Too many signatures");return n.length===e}function E(e){return!!e.finalScriptSig||!!e.finalScriptWitness}function S(e){return t=>!!t.masterFingerprint.equals(e.fingerprint)&&!!e.derivePath(t.path).publicKey.equals(t.pubkey)}function I(e){if("number"!=typeof e||e!==Math.floor(e)||e>4294967295||e<0)throw new Error("Invalid 32 bit integer")}function A(e,t){e.forEach((e=>{if((0,p.isTaprootInput)(e)?(0,p.checkTaprootInputForSigs)(e,t):(0,b.checkInputForSig)(e,t))throw new Error("Can not modify transaction, signatures exist.")}))}function T(e,t,r){if(!(0,b.pubkeyInScript)(e,t))throw new Error(`Can not ${r} for this input with the key ${e.toString("hex")}`)}function k(e,t){const r=(0,f.reverseBuffer)(n.from(t.hash)).toString("hex")+":"+t.index;if(e.__TX_IN_CACHE[r])throw new Error("Duplicate input detected.");e.__TX_IN_CACHE[r]=1}function P(e,t){return(r,n,i,o)=>{const s=e({redeem:{output:i}}).output;if(!n.equals(s))throw new Error(`${t} for ${o} #${r} doesn't match the scriptPubKey in the prevout`)}}const O=P(c.p2sh,"Redeem script"),M=P(c.p2wsh,"Witness script");function x(e,t,r,n){if(!r.every(E))throw new Error(`PSBT must be finalized to calculate ${t}`);if("__FEE_RATE"===e&&n.__FEE_RATE)return n.__FEE_RATE;if("__FEE"===e&&n.__FEE)return n.__FEE;let i,o=!0;return n.__EXTRACTED_TX?(i=n.__EXTRACTED_TX,o=!1):i=n.__TX.clone(),j(r,i,n,o),"__FEE_RATE"===e?n.__FEE_RATE:"__FEE"===e?n.__FEE:void 0}function B(e,t,r,n,i,o){const s=X(r);if(!function(e,t,r){switch(r){case"pubkey":case"pubkeyhash":case"witnesspubkeyhash":return _(1,e.partialSig);case"multisig":const r=c.p2ms({output:t});return _(r.m,e.partialSig,r.pubkeys);default:return!1}}(t,r,s))throw new Error(`Can not finalize input #${e}`);return function(e,t,r,n,i,o){let s,a;const f=function(e,t,r){let n;switch(t){case"multisig":const t=function(e,t){return c.p2ms({output:e}).pubkeys.map((e=>(t.filter((t=>t.pubkey.equals(e)))[0]||{}).signature)).filter((e=>!!e))}(e,r);n=c.p2ms({output:e,signatures:t});break;case"pubkey":n=c.p2pk({output:e,signature:r[0].signature});break;case"pubkeyhash":n=c.p2pkh({output:e,pubkey:r[0].pubkey,signature:r[0].signature});break;case"witnesspubkeyhash":n=c.p2wpkh({output:e,pubkey:r[0].pubkey,signature:r[0].signature})}return n}(e,t,r),u=o?c.p2wsh({redeem:f}):null,h=i?c.p2sh({redeem:u||f}):null;return n?(a=u?(0,b.witnessStackToScriptWitness)(u.witness):(0,b.witnessStackToScriptWitness)(f.witness),h&&(s=h.input)):s=h?h.input:f.input,{finalScriptSig:s,finalScriptWitness:a}}(r,s,t.partialSig,n,i,o)}function L(e,t,r,n,i){const o=(0,s.checkForInput)(e,t),{hash:a,sighashType:f,script:u}=R(t,o,n,!1,i);return T(r,u,"sign"),{hash:a,sighashType:f}}function R(e,t,r,n,i){const o=r.__TX,s=t.sighashType||l.Transaction.SIGHASH_ALL;let a,f;if(H(s,i),t.nonWitnessUtxo){const n=F(r,t,e),i=o.ins[e].hash,s=n.getHash();if(!i.equals(s))throw new Error(`Non-witness UTXO hash for input #${e} doesn't match the hash specified in the prevout`);const a=o.ins[e].index;f=n.outs[a]}else{if(!t.witnessUtxo)throw new Error("Need a Utxo input item for signing");f=t.witnessUtxo}const{meaningfulScript:u,type:h}=G(f.script,e,"input",t.redeemScript,t.witnessScript);if(["p2sh-p2wsh","p2wsh"].indexOf(h)>=0)a=o.hashForWitnessV0(e,u,f.value,s);else if((0,b.isP2WPKH)(u)){const t=c.p2pkh({hash:u.slice(2)}).output;a=o.hashForWitnessV0(e,t,f.value,s)}else{if(void 0===t.nonWitnessUtxo&&!1===r.__UNSAFE_SIGN_NONSEGWIT)throw new Error(`Input #${e} has witnessUtxo but non-segwit script: ${u.toString("hex")}`);n||!1===r.__UNSAFE_SIGN_NONSEGWIT||console.warn("Warning: Signing non-segwit inputs without the full parent transaction means there is a chance that a miner could feed you incorrect information to trick you into paying large fees. This behavior is the same as Psbt's predecessor (TransactionBuilder - now removed) when signing non-segwit scripts. You are not able to export this Psbt with toBuffer|toBase64|toHex since it is not BIP174 compliant.\n*********************\nPROCEED WITH CAUTION!\n*********************"),a=o.hashForSignature(e,u,s)}return{script:u,sighashType:s,hash:a}}function N(e,t,r){const{script:n}=W(e,t,r);return(0,b.isP2TR)(n)?n.subarray(2,34):null}function U(e){return 64===e.length?e:e.subarray(0,64)}function C(e,t,r,i,o,s,a){const f=o.__TX,u=t.sighashType||l.Transaction.SIGHASH_DEFAULT;H(u,a);const c=r.map(((e,t)=>W(t,e,o))),d=c.map((e=>e.script)),y=c.map((e=>e.value)),g=[];if(t.tapInternalKey&&!s){const r=N(e,t,o)||n.from([]);if((0,p.toXOnly)(i).equals(r)){const t=f.hashForWitnessV1(e,d,y,u);g.push({pubkey:i,hash:t})}}const w=(t.tapLeafScript||[]).filter((e=>(0,b.pubkeyInScript)(i,e.script))).map((e=>{const t=(0,h.tapleafHash)({output:e.script,version:e.leafVersion});return Object.assign({hash:t},e)})).filter((e=>!s||s.equals(e.hash))).map((t=>{const r=f.hashForWitnessV1(e,d,y,u,t.hash);return{pubkey:i,hash:r,leafHash:t.hash}}));return g.concat(w)}function H(e,t){if(t&&t.indexOf(e)<0){const t=function(e){let t=e&l.Transaction.SIGHASH_ANYONECANPAY?"SIGHASH_ANYONECANPAY | ":"";switch(31&e){case l.Transaction.SIGHASH_ALL:t+="SIGHASH_ALL";break;case l.Transaction.SIGHASH_SINGLE:t+="SIGHASH_SINGLE";break;case l.Transaction.SIGHASH_NONE:t+="SIGHASH_NONE"}return t}(e);throw new Error(`Sighash type is not allowed. Retry the sign method passing the sighashTypes array of whitelisted types. Sighash type: ${t}`)}}function D(e,t,r){const n=(0,s.checkForInput)(t,e);if(!n.bip32Derivation||0===n.bip32Derivation.length)throw new Error("Need bip32Derivation to sign with HD");const i=n.bip32Derivation.map((e=>e.masterFingerprint.equals(r.fingerprint)?e:void 0)).filter((e=>!!e));if(0===i.length)throw new Error("Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint");return i.map((e=>{const t=r.derivePath(e.path);if(!e.pubkey.equals(t.publicKey))throw new Error("pubkey did not match bip32Derivation");return t}))}function K(e){let t=0;function r(){const r=o.decode(e,t);return t+=o.decode.bytes,r}return function(){const n=r(),i=[];for(let s=0;s{if(n&&e.finalScriptSig&&(t.ins[o].script=e.finalScriptSig),n&&e.finalScriptWitness&&(t.ins[o].witness=K(e.finalScriptWitness)),e.witnessUtxo)i+=e.witnessUtxo.value;else if(e.nonWitnessUtxo){const n=F(r,e,o),s=t.ins[o].index,a=n.outs[s];i+=a.value}}));const o=t.outs.reduce(((e,t)=>e+t.value),0),s=i-o;if(s<0)throw new Error("Outputs are spending more than Inputs");const a=t.virtualSize();r.__FEE=s,r.__EXTRACTED_TX=t,r.__FEE_RATE=Math.floor(s/a)}function F(e,t,r){const n=e.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||V(e,t,r),n[r]}function q(e,t,r){const{script:n}=W(e,t,r);return n}function W(e,t,r){if(void 0!==t.witnessUtxo)return{script:t.witnessUtxo.script,value:t.witnessUtxo.value};if(void 0!==t.nonWitnessUtxo){const n=F(r,t,e).outs[r.__TX.ins[e].index];return{script:n.script,value:n.value}}throw new Error("Can't find pubkey in input without Utxo data")}function z(e){return 33===e.length&&d.isCanonicalPubKey(e)}function G(e,t,r,n,i){const o=(0,b.isP2SHScript)(e),s=o&&n&&(0,b.isP2WSHScript)(n),a=(0,b.isP2WSHScript)(e);if(o&&void 0===n)throw new Error("scriptPubkey is P2SH but redeemScript missing");if((a||s)&&void 0===i)throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");let f;return s?(f=i,O(t,e,n,r),M(t,n,i,r),Y(f)):a?(f=i,M(t,e,i,r),Y(f)):o?(f=n,O(t,e,n,r)):f=e,{meaningfulScript:f,type:s?"p2sh-p2wsh":o?"p2sh":a?"p2wsh":"raw"}}function Y(e){if((0,b.isP2WPKH)(e)||(0,b.isP2SHScript)(e))throw new Error("P2WPKH or P2SH can not be contained within P2WSH")}function X(e){return(0,b.isP2WPKH)(e)?"witnesspubkeyhash":(0,b.isP2PKH)(e)?"pubkeyhash":(0,b.isP2MS)(e)?"multisig":(0,b.isP2PK)(e)?"pubkey":"nonstandard"}function $(e){return[...Array(e).keys()]}},6412:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.checkTaprootInputForSigs=t.tapTreeFromList=t.tapTreeToList=t.tweakInternalPubKey=t.checkTaprootOutputFields=t.checkTaprootInputFields=t.isTaprootOutput=t.isTaprootInput=t.serializeTaprootSignature=t.tapScriptFinalizer=t.toXOnly=void 0;const i=r(5593),o=r(5444),s=r(8990),a=r(5247),f=r(8614),u=r(8990);function c(e){return e&&!!(e.tapInternalKey||e.tapMerkleRoot||e.tapLeafScript&&e.tapLeafScript.length||e.tapBip32Derivation&&e.tapBip32Derivation.length||e.witnessUtxo&&(0,s.isP2TR)(e.witnessUtxo.script))}function h(e,t){return e&&!!(e.tapInternalKey||e.tapTree||e.tapBip32Derivation&&e.tapBip32Derivation.length||t&&(0,s.isP2TR)(t))}function d(e=[]){return 1===e.length&&0===e[0].depth?{output:e[0].script,version:e[0].leafVersion}:function(e){let t;for(const r of e)if(t=b(r,t),!t)throw new Error("No room left to insert tapleaf in tree");return t}(e)}function l(e){return{signature:e.slice(0,64),hashType:e.slice(64)[0]||o.Transaction.SIGHASH_DEFAULT}}function p(e,t=[],r=0){if(r>a.MAX_TAPTREE_DEPTH)throw new Error("Max taptree depth exceeded.");return e?(0,i.isTapleaf)(e)?(t.push({depth:r,leafVersion:e.version||a.LEAF_VERSION_TAPSCRIPT,script:e.output}),t):(e[0]&&p(e[0],t,r+1),e[1]&&p(e[1],t,r+1),t):[]}function b(e,t,r=0){if(r>a.MAX_TAPTREE_DEPTH)throw new Error("Max taptree depth exceeded.");if(e.depth===r)return t?void 0:{output:e.script,version:e.leafVersion};if((0,i.isTapleaf)(t))return;const n=b(e,t&&t[0],r+1);if(n)return[n,t&&t[1]];const o=b(e,t&&t[1],r+1);return o?[t&&t[0],o]:void 0}function y(e,t){if(!t)return!0;const r=(0,a.tapleafHash)({output:e.script,version:e.leafVersion});return(0,a.rootHashFromPath)(e.controlBlock,r).equals(t)}function g(e){return e&&!!(e.redeemScript||e.witnessScript||e.bip32Derivation&&e.bip32Derivation.length)}t.toXOnly=e=>32===e.length?e:e.slice(1,33),t.tapScriptFinalizer=function(e,t,r){const n=function(e,t,r){if(!e.tapScriptSig||!e.tapScriptSig.length)throw new Error(`Can not finalize taproot input #${t}. No tapleaf script signature provided.`);const n=(e.tapLeafScript||[]).sort(((e,t)=>e.controlBlock.length-t.controlBlock.length)).find((t=>function(e,t,r){const n=(0,a.tapleafHash)({output:e.script,version:e.leafVersion});return(!r||r.equals(n))&&void 0!==t.find((e=>e.leafHash.equals(n)))}(t,e.tapScriptSig,r)));if(!n)throw new Error(`Can not finalize taproot input #${t}. Signature for tapleaf script not found.`);return n}(t,e,r);try{const e=function(e,t){const r=(0,a.tapleafHash)({output:t.script,version:t.leafVersion});return(e.tapScriptSig||[]).filter((e=>e.leafHash.equals(r))).map((e=>function(e,t){return Object.assign({positionInScript:(0,s.pubkeyPositionInScript)(t.pubkey,e)},t)}(t.script,e))).sort(((e,t)=>t.positionInScript-e.positionInScript)).map((e=>e.signature))}(t,n),r=e.concat(n.script).concat(n.controlBlock);return{finalScriptWitness:(0,s.witnessStackToScriptWitness)(r)}}catch(t){throw new Error(`Can not finalize taproot input #${e}: ${t}`)}},t.serializeTaprootSignature=function(e,t){const r=t?n.from([t]):n.from([]);return n.concat([e,r])},t.isTaprootInput=c,t.isTaprootOutput=h,t.checkTaprootInputFields=function(e,t,r){!function(e,t,r){const n=c(e)&&g(t),i=g(e)&&c(t),o=e===t&&c(t)&&g(t);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}(e,t,r),function(e,t,r){if(t.tapMerkleRoot){const n=(t.tapLeafScript||[]).every((e=>y(e,t.tapMerkleRoot))),i=(e.tapLeafScript||[]).every((e=>y(e,t.tapMerkleRoot)));if(!n||!i)throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}else if(e.tapMerkleRoot&&!(t.tapLeafScript||[]).every((t=>y(t,e.tapMerkleRoot))))throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}(e,t,r)},t.checkTaprootOutputFields=function(e,t,r){!function(e,t,r){const n=h(e)&&g(t),i=g(e)&&h(t),o=e===t&&h(t)&&g(t);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}(e,t,r),function(e,t){if(!t.tapTree&&!t.tapInternalKey)return;const r=t.tapInternalKey||e.tapInternalKey,n=t.tapTree||e.tapTree;if(r){const{script:t}=e,i=function(e,t){const r=t&&d(t.leaves),{output:n}=(0,f.p2tr)({internalPubkey:e,scriptTree:r});return n}(r,n);if(t&&!t.equals(i))throw new Error("Error adding output. Script or address missmatch.")}}(e,t)},t.tweakInternalPubKey=function(e,t){const r=t.tapInternalKey,n=r&&(0,a.tweakKey)(r,t.tapMerkleRoot);if(!n)throw new Error(`Cannot tweak tap internal key for input #${e}. Public key: ${r&&r.toString("hex")}`);return n.x},t.tapTreeToList=function(e){if(!(0,i.isTaptree)(e))throw new Error("Cannot convert taptree to tapleaf list. Expecting a tapree structure.");return p(e)},t.tapTreeFromList=d,t.checkTaprootInputForSigs=function(e,t){return function(e){const t=[];if(e.tapKeySig&&t.push(e.tapKeySig),e.tapScriptSig&&t.push(...e.tapScriptSig.map((e=>e.signature))),!t.length){const r=function(e){if(!e)return;const t=e.slice(2);return 64===t.length||65===t.length?t:void 0}(e.finalScriptWitness);r&&t.push(r)}return t}(e).some((e=>(0,u.signatureBlocksAction)(e,l,t)))}},8990:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.signatureBlocksAction=t.checkInputForSig=t.pubkeyInScript=t.pubkeyPositionInScript=t.witnessStackToScriptWitness=t.isP2TR=t.isP2SHScript=t.isP2WSHScript=t.isP2WPKH=t.isP2PKH=t.isP2PK=t.isP2MS=void 0;const i=r(2715),o=r(4009),s=r(5444),a=r(6891),f=r(8614);function u(e){return t=>{try{return e({output:t}),!0}catch(e){return!1}}}function c(e,t){const r=(0,a.hash160)(e),n=e.slice(1,33),i=o.decompile(t);if(null===i)throw new Error("Unknown script error");return i.findIndex((t=>"number"!=typeof t&&(t.equals(e)||t.equals(r)||t.equals(n))))}function h(e,t,r){const{hashType:n}=t(e),i=[];switch(n&s.Transaction.SIGHASH_ANYONECANPAY&&i.push("addInput"),31&n){case s.Transaction.SIGHASH_ALL:break;case s.Transaction.SIGHASH_SINGLE:case s.Transaction.SIGHASH_NONE:i.push("addOutput"),i.push("setInputSequence")}return-1===i.indexOf(r)}t.isP2MS=u(f.p2ms),t.isP2PK=u(f.p2pk),t.isP2PKH=u(f.p2pkh),t.isP2WPKH=u(f.p2wpkh),t.isP2WSHScript=u(f.p2wsh),t.isP2SHScript=u(f.p2sh),t.isP2TR=u(f.p2tr),t.witnessStackToScriptWitness=function(e){let t=n.allocUnsafe(0);function r(e){const r=t.length,o=i.encodingLength(e);t=n.concat([t,n.allocUnsafe(o)]),i.encode(e,t,r)}var o;return r((o=e).length),o.forEach((function(e){r(e.length),function(e){t=n.concat([t,n.from(e)])}(e)})),t},t.pubkeyPositionInScript=c,t.pubkeyInScript=function(e,t){return-1!==c(e,t)},t.checkInputForSig=function(e,t){return function(e){let t=[];if(0===(e.partialSig||[]).length){if(!e.finalScriptSig&&!e.finalScriptWitness)return[];t=function(e){const t=e.finalScriptSig&&o.decompile(e.finalScriptSig)||[],r=e.finalScriptWitness&&o.decompile(e.finalScriptWitness)||[];return t.concat(r).filter((e=>n.isBuffer(e)&&o.isCanonicalScriptSignature(e))).map((e=>({signature:e})))}(e)}else t=e.partialSig;return t.map((e=>e.signature))}(e).some((e=>h(e,o.signature.decode,t)))},t.signatureBlocksAction=h},1213:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=t.encode=t.encodingLength=void 0;const n=r(8156);function i(e){return ee.length)return null;i=e.readUInt8(t+1),o=2}else if(r===n.OPS.OP_PUSHDATA2){if(t+3>e.length)return null;i=e.readUInt16LE(t+1),o=3}else{if(t+5>e.length)return null;if(r!==n.OPS.OP_PUSHDATA4)throw new Error("Unexpected opcode");i=e.readUInt32LE(t+1),o=5}return{opcode:r,number:i,size:o}}},4009:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.signature=t.number=t.isCanonicalScriptSignature=t.isDefinedHashType=t.isCanonicalPubKey=t.toStack=t.fromASM=t.toASM=t.decompile=t.compile=t.countNonPushOnlyOPs=t.isPushOnly=t.OPS=void 0;const i=r(195),o=r(8156);Object.defineProperty(t,"OPS",{enumerable:!0,get:function(){return o.OPS}});const s=r(1213),a=r(5333),f=r(1108),u=r(5593),{typeforce:c}=u,h=o.OPS.OP_RESERVED;function d(e){return u.Buffer(e)||function(e){return u.Number(e)&&(e===o.OPS.OP_0||e>=o.OPS.OP_1&&e<=o.OPS.OP_16||e===o.OPS.OP_1NEGATE)}(e)}function l(e){return u.Array(e)&&e.every(d)}function p(e){return 0===e.length?o.OPS.OP_0:1===e.length?e[0]>=1&&e[0]<=16?h+e[0]:129===e[0]?o.OPS.OP_1NEGATE:void 0:void 0}function b(e){return n.isBuffer(e)}function y(e){return n.isBuffer(e)}function g(e){if(b(e))return e;c(u.Array,e);const t=e.reduce(((e,t)=>y(t)?1===t.length&&void 0!==p(t)?e+1:e+s.encodingLength(t.length)+t.length:e+1),0),r=n.allocUnsafe(t);let i=0;if(e.forEach((e=>{if(y(e)){const t=p(e);if(void 0!==t)return r.writeUInt8(t,i),void(i+=1);i+=s.encode(r,e.length,i),e.copy(r,i),i+=e.length}else r.writeUInt8(e,i),i+=1})),i!==r.length)throw new Error("Could not decode chunks");return r}function w(e){if(t=e,u.Array(t))return e;var t;c(u.Buffer,e);const r=[];let n=0;for(;no.OPS.OP_0&&t<=o.OPS.OP_PUSHDATA4){const t=s.decode(e,n);if(null===t)return null;if(n+=t.size,n+t.number>e.length)return null;const i=e.slice(n,n+t.number);n+=t.number;const o=p(i);void 0!==o?r.push(o):r.push(i)}else r.push(t),n+=1}return r}function m(e){const t=-129&e;return t>0&&t<4}t.isPushOnly=l,t.countNonPushOnlyOPs=function(e){return e.length-e.filter(d).length},t.compile=g,t.decompile=w,t.toASM=function(e){if(b(e)&&(e=w(e)),!e)throw new Error("Could not convert invalid chunks to ASM");return e.map((e=>{if(y(e)){const t=p(e);if(void 0===t)return e.toString("hex");e=t}return o.REVERSE_OPS[e]})).join(" ")},t.fromASM=function(e){return c(u.String,e),g(e.split(" ").map((e=>void 0!==o.OPS[e]?o.OPS[e]:(c(u.Hex,e),n.from(e,"hex")))))},t.toStack=function(e){return e=w(e),c(l,e),e.map((e=>y(e)?e:e===o.OPS.OP_0?n.allocUnsafe(0):a.encode(e-h)))},t.isCanonicalPubKey=function(e){return u.isPoint(e)},t.isDefinedHashType=m,t.isCanonicalScriptSignature=function(e){return!!n.isBuffer(e)&&!!m(e[e.length-1])&&i.check(e.slice(0,-1))},t.number=a,t.signature=f},5333:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.encode=t.decode=void 0,t.decode=function(e,t,r){t=t||4,r=void 0===r||r;const n=e.length;if(0===n)return 0;if(n>t)throw new TypeError("Script number overflow");if(r&&!(127&e[n-1]||!(n<=1)&&128&e[n-2]))throw new Error("Non-minimally encoded script number");if(5===n){const t=e.readUInt32LE(0),r=e.readUInt8(4);return 128&r?-(4294967296*(-129&r)+t):4294967296*r+t}let i=0;for(let t=0;t2147483647?5:i>8388607?4:i>32767?3:i>127?2:i>0?1:0;var i;const o=n.allocUnsafe(r),s=e<0;for(let e=0;e>=8;return 128&o[r-1]?o.writeUInt8(s?128:0,r-1):s&&(o[r-1]|=128),o}},1108:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.encode=t.decode=void 0;const i=r(195),o=r(4009),s=r(5593),{typeforce:a}=s,f=n.alloc(1,0);function u(e){let t=0;for(;0===e[t];)++t;return t===e.length?f:128&(e=e.slice(t))[0]?n.concat([f,e],1+e.length):e}function c(e){0===e[0]&&(e=e.slice(1));const t=n.alloc(32,0),r=Math.max(0,32-e.length);return e.copy(t,r),t}t.decode=function(e){const t=e.readUInt8(e.length-1);if(!(0,o.isDefinedHashType)(t))throw new Error("Invalid hashType "+t);const r=i.decode(e.slice(0,-1)),s=c(r.r),a=c(r.s);return{signature:n.concat([s,a],64),hashType:t}},t.encode=function(e,t){if(a({signature:s.BufferN(64),hashType:s.UInt8},{signature:e,hashType:t}),!(0,o.isDefinedHashType)(t))throw new Error("Invalid hashType "+t);const r=n.allocUnsafe(1);r.writeUInt8(t,0);const f=u(e.slice(0,32)),c=u(e.slice(32,64));return n.concat([i.encode(f,c),r])}},5444:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.Transaction=void 0;const i=r(3831),o=r(6891),s=r(4009),a=r(4009),f=r(5593),{typeforce:u}=f;function c(e){const t=e.length;return i.varuint.encodingLength(t)+t}const h=n.allocUnsafe(0),d=[],l=n.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),p=n.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),b=n.from("ffffffffffffffff","hex"),y={script:h,valueBuffer:b};class g{constructor(){this.version=1,this.locktime=0,this.ins=[],this.outs=[]}static fromBuffer(e,t){const r=new i.BufferReader(e),n=new g;n.version=r.readInt32();const o=r.readUInt8(),s=r.readUInt8();let a=!1;o===g.ADVANCED_TRANSACTION_MARKER&&s===g.ADVANCED_TRANSACTION_FLAG?a=!0:r.offset-=2;const f=r.readVarInt();for(let e=0;e0!==e.witness.length))}weight(){return 3*this.byteLength(!1)+this.byteLength(!0)}virtualSize(){return Math.ceil(this.weight()/4)}byteLength(e=!0){const t=e&&this.hasWitnesses();return(t?10:8)+i.varuint.encodingLength(this.ins.length)+i.varuint.encodingLength(this.outs.length)+this.ins.reduce(((e,t)=>e+40+c(t.script)),0)+this.outs.reduce(((e,t)=>e+8+c(t.script)),0)+(t?this.ins.reduce(((e,t)=>e+function(e){const t=e.length;return i.varuint.encodingLength(t)+e.reduce(((e,t)=>e+c(t)),0)}(t.witness)),0):0)}clone(){const e=new g;return e.version=this.version,e.locktime=this.locktime,e.ins=this.ins.map((e=>({hash:e.hash,index:e.index,script:e.script,sequence:e.sequence,witness:e.witness}))),e.outs=this.outs.map((e=>({script:e.script,value:e.value}))),e}hashForSignature(e,t,r){if(u(f.tuple(f.UInt32,f.Buffer,f.Number),arguments),e>=this.ins.length)return p;const i=s.compile(s.decompile(t).filter((e=>e!==a.OPS.OP_CODESEPARATOR))),c=this.clone();if((31&r)===g.SIGHASH_NONE)c.outs=[],c.ins.forEach(((t,r)=>{r!==e&&(t.sequence=0)}));else if((31&r)===g.SIGHASH_SINGLE){if(e>=this.outs.length)return p;c.outs.length=e+1;for(let t=0;t{r!==e&&(t.sequence=0)}))}r&g.SIGHASH_ANYONECANPAY?(c.ins=[c.ins[e]],c.ins[0].script=i):(c.ins.forEach((e=>{e.script=h})),c.ins[e].script=i);const d=n.allocUnsafe(c.byteLength(!1)+4);return d.writeInt32LE(r,d.length-4),c.__toBuffer(d,0,!1),o.hash256(d)}hashForWitnessV1(e,t,r,s,a,d){if(u(f.tuple(f.UInt32,u.arrayOf(f.Buffer),u.arrayOf(f.Satoshi),f.UInt32),arguments),r.length!==this.ins.length||t.length!==this.ins.length)throw new Error("Must supply prevout script and value for all inputs");const l=s===g.SIGHASH_DEFAULT?g.SIGHASH_ALL:s&g.SIGHASH_OUTPUT_MASK,p=(s&g.SIGHASH_INPUT_MASK)===g.SIGHASH_ANYONECANPAY,b=l===g.SIGHASH_NONE,y=l===g.SIGHASH_SINGLE;let w=h,m=h,v=h,_=h,E=h;if(!p){let e=i.BufferWriter.withCapacity(36*this.ins.length);this.ins.forEach((t=>{e.writeSlice(t.hash),e.writeUInt32(t.index)})),w=o.sha256(e.end()),e=i.BufferWriter.withCapacity(8*this.ins.length),r.forEach((t=>e.writeUInt64(t))),m=o.sha256(e.end()),e=i.BufferWriter.withCapacity(t.map(c).reduce(((e,t)=>e+t))),t.forEach((t=>e.writeVarSlice(t))),v=o.sha256(e.end()),e=i.BufferWriter.withCapacity(4*this.ins.length),this.ins.forEach((t=>e.writeUInt32(t.sequence))),_=o.sha256(e.end())}if(b||y){if(y&&e8+c(e.script))).reduce(((e,t)=>e+t)),t=i.BufferWriter.withCapacity(e);this.outs.forEach((e=>{t.writeUInt64(e.value),t.writeVarSlice(e.script)})),E=o.sha256(t.end())}const S=(a?2:0)+(d?1:0),I=174-(p?49:0)-(b?32:0)+(d?32:0)+(a?37:0),A=i.BufferWriter.withCapacity(I);if(A.writeUInt8(s),A.writeInt32(this.version),A.writeUInt32(this.locktime),A.writeSlice(w),A.writeSlice(m),A.writeSlice(v),A.writeSlice(_),b||y||A.writeSlice(E),A.writeUInt8(S),p){const n=this.ins[e];A.writeSlice(n.hash),A.writeUInt32(n.index),A.writeUInt64(r[e]),A.writeVarSlice(t[e]),A.writeUInt32(n.sequence)}else A.writeUInt32(e);if(d){const e=i.BufferWriter.withCapacity(c(d));e.writeVarSlice(d),A.writeSlice(o.sha256(e.end()))}return y&&A.writeSlice(E),a&&(A.writeSlice(a),A.writeUInt8(0),A.writeUInt32(4294967295)),o.taggedHash("TapSighash",n.concat([n.from([0]),A.end()]))}hashForWitnessV0(e,t,r,s){u(f.tuple(f.UInt32,f.Buffer,f.Satoshi,f.UInt32),arguments);let a,h=n.from([]),d=l,p=l,b=l;if(s&g.SIGHASH_ANYONECANPAY||(h=n.allocUnsafe(36*this.ins.length),a=new i.BufferWriter(h,0),this.ins.forEach((e=>{a.writeSlice(e.hash),a.writeUInt32(e.index)})),p=o.hash256(h)),s&g.SIGHASH_ANYONECANPAY||(31&s)===g.SIGHASH_SINGLE||(31&s)===g.SIGHASH_NONE||(h=n.allocUnsafe(4*this.ins.length),a=new i.BufferWriter(h,0),this.ins.forEach((e=>{a.writeUInt32(e.sequence)})),b=o.hash256(h)),(31&s)!==g.SIGHASH_SINGLE&&(31&s)!==g.SIGHASH_NONE){const e=this.outs.reduce(((e,t)=>e+8+c(t.script)),0);h=n.allocUnsafe(e),a=new i.BufferWriter(h,0),this.outs.forEach((e=>{a.writeUInt64(e.value),a.writeVarSlice(e.script)})),d=o.hash256(h)}else if((31&s)===g.SIGHASH_SINGLE&&e{o.writeSlice(e.hash),o.writeUInt32(e.index),o.writeVarSlice(e.script),o.writeUInt32(e.sequence)})),o.writeVarInt(this.outs.length),this.outs.forEach((e=>{void 0!==e.value?o.writeUInt64(e.value):o.writeSlice(e.valueBuffer),o.writeVarSlice(e.script)})),s&&this.ins.forEach((e=>{o.writeVector(e.witness)})),o.writeUInt32(this.locktime),void 0!==t?e.slice(t,o.offset):e}}t.Transaction=g,g.DEFAULT_SEQUENCE=4294967295,g.SIGHASH_DEFAULT=0,g.SIGHASH_ALL=1,g.SIGHASH_NONE=2,g.SIGHASH_SINGLE=3,g.SIGHASH_ANYONECANPAY=128,g.SIGHASH_OUTPUT_MASK=3,g.SIGHASH_INPUT_MASK=128,g.ADVANCED_TRANSACTION_MARKER=0,g.ADVANCED_TRANSACTION_FLAG=1},5593:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.oneOf=t.Null=t.BufferN=t.Function=t.UInt32=t.UInt8=t.tuple=t.maybe=t.Hex=t.Buffer=t.String=t.Boolean=t.Array=t.Number=t.Hash256bit=t.Hash160bit=t.Buffer256bit=t.isTaptree=t.isTapleaf=t.TAPLEAF_VERSION_MASK=t.Satoshi=t.isPoint=t.stacksEqual=t.typeforce=void 0;const n=r(1048);t.typeforce=r(973);const i=n.Buffer.alloc(32,0),o=n.Buffer.from("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f","hex");function s(e){return!(!e||!("output"in e)||!n.Buffer.isBuffer(e.output)||void 0!==e.version&&(e.version&t.TAPLEAF_VERSION_MASK)!==e.version)}t.stacksEqual=function(e,t){return e.length===t.length&&e.every(((e,r)=>e.equals(t[r])))},t.isPoint=function(e){if(!n.Buffer.isBuffer(e))return!1;if(e.length<33)return!1;const t=e[0],r=e.slice(1,33);if(0===r.compare(i))return!1;if(r.compare(o)>=0)return!1;if((2===t||3===t)&&33===e.length)return!0;const s=e.slice(33);return 0!==s.compare(i)&&!(s.compare(o)>=0)&&4===t&&65===e.length},t.Satoshi=function(e){return t.typeforce.UInt53(e)&&e<=21e14},t.TAPLEAF_VERSION_MASK=254,t.isTapleaf=s,t.isTaptree=function e(r){return(0,t.Array)(r)?2===r.length&&r.every((t=>e(t))):s(r)},t.Buffer256bit=t.typeforce.BufferN(32),t.Hash160bit=t.typeforce.BufferN(20),t.Hash256bit=t.typeforce.BufferN(32),t.Number=t.typeforce.Number,t.Array=t.typeforce.Array,t.Boolean=t.typeforce.Boolean,t.String=t.typeforce.String,t.Buffer=t.typeforce.Buffer,t.Hex=t.typeforce.Hex,t.maybe=t.typeforce.maybe,t.tuple=t.typeforce.tuple,t.UInt8=t.typeforce.UInt8,t.UInt32=t.typeforce.UInt32,t.Function=t.typeforce.Function,t.BufferN=t.typeforce.BufferN,t.Null=t.typeforce.Null,t.oneOf=t.typeforce.oneOf},6989:(e,t,r)=>{var n=r(1048).Buffer;const i=r(5449),o=r(4018),s=r(494),a=r(3257),f=r(9942),u=r(7820),c="p2wpkh",h="p2sh(p2wpkh)";function d(e){return a("sha256").update(e).digest()}function l(e){return a("ripemd160").update(d(e)).digest()}function p(e,t,r,i){return void 0!==i?(t+=8,i===c&&(t+=4)):r&&(t+=4),n.concat([n.alloc(1,t+27),e])}function b(e,t){t=t||"Bitcoin Signed Message:\n",n.isBuffer(t)||(t=n.from(t,"utf8")),n.isBuffer(e)||(e=n.from(e,"utf8"));const r=u.encodingLength(e.length),i=n.allocUnsafe(t.length+r+e.length);return t.copy(i,0),u.encode(e.length,i,t.length),e.copy(i,t.length+r),function(e){return d(d(e))}(i)}function y(e,t){"object"==typeof e&&void 0===t&&(t=e,e=void 0);let{segwitType:r,extraEntropy:n}=t||{};if(r&&("string"==typeof r||r instanceof String)&&(r=r.toLowerCase()),r&&r!==h&&r!==c)throw new Error('Unrecognized segwitType: use "'+h+'" or "'+c+'"');return{messagePrefixArg:e,segwitType:r,extraEntropy:n}}function g(e){return e&&"function"==typeof e.sign}function w(e){return l(n.concat([n.from("0014","hex"),e]))}function m(e){const t=o.decode(e),r=o.fromWords(t.words.slice(1));return n.from(r)}e.exports={magicHash:b,sign:function(e,t,r,n,i){const{messagePrefixArg:o,segwitType:s,extraEntropy:a}=y(n,i),u=b(e,o),c=g(t)?t.sign(u,a):f.sign(u,t,{data:a});return p(c.signature,c.recovery,r,s)},signAsync:function(e,t,r,n,i){let o,s,a;return Promise.resolve().then((()=>{({messagePrefixArg:o,segwitType:s,extraEntropy:a}=y(n,i));const r=b(e,o);return g(t)?t.sign(r,a):f.sign(r,t,{data:a})})).then((e=>p(e.signature,e.recovery,r,s)))},verify:function(e,t,r,o,a){n.isBuffer(r)||(r=n.from(r,"base64"));const u=function(e){if(65!==e.length)throw new Error("Invalid signature length");const t=e.readUInt8(0)-27;if(t>15||t<0)throw new Error("Invalid signature parameter");return{compressed:!!(12&t),segwitType:8&t?4&t?c:h:null,recovery:3&t,signature:e.slice(1)}}(r);if(a&&!u.compressed)throw new Error("checkSegwitAlways can only be used with a compressed pubkey signature flagbyte");const d=b(e,o),p=l(f.recover(d,u.signature,u.recovery,u.compressed));let y,g;if(u.segwitType)u.segwitType===h?(y=w(p),g=i.decode(t).slice(1)):(y=p,g=m(t));else if(a)try{return g=m(t),s(p,g)}catch(e){const r=w(p);return g=i.decode(t).slice(1),s(p,g)||s(r,g)}else y=p,g=i.decode(t).slice(1);return s(y,g)}}},5228:(e,t,r)=>{"use strict";var n=r(5636).Buffer;e.exports=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r>>0,c=new Uint8Array(s);r>>0,c[l]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");o=d,r++}for(var p=s-o;p!==s&&0===c[p];)p++;var b=n.allocUnsafe(i+(s-p));b.fill(0,0,i);for(var y=i;p!==s;)b[y++]=c[p++];return b}return{encode:function(t){if((Array.isArray(t)||t instanceof Uint8Array)&&(t=n.from(t)),!n.isBuffer(t))throw new TypeError("Expected Buffer");if(0===t.length)return"";for(var r=0,i=0,o=0,s=t.length;o!==s&&0===t[o];)o++,r++;for(var u=(s-o)*c+1>>>0,h=new Uint8Array(u);o!==s;){for(var d=t[o],l=0,p=u-1;(0!==d||l>>0,h[p]=d%a>>>0,d=d/a>>>0;if(0!==d)throw new Error("Non-zero carry");i=l,o++}for(var b=u-i;b!==u&&0===h[b];)b++;for(var y=f.repeat(r);b{"use strict";for(var t="qpzry9x8gf2tvdw0s3jn54khce6mua7l",r={},n=0;n<32;n++){var i=t.charAt(n);if(void 0!==r[i])throw new TypeError(i+" is ambiguous");r[i]=n}function o(e){var t=e>>25;return(33554431&e)<<5^996825010&-(1&t)^642813549&-(t>>1&1)^513874426&-(t>>2&1)^1027748829&-(t>>3&1)^705979059&-(t>>4&1)}function s(e){for(var t=1,r=0;r126)return"Invalid prefix ("+e+")";t=o(t)^n>>5}for(t=o(t),r=0;rt)return"Exceeds length limit";var n=e.toLowerCase(),i=e.toUpperCase();if(e!==n&&e!==i)return"Mixed-case string "+e;var a=(e=n).lastIndexOf("1");if(-1===a)return"No separator character for "+e;if(0===a)return"Missing prefix for "+e;var f=e.slice(0,a),u=e.slice(a+1);if(u.length<6)return"Data too short";var c=s(f);if("string"==typeof c)return c;for(var h=[],d=0;d=u.length||h.push(p)}return 1!==c?"Invalid checksum for "+e:{prefix:f,words:h}}function f(e,t,r,n){for(var i=0,o=0,s=(1<=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<=t)return"Excess padding";if(i<n)throw new TypeError("Exceeds length limit");var i=s(e=e.toLowerCase());if("string"==typeof i)throw new Error(i);for(var a=e+"1",f=0;f>5)throw new Error("Non 5-bit word");i=o(i)^u,a+=t.charAt(u)}for(f=0;f<6;++f)i=o(i);for(i^=1,f=0;f<6;++f)a+=t.charAt(i>>5*(5-f)&31);return a},toWordsUnsafe:function(e){var t=f(e,8,5,!0);if(Array.isArray(t))return t},toWords:function(e){var t=f(e,8,5,!0);if(Array.isArray(t))return t;throw new Error(t)},fromWordsUnsafe:function(e){var t=f(e,5,8,!1);if(Array.isArray(t))return t},fromWords:function(e){var t=f(e,5,8,!1);if(Array.isArray(t))return t;throw new Error(t)}}},851:(e,t,r)=>{var n=r(5228);e.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},188:(e,t,r)=>{"use strict";var n=r(851),i=r(5636).Buffer;e.exports=function(e){function t(t){var r=t.slice(0,-4),n=t.slice(-4),i=e(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(t){var r=e(t);return n.encode(i.concat([t,r],t.length+4))},decode:function(e){var r=t(n.decode(e));if(!r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(e){var r=n.decodeUnsafe(e);if(r)return t(r)}}}},5449:(e,t,r)=>{"use strict";var n=r(3257),i=r(188);e.exports=i((function(e){var t=n("sha256").update(e).digest();return n("sha256").update(t).digest()}))},2823:function(e,t,r){!function(e,t){"use strict";function n(e,t){if(!e)throw new Error(t||"Assertion failed")}function i(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function o(e,t,r){if(o.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var s;"object"==typeof e?e.exports=o:t.BN=o,o.BN=o,o.wordSize=26;try{s="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:r(8379).Buffer}catch(e){}function a(e,t){var r=e.charCodeAt(t);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function f(e,t,r){var n=a(e,r);return r-1>=t&&(n|=a(e,r-1)<<4),n}function u(e,t,r,n){for(var i=0,o=Math.min(e.length,r),s=t;s=49?a-49+10:a>=17?a-17+10:a}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i=0;i-=3)s=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t,r){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var n=0;n=t;n-=2)i=f(e,t,n)<=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(e.length-t)%2==0?t+1:t;n=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;this.strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,s=o%n,a=Math.min(o,o-s)+r,f=0,c=r;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?""};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],h=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],d=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function l(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],s=i*o,a=67108863&s,f=s/67108864|0;r.words[0]=a;for(var u=1;u>>26,h=67108863&f,d=Math.min(u,t.length-1),l=Math.max(0,u-e.length+1);l<=d;l++){var p=u-l|0;c+=(s=(i=0|e.words[p])*(o=0|t.words[l])+h)/67108864|0,h=67108863&s}r.words[u]=0|h,f=0|c}return 0!==f?r.words[u]=0|f:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,s=0;s>>24-i&16777215,(i+=2)>=26&&(i-=26,s--),r=0!==o||s!==this.length-1?c[6-f.length]+f+r:f+r}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var u=h[e],l=d[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(l).toString(e);r=(p=p.idivn(l)).isZero()?b+r:c[u-b.length]+b+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return n(void 0!==s),this.toArrayLike(s,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var s,a,f="le"===t,u=new e(o),c=this.clone();if(f){for(a=0;!c.isZero();a++)s=c.andln(255),c.iushrn(8),u[a]=s;for(;a=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 8191&t||(r+=13,t>>>=13),127&t||(r+=7,t>>>=7),15&t||(r+=4,t>>>=4),3&t||(r+=2,t>>>=2),1&t||r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,s=0;s>26,this.words[s]=67108863&t;for(;0!==o&&s>26,this.words[s]=67108863&t;if(0===o&&s>>13,l=0|s[1],p=8191&l,b=l>>>13,y=0|s[2],g=8191&y,w=y>>>13,m=0|s[3],v=8191&m,_=m>>>13,E=0|s[4],S=8191&E,I=E>>>13,A=0|s[5],T=8191&A,k=A>>>13,P=0|s[6],O=8191&P,M=P>>>13,x=0|s[7],B=8191&x,L=x>>>13,R=0|s[8],N=8191&R,U=R>>>13,C=0|s[9],H=8191&C,D=C>>>13,K=0|a[0],V=8191&K,j=K>>>13,F=0|a[1],q=8191&F,W=F>>>13,z=0|a[2],G=8191&z,Y=z>>>13,X=0|a[3],$=8191&X,Z=X>>>13,J=0|a[4],Q=8191&J,ee=J>>>13,te=0|a[5],re=8191&te,ne=te>>>13,ie=0|a[6],oe=8191&ie,se=ie>>>13,ae=0|a[7],fe=8191&ae,ue=ae>>>13,ce=0|a[8],he=8191&ce,de=ce>>>13,le=0|a[9],pe=8191&le,be=le>>>13;r.negative=e.negative^t.negative,r.length=19;var ye=(u+(n=Math.imul(h,V))|0)+((8191&(i=(i=Math.imul(h,j))+Math.imul(d,V)|0))<<13)|0;u=((o=Math.imul(d,j))+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(p,V),i=(i=Math.imul(p,j))+Math.imul(b,V)|0,o=Math.imul(b,j);var ge=(u+(n=n+Math.imul(h,q)|0)|0)+((8191&(i=(i=i+Math.imul(h,W)|0)+Math.imul(d,q)|0))<<13)|0;u=((o=o+Math.imul(d,W)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(g,V),i=(i=Math.imul(g,j))+Math.imul(w,V)|0,o=Math.imul(w,j),n=n+Math.imul(p,q)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(b,q)|0,o=o+Math.imul(b,W)|0;var we=(u+(n=n+Math.imul(h,G)|0)|0)+((8191&(i=(i=i+Math.imul(h,Y)|0)+Math.imul(d,G)|0))<<13)|0;u=((o=o+Math.imul(d,Y)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(v,V),i=(i=Math.imul(v,j))+Math.imul(_,V)|0,o=Math.imul(_,j),n=n+Math.imul(g,q)|0,i=(i=i+Math.imul(g,W)|0)+Math.imul(w,q)|0,o=o+Math.imul(w,W)|0,n=n+Math.imul(p,G)|0,i=(i=i+Math.imul(p,Y)|0)+Math.imul(b,G)|0,o=o+Math.imul(b,Y)|0;var me=(u+(n=n+Math.imul(h,$)|0)|0)+((8191&(i=(i=i+Math.imul(h,Z)|0)+Math.imul(d,$)|0))<<13)|0;u=((o=o+Math.imul(d,Z)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(S,V),i=(i=Math.imul(S,j))+Math.imul(I,V)|0,o=Math.imul(I,j),n=n+Math.imul(v,q)|0,i=(i=i+Math.imul(v,W)|0)+Math.imul(_,q)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(g,G)|0,i=(i=i+Math.imul(g,Y)|0)+Math.imul(w,G)|0,o=o+Math.imul(w,Y)|0,n=n+Math.imul(p,$)|0,i=(i=i+Math.imul(p,Z)|0)+Math.imul(b,$)|0,o=o+Math.imul(b,Z)|0;var ve=(u+(n=n+Math.imul(h,Q)|0)|0)+((8191&(i=(i=i+Math.imul(h,ee)|0)+Math.imul(d,Q)|0))<<13)|0;u=((o=o+Math.imul(d,ee)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(T,V),i=(i=Math.imul(T,j))+Math.imul(k,V)|0,o=Math.imul(k,j),n=n+Math.imul(S,q)|0,i=(i=i+Math.imul(S,W)|0)+Math.imul(I,q)|0,o=o+Math.imul(I,W)|0,n=n+Math.imul(v,G)|0,i=(i=i+Math.imul(v,Y)|0)+Math.imul(_,G)|0,o=o+Math.imul(_,Y)|0,n=n+Math.imul(g,$)|0,i=(i=i+Math.imul(g,Z)|0)+Math.imul(w,$)|0,o=o+Math.imul(w,Z)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,ee)|0;var _e=(u+(n=n+Math.imul(h,re)|0)|0)+((8191&(i=(i=i+Math.imul(h,ne)|0)+Math.imul(d,re)|0))<<13)|0;u=((o=o+Math.imul(d,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(O,V),i=(i=Math.imul(O,j))+Math.imul(M,V)|0,o=Math.imul(M,j),n=n+Math.imul(T,q)|0,i=(i=i+Math.imul(T,W)|0)+Math.imul(k,q)|0,o=o+Math.imul(k,W)|0,n=n+Math.imul(S,G)|0,i=(i=i+Math.imul(S,Y)|0)+Math.imul(I,G)|0,o=o+Math.imul(I,Y)|0,n=n+Math.imul(v,$)|0,i=(i=i+Math.imul(v,Z)|0)+Math.imul(_,$)|0,o=o+Math.imul(_,Z)|0,n=n+Math.imul(g,Q)|0,i=(i=i+Math.imul(g,ee)|0)+Math.imul(w,Q)|0,o=o+Math.imul(w,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(b,re)|0,o=o+Math.imul(b,ne)|0;var Ee=(u+(n=n+Math.imul(h,oe)|0)|0)+((8191&(i=(i=i+Math.imul(h,se)|0)+Math.imul(d,oe)|0))<<13)|0;u=((o=o+Math.imul(d,se)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(B,V),i=(i=Math.imul(B,j))+Math.imul(L,V)|0,o=Math.imul(L,j),n=n+Math.imul(O,q)|0,i=(i=i+Math.imul(O,W)|0)+Math.imul(M,q)|0,o=o+Math.imul(M,W)|0,n=n+Math.imul(T,G)|0,i=(i=i+Math.imul(T,Y)|0)+Math.imul(k,G)|0,o=o+Math.imul(k,Y)|0,n=n+Math.imul(S,$)|0,i=(i=i+Math.imul(S,Z)|0)+Math.imul(I,$)|0,o=o+Math.imul(I,Z)|0,n=n+Math.imul(v,Q)|0,i=(i=i+Math.imul(v,ee)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(g,re)|0,i=(i=i+Math.imul(g,ne)|0)+Math.imul(w,re)|0,o=o+Math.imul(w,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,se)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,se)|0;var Se=(u+(n=n+Math.imul(h,fe)|0)|0)+((8191&(i=(i=i+Math.imul(h,ue)|0)+Math.imul(d,fe)|0))<<13)|0;u=((o=o+Math.imul(d,ue)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(N,V),i=(i=Math.imul(N,j))+Math.imul(U,V)|0,o=Math.imul(U,j),n=n+Math.imul(B,q)|0,i=(i=i+Math.imul(B,W)|0)+Math.imul(L,q)|0,o=o+Math.imul(L,W)|0,n=n+Math.imul(O,G)|0,i=(i=i+Math.imul(O,Y)|0)+Math.imul(M,G)|0,o=o+Math.imul(M,Y)|0,n=n+Math.imul(T,$)|0,i=(i=i+Math.imul(T,Z)|0)+Math.imul(k,$)|0,o=o+Math.imul(k,Z)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(I,Q)|0,o=o+Math.imul(I,ee)|0,n=n+Math.imul(v,re)|0,i=(i=i+Math.imul(v,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(g,oe)|0,i=(i=i+Math.imul(g,se)|0)+Math.imul(w,oe)|0,o=o+Math.imul(w,se)|0,n=n+Math.imul(p,fe)|0,i=(i=i+Math.imul(p,ue)|0)+Math.imul(b,fe)|0,o=o+Math.imul(b,ue)|0;var Ie=(u+(n=n+Math.imul(h,he)|0)|0)+((8191&(i=(i=i+Math.imul(h,de)|0)+Math.imul(d,he)|0))<<13)|0;u=((o=o+Math.imul(d,de)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(H,V),i=(i=Math.imul(H,j))+Math.imul(D,V)|0,o=Math.imul(D,j),n=n+Math.imul(N,q)|0,i=(i=i+Math.imul(N,W)|0)+Math.imul(U,q)|0,o=o+Math.imul(U,W)|0,n=n+Math.imul(B,G)|0,i=(i=i+Math.imul(B,Y)|0)+Math.imul(L,G)|0,o=o+Math.imul(L,Y)|0,n=n+Math.imul(O,$)|0,i=(i=i+Math.imul(O,Z)|0)+Math.imul(M,$)|0,o=o+Math.imul(M,Z)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,ee)|0)+Math.imul(k,Q)|0,o=o+Math.imul(k,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(I,re)|0,o=o+Math.imul(I,ne)|0,n=n+Math.imul(v,oe)|0,i=(i=i+Math.imul(v,se)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,se)|0,n=n+Math.imul(g,fe)|0,i=(i=i+Math.imul(g,ue)|0)+Math.imul(w,fe)|0,o=o+Math.imul(w,ue)|0,n=n+Math.imul(p,he)|0,i=(i=i+Math.imul(p,de)|0)+Math.imul(b,he)|0,o=o+Math.imul(b,de)|0;var Ae=(u+(n=n+Math.imul(h,pe)|0)|0)+((8191&(i=(i=i+Math.imul(h,be)|0)+Math.imul(d,pe)|0))<<13)|0;u=((o=o+Math.imul(d,be)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(H,q),i=(i=Math.imul(H,W))+Math.imul(D,q)|0,o=Math.imul(D,W),n=n+Math.imul(N,G)|0,i=(i=i+Math.imul(N,Y)|0)+Math.imul(U,G)|0,o=o+Math.imul(U,Y)|0,n=n+Math.imul(B,$)|0,i=(i=i+Math.imul(B,Z)|0)+Math.imul(L,$)|0,o=o+Math.imul(L,Z)|0,n=n+Math.imul(O,Q)|0,i=(i=i+Math.imul(O,ee)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,ee)|0,n=n+Math.imul(T,re)|0,i=(i=i+Math.imul(T,ne)|0)+Math.imul(k,re)|0,o=o+Math.imul(k,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,se)|0)+Math.imul(I,oe)|0,o=o+Math.imul(I,se)|0,n=n+Math.imul(v,fe)|0,i=(i=i+Math.imul(v,ue)|0)+Math.imul(_,fe)|0,o=o+Math.imul(_,ue)|0,n=n+Math.imul(g,he)|0,i=(i=i+Math.imul(g,de)|0)+Math.imul(w,he)|0,o=o+Math.imul(w,de)|0;var Te=(u+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,be)|0)+Math.imul(b,pe)|0))<<13)|0;u=((o=o+Math.imul(b,be)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(H,G),i=(i=Math.imul(H,Y))+Math.imul(D,G)|0,o=Math.imul(D,Y),n=n+Math.imul(N,$)|0,i=(i=i+Math.imul(N,Z)|0)+Math.imul(U,$)|0,o=o+Math.imul(U,Z)|0,n=n+Math.imul(B,Q)|0,i=(i=i+Math.imul(B,ee)|0)+Math.imul(L,Q)|0,o=o+Math.imul(L,ee)|0,n=n+Math.imul(O,re)|0,i=(i=i+Math.imul(O,ne)|0)+Math.imul(M,re)|0,o=o+Math.imul(M,ne)|0,n=n+Math.imul(T,oe)|0,i=(i=i+Math.imul(T,se)|0)+Math.imul(k,oe)|0,o=o+Math.imul(k,se)|0,n=n+Math.imul(S,fe)|0,i=(i=i+Math.imul(S,ue)|0)+Math.imul(I,fe)|0,o=o+Math.imul(I,ue)|0,n=n+Math.imul(v,he)|0,i=(i=i+Math.imul(v,de)|0)+Math.imul(_,he)|0,o=o+Math.imul(_,de)|0;var ke=(u+(n=n+Math.imul(g,pe)|0)|0)+((8191&(i=(i=i+Math.imul(g,be)|0)+Math.imul(w,pe)|0))<<13)|0;u=((o=o+Math.imul(w,be)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(H,$),i=(i=Math.imul(H,Z))+Math.imul(D,$)|0,o=Math.imul(D,Z),n=n+Math.imul(N,Q)|0,i=(i=i+Math.imul(N,ee)|0)+Math.imul(U,Q)|0,o=o+Math.imul(U,ee)|0,n=n+Math.imul(B,re)|0,i=(i=i+Math.imul(B,ne)|0)+Math.imul(L,re)|0,o=o+Math.imul(L,ne)|0,n=n+Math.imul(O,oe)|0,i=(i=i+Math.imul(O,se)|0)+Math.imul(M,oe)|0,o=o+Math.imul(M,se)|0,n=n+Math.imul(T,fe)|0,i=(i=i+Math.imul(T,ue)|0)+Math.imul(k,fe)|0,o=o+Math.imul(k,ue)|0,n=n+Math.imul(S,he)|0,i=(i=i+Math.imul(S,de)|0)+Math.imul(I,he)|0,o=o+Math.imul(I,de)|0;var Pe=(u+(n=n+Math.imul(v,pe)|0)|0)+((8191&(i=(i=i+Math.imul(v,be)|0)+Math.imul(_,pe)|0))<<13)|0;u=((o=o+Math.imul(_,be)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,n=Math.imul(H,Q),i=(i=Math.imul(H,ee))+Math.imul(D,Q)|0,o=Math.imul(D,ee),n=n+Math.imul(N,re)|0,i=(i=i+Math.imul(N,ne)|0)+Math.imul(U,re)|0,o=o+Math.imul(U,ne)|0,n=n+Math.imul(B,oe)|0,i=(i=i+Math.imul(B,se)|0)+Math.imul(L,oe)|0,o=o+Math.imul(L,se)|0,n=n+Math.imul(O,fe)|0,i=(i=i+Math.imul(O,ue)|0)+Math.imul(M,fe)|0,o=o+Math.imul(M,ue)|0,n=n+Math.imul(T,he)|0,i=(i=i+Math.imul(T,de)|0)+Math.imul(k,he)|0,o=o+Math.imul(k,de)|0;var Oe=(u+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,be)|0)+Math.imul(I,pe)|0))<<13)|0;u=((o=o+Math.imul(I,be)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,n=Math.imul(H,re),i=(i=Math.imul(H,ne))+Math.imul(D,re)|0,o=Math.imul(D,ne),n=n+Math.imul(N,oe)|0,i=(i=i+Math.imul(N,se)|0)+Math.imul(U,oe)|0,o=o+Math.imul(U,se)|0,n=n+Math.imul(B,fe)|0,i=(i=i+Math.imul(B,ue)|0)+Math.imul(L,fe)|0,o=o+Math.imul(L,ue)|0,n=n+Math.imul(O,he)|0,i=(i=i+Math.imul(O,de)|0)+Math.imul(M,he)|0,o=o+Math.imul(M,de)|0;var Me=(u+(n=n+Math.imul(T,pe)|0)|0)+((8191&(i=(i=i+Math.imul(T,be)|0)+Math.imul(k,pe)|0))<<13)|0;u=((o=o+Math.imul(k,be)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(H,oe),i=(i=Math.imul(H,se))+Math.imul(D,oe)|0,o=Math.imul(D,se),n=n+Math.imul(N,fe)|0,i=(i=i+Math.imul(N,ue)|0)+Math.imul(U,fe)|0,o=o+Math.imul(U,ue)|0,n=n+Math.imul(B,he)|0,i=(i=i+Math.imul(B,de)|0)+Math.imul(L,he)|0,o=o+Math.imul(L,de)|0;var xe=(u+(n=n+Math.imul(O,pe)|0)|0)+((8191&(i=(i=i+Math.imul(O,be)|0)+Math.imul(M,pe)|0))<<13)|0;u=((o=o+Math.imul(M,be)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(H,fe),i=(i=Math.imul(H,ue))+Math.imul(D,fe)|0,o=Math.imul(D,ue),n=n+Math.imul(N,he)|0,i=(i=i+Math.imul(N,de)|0)+Math.imul(U,he)|0,o=o+Math.imul(U,de)|0;var Be=(u+(n=n+Math.imul(B,pe)|0)|0)+((8191&(i=(i=i+Math.imul(B,be)|0)+Math.imul(L,pe)|0))<<13)|0;u=((o=o+Math.imul(L,be)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(H,he),i=(i=Math.imul(H,de))+Math.imul(D,he)|0,o=Math.imul(D,de);var Le=(u+(n=n+Math.imul(N,pe)|0)|0)+((8191&(i=(i=i+Math.imul(N,be)|0)+Math.imul(U,pe)|0))<<13)|0;u=((o=o+Math.imul(U,be)|0)+(i>>>13)|0)+(Le>>>26)|0,Le&=67108863;var Re=(u+(n=Math.imul(H,pe))|0)+((8191&(i=(i=Math.imul(H,be))+Math.imul(D,pe)|0))<<13)|0;return u=((o=Math.imul(D,be))+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863,f[0]=ye,f[1]=ge,f[2]=we,f[3]=me,f[4]=ve,f[5]=_e,f[6]=Ee,f[7]=Se,f[8]=Ie,f[9]=Ae,f[10]=Te,f[11]=ke,f[12]=Pe,f[13]=Oe,f[14]=Me,f[15]=xe,f[16]=Be,f[17]=Le,f[18]=Re,0!==u&&(f[19]=u,r.length++),r};function b(e,t,r){return(new y).mulp(e,t,r)}function y(e,t){this.x=e,this.y=t}Math.imul||(p=l),o.prototype.mulTo=function(e,t){var r,n=this.length+e.length;return r=10===this.length&&10===e.length?p(this,e,t):n<63?l(this,e,t):n<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):b(this,e,t),r},y.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},y.prototype.permute=function(e,t,r,n,i,o){for(var s=0;s>>=1)i++;return 1<>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*t;s>=26,t+=i/67108864|0,t+=o>>>26,this.words[r]=67108863&o}return 0!==t&&(this.words[r]=t,this.length++),this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var s=0;for(t=0;t>>26-r}s&&(this.words[t]=s,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,s=Math.min((e-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,u=0;u=0&&(0!==c||u>=i);u--){var h=0|this.words[u];this.words[u]=c<<26-o|h>>>o,c=h&a}return f&&0!==c&&(f.words[f.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(f/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===a)return this.strip();for(n(-1===a),a=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,s=0|i.words[i.length-1];0!=(r=26-this._countBits(s))&&(i=i.ushln(r),n.iushln(r),s=0|i.words[i.length-1]);var a,f=n.length-i.length;if("mod"!==t){(a=new o(null)).length=f+1,a.words=new Array(a.length);for(var u=0;u=0;h--){var d=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(d=Math.min(d/s|0,67108863),n._ishlnsubmul(i,d,h);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);a&&(a.words[h]=d)}return a&&a.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(a=this.neg().divmod(e,t),"mod"!==t&&(i=a.div.neg()),"div"!==t&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(e)),{div:i,mod:s}):0===this.negative&&0!==e.negative?(a=this.divmod(e.neg(),t),"mod"!==t&&(i=a.div.neg()),{div:i,mod:a.mod}):this.negative&e.negative?(a=this.neg().divmod(e.neg(),t),"div"!==t&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(e)),{div:a.div,mod:s}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,s,a},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;i>=0;i--)r=(t*r+(0|this.words[i]))%e;return r},o.prototype.idivn=function(e){n(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),s=new o(0),a=new o(0),f=new o(1),u=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++u;for(var c=r.clone(),h=t.clone();!t.isZero();){for(var d=0,l=1;!(t.words[0]&l)&&d<26;++d,l<<=1);if(d>0)for(t.iushrn(d);d-- >0;)(i.isOdd()||s.isOdd())&&(i.iadd(c),s.isub(h)),i.iushrn(1),s.iushrn(1);for(var p=0,b=1;!(r.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||f.isOdd())&&(a.iadd(c),f.isub(h)),a.iushrn(1),f.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(a),s.isub(f)):(r.isub(t),a.isub(i),f.isub(s))}return{a,b:f,gcd:r.iushln(u)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,s=new o(1),a=new o(0),f=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,c=1;!(t.words[0]&c)&&u<26;++u,c<<=1);if(u>0)for(t.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(f),s.iushrn(1);for(var h=0,d=1;!(r.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(r.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(f),a.iushrn(1);t.cmp(r)>=0?(t.isub(r),s.isub(a)):(r.isub(t),a.isub(s))}return(i=0===t.cmpn(1)?s:a).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return!(1&this.words[0])},o.prototype.isOdd=function(){return!(1&~this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new S(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var g={k256:null,p224:null,p192:null,p25519:null};function w(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function m(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function v(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function _(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function S(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function I(e){S.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}w.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},w.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},w.prototype.split=function(e,t){e.iushrn(this.n,0,t)},w.prototype.imulK=function(e){return e.imul(this.k)},i(m,w),m.prototype.split=function(e,t){for(var r=4194303,n=Math.min(e.length,9),i=0;i>>22,o=s}o>>>=22,e.words[i-10]=o,0===o&&e.length>10?e.length-=10:e.length-=9},m.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(g[e])return g[e];var t;if("k256"===e)t=new m;else if("p224"===e)t=new v;else if("p192"===e)t=new _;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new E}return g[e]=t,t},S.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},S.prototype._verify2=function(e,t){n(!(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},S.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},S.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},S.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},S.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},S.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},S.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},S.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},S.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},S.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},S.prototype.isqr=function(e){return this.imul(e,e.clone())},S.prototype.sqr=function(e){return this.mul(e,e)},S.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);n(!i.isZero());var a=new o(1).toRed(this),f=a.redNeg(),u=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new o(2*c*c).toRed(this);0!==this.pow(c,u).cmp(f);)c.redIAdd(f);for(var h=this.pow(c,i),d=this.pow(e,i.addn(1).iushrn(1)),l=this.pow(e,i),p=s;0!==l.cmp(a);){for(var b=l,y=0;0!==b.cmp(a);y++)b=b.redSqr();n(y=0;n--){for(var u=t.words[n],c=f-1;c>=0;c--){var h=u>>c&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==s?(s<<=1,s|=h,(4==++a||0===n&&0===c)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}f=26}return i},S.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},S.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new I(e)},i(I,S),I.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},I.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},I.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},I.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},I.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e=r.nmd(e),this)},7048:(e,t,r)=>{var n;function i(e){this.rand=e}if(e.exports=function(e){return n||(n=new i(null)),n.generate(e)},e.exports.Rand=i,i.prototype.generate=function(e){return this._rand(e)},i.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),r=0;r{const n=r(7403);e.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},7639:(e,t,r)=>{"use strict";var n=r(9216);e.exports=function(e){function t(t){var r=t.slice(0,-4),n=t.slice(-4),i=e(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(t){var r=Uint8Array.from(t),i=e(r),o=r.length+4,s=new Uint8Array(o);return s.set(r,0),s.set(i.subarray(0,4),r.length),n.encode(s,o)},decode:function(e){var r=t(n.decode(e));if(!r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(e){var r=n.decodeUnsafe(e);if(r)return t(r)}}}},9848:(e,t,r)=>{"use strict";var{sha256:n}=r(9688),i=r(7639);e.exports=i((function(e){return n(n(e))}))},494:(e,t,r)=>{"use strict";var n=r(1048).Buffer;e.exports=function(e,t){if(!n.isBuffer(e)||!n.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return!0;if("function"==typeof e.equals)return e.equals(t);if(e.length!==t.length)return!1;for(var r=0;r{"use strict";const n=r(7991),i=r(9318),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=f,t.SlowBuffer=function(e){return+e!=e&&(e=0),f.alloc(+e)},t.INSPECT_MAX_BYTES=50;const s=2147483647;function a(e){if(e>s)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,f.prototype),t}function f(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return h(e)}return u(e,t,r)}function u(e,t,r){if("string"==typeof e)return function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!f.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const r=0|b(e,t);let n=a(r);const i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}(e,t);if(ArrayBuffer.isView(e))return function(e){if(X(e,Uint8Array)){const t=new Uint8Array(e);return l(t.buffer,t.byteOffset,t.byteLength)}return d(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(X(e,ArrayBuffer)||e&&X(e.buffer,ArrayBuffer))return l(e,t,r);if("undefined"!=typeof SharedArrayBuffer&&(X(e,SharedArrayBuffer)||e&&X(e.buffer,SharedArrayBuffer)))return l(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return f.from(n,t,r);const i=function(e){if(f.isBuffer(e)){const t=0|p(e.length),r=a(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||$(e.length)?a(0):d(e):"Buffer"===e.type&&Array.isArray(e.data)?d(e.data):void 0}(e);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return f.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function c(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function h(e){return c(e),a(e<0?0:0|p(e))}function d(e){const t=e.length<0?0:0|p(e.length),r=a(t);for(let n=0;n=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|e}function b(e,t){if(f.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||X(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return z(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return G(e).length;default:if(i)return n?-1:z(e).length;t=(""+t).toLowerCase(),i=!0}}function y(e,t,r){let n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return M(this,t,r);case"utf8":case"utf-8":return T(this,t,r);case"ascii":return P(this,t,r);case"latin1":case"binary":return O(this,t,r);case"base64":return A(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function g(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function w(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),$(r=+r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=f.from(t,n)),f.isBuffer(t))return 0===t.length?-1:m(e,t,r,n,i);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):m(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function m(e,t,r,n,i){let o,s=1,a=e.length,f=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,f/=2,r/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){let n=-1;for(o=r;oa&&(r=a-f),o=r;o>=0;o--){let r=!0;for(let n=0;ni&&(n=i):n=i;const o=t.length;let s;for(n>o/2&&(n=o/2),s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function A(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function T(e,t,r){r=Math.min(e.length,r);const n=[];let i=t;for(;i239?4:t>223?3:t>191?2:1;if(i+s<=r){let r,n,a,f;switch(s){case 1:t<128&&(o=t);break;case 2:r=e[i+1],128==(192&r)&&(f=(31&t)<<6|63&r,f>127&&(o=f));break;case 3:r=e[i+1],n=e[i+2],128==(192&r)&&128==(192&n)&&(f=(15&t)<<12|(63&r)<<6|63&n,f>2047&&(f<55296||f>57343)&&(o=f));break;case 4:r=e[i+1],n=e[i+2],a=e[i+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(f=(15&t)<<18|(63&r)<<12|(63&n)<<6|63&a,f>65535&&f<1114112&&(o=f))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return function(e){const t=e.length;if(t<=k)return String.fromCharCode.apply(String,e);let r="",n=0;for(;nn.length?(f.isBuffer(t)||(t=f.from(t)),t.copy(n,i)):Uint8Array.prototype.set.call(n,t,i);else{if(!f.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(n,i)}i+=t.length}return n},f.byteLength=b,f.prototype._isBuffer=!0,f.prototype.swap16=function(){const e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;tr&&(e+=" ... "),""},o&&(f.prototype[o]=f.prototype.inspect),f.prototype.compare=function(e,t,r,n,i){if(X(e,Uint8Array)&&(e=f.from(e,e.offset,e.byteLength)),!f.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;let o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0);const a=Math.min(o,s),u=this.slice(n,i),c=e.slice(t,r);for(let e=0;e>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return v(this,e,t,r);case"utf8":case"utf-8":return _(this,e,t,r);case"ascii":case"latin1":case"binary":return E(this,e,t,r);case"base64":return S(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},f.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const k=4096;function P(e,t,r){let n="";r=Math.min(e.length,r);for(let i=t;in)&&(r=n);let i="";for(let n=t;nr)throw new RangeError("Trying to access beyond buffer length")}function L(e,t,r,n,i,o){if(!f.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function R(e,t,r,n,i){j(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r++]=o,o>>=8,e[r++]=o,o>>=8,e[r++]=o,o>>=8,e[r++]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=s,s>>=8,e[r++]=s,s>>=8,e[r++]=s,s>>=8,e[r++]=s,r}function N(e,t,r,n,i){j(t,n,i,e,r,7);let o=Number(t&BigInt(4294967295));e[r+7]=o,o>>=8,e[r+6]=o,o>>=8,e[r+5]=o,o>>=8,e[r+4]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=s,s>>=8,e[r+2]=s,s>>=8,e[r+1]=s,s>>=8,e[r]=s,r+8}function U(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function C(e,t,r,n,o){return t=+t,r>>>=0,o||U(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function H(e,t,r,n,o){return t=+t,r>>>=0,o||U(e,0,r,8),i.write(e,t,r,n,52,8),r+8}f.prototype.slice=function(e,t){const r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t>>=0,t>>>=0,r||B(e,t,this.length);let n=this[e],i=1,o=0;for(;++o>>=0,t>>>=0,r||B(e,t,this.length);let n=this[e+--t],i=1;for(;t>0&&(i*=256);)n+=this[e+--t]*i;return n},f.prototype.readUint8=f.prototype.readUInt8=function(e,t){return e>>>=0,t||B(e,1,this.length),this[e]},f.prototype.readUint16LE=f.prototype.readUInt16LE=function(e,t){return e>>>=0,t||B(e,2,this.length),this[e]|this[e+1]<<8},f.prototype.readUint16BE=f.prototype.readUInt16BE=function(e,t){return e>>>=0,t||B(e,2,this.length),this[e]<<8|this[e+1]},f.prototype.readUint32LE=f.prototype.readUInt32LE=function(e,t){return e>>>=0,t||B(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},f.prototype.readUint32BE=f.prototype.readUInt32BE=function(e,t){return e>>>=0,t||B(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},f.prototype.readBigUInt64LE=J((function(e){F(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||q(e,this.length-8);const n=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,i=this[++e]+256*this[++e]+65536*this[++e]+r*2**24;return BigInt(n)+(BigInt(i)<>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||q(e,this.length-8);const n=t*2**24+65536*this[++e]+256*this[++e]+this[++e],i=this[++e]*2**24+65536*this[++e]+256*this[++e]+r;return(BigInt(n)<>>=0,t>>>=0,r||B(e,t,this.length);let n=this[e],i=1,o=0;for(;++o=i&&(n-=Math.pow(2,8*t)),n},f.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||B(e,t,this.length);let n=t,i=1,o=this[e+--n];for(;n>0&&(i*=256);)o+=this[e+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*t)),o},f.prototype.readInt8=function(e,t){return e>>>=0,t||B(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},f.prototype.readInt16LE=function(e,t){e>>>=0,t||B(e,2,this.length);const r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},f.prototype.readInt16BE=function(e,t){e>>>=0,t||B(e,2,this.length);const r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},f.prototype.readInt32LE=function(e,t){return e>>>=0,t||B(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},f.prototype.readInt32BE=function(e,t){return e>>>=0,t||B(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},f.prototype.readBigInt64LE=J((function(e){F(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||q(e,this.length-8);const n=this[e+4]+256*this[e+5]+65536*this[e+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||q(e,this.length-8);const n=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(n)<>>=0,t||B(e,4,this.length),i.read(this,e,!0,23,4)},f.prototype.readFloatBE=function(e,t){return e>>>=0,t||B(e,4,this.length),i.read(this,e,!1,23,4)},f.prototype.readDoubleLE=function(e,t){return e>>>=0,t||B(e,8,this.length),i.read(this,e,!0,52,8)},f.prototype.readDoubleBE=function(e,t){return e>>>=0,t||B(e,8,this.length),i.read(this,e,!1,52,8)},f.prototype.writeUintLE=f.prototype.writeUIntLE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||L(this,e,t,r,Math.pow(2,8*r)-1,0);let i=1,o=0;for(this[t]=255&e;++o>>=0,r>>>=0,n||L(this,e,t,r,Math.pow(2,8*r)-1,0);let i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},f.prototype.writeUint8=f.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||L(this,e,t,1,255,0),this[t]=255&e,t+1},f.prototype.writeUint16LE=f.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||L(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},f.prototype.writeUint16BE=f.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||L(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},f.prototype.writeUint32LE=f.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||L(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},f.prototype.writeUint32BE=f.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||L(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},f.prototype.writeBigUInt64LE=J((function(e,t=0){return R(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),f.prototype.writeBigUInt64BE=J((function(e,t=0){return N(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),f.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*r-1);L(this,e,t,r,n-1,-n)}let i=0,o=1,s=0;for(this[t]=255&e;++i>>=0,!n){const n=Math.pow(2,8*r-1);L(this,e,t,r,n-1,-n)}let i=r-1,o=1,s=0;for(this[t+i]=255&e;--i>=0&&(o*=256);)e<0&&0===s&&0!==this[t+i+1]&&(s=1),this[t+i]=(e/o|0)-s&255;return t+r},f.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||L(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},f.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||L(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},f.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||L(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},f.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||L(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},f.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||L(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},f.prototype.writeBigInt64LE=J((function(e,t=0){return R(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),f.prototype.writeBigInt64BE=J((function(e,t=0){return N(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),f.prototype.writeFloatLE=function(e,t,r){return C(this,e,t,!0,r)},f.prototype.writeFloatBE=function(e,t,r){return C(this,e,t,!1,r)},f.prototype.writeDoubleLE=function(e,t,r){return H(this,e,t,!0,r)},f.prototype.writeDoubleBE=function(e,t,r){return H(this,e,t,!1,r)},f.prototype.copy=function(e,t,r,n){if(!f.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function j(e,t,r,n,i,o){if(e>r||e3?0===t||t===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(o+1)}${n}`:`>= -(2${n} ** ${8*(o+1)-1}${n}) and < 2 ** ${8*(o+1)-1}${n}`:`>= ${t}${n} and <= ${r}${n}`,new D.ERR_OUT_OF_RANGE("value",i,e)}!function(e,t,r){F(t,"offset"),void 0!==e[t]&&void 0!==e[t+r]||q(t,e.length-(r+1))}(n,i,o)}function F(e,t){if("number"!=typeof e)throw new D.ERR_INVALID_ARG_TYPE(t,"number",e)}function q(e,t,r){if(Math.floor(e)!==e)throw F(e,r),new D.ERR_OUT_OF_RANGE(r||"offset","an integer",e);if(t<0)throw new D.ERR_BUFFER_OUT_OF_BOUNDS;throw new D.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}K("ERR_BUFFER_OUT_OF_BOUNDS",(function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),K("ERR_INVALID_ARG_TYPE",(function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`}),TypeError),K("ERR_OUT_OF_RANGE",(function(e,t,r){let n=`The value of "${e}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=V(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=V(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n}),RangeError);const W=/[^+/0-9A-Za-z-_]/g;function z(e,t){let r;t=t||1/0;const n=e.length;let i=null;const o=[];for(let s=0;s55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function G(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(W,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Y(e,t,r,n){let i;for(i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function X(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function $(e){return e!=e}const Z=function(){const e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)t[n+i]=e[r]+e[i]}return t}();function J(e){return"undefined"==typeof BigInt?Q:e}function Q(){throw new Error("BigInt not supported")}},7589:(e,t,r)=>{var n=r(5636).Buffer,i=r(1983).Transform,o=r(8888).I;function s(e){i.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}r(5615)(s,i),s.prototype.update=function(e,t,r){"string"==typeof e&&(e=n.from(e,t));var i=this._update(e);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)},s.prototype.setAutoPadding=function(){},s.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},s.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},s.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},s.prototype._transform=function(e,t,r){var n;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(e){n=e}finally{r(n)}},s.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(e){t=e}e(t)},s.prototype._finalOrDigest=function(e){var t=this.__final()||n.alloc(0);return e&&(t=this._toString(t,e,!0)),t},s.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new o(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var n=this._decoder.write(e);return r&&(n+=this._decoder.end()),n},e.exports=s},3257:(e,t,r)=>{"use strict";var n=r(5615),i=r(3275),o=r(5586),s=r(3229),a=r(7589);function f(e){a.call(this,"digest"),this._hash=e}n(f,a),f.prototype._update=function(e){this._hash.update(e)},f.prototype._final=function(){return this._hash.digest()},e.exports=function(e){return"md5"===(e=e.toLowerCase())?new i:"rmd160"===e||"ripemd160"===e?new o:new f(s(e))}},2239:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.ECPairFactory=t.networks=void 0;const i=r(3540);t.networks=i;const o=r(146),s=r(2644),a=r(6952),f=r(7962),u=o.typeforce.maybe(o.typeforce.compile({compressed:o.maybe(o.Boolean),network:o.maybe(o.Network)}));t.ECPairFactory=function(e){function t(t,r){if(o.typeforce(o.Buffer256bit,t),!e.isPrivate(t))throw new TypeError("Private key not in range [1, n)");return o.typeforce(u,r),new c(t,void 0,r)}function r(t,r){return o.typeforce(e.isPoint,t),o.typeforce(u,r),new c(void 0,t,r)}(0,f.testEcc)(e);class c{__D;__Q;compressed;network;lowR;constructor(t,r,o){this.__D=t,this.__Q=r,this.lowR=!1,void 0===o&&(o={}),this.compressed=void 0===o.compressed||o.compressed,this.network=o.network||i.bitcoin,void 0!==r&&(this.__Q=n.from(e.pointCompress(r,this.compressed)))}get privateKey(){return this.__D}get publicKey(){if(!this.__Q){const t=e.pointFromScalar(this.__D,this.compressed);this.__Q=n.from(t)}return this.__Q}toWIF(){if(!this.__D)throw new Error("Missing private key");return a.encode(this.network.wif,this.__D,this.compressed)}tweak(e){return this.privateKey?this.tweakFromPrivateKey(e):this.tweakFromPublicKey(e)}sign(t,r){if(!this.__D)throw new Error("Missing private key");if(void 0===r&&(r=this.lowR),!1===r)return n.from(e.sign(t,this.__D));{let r=e.sign(t,this.__D);const i=n.alloc(32,0);let o=0;for(;r[0]>127;)o++,i.writeUIntLE(o,0,6),r=e.sign(t,this.__D,i);return n.from(r)}}signSchnorr(t){if(!this.privateKey)throw new Error("Missing private key");if(!e.signSchnorr)throw new Error("signSchnorr not supported by ecc library");return n.from(e.signSchnorr(t,this.privateKey))}verify(t,r){return e.verify(t,this.publicKey,r)}verifySchnorr(t,r){if(!e.verifySchnorr)throw new Error("verifySchnorr not supported by ecc library");return e.verifySchnorr(t,this.publicKey.subarray(1,33),r)}tweakFromPublicKey(t){const i=32===(o=this.publicKey).length?o:o.slice(1,33);var o;const s=e.xOnlyPointAddTweak(i,t);if(!s||null===s.xOnlyPubkey)throw new Error("Cannot tweak public key!");const a=n.from([0===s.parity?2:3]);return r(n.concat([a,s.xOnlyPubkey]),{network:this.network,compressed:this.compressed})}tweakFromPrivateKey(r){const i=3!==this.publicKey[0]&&(4!==this.publicKey[0]||1&~this.publicKey[64])?this.privateKey:e.privateNegate(this.privateKey),o=e.privateAdd(i,r);if(!o)throw new Error("Invalid tweaked private key!");return t(n.from(o),{network:this.network,compressed:this.compressed})}}return{isPoint:function(t){return e.isPoint(t)},fromPrivateKey:t,fromPublicKey:r,fromWIF:function(e,r){const n=a.decode(e),s=n.version;if(o.Array(r)){if(!(r=r.filter((e=>s===e.wif)).pop()))throw new Error("Unknown network version")}else if(r=r||i.bitcoin,s!==r.wif)throw new Error("Invalid network version");return t(n.privateKey,{compressed:n.compressed,network:r})},makeRandom:function(r){o.typeforce(u,r),void 0===r&&(r={});const n=r.rng||s;let i;do{i=n(32),o.typeforce(o.Buffer256bit,i)}while(!e.isPrivate(i));return t(i,r)}}}},1075:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.networks=t.ECPairFactory=t.default=void 0;var n=r(2239);Object.defineProperty(t,"default",{enumerable:!0,get:function(){return n.ECPairFactory}}),Object.defineProperty(t,"ECPairFactory",{enumerable:!0,get:function(){return n.ECPairFactory}}),Object.defineProperty(t,"networks",{enumerable:!0,get:function(){return n.networks}})},3540:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.testnet=t.bitcoin=void 0,t.bitcoin={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},t.testnet={messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239}},7962:(e,t,r)=>{"use strict";var n=r(1048).Buffer;Object.defineProperty(t,"__esModule",{value:!0}),t.testEcc=void 0;const i=e=>n.from(e,"hex");function o(e){if(!e)throw new Error("ecc library invalid")}t.testEcc=function(e){o(e.isPoint(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(!e.isPoint(i("030000000000000000000000000000000000000000000000000000000000000005"))),o(e.isPrivate(i("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(e.isPrivate(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),o(!e.isPrivate(i("0000000000000000000000000000000000000000000000000000000000000000"))),o(!e.isPrivate(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"))),o(!e.isPrivate(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142"))),o(n.from(e.privateAdd(i("0000000000000000000000000000000000000000000000000000000000000001"),i("0000000000000000000000000000000000000000000000000000000000000000"))).equals(i("0000000000000000000000000000000000000000000000000000000000000001"))),o(null===e.privateAdd(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"),i("0000000000000000000000000000000000000000000000000000000000000003"))),o(n.from(e.privateAdd(i("e211078564db65c3ce7704f08262b1f38f1ef412ad15b5ac2d76657a63b2c500"),i("b51fbb69051255d1becbd683de5848242a89c229348dd72896a87ada94ae8665"))).equals(i("9730c2ee69edbb958d42db7460bafa18fef9d955325aec99044c81c8282b0a24"))),o(n.from(e.privateNegate(i("0000000000000000000000000000000000000000000000000000000000000001"))).equals(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),o(n.from(e.privateNegate(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"))).equals(i("0000000000000000000000000000000000000000000000000000000000000003"))),o(n.from(e.privateNegate(i("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(i("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792"))),o(n.from(e.pointCompress(i("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!0)).equals(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(n.from(e.pointCompress(i("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!1)).equals(i("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),o(n.from(e.pointCompress(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!0)).equals(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(n.from(e.pointCompress(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!1)).equals(i("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),o(n.from(e.pointFromScalar(i("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(i("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99"))),o(null===e.xOnlyPointAddTweak(i("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140")));let t=e.xOnlyPointAddTweak(i("1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b"),i("a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac"));o(n.from(t.xOnlyPubkey).equals(i("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"))&&1===t.parity),t=e.xOnlyPointAddTweak(i("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"),i("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47")),o(n.from(t.xOnlyPubkey).equals(i("9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"))&&0===t.parity),o(n.from(e.sign(i("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))).equals(i("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),o(e.verify(i("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),i("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),i("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),e.signSchnorr&&o(n.from(e.signSchnorr(i("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),i("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"),i("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906"))).equals(i("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7"))),e.verifySchnorr&&o(e.verifySchnorr(i("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),i("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"),i("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")))}},146:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.maybe=t.Boolean=t.Array=t.Buffer256bit=t.Network=t.typeforce=void 0,t.typeforce=r(973),t.Network=t.typeforce.compile({messagePrefix:t.typeforce.oneOf(t.typeforce.Buffer,t.typeforce.String),bip32:{public:t.typeforce.UInt32,private:t.typeforce.UInt32},pubKeyHash:t.typeforce.UInt8,scriptHash:t.typeforce.UInt8,wif:t.typeforce.UInt8}),t.Buffer256bit=t.typeforce.BufferN(32),t.Array=t.typeforce.Array,t.Boolean=t.typeforce.Boolean,t.maybe=t.typeforce.maybe},3360:(e,t,r)=>{"use strict";var n=t;n.version=r(183).rE,n.utils=r(1874),n.rand=r(7048),n.curve=r(7131),n.curves=r(6443),n.ec=r(5064),n.eddsa=r(4807)},5174:(e,t,r)=>{"use strict";var n=r(2823),i=r(1874),o=i.getNAF,s=i.getJSF,a=i.assert;function f(e,t){this.type=e,this.p=new n(t.p,16),this.red=t.prime?n.red(t.prime):n.mont(this.p),this.zero=new n(0).toRed(this.red),this.one=new n(1).toRed(this.red),this.two=new n(2).toRed(this.red),this.n=t.n&&new n(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function u(e,t){this.curve=e,this.type=t,this.precomputed=null}e.exports=f,f.prototype.point=function(){throw new Error("Not implemented")},f.prototype.validate=function(){throw new Error("Not implemented")},f.prototype._fixedNafMul=function(e,t){a(e.precomputed);var r=e._getDoubles(),n=o(t,1,this._bitLength),i=(1<=s;c--)f=(f<<1)+n[c];u.push(f)}for(var h=this.jpoint(null,null,null),d=this.jpoint(null,null,null),l=i;l>0;l--){for(s=0;s=0;u--){for(var c=0;u>=0&&0===s[u];u--)c++;if(u>=0&&c++,f=f.dblp(c),u<0)break;var h=s[u];a(0!==h),f="affine"===e.type?h>0?f.mixedAdd(i[h-1>>1]):f.mixedAdd(i[-h-1>>1].neg()):h>0?f.add(i[h-1>>1]):f.add(i[-h-1>>1].neg())}return"affine"===e.type?f.toP():f},f.prototype._wnafMulAdd=function(e,t,r,n,i){var a,f,u,c=this._wnafT1,h=this._wnafT2,d=this._wnafT3,l=0;for(a=0;a=1;a-=2){var b=a-1,y=a;if(1===c[b]&&1===c[y]){var g=[t[b],null,null,t[y]];0===t[b].y.cmp(t[y].y)?(g[1]=t[b].add(t[y]),g[2]=t[b].toJ().mixedAdd(t[y].neg())):0===t[b].y.cmp(t[y].y.redNeg())?(g[1]=t[b].toJ().mixedAdd(t[y]),g[2]=t[b].add(t[y].neg())):(g[1]=t[b].toJ().mixedAdd(t[y]),g[2]=t[b].toJ().mixedAdd(t[y].neg()));var w=[-3,-1,-5,-7,0,7,5,1,3],m=s(r[b],r[y]);for(l=Math.max(m[0].length,l),d[b]=new Array(l),d[y]=new Array(l),f=0;f=0;a--){for(var I=0;a>=0;){var A=!0;for(f=0;f=0&&I++,E=E.dblp(I),a<0)break;for(f=0;f0?u=h[f][T-1>>1]:T<0&&(u=h[f][-T-1>>1].neg()),E="affine"===u.type?E.mixedAdd(u):E.add(u))}}for(a=0;a=Math.ceil((e.bitLength()+1)/t.step)},u.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i{"use strict";var n=r(1874),i=r(2823),o=r(5615),s=r(5174),a=n.assert;function f(e){this.twisted=1!=(0|e.a),this.mOneA=this.twisted&&-1==(0|e.a),this.extended=this.mOneA,s.call(this,"edwards",e),this.a=new i(e.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new i(e.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new i(e.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),a(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|e.c)}function u(e,t,r,n,o){s.BasePoint.call(this,e,"projective"),null===t&&null===r&&null===n?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new i(t,16),this.y=new i(r,16),this.z=n?new i(n,16):this.curve.one,this.t=o&&new i(o,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}o(f,s),e.exports=f,f.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},f.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},f.prototype.jpoint=function(e,t,r,n){return this.point(e,t,r,n)},f.prototype.pointFromX=function(e,t){(e=new i(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr(),n=this.c2.redSub(this.a.redMul(r)),o=this.one.redSub(this.c2.redMul(this.d).redMul(r)),s=n.redMul(o.redInvm()),a=s.redSqrt();if(0!==a.redSqr().redSub(s).cmp(this.zero))throw new Error("invalid point");var f=a.fromRed().isOdd();return(t&&!f||!t&&f)&&(a=a.redNeg()),this.point(e,a)},f.prototype.pointFromY=function(e,t){(e=new i(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr(),n=r.redSub(this.c2),o=r.redMul(this.d).redMul(this.c2).redSub(this.a),s=n.redMul(o.redInvm());if(0===s.cmp(this.zero)){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var a=s.redSqrt();if(0!==a.redSqr().redSub(s).cmp(this.zero))throw new Error("invalid point");return a.fromRed().isOdd()!==t&&(a=a.redNeg()),this.point(a,e)},f.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),r=e.y.redSqr(),n=t.redMul(this.a).redAdd(r),i=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(r)));return 0===n.cmp(i)},o(u,s.BasePoint),f.prototype.pointFromJSON=function(e){return u.fromJSON(this,e)},f.prototype.point=function(e,t,r,n){return new u(this,e,t,r,n)},u.fromJSON=function(e,t){return new u(e,t[0],t[1],t[2])},u.prototype.inspect=function(){return this.isInfinity()?"":""},u.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},u.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(e),i=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),s=o.redSub(r),a=n.redSub(t),f=i.redMul(s),u=o.redMul(a),c=i.redMul(a),h=s.redMul(o);return this.curve.point(f,u,h,c)},u.prototype._projDbl=function(){var e,t,r,n,i,o,s=this.x.redAdd(this.y).redSqr(),a=this.x.redSqr(),f=this.y.redSqr();if(this.curve.twisted){var u=(n=this.curve._mulA(a)).redAdd(f);this.zOne?(e=s.redSub(a).redSub(f).redMul(u.redSub(this.curve.two)),t=u.redMul(n.redSub(f)),r=u.redSqr().redSub(u).redSub(u)):(i=this.z.redSqr(),o=u.redSub(i).redISub(i),e=s.redSub(a).redISub(f).redMul(o),t=u.redMul(n.redSub(f)),r=u.redMul(o))}else n=a.redAdd(f),i=this.curve._mulC(this.z).redSqr(),o=n.redSub(i).redSub(i),e=this.curve._mulC(s.redISub(n)).redMul(o),t=this.curve._mulC(n).redMul(a.redISub(f)),r=n.redMul(o);return this.curve.point(e,t,r)},u.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},u.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),r=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),i=this.z.redMul(e.z.redAdd(e.z)),o=r.redSub(t),s=i.redSub(n),a=i.redAdd(n),f=r.redAdd(t),u=o.redMul(s),c=a.redMul(f),h=o.redMul(f),d=s.redMul(a);return this.curve.point(u,c,d,h)},u.prototype._projAdd=function(e){var t,r,n=this.z.redMul(e.z),i=n.redSqr(),o=this.x.redMul(e.x),s=this.y.redMul(e.y),a=this.curve.d.redMul(o).redMul(s),f=i.redSub(a),u=i.redAdd(a),c=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(o).redISub(s),h=n.redMul(f).redMul(c);return this.curve.twisted?(t=n.redMul(u).redMul(s.redSub(this.curve._mulA(o))),r=f.redMul(u)):(t=n.redMul(u).redMul(s.redSub(o)),r=this.curve._mulC(f).redMul(u)),this.curve.point(h,t,r)},u.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},u.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},u.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!1)},u.prototype.jmulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!0)},u.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},u.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},u.prototype.getX=function(){return this.normalize(),this.x.fromRed()},u.prototype.getY=function(){return this.normalize(),this.y.fromRed()},u.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},u.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var r=e.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),0===this.x.cmp(t))return!0}},u.prototype.toP=u.prototype.normalize,u.prototype.mixedAdd=u.prototype.add},7131:(e,t,r)=>{"use strict";var n=t;n.base=r(5174),n.short=r(277),n.mont=r(3245),n.edwards=r(1547)},3245:(e,t,r)=>{"use strict";var n=r(2823),i=r(5615),o=r(5174),s=r(1874);function a(e){o.call(this,"mont",e),this.a=new n(e.a,16).toRed(this.red),this.b=new n(e.b,16).toRed(this.red),this.i4=new n(4).toRed(this.red).redInvm(),this.two=new n(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function f(e,t,r){o.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new n(t,16),this.z=new n(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}i(a,o),e.exports=a,a.prototype.validate=function(e){var t=e.normalize().x,r=t.redSqr(),n=r.redMul(t).redAdd(r.redMul(this.a)).redAdd(t);return 0===n.redSqrt().redSqr().cmp(n)},i(f,o.BasePoint),a.prototype.decodePoint=function(e,t){return this.point(s.toArray(e,t),1)},a.prototype.point=function(e,t){return new f(this,e,t)},a.prototype.pointFromJSON=function(e){return f.fromJSON(this,e)},f.prototype.precompute=function(){},f.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},f.fromJSON=function(e,t){return new f(e,t[0],t[1]||e.one)},f.prototype.inspect=function(){return this.isInfinity()?"":""},f.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},f.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),r=e.redSub(t),n=e.redMul(t),i=r.redMul(t.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},f.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},f.prototype.diffAdd=function(e,t){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=e.x.redAdd(e.z),o=e.x.redSub(e.z).redMul(r),s=i.redMul(n),a=t.z.redMul(o.redAdd(s).redSqr()),f=t.x.redMul(o.redISub(s).redSqr());return this.curve.point(a,f)},f.prototype.mul=function(e){for(var t=e.clone(),r=this,n=this.curve.point(null,null),i=[];0!==t.cmpn(0);t.iushrn(1))i.push(t.andln(1));for(var o=i.length-1;o>=0;o--)0===i[o]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},f.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},f.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},f.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},f.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},f.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},277:(e,t,r)=>{"use strict";var n=r(1874),i=r(2823),o=r(5615),s=r(5174),a=n.assert;function f(e){s.call(this,"short",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function u(e,t,r,n){s.BasePoint.call(this,e,"affine"),null===t&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new i(t,16),this.y=new i(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function c(e,t,r,n){s.BasePoint.call(this,e,"jacobian"),null===t&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new i(0)):(this.x=new i(t,16),this.y=new i(r,16),this.z=new i(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}o(f,s),e.exports=f,f.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,r;if(e.beta)t=new i(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=(t=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(e.lambda)r=new i(e.lambda,16);else{var o=this._getEndoRoots(this.n);0===this.g.mul(o[0]).x.cmp(this.g.x.redMul(t))?r=o[0]:(r=o[1],a(0===this.g.mul(r).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:r,basis:e.basis?e.basis.map((function(e){return{a:new i(e.a,16),b:new i(e.b,16)}})):this._getEndoBasis(r)}}},f.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:i.mont(e),r=new i(2).toRed(t).redInvm(),n=r.redNeg(),o=new i(3).toRed(t).redNeg().redSqrt().redMul(r);return[n.redAdd(o).fromRed(),n.redSub(o).fromRed()]},f.prototype._getEndoBasis=function(e){for(var t,r,n,o,s,a,f,u,c,h=this.n.ushrn(Math.floor(this.n.bitLength()/2)),d=e,l=this.n.clone(),p=new i(1),b=new i(0),y=new i(0),g=new i(1),w=0;0!==d.cmpn(0);){var m=l.div(d);u=l.sub(m.mul(d)),c=y.sub(m.mul(p));var v=g.sub(m.mul(b));if(!n&&u.cmp(h)<0)t=f.neg(),r=p,n=u.neg(),o=c;else if(n&&2==++w)break;f=u,l=d,d=u,y=p,p=c,g=b,b=v}s=u.neg(),a=c;var _=n.sqr().add(o.sqr());return s.sqr().add(a.sqr()).cmp(_)>=0&&(s=t,a=r),n.negative&&(n=n.neg(),o=o.neg()),s.negative&&(s=s.neg(),a=a.neg()),[{a:n,b:o},{a:s,b:a}]},f.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),s=i.mul(r.a),a=o.mul(n.a),f=i.mul(r.b),u=o.mul(n.b);return{k1:e.sub(s).sub(a),k2:f.add(u).neg()}},f.prototype.pointFromX=function(e,t){(e=new i(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var o=n.fromRed().isOdd();return(t&&!o||!t&&o)&&(n=n.redNeg()),this.point(e,n)},f.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},f.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},u.prototype.isInfinity=function(){return this.inf},u.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},u.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),s=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,s)},u.prototype.getX=function(){return this.x.fromRed()},u.prototype.getY=function(){return this.y.fromRed()},u.prototype.mul=function(e){return e=new i(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},u.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},u.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},u.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},u.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},u.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},o(c,s.BasePoint),f.prototype.jpoint=function(e,t,r){return new c(this,e,t,r)},c.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},c.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},c.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),s=e.y.redMul(r.redMul(this.z)),a=n.redSub(i),f=o.redSub(s);if(0===a.cmpn(0))return 0!==f.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),c=u.redMul(a),h=n.redMul(u),d=f.redSqr().redIAdd(c).redISub(h).redISub(h),l=f.redMul(h.redISub(d)).redISub(o.redMul(c)),p=this.z.redMul(e.z).redMul(a);return this.curve.jpoint(d,l,p)},c.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),s=r.redSub(n),a=i.redSub(o);if(0===s.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var f=s.redSqr(),u=f.redMul(s),c=r.redMul(f),h=a.redSqr().redIAdd(u).redISub(c).redISub(c),d=a.redMul(c.redISub(h)).redISub(i.redMul(u)),l=this.z.redMul(s);return this.curve.jpoint(h,d,l)},c.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var r=this;for(t=0;t=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},c.prototype.inspect=function(){return this.isInfinity()?"":""},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},6443:(e,t,r)=>{"use strict";var n,i=t,o=r(9499),s=r(7131),a=r(1874).assert;function f(e){"short"===e.type?this.curve=new s.short(e):"edwards"===e.type?this.curve=new s.edwards(e):this.curve=new s.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,a(this.g.validate(),"Invalid curve"),a(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function u(e,t){Object.defineProperty(i,e,{configurable:!0,enumerable:!0,get:function(){var r=new f(t);return Object.defineProperty(i,e,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=f,u("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),u("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),u("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),u("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),u("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),u("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),u("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=r(3986)}catch(e){n=void 0}u("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},5064:(e,t,r)=>{"use strict";var n=r(2823),i=r(4742),o=r(1874),s=r(6443),a=r(7048),f=o.assert,u=r(7531),c=r(7782);function h(e){if(!(this instanceof h))return new h(e);"string"==typeof e&&(f(Object.prototype.hasOwnProperty.call(s,e),"Unknown curve "+e),e=s[e]),e instanceof s.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}e.exports=h,h.prototype.keyPair=function(e){return new u(this,e)},h.prototype.keyFromPrivate=function(e,t){return u.fromPrivate(this,e,t)},h.prototype.keyFromPublic=function(e,t){return u.fromPublic(this,e,t)},h.prototype.genKeyPair=function(e){e||(e={});for(var t=new i({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||a(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),o=this.n.sub(new n(2));;){var s=new n(t.generate(r));if(!(s.cmp(o)>0))return s.iaddn(1),this.keyFromPrivate(s)}},h.prototype._truncateToN=function(e,t,r){var i;if(n.isBN(e)||"number"==typeof e)i=(e=new n(e,16)).byteLength();else if("object"==typeof e)i=e.length,e=new n(e,16);else{var o=e.toString();i=o.length+1>>>1,e=new n(o,16)}"number"!=typeof r&&(r=8*i);var s=r-this.n.bitLength();return s>0&&(e=e.ushrn(s)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},h.prototype.sign=function(e,t,r,o){if("object"==typeof r&&(o=r,r=null),o||(o={}),"string"!=typeof e&&"number"!=typeof e&&!n.isBN(e)){f("object"==typeof e&&e&&"number"==typeof e.length,"Expected message to be an array-like, a hex string, or a BN instance"),f(e.length>>>0===e.length);for(var s=0;s=0)){var y=this.g.mul(b);if(!y.isInfinity()){var g=y.getX(),w=g.umod(this.n);if(0!==w.cmpn(0)){var m=b.invm(this.n).mul(w.mul(t.getPrivate()).iadd(e));if(0!==(m=m.umod(this.n)).cmpn(0)){var v=(y.getY().isOdd()?1:0)|(0!==g.cmp(w)?2:0);return o.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),v^=1),new c({r:w,s:m,recoveryParam:v})}}}}}},h.prototype.verify=function(e,t,r,n,i){i||(i={}),e=this._truncateToN(e,!1,i.msgBitLength),r=this.keyFromPublic(r,n);var o=(t=new c(t,"hex")).r,s=t.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var a,f=s.invm(this.n),u=f.mul(e).umod(this.n),h=f.mul(o).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(u,r.getPublic(),h)).isInfinity()&&a.eqXToP(o):!(a=this.g.mulAdd(u,r.getPublic(),h)).isInfinity()&&0===a.getX().umod(this.n).cmp(o)},h.prototype.recoverPubKey=function(e,t,r,i){f((3&r)===r,"The recovery param is more than two bits"),t=new c(t,i);var o=this.n,s=new n(e),a=t.r,u=t.s,h=1&r,d=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&d)throw new Error("Unable to find sencond key candinate");a=d?this.curve.pointFromX(a.add(this.curve.n),h):this.curve.pointFromX(a,h);var l=t.r.invm(o),p=o.sub(s).mul(l).umod(o),b=u.mul(l).umod(o);return this.g.mulAdd(p,a,b)},h.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new c(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},7531:(e,t,r)=>{"use strict";var n=r(2823),i=r(1874).assert;function o(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}e.exports=o,o.fromPublic=function(e,t,r){return t instanceof o?t:new o(e,{pub:t,pubEnc:r})},o.fromPrivate=function(e,t,r){return t instanceof o?t:new o(e,{priv:t,privEnc:r})},o.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},o.prototype.getPublic=function(e,t){return"string"==typeof e&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},o.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},o.prototype._importPrivate=function(e,t){this.priv=new n(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},o.prototype._importPublic=function(e,t){if(e.x||e.y)return"mont"===this.ec.curve.type?i(e.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||i(e.x&&e.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(e.x,e.y));this.pub=this.ec.curve.decodePoint(e,t)},o.prototype.derive=function(e){return e.validate()||i(e.validate(),"public point not validated"),e.mul(this.priv).getX()},o.prototype.sign=function(e,t,r){return this.ec.sign(e,this,t,r)},o.prototype.verify=function(e,t,r){return this.ec.verify(e,t,this,void 0,r)},o.prototype.inspect=function(){return""}},7782:(e,t,r)=>{"use strict";var n=r(2823),i=r(1874),o=i.assert;function s(e,t){if(e instanceof s)return e;this._importDER(e,t)||(o(e.r&&e.s,"Signature without r or s"),this.r=new n(e.r,16),this.s=new n(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function a(){this.place=0}function f(e,t){var r=e[t.place++];if(!(128&r))return r;var n=15&r;if(0===n||n>4)return!1;if(0===e[t.place])return!1;for(var i=0,o=0,s=t.place;o>>=0;return!(i<=127)&&(t.place=s,i)}function u(e){for(var t=0,r=e.length-1;!e[t]&&!(128&e[t+1])&&t>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}e.exports=s,s.prototype._importDER=function(e,t){e=i.toArray(e,t);var r=new a;if(48!==e[r.place++])return!1;var o=f(e,r);if(!1===o)return!1;if(o+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var s=f(e,r);if(!1===s)return!1;if(128&e[r.place])return!1;var u=e.slice(r.place,s+r.place);if(r.place+=s,2!==e[r.place++])return!1;var c=f(e,r);if(!1===c)return!1;if(e.length!==c+r.place)return!1;if(128&e[r.place])return!1;var h=e.slice(r.place,c+r.place);if(0===u[0]){if(!(128&u[1]))return!1;u=u.slice(1)}if(0===h[0]){if(!(128&h[1]))return!1;h=h.slice(1)}return this.r=new n(u),this.s=new n(h),this.recoveryParam=null,!0},s.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=u(t),r=u(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];c(n,t.length),(n=n.concat(t)).push(2),c(n,r.length);var o=n.concat(r),s=[48];return c(s,o.length),s=s.concat(o),i.encode(s,e)}},4807:(e,t,r)=>{"use strict";var n=r(9499),i=r(6443),o=r(1874),s=o.assert,a=o.parseBytes,f=r(4672),u=r(8401);function c(e){if(s("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof c))return new c(e);e=i[e].curve,this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=n.sha512}e.exports=c,c.prototype.sign=function(e,t){e=a(e);var r=this.keyFromSecret(t),n=this.hashInt(r.messagePrefix(),e),i=this.g.mul(n),o=this.encodePoint(i),s=this.hashInt(o,r.pubBytes(),e).mul(r.priv()),f=n.add(s).umod(this.curve.n);return this.makeSignature({R:i,S:f,Rencoded:o})},c.prototype.verify=function(e,t,r){if(e=a(e),(t=this.makeSignature(t)).S().gte(t.eddsa.curve.n)||t.S().isNeg())return!1;var n=this.keyFromPublic(r),i=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S());return t.R().add(n.pub().mul(i)).eq(o)},c.prototype.hashInt=function(){for(var e=this.hash(),t=0;t{"use strict";var n=r(1874),i=n.assert,o=n.parseBytes,s=n.cachedProperty;function a(e,t){this.eddsa=e,this._secret=o(t.secret),e.isPoint(t.pub)?this._pub=t.pub:this._pubBytes=o(t.pub)}a.fromPublic=function(e,t){return t instanceof a?t:new a(e,{pub:t})},a.fromSecret=function(e,t){return t instanceof a?t:new a(e,{secret:t})},a.prototype.secret=function(){return this._secret},s(a,"pubBytes",(function(){return this.eddsa.encodePoint(this.pub())})),s(a,"pub",(function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())})),s(a,"privBytes",(function(){var e=this.eddsa,t=this.hash(),r=e.encodingLength-1,n=t.slice(0,e.encodingLength);return n[0]&=248,n[r]&=127,n[r]|=64,n})),s(a,"priv",(function(){return this.eddsa.decodeInt(this.privBytes())})),s(a,"hash",(function(){return this.eddsa.hash().update(this.secret()).digest()})),s(a,"messagePrefix",(function(){return this.hash().slice(this.eddsa.encodingLength)})),a.prototype.sign=function(e){return i(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)},a.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)},a.prototype.getSecret=function(e){return i(this._secret,"KeyPair is public only"),n.encode(this.secret(),e)},a.prototype.getPublic=function(e){return n.encode(this.pubBytes(),e)},e.exports=a},8401:(e,t,r)=>{"use strict";var n=r(2823),i=r(1874),o=i.assert,s=i.cachedProperty,a=i.parseBytes;function f(e,t){this.eddsa=e,"object"!=typeof t&&(t=a(t)),Array.isArray(t)&&(o(t.length===2*e.encodingLength,"Signature has invalid size"),t={R:t.slice(0,e.encodingLength),S:t.slice(e.encodingLength)}),o(t.R&&t.S,"Signature without R or S"),e.isPoint(t.R)&&(this._R=t.R),t.S instanceof n&&(this._S=t.S),this._Rencoded=Array.isArray(t.R)?t.R:t.Rencoded,this._Sencoded=Array.isArray(t.S)?t.S:t.Sencoded}s(f,"S",(function(){return this.eddsa.decodeInt(this.Sencoded())})),s(f,"R",(function(){return this.eddsa.decodePoint(this.Rencoded())})),s(f,"Rencoded",(function(){return this.eddsa.encodePoint(this.R())})),s(f,"Sencoded",(function(){return this.eddsa.encodeInt(this.S())})),f.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},f.prototype.toHex=function(){return i.encode(this.toBytes(),"hex").toUpperCase()},e.exports=f},3986:e=>{e.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}},1874:(e,t,r)=>{"use strict";var n=t,i=r(2823),o=r(7784),s=r(9042);n.assert=o,n.toArray=s.toArray,n.zero2=s.zero2,n.toHex=s.toHex,n.encode=s.encode,n.getNAF=function(e,t,r){var n,i=new Array(Math.max(e.bitLength(),r)+1);for(n=0;n(o>>1)-1?(o>>1)-f:f,s.isubn(a)):a=0,i[n]=a,s.iushrn(1)}return i},n.getJSF=function(e,t){var r=[[],[]];e=e.clone(),t=t.clone();for(var n,i=0,o=0;e.cmpn(-i)>0||t.cmpn(-o)>0;){var s,a,f=e.andln(3)+i&3,u=t.andln(3)+o&3;3===f&&(f=-1),3===u&&(u=-1),s=1&f?3!=(n=e.andln(7)+i&7)&&5!==n||2!==u?f:-f:0,r[0].push(s),a=1&u?3!=(n=t.andln(7)+o&7)&&5!==n||2!==f?u:-u:0,r[1].push(a),2*i===s+1&&(i=1-i),2*o===a+1&&(o=1-o),e.iushrn(1),t.iushrn(1)}return r},n.cachedProperty=function(e,t,r){var n="_"+t;e.prototype[t]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(e){return"string"==typeof e?n.toArray(e,"hex"):e},n.intFromLE=function(e){return new i(e,"hex","le")}},46:e=>{"use strict";var t,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var i=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise((function(r,n){function i(r){e.removeListener(t,o),n(r)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",i),r([].slice.call(arguments))}b(e,t,o,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&b(e,"error",t,{once:!0})}(e,i)}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function f(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function u(e,t,r,n){var i,o,s,u;if(a(r),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]),void 0===s)s=o[t]=r,++e._eventsCount;else if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(i=f(e))>0&&s.length>i&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,u=c,console&&console.warn&&console.warn(u)}return e}function c(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=c.bind(n);return i.listener=r,n.wrapFn=i,i}function d(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var f=o[e];if(void 0===f)return!1;if("function"==typeof f)n(f,this,t);else{var u=f.length,c=p(f,u);for(r=0;r=0;o--)if(r[o]===t||r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},o.prototype.listeners=function(e){return d(this,e,!0)},o.prototype.rawListeners=function(e){return d(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):l.call(e,t)},o.prototype.listenerCount=l,o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},2337:function(e,t,r){var n;!function(){var t={};!function(e){"use strict";e.__esModule=!0,e.digestLength=32,e.blockSize=64;var t=new Uint32Array([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]);function r(e,r,n,i,o){for(var s,a,f,u,c,h,d,l,p,b,y,g,w;o>=64;){for(s=r[0],a=r[1],f=r[2],u=r[3],c=r[4],h=r[5],d=r[6],l=r[7],b=0;b<16;b++)y=i+4*b,e[b]=(255&n[y])<<24|(255&n[y+1])<<16|(255&n[y+2])<<8|255&n[y+3];for(b=16;b<64;b++)g=((p=e[b-2])>>>17|p<<15)^(p>>>19|p<<13)^p>>>10,w=((p=e[b-15])>>>7|p<<25)^(p>>>18|p<<14)^p>>>3,e[b]=(g+e[b-7]|0)+(w+e[b-16]|0);for(b=0;b<64;b++)g=(((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))+(c&h^~c&d)|0)+(l+(t[b]+e[b]|0)|0)|0,w=((s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10))+(s&a^s&f^a&f)|0,l=d,d=h,h=c,c=u+g|0,u=f,f=a,a=s,s=g+w|0;r[0]+=s,r[1]+=a,r[2]+=f,r[3]+=u,r[4]+=c,r[5]+=h,r[6]+=d,r[7]+=l,i+=64,o-=64}return i}var n=function(){function t(){this.digestLength=e.digestLength,this.blockSize=e.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return t.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},t.prototype.clean=function(){for(var e=0;e0){for(;this.bufferLength<64&&t>0;)this.buffer[this.bufferLength++]=e[n++],t--;64===this.bufferLength&&(r(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(t>=64&&(n=r(this.temp,this.state,e,n,t),t%=64);t>0;)this.buffer[this.bufferLength++]=e[n++],t--;return this},t.prototype.finish=function(e){if(!this.finished){var t=this.bytesHashed,n=this.bufferLength,i=t/536870912|0,o=t<<3,s=t%64<56?64:128;this.buffer[n]=128;for(var a=n+1;a>>24&255,this.buffer[s-7]=i>>>16&255,this.buffer[s-6]=i>>>8&255,this.buffer[s-5]=i>>>0&255,this.buffer[s-4]=o>>>24&255,this.buffer[s-3]=o>>>16&255,this.buffer[s-2]=o>>>8&255,this.buffer[s-1]=o>>>0&255,r(this.temp,this.state,this.buffer,0,s),this.finished=!0}for(a=0;a<8;a++)e[4*a+0]=this.state[a]>>>24&255,e[4*a+1]=this.state[a]>>>16&255,e[4*a+2]=this.state[a]>>>8&255,e[4*a+3]=this.state[a]>>>0&255;return this},t.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},t.prototype._saveState=function(e){for(var t=0;tthis.blockSize)(new n).update(e).finish(t).clean();else for(var r=0;r1&&t.update(e),r&&t.update(r),t.update(n),t.finish(e),n[0]++}e.HMAC=i,e.hash=o,e.default=o,e.hmac=s;var f=new Uint8Array(e.digestLength);e.hkdf=function(e,t,r,n){void 0===t&&(t=f),void 0===n&&(n=32);for(var o=new Uint8Array([1]),u=s(t,e),c=new i(u),h=new Uint8Array(c.digestLength),d=h.length,l=new Uint8Array(n),p=0;p>>24&255,a[1]=d>>>16&255,a[2]=d>>>8&255,a[3]=d>>>0&255,o.reset(),o.update(t),o.update(a),o.finish(u);for(var l=0;l{"use strict";var n=r(5636).Buffer,i=r(4156).Transform;function o(e){i.call(this),this._block=n.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}r(5615)(o,i),o.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(e){n=e}r(n)},o.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(e){t=e}e(t)},o.prototype.update=function(e,t){if(function(e){if(!n.isBuffer(e)&&"string"!=typeof e)throw new TypeError("Data must be a string or a buffer")}(e),this._finalized)throw new Error("Digest already called");n.isBuffer(e)||(e=n.from(e,t));for(var r=this._block,i=0;this._blockOffset+e.length-i>=this._blockSize;){for(var o=this._blockOffset;o0;++s)this._length[s]+=a,(a=this._length[s]/4294967296|0)>0&&(this._length[s]-=4294967296*a);return this},o.prototype._update=function(){throw new Error("_update is not implemented")},o.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();void 0!==e&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t},o.prototype._digest=function(){throw new Error("_digest is not implemented")},e.exports=o},9499:(e,t,r)=>{var n=t;n.utils=r(461),n.common=r(2191),n.sha=r(5746),n.ripemd=r(4169),n.hmac=r(1825),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},2191:(e,t,r)=>{"use strict";var n=r(461),i=r(7784);function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}t.BlockHash=o,o.prototype.update=function(e,t){if(e=n.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=n.join32(e,0,e.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;o{"use strict";var n=r(461),i=r(7784);function o(e,t,r){if(!(this instanceof o))return new o(e,t,r);this.Hash=e,this.blockSize=e.blockSize/8,this.outSize=e.outSize/8,this.inner=null,this.outer=null,this._init(n.toArray(t,r))}e.exports=o,o.prototype._init=function(e){e.length>this.blockSize&&(e=(new this.Hash).update(e).digest()),i(e.length<=this.blockSize);for(var t=e.length;t{"use strict";var n=r(461),i=r(2191),o=n.rotl32,s=n.sum32,a=n.sum32_3,f=n.sum32_4,u=i.BlockHash;function c(){if(!(this instanceof c))return new c;u.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}function h(e,t,r,n){return e<=15?t^r^n:e<=31?t&r|~t&n:e<=47?(t|~r)^n:e<=63?t&n|r&~n:t^(r|~n)}function d(e){return e<=15?0:e<=31?1518500249:e<=47?1859775393:e<=63?2400959708:2840853838}function l(e){return e<=15?1352829926:e<=31?1548603684:e<=47?1836072691:e<=63?2053994217:0}n.inherits(c,u),t.ripemd160=c,c.blockSize=512,c.outSize=160,c.hmacStrength=192,c.padLength=64,c.prototype._update=function(e,t){for(var r=this.h[0],n=this.h[1],i=this.h[2],u=this.h[3],c=this.h[4],w=r,m=n,v=i,_=u,E=c,S=0;S<80;S++){var I=s(o(f(r,h(S,n,i,u),e[p[S]+t],d(S)),y[S]),c);r=c,c=u,u=o(i,10),i=n,n=I,I=s(o(f(w,h(79-S,m,v,_),e[b[S]+t],l(S)),g[S]),E),w=E,E=_,_=o(v,10),v=m,m=I}I=a(this.h[1],i,_),this.h[1]=a(this.h[2],u,E),this.h[2]=a(this.h[3],c,w),this.h[3]=a(this.h[4],r,m),this.h[4]=a(this.h[0],n,v),this.h[0]=I},c.prototype._digest=function(e){return"hex"===e?n.toHex32(this.h,"little"):n.split32(this.h,"little")};var p=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],b=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],y=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],g=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]},5746:(e,t,r)=>{"use strict";t.sha1=r(2986),t.sha224=r(5393),t.sha256=r(536),t.sha384=r(2348),t.sha512=r(2157)},2986:(e,t,r)=>{"use strict";var n=r(461),i=r(2191),o=r(600),s=n.rotl32,a=n.sum32,f=n.sum32_5,u=o.ft_1,c=i.BlockHash,h=[1518500249,1859775393,2400959708,3395469782];function d(){if(!(this instanceof d))return new d;c.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}n.inherits(d,c),e.exports=d,d.blockSize=512,d.outSize=160,d.hmacStrength=80,d.padLength=64,d.prototype._update=function(e,t){for(var r=this.W,n=0;n<16;n++)r[n]=e[t+n];for(;n{"use strict";var n=r(461),i=r(536);function o(){if(!(this instanceof o))return new o;i.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}n.inherits(o,i),e.exports=o,o.blockSize=512,o.outSize=224,o.hmacStrength=192,o.padLength=64,o.prototype._digest=function(e){return"hex"===e?n.toHex32(this.h.slice(0,7),"big"):n.split32(this.h.slice(0,7),"big")}},536:(e,t,r)=>{"use strict";var n=r(461),i=r(2191),o=r(600),s=r(7784),a=n.sum32,f=n.sum32_4,u=n.sum32_5,c=o.ch32,h=o.maj32,d=o.s0_256,l=o.s1_256,p=o.g0_256,b=o.g1_256,y=i.BlockHash,g=[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];function w(){if(!(this instanceof w))return new w;y.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=g,this.W=new Array(64)}n.inherits(w,y),e.exports=w,w.blockSize=512,w.outSize=256,w.hmacStrength=192,w.padLength=64,w.prototype._update=function(e,t){for(var r=this.W,n=0;n<16;n++)r[n]=e[t+n];for(;n{"use strict";var n=r(461),i=r(2157);function o(){if(!(this instanceof o))return new o;i.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}n.inherits(o,i),e.exports=o,o.blockSize=1024,o.outSize=384,o.hmacStrength=192,o.padLength=128,o.prototype._digest=function(e){return"hex"===e?n.toHex32(this.h.slice(0,12),"big"):n.split32(this.h.slice(0,12),"big")}},2157:(e,t,r)=>{"use strict";var n=r(461),i=r(2191),o=r(7784),s=n.rotr64_hi,a=n.rotr64_lo,f=n.shr64_hi,u=n.shr64_lo,c=n.sum64,h=n.sum64_hi,d=n.sum64_lo,l=n.sum64_4_hi,p=n.sum64_4_lo,b=n.sum64_5_hi,y=n.sum64_5_lo,g=i.BlockHash,w=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function m(){if(!(this instanceof m))return new m;g.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=w,this.W=new Array(160)}function v(e,t,r,n,i){var o=e&r^~e&i;return o<0&&(o+=4294967296),o}function _(e,t,r,n,i,o){var s=t&n^~t&o;return s<0&&(s+=4294967296),s}function E(e,t,r,n,i){var o=e&r^e&i^r&i;return o<0&&(o+=4294967296),o}function S(e,t,r,n,i,o){var s=t&n^t&o^n&o;return s<0&&(s+=4294967296),s}function I(e,t){var r=s(e,t,28)^s(t,e,2)^s(t,e,7);return r<0&&(r+=4294967296),r}function A(e,t){var r=a(e,t,28)^a(t,e,2)^a(t,e,7);return r<0&&(r+=4294967296),r}function T(e,t){var r=a(e,t,14)^a(e,t,18)^a(t,e,9);return r<0&&(r+=4294967296),r}function k(e,t){var r=s(e,t,1)^s(e,t,8)^f(e,t,7);return r<0&&(r+=4294967296),r}function P(e,t){var r=a(e,t,1)^a(e,t,8)^u(e,t,7);return r<0&&(r+=4294967296),r}function O(e,t){var r=a(e,t,19)^a(t,e,29)^u(e,t,6);return r<0&&(r+=4294967296),r}n.inherits(m,g),e.exports=m,m.blockSize=1024,m.outSize=512,m.hmacStrength=192,m.padLength=128,m.prototype._prepareBlock=function(e,t){for(var r=this.W,n=0;n<32;n++)r[n]=e[t+n];for(;n{"use strict";var n=r(461).rotr32;function i(e,t,r){return e&t^~e&r}function o(e,t,r){return e&t^e&r^t&r}function s(e,t,r){return e^t^r}t.ft_1=function(e,t,r,n){return 0===e?i(t,r,n):1===e||3===e?s(t,r,n):2===e?o(t,r,n):void 0},t.ch32=i,t.maj32=o,t.p32=s,t.s0_256=function(e){return n(e,2)^n(e,13)^n(e,22)},t.s1_256=function(e){return n(e,6)^n(e,11)^n(e,25)},t.g0_256=function(e){return n(e,7)^n(e,18)^e>>>3},t.g1_256=function(e){return n(e,17)^n(e,19)^e>>>10}},461:(e,t,r)=>{"use strict";var n=r(7784),i=r(5615);function o(e,t){return 55296==(64512&e.charCodeAt(t))&&!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1))}function s(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function a(e){return 1===e.length?"0"+e:e}function f(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}t.inherits=i,t.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),i=0;i>6|192,r[n++]=63&s|128):o(e,i)?(s=65536+((1023&s)<<10)+(1023&e.charCodeAt(++i)),r[n++]=s>>18|240,r[n++]=s>>12&63|128,r[n++]=s>>6&63|128,r[n++]=63&s|128):(r[n++]=s>>12|224,r[n++]=s>>6&63|128,r[n++]=63&s|128)}else for(i=0;i>>0}return s},t.split32=function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},t.rotr32=function(e,t){return e>>>t|e<<32-t},t.rotl32=function(e,t){return e<>>32-t},t.sum32=function(e,t){return e+t>>>0},t.sum32_3=function(e,t,r){return e+t+r>>>0},t.sum32_4=function(e,t,r,n){return e+t+r+n>>>0},t.sum32_5=function(e,t,r,n,i){return e+t+r+n+i>>>0},t.sum64=function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,s=(o>>0,e[t+1]=o},t.sum64_hi=function(e,t,r,n){return(t+n>>>0>>0},t.sum64_lo=function(e,t,r,n){return t+n>>>0},t.sum64_4_hi=function(e,t,r,n,i,o,s,a){var f=0,u=t;return f+=(u=u+n>>>0)>>0)>>0)>>0},t.sum64_4_lo=function(e,t,r,n,i,o,s,a){return t+n+o+a>>>0},t.sum64_5_hi=function(e,t,r,n,i,o,s,a,f,u){var c=0,h=t;return c+=(h=h+n>>>0)>>0)>>0)>>0)>>0},t.sum64_5_lo=function(e,t,r,n,i,o,s,a,f,u){return t+n+o+a+u>>>0},t.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},t.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},t.shr64_hi=function(e,t,r){return e>>>r},t.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},4742:(e,t,r)=>{"use strict";var n=r(9499),i=r(9042),o=r(7784);function s(e){if(!(this instanceof s))return new s(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=i.toArray(e.entropy,e.entropyEnc||"hex"),r=i.toArray(e.nonce,e.nonceEnc||"hex"),n=i.toArray(e.pers,e.persEnc||"hex");o(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}e.exports=s,s.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},s.prototype.generate=function(e,t,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var o=[];o.length{t.read=function(e,t,r,n,i){var o,s,a=8*i-n-1,f=(1<>1,c=-7,h=r?i-1:0,d=r?-1:1,l=e[t+h];for(h+=d,o=l&(1<<-c)-1,l>>=-c,c+=a;c>0;o=256*o+e[t+h],h+=d,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=n;c>0;s=256*s+e[t+h],h+=d,c-=8);if(0===o)o=1-u;else{if(o===f)return s?NaN:1/0*(l?-1:1);s+=Math.pow(2,n),o-=u}return(l?-1:1)*s*Math.pow(2,o-n)},t.write=function(e,t,r,n,i,o){var s,a,f,u=8*o-i-1,c=(1<>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,l=n?0:o-1,p=n?1:-1,b=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=c):(s=Math.floor(Math.log(t)/Math.LN2),t*(f=Math.pow(2,-s))<1&&(s--,f*=2),(t+=s+h>=1?d/f:d*Math.pow(2,1-h))*f>=2&&(s++,f/=2),s+h>=c?(a=0,s=c):s+h>=1?(a=(t*f-1)*Math.pow(2,i),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;e[r+l]=255&a,l+=p,a/=256,i-=8);for(s=s<0;e[r+l]=255&s,l+=p,s/=256,u-=8);e[r+l-p]|=128*b}},5615:e=>{"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},3275:(e,t,r)=>{"use strict";var n=r(5615),i=r(1848),o=r(5636).Buffer,s=new Array(16);function a(){i.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function f(e,t){return e<>>32-t}function u(e,t,r,n,i,o,s){return f(e+(t&r|~t&n)+i+o|0,s)+t|0}function c(e,t,r,n,i,o,s){return f(e+(t&n|r&~n)+i+o|0,s)+t|0}function h(e,t,r,n,i,o,s){return f(e+(t^r^n)+i+o|0,s)+t|0}function d(e,t,r,n,i,o,s){return f(e+(r^(t|~n))+i+o|0,s)+t|0}n(a,i),a.prototype._update=function(){for(var e=s,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,n=this._b,i=this._c,o=this._d;r=u(r,n,i,o,e[0],3614090360,7),o=u(o,r,n,i,e[1],3905402710,12),i=u(i,o,r,n,e[2],606105819,17),n=u(n,i,o,r,e[3],3250441966,22),r=u(r,n,i,o,e[4],4118548399,7),o=u(o,r,n,i,e[5],1200080426,12),i=u(i,o,r,n,e[6],2821735955,17),n=u(n,i,o,r,e[7],4249261313,22),r=u(r,n,i,o,e[8],1770035416,7),o=u(o,r,n,i,e[9],2336552879,12),i=u(i,o,r,n,e[10],4294925233,17),n=u(n,i,o,r,e[11],2304563134,22),r=u(r,n,i,o,e[12],1804603682,7),o=u(o,r,n,i,e[13],4254626195,12),i=u(i,o,r,n,e[14],2792965006,17),r=c(r,n=u(n,i,o,r,e[15],1236535329,22),i,o,e[1],4129170786,5),o=c(o,r,n,i,e[6],3225465664,9),i=c(i,o,r,n,e[11],643717713,14),n=c(n,i,o,r,e[0],3921069994,20),r=c(r,n,i,o,e[5],3593408605,5),o=c(o,r,n,i,e[10],38016083,9),i=c(i,o,r,n,e[15],3634488961,14),n=c(n,i,o,r,e[4],3889429448,20),r=c(r,n,i,o,e[9],568446438,5),o=c(o,r,n,i,e[14],3275163606,9),i=c(i,o,r,n,e[3],4107603335,14),n=c(n,i,o,r,e[8],1163531501,20),r=c(r,n,i,o,e[13],2850285829,5),o=c(o,r,n,i,e[2],4243563512,9),i=c(i,o,r,n,e[7],1735328473,14),r=h(r,n=c(n,i,o,r,e[12],2368359562,20),i,o,e[5],4294588738,4),o=h(o,r,n,i,e[8],2272392833,11),i=h(i,o,r,n,e[11],1839030562,16),n=h(n,i,o,r,e[14],4259657740,23),r=h(r,n,i,o,e[1],2763975236,4),o=h(o,r,n,i,e[4],1272893353,11),i=h(i,o,r,n,e[7],4139469664,16),n=h(n,i,o,r,e[10],3200236656,23),r=h(r,n,i,o,e[13],681279174,4),o=h(o,r,n,i,e[0],3936430074,11),i=h(i,o,r,n,e[3],3572445317,16),n=h(n,i,o,r,e[6],76029189,23),r=h(r,n,i,o,e[9],3654602809,4),o=h(o,r,n,i,e[12],3873151461,11),i=h(i,o,r,n,e[15],530742520,16),r=d(r,n=h(n,i,o,r,e[2],3299628645,23),i,o,e[0],4096336452,6),o=d(o,r,n,i,e[7],1126891415,10),i=d(i,o,r,n,e[14],2878612391,15),n=d(n,i,o,r,e[5],4237533241,21),r=d(r,n,i,o,e[12],1700485571,6),o=d(o,r,n,i,e[3],2399980690,10),i=d(i,o,r,n,e[10],4293915773,15),n=d(n,i,o,r,e[1],2240044497,21),r=d(r,n,i,o,e[8],1873313359,6),o=d(o,r,n,i,e[15],4264355552,10),i=d(i,o,r,n,e[6],2734768916,15),n=d(n,i,o,r,e[13],1309151649,21),r=d(r,n,i,o,e[4],4149444226,6),o=d(o,r,n,i,e[11],3174756917,10),i=d(i,o,r,n,e[2],718787259,15),n=d(n,i,o,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+o|0},a.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=o.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e},e.exports=a},7784:e=>{function t(e,t){if(!e)throw new Error(t||"Assertion failed")}e.exports=t,t.equal=function(e,t,r){if(e!=t)throw new Error(r||"Assertion failed: "+e+" != "+t)}},9042:(e,t)=>{"use strict";var r=t;function n(e){return 1===e.length?"0"+e:e}function i(e){for(var t="",r=0;r>8,s=255&i;o?r.push(o,s):r.push(s)}return r},r.zero2=n,r.toHex=i,r.encode=function(e,t){return"hex"===t?i(e):e}},2644:(e,t,r)=>{"use strict";var n=65536,i=r(5636).Buffer,o=r.g.crypto||r.g.msCrypto;o&&o.getRandomValues?e.exports=function(e,t){if(e>4294967295)throw new RangeError("requested too many random bytes");var r=i.allocUnsafe(e);if(e>0)if(e>n)for(var s=0;s{"use strict";var t={};function r(e,r,n){n||(n=Error);var i=function(e){var t,n;function i(t,n,i){return e.call(this,function(e,t,n){return"string"==typeof r?r:r(e,t,n)}(t,n,i))||this}return n=e,(t=i).prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n,i}(n);i.prototype.name=n.name,i.prototype.code=e,t[e]=i}function n(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map((function(e){return String(e)})),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:2===r?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}r("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),r("ERR_INVALID_ARG_TYPE",(function(e,t,r){var i,o,s,a,f;if("string"==typeof t&&(o="not ",t.substr(0,4)===o)?(i="must not be",t=t.replace(/^not /,"")):i="must be",function(e,t,r){return(void 0===r||r>e.length)&&(r=e.length),e.substring(r-9,r)===t}(e," argument"))s="The ".concat(e," ").concat(i," ").concat(n(t,"type"));else{var u=("number"!=typeof f&&(f=0),f+1>(a=e).length||-1===a.indexOf(".",f)?"argument":"property");s='The "'.concat(e,'" ').concat(u," ").concat(i," ").concat(n(t,"type"))}return s+". Received type ".concat(typeof r)}),TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.F=t},1265:(e,t,r)=>{"use strict";var n=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};e.exports=u;var i=r(8199),o=r(5291);r(5615)(u,i);for(var s=n(o.prototype),a=0;a{"use strict";e.exports=i;var n=r(9415);function i(e){if(!(this instanceof i))return new i(e);n.call(this,e)}r(5615)(i,n),i.prototype._transform=function(e,t,r){r(null,e)}},8199:(e,t,r)=>{"use strict";var n;e.exports=I,I.ReadableState=S,r(46).EventEmitter;var i,o=function(e,t){return e.listeners(t).length},s=r(4856),a=r(1048).Buffer,f=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},u=r(3951);i=u&&u.debuglog?u.debuglog("stream"):function(){};var c,h,d,l=r(82),p=r(6527),b=r(9952).getHighWaterMark,y=r(5699).F,g=y.ERR_INVALID_ARG_TYPE,w=y.ERR_STREAM_PUSH_AFTER_EOF,m=y.ERR_METHOD_NOT_IMPLEMENTED,v=y.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(5615)(I,s);var _=p.errorOrDestroy,E=["error","close","destroy","pause","resume"];function S(e,t,i){n=n||r(1265),e=e||{},"boolean"!=typeof i&&(i=t instanceof n),this.objectMode=!!e.objectMode,i&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=b(this,e,"readableHighWaterMark",i),this.buffer=new l,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(c||(c=r(8888).I),this.decoder=new c(e.encoding),this.encoding=e.encoding)}function I(e){if(n=n||r(1265),!(this instanceof I))return new I(e);var t=this instanceof n;this._readableState=new S(e,this,t),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),s.call(this)}function A(e,t,r,n,o){i("readableAddChunk",t);var s,u=e._readableState;if(null===t)u.reading=!1,function(e,t){if(i("onEofChunk"),!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,t.sync?O(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,M(e)))}}(e,u);else if(o||(s=function(e,t){var r,n;return n=t,a.isBuffer(n)||n instanceof f||"string"==typeof t||void 0===t||e.objectMode||(r=new g("chunk",["string","Buffer","Uint8Array"],t)),r}(u,t)),s)_(e,s);else if(u.objectMode||t&&t.length>0)if("string"==typeof t||u.objectMode||Object.getPrototypeOf(t)===a.prototype||(t=function(e){return a.from(e)}(t)),n)u.endEmitted?_(e,new v):T(e,u,t,!0);else if(u.ended)_(e,new w);else{if(u.destroyed)return!1;u.reading=!1,u.decoder&&!r?(t=u.decoder.write(t),u.objectMode||0!==t.length?T(e,u,t,!1):x(e,u)):T(e,u,t,!1)}else n||(u.reading=!1,x(e,u));return!u.ended&&(u.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=k?e=k:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function O(e){var t=e._readableState;i("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(i("emitReadable",t.flowing),t.emittedReadable=!0,process.nextTick(M,e))}function M(e){var t=e._readableState;i("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,U(e)}function x(e,t){t.readingMore||(t.readingMore=!0,process.nextTick(B,e,t))}function B(e,t){for(;!t.reading&&!t.ended&&(t.length0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function R(e){i("readable nexttick read 0"),e.read(0)}function N(e,t){i("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),U(e),t.flowing&&!t.reading&&e.read(0)}function U(e){var t=e._readableState;for(i("flow",t.flowing);t.flowing&&null!==e.read(););}function C(e,t){return 0===t.length?null:(t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r);var r}function H(e){var t=e._readableState;i("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,process.nextTick(D,t,e))}function D(e,t){if(i("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}function K(e,t){for(var r=0,n=e.length;r=t.highWaterMark:t.length>0)||t.ended))return i("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?H(this):O(this),null;if(0===(e=P(e,t))&&t.ended)return 0===t.length&&H(this),null;var n,o=t.needReadable;return i("need readable",o),(0===t.length||t.length-e0?C(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&H(this)),null!==n&&this.emit("data",n),n},I.prototype._read=function(e){_(this,new m("_read()"))},I.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,i("pipe count=%d opts=%j",n.pipesCount,t);var s=t&&!1===t.end||e===process.stdout||e===process.stderr?p:a;function a(){i("onend"),e.end()}n.endEmitted?process.nextTick(s):r.once("end",s),e.on("unpipe",(function t(o,s){i("onunpipe"),o===r&&s&&!1===s.hasUnpiped&&(s.hasUnpiped=!0,i("cleanup"),e.removeListener("close",d),e.removeListener("finish",l),e.removeListener("drain",f),e.removeListener("error",h),e.removeListener("unpipe",t),r.removeListener("end",a),r.removeListener("end",p),r.removeListener("data",c),u=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||f())}));var f=function(e){return function(){var t=e._readableState;i("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&o(e,"data")&&(t.flowing=!0,U(e))}}(r);e.on("drain",f);var u=!1;function c(t){i("ondata");var o=e.write(t);i("dest.write",o),!1===o&&((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==K(n.pipes,e))&&!u&&(i("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function h(t){i("onerror",t),p(),e.removeListener("error",h),0===o(e,"error")&&_(e,t)}function d(){e.removeListener("finish",l),p()}function l(){i("onfinish"),e.removeListener("close",d),p()}function p(){i("unpipe"),r.unpipe(e)}return r.on("data",c),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",h),e.once("close",d),e.once("finish",l),e.emit("pipe",r),n.flowing||(i("pipe resume"),r.resume()),e},I.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o0,!1!==n.flowing&&this.resume()):"readable"===e&&(n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,i("on readable",n.length,n.reading),n.length?O(this):n.reading||process.nextTick(R,this))),r},I.prototype.addListener=I.prototype.on,I.prototype.removeListener=function(e,t){var r=s.prototype.removeListener.call(this,e,t);return"readable"===e&&process.nextTick(L,this),r},I.prototype.removeAllListeners=function(e){var t=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||process.nextTick(L,this),t},I.prototype.resume=function(){var e=this._readableState;return e.flowing||(i("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,process.nextTick(N,e,t))}(this,e)),e.paused=!1,this},I.prototype.pause=function(){return i("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(i("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},I.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;for(var o in e.on("end",(function(){if(i("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(o){i("wrapped data"),r.decoder&&(o=r.decoder.write(o)),r.objectMode&&null==o||(r.objectMode||o&&o.length)&&(t.push(o)||(n=!0,e.pause()))})),e)void 0===this[o]&&"function"==typeof e[o]&&(this[o]=function(t){return function(){return e[t].apply(e,arguments)}}(o));for(var s=0;s{"use strict";e.exports=c;var n=r(5699).F,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,s=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=n.ERR_TRANSFORM_WITH_LENGTH_0,f=r(1265);function u(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length{"use strict";function n(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t){var r=e.entry;for(e.entry=null;r;){var n=r.callback;t.pendingcb--,n(undefined),r=r.next}t.corkedRequestsFree.next=e}(t,e)}}var i;e.exports=I,I.WritableState=S;var o,s={deprecate:r(6732)},a=r(4856),f=r(1048).Buffer,u=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},c=r(6527),h=r(9952).getHighWaterMark,d=r(5699).F,l=d.ERR_INVALID_ARG_TYPE,p=d.ERR_METHOD_NOT_IMPLEMENTED,b=d.ERR_MULTIPLE_CALLBACK,y=d.ERR_STREAM_CANNOT_PIPE,g=d.ERR_STREAM_DESTROYED,w=d.ERR_STREAM_NULL_VALUES,m=d.ERR_STREAM_WRITE_AFTER_END,v=d.ERR_UNKNOWN_ENCODING,_=c.errorOrDestroy;function E(){}function S(e,t,o){i=i||r(1265),e=e||{},"boolean"!=typeof o&&(o=t instanceof i),this.objectMode=!!e.objectMode,o&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=h(this,e,"writableHighWaterMark",o),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===e.decodeStrings;this.decodeStrings=!s,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if("function"!=typeof i)throw new b;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,i){--t.pendingcb,r?(process.nextTick(i,n),process.nextTick(M,e,t),e._writableState.errorEmitted=!0,_(e,n)):(i(n),e._writableState.errorEmitted=!0,_(e,n),M(e,t))}(e,r,n,t,i);else{var o=P(r)||e.destroyed;o||r.corked||r.bufferProcessing||!r.bufferedRequest||k(e,r),n?process.nextTick(T,e,r,o,i):T(e,r,o,i)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new n(this)}function I(e){var t=this instanceof(i=i||r(1265));if(!t&&!o.call(I,this))return new I(e);this._writableState=new S(e,this,t),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),a.call(this)}function A(e,t,r,n,i,o,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new g("write")):r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function T(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),M(e,t)}function k(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var i=t.bufferedRequestCount,o=new Array(i),s=t.corkedRequestsFree;s.entry=r;for(var a=0,f=!0;r;)o[a]=r,r.isBuf||(f=!1),r=r.next,a+=1;o.allBuffers=f,A(e,t,!0,t.length,o,"",s.finish),t.pendingcb++,t.lastBufferedRequest=null,s.next?(t.corkedRequestsFree=s.next,s.next=null):t.corkedRequestsFree=new n(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,c=r.encoding,h=r.callback;if(A(e,t,!1,t.objectMode?1:u.length,u,c,h),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function P(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function O(e,t){e._final((function(r){t.pendingcb--,r&&_(e,r),t.prefinished=!0,e.emit("prefinish"),M(e,t)}))}function M(e,t){var r=P(t);if(r&&(function(e,t){t.prefinished||t.finalCalled||("function"!=typeof e._final||t.destroyed?(t.prefinished=!0,e.emit("prefinish")):(t.pendingcb++,t.finalCalled=!0,process.nextTick(O,e,t)))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var n=e._readableState;(!n||n.autoDestroy&&n.endEmitted)&&e.destroy()}return r}r(5615)(I,a),S.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(S.prototype,"buffer",{get:s.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(o=Function.prototype[Symbol.hasInstance],Object.defineProperty(I,Symbol.hasInstance,{value:function(e){return!!o.call(this,e)||this===I&&e&&e._writableState instanceof S}})):o=function(e){return e instanceof this},I.prototype.pipe=function(){_(this,new y)},I.prototype.write=function(e,t,r){var n,i=this._writableState,o=!1,s=!i.objectMode&&(n=e,f.isBuffer(n)||n instanceof u);return s&&!f.isBuffer(e)&&(e=function(e){return f.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=E),i.ending?function(e,t){var r=new m;_(e,r),process.nextTick(t,r)}(this,r):(s||function(e,t,r,n){var i;return null===r?i=new w:"string"==typeof r||t.objectMode||(i=new l("chunk",["string","Buffer"],r)),!i||(_(e,i),process.nextTick(n,i),!1)}(this,i,e,r))&&(i.pendingcb++,o=function(e,t,r,n,i,o){if(!r){var s=function(e,t,r){return e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=f.from(t,r)),t}(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=t.objectMode?1:n.length;t.length+=a;var u=t.length-1))throw new v(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(I.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(I.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),I.prototype._write=function(e,t,r){r(new p("_write()"))},I.prototype._writev=null,I.prototype.end=function(e,t,r){var n=this._writableState;return"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||function(e,t,r){t.ending=!0,M(e,t),r&&(t.finished?process.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}(this,n,r),this},Object.defineProperty(I.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(I.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),I.prototype.destroy=c.destroy,I.prototype._undestroy=c.undestroy,I.prototype._destroy=function(e,t){t(e)}},534:(e,t,r)=>{"use strict";var n;function i(e,t,r){return(t=function(e){var t=function(e){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var o=r(4869),s=Symbol("lastResolve"),a=Symbol("lastReject"),f=Symbol("error"),u=Symbol("ended"),c=Symbol("lastPromise"),h=Symbol("handlePromise"),d=Symbol("stream");function l(e,t){return{value:e,done:t}}function p(e){var t=e[s];if(null!==t){var r=e[d].read();null!==r&&(e[c]=null,e[s]=null,e[a]=null,t(l(r,!1)))}}function b(e){process.nextTick(p,e)}var y=Object.getPrototypeOf((function(){})),g=Object.setPrototypeOf((i(n={get stream(){return this[d]},next:function(){var e=this,t=this[f];if(null!==t)return Promise.reject(t);if(this[u])return Promise.resolve(l(void 0,!0));if(this[d].destroyed)return new Promise((function(t,r){process.nextTick((function(){e[f]?r(e[f]):t(l(void 0,!0))}))}));var r,n=this[c];if(n)r=new Promise(function(e,t){return function(r,n){e.then((function(){t[u]?r(l(void 0,!0)):t[h](r,n)}),n)}}(n,this));else{var i=this[d].read();if(null!==i)return Promise.resolve(l(i,!1));r=new Promise(this[h])}return this[c]=r,r}},Symbol.asyncIterator,(function(){return this})),i(n,"return",(function(){var e=this;return new Promise((function(t,r){e[d].destroy(null,(function(e){e?r(e):t(l(void 0,!0))}))}))})),n),y);e.exports=function(e){var t,r=Object.create(g,(i(t={},d,{value:e,writable:!0}),i(t,s,{value:null,writable:!0}),i(t,a,{value:null,writable:!0}),i(t,f,{value:null,writable:!0}),i(t,u,{value:e._readableState.endEmitted,writable:!0}),i(t,h,{value:function(e,t){var n=r[d].read();n?(r[c]=null,r[s]=null,r[a]=null,e(l(n,!1))):(r[s]=e,r[a]=t)},writable:!0}),t));return r[c]=null,o(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=r[a];return null!==t&&(r[c]=null,r[s]=null,r[a]=null,t(e)),void(r[f]=e)}var n=r[s];null!==n&&(r[c]=null,r[s]=null,r[a]=null,n(l(void 0,!0))),r[u]=!0})),e.on("readable",b.bind(null,r)),r}},82:(e,t,r)=>{"use strict";function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function i(e){for(var t=1;t0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r}},{key:"concat",value:function(e){if(0===this.length)return f.alloc(0);for(var t,r,n,i=f.allocUnsafe(e>>>0),o=this.head,s=0;o;)t=o.data,r=i,n=s,f.prototype.copy.call(t,r,n),s+=o.data.length,o=o.next;return i}},{key:"consume",value:function(e,t){var r;return ei.length?i.length:e;if(o===i.length?n+=i:n+=i.slice(0,e),0==(e-=o)){o===i.length?(++r,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(e){var t=f.allocUnsafe(e),r=this.head,n=1;for(r.data.copy(t),e-=r.data.length;r=r.next;){var i=r.data,o=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,o),0==(e-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,t}},{key:c,value:function(e,t){return u(this,i(i({},t),{},{depth:0,customInspect:!1}))}}])&&s(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),e}()},6527:e=>{"use strict";function t(e,t){n(e,t),r(e)}function r(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function n(e,t){e.emit("error",t)}e.exports={destroy:function(e,i){var o=this,s=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;return s||a?(i?i(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(n,this,e)):process.nextTick(n,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,(function(e){!i&&e?o._writableState?o._writableState.errorEmitted?process.nextTick(r,o):(o._writableState.errorEmitted=!0,process.nextTick(t,o,e)):process.nextTick(t,o,e):i?(process.nextTick(r,o),i(e)):process.nextTick(r,o)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(e,t){var r=e._readableState,n=e._writableState;r&&r.autoDestroy||n&&n.autoDestroy?e.destroy(t):e.emit("error",t)}}},4869:(e,t,r)=>{"use strict";var n=r(5699).F.ERR_STREAM_PREMATURE_CLOSE;function i(){}e.exports=function e(t,r,o){if("function"==typeof r)return e(t,null,r);r||(r={}),o=function(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,n=new Array(r),i=0;i{e.exports=function(){throw new Error("Readable.from is not available in the browser")}},6815:(e,t,r)=>{"use strict";var n,i=r(5699).F,o=i.ERR_MISSING_ARGS,s=i.ERR_STREAM_DESTROYED;function a(e){if(e)throw e}function f(e){e()}function u(e,t){return e.pipe(t)}e.exports=function(){for(var e=arguments.length,t=new Array(e),i=0;i0,(function(e){c||(c=e),e&&d.forEach(f),o||(d.forEach(f),h(c))}))}));return t.reduce(u)}},9952:(e,t,r)=>{"use strict";var n=r(5699).F.ERR_INVALID_OPT_VALUE;e.exports={getHighWaterMark:function(e,t,r,i){var o=function(e,t,r){return null!=e.highWaterMark?e.highWaterMark:t?e[r]:null}(t,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new n(i?r:"highWaterMark",o);return Math.floor(o)}return e.objectMode?16:16384}}},4856:(e,t,r)=>{e.exports=r(46).EventEmitter},4156:(e,t,r)=>{(t=e.exports=r(8199)).Stream=t,t.Readable=t,t.Writable=r(5291),t.Duplex=r(1265),t.Transform=r(9415),t.PassThrough=r(4421),t.finished=r(4869),t.pipeline=r(6815)},5586:(e,t,r)=>{"use strict";var n=r(1048).Buffer,i=r(5615),o=r(1848),s=new Array(16),a=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],f=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],u=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],c=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],h=[0,1518500249,1859775393,2400959708,2840853838],d=[1352829926,1548603684,1836072691,2053994217,0];function l(){o.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function p(e,t){return e<>>32-t}function b(e,t,r,n,i,o,s,a){return p(e+(t^r^n)+o+s|0,a)+i|0}function y(e,t,r,n,i,o,s,a){return p(e+(t&r|~t&n)+o+s|0,a)+i|0}function g(e,t,r,n,i,o,s,a){return p(e+((t|~r)^n)+o+s|0,a)+i|0}function w(e,t,r,n,i,o,s,a){return p(e+(t&n|r&~n)+o+s|0,a)+i|0}function m(e,t,r,n,i,o,s,a){return p(e+(t^(r|~n))+o+s|0,a)+i|0}i(l,o),l.prototype._update=function(){for(var e=s,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);for(var r=0|this._a,n=0|this._b,i=0|this._c,o=0|this._d,l=0|this._e,v=0|this._a,_=0|this._b,E=0|this._c,S=0|this._d,I=0|this._e,A=0;A<80;A+=1){var T,k;A<16?(T=b(r,n,i,o,l,e[a[A]],h[0],u[A]),k=m(v,_,E,S,I,e[f[A]],d[0],c[A])):A<32?(T=y(r,n,i,o,l,e[a[A]],h[1],u[A]),k=w(v,_,E,S,I,e[f[A]],d[1],c[A])):A<48?(T=g(r,n,i,o,l,e[a[A]],h[2],u[A]),k=g(v,_,E,S,I,e[f[A]],d[2],c[A])):A<64?(T=w(r,n,i,o,l,e[a[A]],h[3],u[A]),k=y(v,_,E,S,I,e[f[A]],d[3],c[A])):(T=m(r,n,i,o,l,e[a[A]],h[4],u[A]),k=b(v,_,E,S,I,e[f[A]],d[4],c[A])),r=l,l=o,o=p(i,10),i=n,n=T,v=I,I=S,S=p(E,10),E=_,_=k}var P=this._b+i+S|0;this._b=this._c+o+I|0,this._c=this._d+l+v|0,this._d=this._e+r+_|0,this._e=this._a+n+E|0,this._a=P},l.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=n.alloc?n.alloc(20):new n(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e},e.exports=l},5636:(e,t,r)=>{var n=r(1048),i=n.Buffer;function o(e,t){for(var r in e)t[r]=e[r]}function s(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=n:(o(n,t),t.Buffer=s),s.prototype=Object.create(i.prototype),o(i,s),s.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,r)},s.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},9942:(e,t,r)=>{"use strict";e.exports=r(5574)(r(7705))},7562:(e,t,r)=>{"use strict";var n=r(1048).Buffer,i=Object.prototype.toString;t.isArray=function(e,t){if(!Array.isArray(e))throw TypeError(t)},t.isBoolean=function(e,t){if("[object Boolean]"!==i.call(e))throw TypeError(t)},t.isBuffer=function(e,t){if(!n.isBuffer(e))throw TypeError(t)},t.isFunction=function(e,t){if("[object Function]"!==i.call(e))throw TypeError(t)},t.isNumber=function(e,t){if("[object Number]"!==i.call(e))throw TypeError(t)},t.isObject=function(e,t){if("[object Object]"!==i.call(e))throw TypeError(t)},t.isBufferLength=function(e,t,r){if(e.length!==t)throw RangeError(r)},t.isBufferLength2=function(e,t,r,n){if(e.length!==t&&e.length!==r)throw RangeError(n)},t.isLengthGTZero=function(e,t){if(0===e.length)throw RangeError(t)},t.isNumberInInterval=function(e,t,r,n){if(e<=t||e>=r)throw RangeError(n)}},4325:(e,t,r)=>{"use strict";var n=r(5636).Buffer,i=r(1821),o=n.from([48,129,211,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,133,48,129,130,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,33,2,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,36,3,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),s=n.from([48,130,1,19,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,165,48,129,162,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,65,4,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,72,58,218,119,38,163,196,101,93,164,251,252,14,17,8,168,253,23,180,72,166,133,84,25,156,71,208,143,251,16,212,184,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,68,3,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);t.privateKeyExport=function(e,t,r){var i=n.from(r?o:s);return e.copy(i,r?8:9),t.copy(i,r?181:214),i},t.privateKeyImport=function(e){var t=e.length,r=0;if(!(t2||t1?e[r+n-2]<<8:0);if(!(t<(r+=n)+i||t32||t1&&0===t[o]&&!(128&t[o+1]);--r,++o);for(var s=n.concat([n.from([0]),e.s]),a=33,f=0;a>1&&0===s[f]&&!(128&s[f+1]);--a,++f);return i.encode(t.slice(o),s.slice(f))},t.signatureImport=function(e){var t=n.alloc(32,0),r=n.alloc(32,0);try{var o=i.decode(e);if(33===o.r.length&&0===o.r[0]&&(o.r=o.r.slice(1)),o.r.length>32)throw new Error("R length is too long");if(33===o.s.length&&0===o.s[0]&&(o.s=o.s.slice(1)),o.s.length>32)throw new Error("S length is too long")}catch(e){return}return o.r.copy(t,32-o.r.length),o.s.copy(r,32-o.s.length),{r:t,s:r}},t.signatureImportLax=function(e){var t=n.alloc(32,0),r=n.alloc(32,0),i=e.length,o=0;if(48===e[o++]){var s=e[o++];if(!(128&s&&(o+=s-128)>i)&&2===e[o++]){var a=e[o++];if(128&a){if(o+(s=a-128)>i)return;for(;s>0&&0===e[o];o+=1,s-=1);for(a=0;s>0;o+=1,s-=1)a=(a<<8)+e[o]}if(!(a>i-o)){var f=o;if(o+=a,2===e[o++]){var u=e[o++];if(128&u){if(o+(s=u-128)>i)return;for(;s>0&&0===e[o];o+=1,s-=1);for(u=0;s>0;o+=1,s-=1)u=(u<<8)+e[o]}if(!(u>i-o)){var c=o;for(o+=u;a>0&&0===e[f];a-=1,f+=1);if(!(a>32)){var h=e.slice(f,f+a);for(h.copy(t,32-h.length);u>0&&0===e[c];u-=1,c+=1);if(!(u>32)){var d=e.slice(c,c+u);return d.copy(r,32-d.length),{r:t,s:r}}}}}}}}}},7705:(e,t,r)=>{"use strict";var n=r(5636).Buffer,i=r(3257),o=r(2823),s=r(3360).ec,a=r(2231),f=new s("secp256k1"),u=f.curve;function c(e){var t=e[0];switch(t){case 2:case 3:return 33!==e.length?null:function(e,t){var r=new o(t);if(r.cmp(u.p)>=0)return null;var n=(r=r.toRed(u.red)).redSqr().redIMul(r).redIAdd(u.b).redSqrt();3===e!==n.isOdd()&&(n=n.redNeg());const i=r.redSqr().redIMul(r);return n.redSqr().redISub(i.redIAdd(u.b)).isZero()?f.keyPair({pub:{x:r,y:n}}):null}(t,e.slice(1,33));case 4:case 6:case 7:return 65!==e.length?null:function(e,t,r){var n=new o(t),i=new o(r);if(n.cmp(u.p)>=0||i.cmp(u.p)>=0)return null;if(n=n.toRed(u.red),i=i.toRed(u.red),(6===e||7===e)&&i.isOdd()!==(7===e))return null;var s=n.redSqr().redIMul(n);return i.redSqr().redISub(s.redIAdd(u.b)).isZero()?f.keyPair({pub:{x:n,y:i}}):null}(t,e.slice(1,33),e.slice(33,65));default:return null}}t.privateKeyVerify=function(e){var t=new o(e);return t.cmp(u.n)<0&&!t.isZero()},t.privateKeyExport=function(e,t){var r=new o(e);if(r.cmp(u.n)>=0||r.isZero())throw new Error(a.EC_PRIVATE_KEY_EXPORT_DER_FAIL);return n.from(f.keyFromPrivate(e).getPublic(t,!0))},t.privateKeyNegate=function(e){var t=new o(e);return t.isZero()?n.alloc(32):u.n.sub(t).umod(u.n).toArrayLike(n,"be",32)},t.privateKeyModInverse=function(e){var t=new o(e);if(t.cmp(u.n)>=0||t.isZero())throw new Error(a.EC_PRIVATE_KEY_RANGE_INVALID);return t.invm(u.n).toArrayLike(n,"be",32)},t.privateKeyTweakAdd=function(e,t){var r=new o(t);if(r.cmp(u.n)>=0)throw new Error(a.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);if(r.iadd(new o(e)),r.cmp(u.n)>=0&&r.isub(u.n),r.isZero())throw new Error(a.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);return r.toArrayLike(n,"be",32)},t.privateKeyTweakMul=function(e,t){var r=new o(t);if(r.cmp(u.n)>=0||r.isZero())throw new Error(a.EC_PRIVATE_KEY_TWEAK_MUL_FAIL);return r.imul(new o(e)),r.cmp(u.n)&&(r=r.umod(u.n)),r.toArrayLike(n,"be",32)},t.publicKeyCreate=function(e,t){var r=new o(e);if(r.cmp(u.n)>=0||r.isZero())throw new Error(a.EC_PUBLIC_KEY_CREATE_FAIL);return n.from(f.keyFromPrivate(e).getPublic(t,!0))},t.publicKeyConvert=function(e,t){var r=c(e);if(null===r)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);return n.from(r.getPublic(t,!0))},t.publicKeyVerify=function(e){return null!==c(e)},t.publicKeyTweakAdd=function(e,t,r){var i=c(e);if(null===i)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new o(t)).cmp(u.n)>=0)throw new Error(a.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);var s=u.g.mul(t).add(i.pub);if(s.isInfinity())throw new Error(a.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);return n.from(s.encode(!0,r))},t.publicKeyTweakMul=function(e,t,r){var i=c(e);if(null===i)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new o(t)).cmp(u.n)>=0||t.isZero())throw new Error(a.EC_PUBLIC_KEY_TWEAK_MUL_FAIL);return n.from(i.pub.mul(t).encode(!0,r))},t.publicKeyCombine=function(e,t){for(var r=new Array(e.length),i=0;i=0||r.cmp(u.n)>=0)throw new Error(a.ECDSA_SIGNATURE_PARSE_FAIL);var i=n.from(e);return 1===r.cmp(f.nh)&&u.n.sub(r).toArrayLike(n,"be",32).copy(i,32),i},t.signatureExport=function(e){var t=e.slice(0,32),r=e.slice(32,64);if(new o(t).cmp(u.n)>=0||new o(r).cmp(u.n)>=0)throw new Error(a.ECDSA_SIGNATURE_PARSE_FAIL);return{r:t,s:r}},t.signatureImport=function(e){var t=new o(e.r);t.cmp(u.n)>=0&&(t=new o(0));var r=new o(e.s);return r.cmp(u.n)>=0&&(r=new o(0)),n.concat([t.toArrayLike(n,"be",32),r.toArrayLike(n,"be",32)])},t.sign=function(e,t,r,i){if("function"==typeof r){var s=r;r=function(r){var f=s(e,t,null,i,r);if(!n.isBuffer(f)||32!==f.length)throw new Error(a.ECDSA_SIGN_FAIL);return new o(f)}}var c=new o(t);if(c.cmp(u.n)>=0||c.isZero())throw new Error(a.ECDSA_SIGN_FAIL);var h=f.sign(e,t,{canonical:!0,k:r,pers:i});return{signature:n.concat([h.r.toArrayLike(n,"be",32),h.s.toArrayLike(n,"be",32)]),recovery:h.recoveryParam}},t.verify=function(e,t,r){var n={r:t.slice(0,32),s:t.slice(32,64)},i=new o(n.r),s=new o(n.s);if(i.cmp(u.n)>=0||s.cmp(u.n)>=0)throw new Error(a.ECDSA_SIGNATURE_PARSE_FAIL);if(1===s.cmp(f.nh)||i.isZero()||s.isZero())return!1;var h=c(r);if(null===h)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);return f.verify(e,n,{x:h.pub.x,y:h.pub.y})},t.recover=function(e,t,r,i){var s={r:t.slice(0,32),s:t.slice(32,64)},c=new o(s.r),h=new o(s.s);if(c.cmp(u.n)>=0||h.cmp(u.n)>=0)throw new Error(a.ECDSA_SIGNATURE_PARSE_FAIL);try{if(c.isZero()||h.isZero())throw new Error;var d=f.recoverPubKey(e,s,r);return n.from(d.encode(!0,i))}catch(e){throw new Error(a.ECDSA_RECOVER_FAIL)}},t.ecdh=function(e,r){var n=t.ecdhUnsafe(e,r,!0);return i("sha256").update(n).digest()},t.ecdhUnsafe=function(e,t,r){var i=c(e);if(null===i)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);var s=new o(t);if(s.cmp(u.n)>=0||s.isZero())throw new Error(a.ECDH_FAIL);return n.from(i.pub.mul(s).encode(!0,r))}},5574:(e,t,r)=>{"use strict";var n=r(7562),i=r(4325),o=r(2231);function s(e,t){return void 0===e?t:(n.isBoolean(e,o.COMPRESSED_TYPE_INVALID),e)}e.exports=function(e){return{privateKeyVerify:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),32===t.length&&e.privateKeyVerify(t)},privateKeyExport:function(t,r){n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=s(r,!0);var a=e.privateKeyExport(t,r);return i.privateKeyExport(t,a,r)},privateKeyImport:function(t){if(n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),(t=i.privateKeyImport(t))&&32===t.length&&e.privateKeyVerify(t))return t;throw new Error(o.EC_PRIVATE_KEY_IMPORT_DER_FAIL)},privateKeyNegate:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),e.privateKeyNegate(t)},privateKeyModInverse:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),e.privateKeyModInverse(t)},privateKeyTweakAdd:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),e.privateKeyTweakAdd(t,r)},privateKeyTweakMul:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),e.privateKeyTweakMul(t,r)},publicKeyCreate:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=s(r,!0),e.publicKeyCreate(t,r)},publicKeyConvert:function(t,r){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),r=s(r,!0),e.publicKeyConvert(t,r)},publicKeyVerify:function(t){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),e.publicKeyVerify(t)},publicKeyTweakAdd:function(t,r,i){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=s(i,!0),e.publicKeyTweakAdd(t,r,i)},publicKeyTweakMul:function(t,r,i){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=s(i,!0),e.publicKeyTweakMul(t,r,i)},publicKeyCombine:function(t,r){n.isArray(t,o.EC_PUBLIC_KEYS_TYPE_INVALID),n.isLengthGTZero(t,o.EC_PUBLIC_KEYS_LENGTH_INVALID);for(var i=0;i{var n=r(5636).Buffer;function i(e,t){this._block=n.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}i.prototype.update=function(e,t){"string"==typeof e&&(t=t||"utf8",e=n.from(e,t));for(var r=this._block,i=this._blockSize,o=e.length,s=this._len,a=0;a=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return e?o.toString(e):o},i.prototype._update=function(){throw new Error("_update must be implemented by subclass")},e.exports=i},3229:(e,t,r)=>{var n=e.exports=function(e){e=e.toLowerCase();var t=n[e];if(!t)throw new Error(e+" is not supported (we accept pull requests)");return new t};n.sha=r(3675),n.sha1=r(8980),n.sha224=r(947),n.sha256=r(2826),n.sha384=r(9922),n.sha512=r(3699)},3675:(e,t,r)=>{var n=r(5615),i=r(1229),o=r(5636).Buffer,s=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function f(){this.init(),this._w=a,i.call(this,64,56)}function u(e){return e<<30|e>>>2}function c(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(f,i),f.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},f.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,f=0|this._e,h=0;h<16;++h)r[h]=e.readInt32BE(4*h);for(;h<80;++h)r[h]=r[h-3]^r[h-8]^r[h-14]^r[h-16];for(var d=0;d<80;++d){var l=~~(d/20),p=0|((t=n)<<5|t>>>27)+c(l,i,o,a)+f+r[d]+s[l];f=a,a=o,o=u(i),i=n,n=p}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=f+this._e|0},f.prototype._hash=function(){var e=o.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},e.exports=f},8980:(e,t,r)=>{var n=r(5615),i=r(1229),o=r(5636).Buffer,s=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function f(){this.init(),this._w=a,i.call(this,64,56)}function u(e){return e<<5|e>>>27}function c(e){return e<<30|e>>>2}function h(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(f,i),f.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},f.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,f=0|this._e,d=0;d<16;++d)r[d]=e.readInt32BE(4*d);for(;d<80;++d)r[d]=(t=r[d-3]^r[d-8]^r[d-14]^r[d-16])<<1|t>>>31;for(var l=0;l<80;++l){var p=~~(l/20),b=u(n)+h(p,i,o,a)+f+r[l]+s[p]|0;f=a,a=o,o=c(i),i=n,n=b}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=f+this._e|0},f.prototype._hash=function(){var e=o.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},e.exports=f},947:(e,t,r)=>{var n=r(5615),i=r(2826),o=r(1229),s=r(5636).Buffer,a=new Array(64);function f(){this.init(),this._w=a,o.call(this,64,56)}n(f,i),f.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},f.prototype._hash=function(){var e=s.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e},e.exports=f},2826:(e,t,r)=>{var n=r(5615),i=r(1229),o=r(5636).Buffer,s=[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],a=new Array(64);function f(){this.init(),this._w=a,i.call(this,64,56)}function u(e,t,r){return r^e&(t^r)}function c(e,t,r){return e&t|r&(e|t)}function h(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function d(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function l(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}n(f,i),f.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},f.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,f=0|this._e,p=0|this._f,b=0|this._g,y=0|this._h,g=0;g<16;++g)r[g]=e.readInt32BE(4*g);for(;g<64;++g)r[g]=0|(((t=r[g-2])>>>17|t<<15)^(t>>>19|t<<13)^t>>>10)+r[g-7]+l(r[g-15])+r[g-16];for(var w=0;w<64;++w){var m=y+d(f)+u(f,p,b)+s[w]+r[w]|0,v=h(n)+c(n,i,o)|0;y=b,b=p,p=f,f=a+m|0,a=o,o=i,i=n,n=m+v|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=f+this._e|0,this._f=p+this._f|0,this._g=b+this._g|0,this._h=y+this._h|0},f.prototype._hash=function(){var e=o.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},e.exports=f},9922:(e,t,r)=>{var n=r(5615),i=r(3699),o=r(1229),s=r(5636).Buffer,a=new Array(160);function f(){this.init(),this._w=a,o.call(this,128,112)}n(f,i),f.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},f.prototype._hash=function(){var e=s.allocUnsafe(48);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e},e.exports=f},3699:(e,t,r)=>{var n=r(5615),i=r(1229),o=r(5636).Buffer,s=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],a=new Array(160);function f(){this.init(),this._w=a,i.call(this,128,112)}function u(e,t,r){return r^e&(t^r)}function c(e,t,r){return e&t|r&(e|t)}function h(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function d(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function l(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function p(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function b(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function y(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function g(e,t){return e>>>0>>0?1:0}n(f,i),f.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},f.prototype._update=function(e){for(var t=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,o=0|this._dh,a=0|this._eh,f=0|this._fh,w=0|this._gh,m=0|this._hh,v=0|this._al,_=0|this._bl,E=0|this._cl,S=0|this._dl,I=0|this._el,A=0|this._fl,T=0|this._gl,k=0|this._hl,P=0;P<32;P+=2)t[P]=e.readInt32BE(4*P),t[P+1]=e.readInt32BE(4*P+4);for(;P<160;P+=2){var O=t[P-30],M=t[P-30+1],x=l(O,M),B=p(M,O),L=b(O=t[P-4],M=t[P-4+1]),R=y(M,O),N=t[P-14],U=t[P-14+1],C=t[P-32],H=t[P-32+1],D=B+U|0,K=x+N+g(D,B)|0;K=(K=K+L+g(D=D+R|0,R)|0)+C+g(D=D+H|0,H)|0,t[P]=K,t[P+1]=D}for(var V=0;V<160;V+=2){K=t[V],D=t[V+1];var j=c(r,n,i),F=c(v,_,E),q=h(r,v),W=h(v,r),z=d(a,I),G=d(I,a),Y=s[V],X=s[V+1],$=u(a,f,w),Z=u(I,A,T),J=k+G|0,Q=m+z+g(J,k)|0;Q=(Q=(Q=Q+$+g(J=J+Z|0,Z)|0)+Y+g(J=J+X|0,X)|0)+K+g(J=J+D|0,D)|0;var ee=W+F|0,te=q+j+g(ee,W)|0;m=w,k=T,w=f,T=A,f=a,A=I,a=o+Q+g(I=S+J|0,S)|0,o=i,S=E,i=n,E=_,n=r,_=v,r=Q+te+g(v=J+ee|0,J)|0}this._al=this._al+v|0,this._bl=this._bl+_|0,this._cl=this._cl+E|0,this._dl=this._dl+S|0,this._el=this._el+I|0,this._fl=this._fl+A|0,this._gl=this._gl+T|0,this._hl=this._hl+k|0,this._ah=this._ah+r+g(this._al,v)|0,this._bh=this._bh+n+g(this._bl,_)|0,this._ch=this._ch+i+g(this._cl,E)|0,this._dh=this._dh+o+g(this._dl,S)|0,this._eh=this._eh+a+g(this._el,I)|0,this._fh=this._fh+f+g(this._fl,A)|0,this._gh=this._gh+w+g(this._gl,T)|0,this._hh=this._hh+m+g(this._hl,k)|0},f.prototype._hash=function(){var e=o.allocUnsafe(64);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e},e.exports=f},1983:(e,t,r)=>{e.exports=i;var n=r(46).EventEmitter;function i(){n.call(this)}r(5615)(i,n),i.Readable=r(8199),i.Writable=r(5291),i.Duplex=r(1265),i.Transform=r(9415),i.PassThrough=r(4421),i.finished=r(4869),i.pipeline=r(6815),i.Stream=i,i.prototype.pipe=function(e,t){var r=this;function i(t){e.writable&&!1===e.write(t)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),e.on("drain",o),e._isStdio||t&&!1===t.end||(r.on("end",a),r.on("close",f));var s=!1;function a(){s||(s=!0,e.end())}function f(){s||(s=!0,"function"==typeof e.destroy&&e.destroy())}function u(e){if(c(),0===n.listenerCount(this,"error"))throw e}function c(){r.removeListener("data",i),e.removeListener("drain",o),r.removeListener("end",a),r.removeListener("close",f),r.removeListener("error",u),e.removeListener("error",u),r.removeListener("end",c),r.removeListener("close",c),e.removeListener("close",c)}return r.on("error",u),e.on("error",u),r.on("end",c),r.on("close",c),e.on("close",c),e.emit("pipe",r),e}},8888:(e,t,r)=>{"use strict";var n=r(5636).Buffer,i=n.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(n.isEncoding===i||!i(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=f,this.end=u,t=4;break;case"utf8":this.fillLast=a,t=4;break;case"base64":this.text=c,this.end=h,t=3;break;default:return this.write=d,void(this.end=l)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(t)}function s(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function a(e){var t=this.lastTotal-this.lastNeed,r=function(e,t){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function f(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function u(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function c(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function h(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function d(e){return e.toString(this.encoding)}function l(e){return e&&e.length?this.write(e):""}t.I=o,o.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0?(i>0&&(e.lastNeed=i-1),i):--n=0?(i>0&&(e.lastNeed=i-2),i):--n=0?(i>0&&(2===i?i=0:e.lastNeed=i-3),i):0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},o.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},4322:(e,t,r)=>{var n=r(2890);function i(e){return e.name||e.toString().match(/function (.*?)\s*\(/)[1]}function o(e){return n.Nil(e)?"":i(e.constructor)}function s(e,t){Error.captureStackTrace&&Error.captureStackTrace(e,t)}function a(e){return n.Function(e)?e.toJSON?e.toJSON():i(e):n.Array(e)?"Array":e&&n.Object(e)?"Object":void 0!==e?e:""}function f(e,t,r){var i=function(e){return n.Function(e)?"":n.String(e)?JSON.stringify(e):e&&n.Object(e)?"":e}(t);return"Expected "+a(e)+", got"+(""!==r?" "+r:"")+(""!==i?" "+i:"")}function u(e,t,r){r=r||o(t),this.message=f(e,t,r),s(this,u),this.__type=e,this.__value=t,this.__valueTypeName=r}function c(e,t,r,n,i){e?(i=i||o(n),this.message=function(e,t,r,n,i){var o='" of type ';return"key"===t&&(o='" with key type '),f('property "'+a(r)+o+a(e),n,i)}(e,r,t,n,i)):this.message='Unexpected property "'+t+'"',s(this,u),this.__label=r,this.__property=t,this.__type=e,this.__value=n,this.__valueTypeName=i}u.prototype=Object.create(Error.prototype),u.prototype.constructor=u,c.prototype=Object.create(Error.prototype),c.prototype.constructor=u,e.exports={TfTypeError:u,TfPropertyTypeError:c,tfCustomError:function(e,t){return new u(e,{},t)},tfSubError:function(e,t,r){return e instanceof c?(t=t+"."+e.__property,e=new c(e.__type,t,e.__label,e.__value,e.__valueTypeName)):e instanceof u&&(e=new c(e.__type,t,r,e.__value,e.__valueTypeName)),s(e),e},tfJSON:a,getValueTypeName:o}},315:(e,t,r)=>{var n=r(1048).Buffer,i=r(2890),o=r(4322);function s(e){return n.isBuffer(e)}function a(e){return"string"==typeof e&&/^([0-9a-f]{2})+$/i.test(e)}function f(e,t){var r=e.toJSON();function n(n){if(!e(n))return!1;if(n.length===t)return!0;throw o.tfCustomError(r+"(Length: "+t+")",r+"(Length: "+n.length+")")}return n.toJSON=function(){return r},n}var u=f.bind(null,i.Array),c=f.bind(null,s),h=f.bind(null,a),d=f.bind(null,i.String),l=Math.pow(2,53)-1,p={ArrayN:u,Buffer:s,BufferN:c,Finite:function(e){return"number"==typeof e&&isFinite(e)},Hex:a,HexN:h,Int8:function(e){return e<<24>>24===e},Int16:function(e){return e<<16>>16===e},Int32:function(e){return(0|e)===e},Int53:function(e){return"number"==typeof e&&e>=-l&&e<=l&&Math.floor(e)===e},Range:function(e,t,r){function n(n,i){return r(n,i)&&n>e&&n>>0===e},UInt53:function(e){return"number"==typeof e&&e>=0&&e<=l&&Math.floor(e)===e}};for(var b in p)p[b].toJSON=function(e){return e}.bind(null,b);e.exports=p},973:(e,t,r)=>{var n=r(4322),i=r(2890),o=n.tfJSON,s=n.TfTypeError,a=n.TfPropertyTypeError,f=n.tfSubError,u=n.getValueTypeName,c={arrayOf:function(e,t){function r(r,n){return!!i.Array(r)&&!i.Nil(r)&&!(void 0!==t.minLength&&r.lengtht.maxLength)&&(void 0===t.length||r.length===t.length)&&r.every((function(t,r){try{return d(e,t,n)}catch(e){throw f(e,r)}}))}return e=h(e),t=t||{},r.toJSON=function(){var r="["+o(e)+"]";return void 0!==t.length?r+="{"+t.length+"}":void 0===t.minLength&&void 0===t.maxLength||(r+="{"+(void 0===t.minLength?0:t.minLength)+","+(void 0===t.maxLength?1/0:t.maxLength)+"}"),r},r},maybe:function e(t){function r(r,n){return i.Nil(r)||t(r,n,e)}return t=h(t),r.toJSON=function(){return"?"+o(t)},r},map:function(e,t){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var o in r){try{t&&d(t,o,n)}catch(e){throw f(e,o,"key")}try{var s=r[o];d(e,s,n)}catch(e){throw f(e,o)}}return!0}return e=h(e),t&&(t=h(t)),r.toJSON=t?function(){return"{"+o(t)+": "+o(e)+"}"}:function(){return"{"+o(e)+"}"},r},object:function(e){var t={};for(var r in e)t[r]=h(e[r]);function n(e,r){if(!i.Object(e))return!1;if(i.Nil(e))return!1;var n;try{for(n in t)d(t[n],e[n],r)}catch(e){throw f(e,n)}if(r)for(n in e)if(!t[n])throw new a(void 0,n);return!0}return n.toJSON=function(){return o(t)},n},anyOf:function(){var e=[].slice.call(arguments).map(h);function t(t,r){return e.some((function(e){try{return d(e,t,r)}catch(e){return!1}}))}return t.toJSON=function(){return e.map(o).join("|")},t},allOf:function(){var e=[].slice.call(arguments).map(h);function t(t,r){return e.every((function(e){try{return d(e,t,r)}catch(e){return!1}}))}return t.toJSON=function(){return e.map(o).join(" & ")},t},quacksLike:function(e){function t(t){return e===u(t)}return t.toJSON=function(){return e},t},tuple:function(){var e=[].slice.call(arguments).map(h);function t(t,r){return!i.Nil(t)&&!i.Nil(t.length)&&(!r||t.length===e.length)&&e.every((function(e,n){try{return d(e,t[n],r)}catch(e){throw f(e,n)}}))}return t.toJSON=function(){return"("+e.map(o).join(", ")+")"},t},value:function(e){function t(t){return t===e}return t.toJSON=function(){return e},t}};function h(e){if(i.String(e))return"?"===e[0]?c.maybe(e.slice(1)):i[e]||c.quacksLike(e);if(e&&i.Object(e)){if(i.Array(e)){if(1!==e.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return c.arrayOf(e[0])}return c.object(e)}return i.Function(e)?e:c.value(e)}function d(e,t,r,n){if(i.Function(e)){if(e(t,r))return!0;throw new s(n||e,t)}return d(h(e),t,r)}for(var l in c.oneOf=c.anyOf,i)d[l]=i[l];for(l in c)d[l]=c[l];var p=r(315);for(l in p)d[l]=p[l];d.compile=h,d.TfTypeError=s,d.TfPropertyTypeError=a,e.exports=d},2890:e=>{var t={Array:function(e){return null!=e&&e.constructor===Array},Boolean:function(e){return"boolean"==typeof e},Function:function(e){return"function"==typeof e},Nil:function(e){return null==e},Number:function(e){return"number"==typeof e},Object:function(e){return"object"==typeof e},String:function(e){return"string"==typeof e},"":function(){return!0}};for(var r in t.Null=t.Nil,t)t[r].toJSON=function(e){return e}.bind(null,r);e.exports=t},6732:(e,t,r)=>{function n(e){try{if(!r.g.localStorage)return!1}catch(e){return!1}var t=r.g.localStorage[e];return null!=t&&"true"===String(t).toLowerCase()}e.exports=function(e,t){if(n("noDeprecation"))return e;var r=!1;return function(){if(!r){if(n("throwDeprecation"))throw new Error(t);n("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}}},7820:(e,t,r)=>{"use strict";var n=r(5636).Buffer,i=9007199254740991;function o(e){if(e<0||e>i||e%1!=0)throw new RangeError("value out of range")}function s(e){return o(e),e<253?1:e<=65535?3:e<=4294967295?5:9}e.exports={encode:function e(t,r,i){if(o(t),r||(r=n.allocUnsafe(s(t))),!n.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return i||(i=0),t<253?(r.writeUInt8(t,i),e.bytes=1):t<=65535?(r.writeUInt8(253,i),r.writeUInt16LE(t,i+1),e.bytes=3):t<=4294967295?(r.writeUInt8(254,i),r.writeUInt32LE(t,i+1),e.bytes=5):(r.writeUInt8(255,i),r.writeUInt32LE(t>>>0,i+1),r.writeUInt32LE(t/4294967296|0,i+5),e.bytes=9),r},decode:function e(t,r){if(!n.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");r||(r=0);var i=t.readUInt8(r);if(i<253)return e.bytes=1,i;if(253===i)return e.bytes=3,t.readUInt16LE(r+1);if(254===i)return e.bytes=5,t.readUInt32LE(r+1);e.bytes=9;var s=t.readUInt32LE(r+1),a=4294967296*t.readUInt32LE(r+5)+s;return o(a),a},encodingLength:s}},6952:(e,t,r)=>{var n=r(1048).Buffer,i=r(4298);function o(e,t){if(void 0!==t&&e[0]!==t)throw new Error("Invalid network version");if(33===e.length)return{version:e[0],privateKey:e.slice(1,33),compressed:!1};if(34!==e.length)throw new Error("Invalid WIF length");if(1!==e[33])throw new Error("Invalid compression flag");return{version:e[0],privateKey:e.slice(1,33),compressed:!0}}function s(e,t,r){var i=new n(r?34:33);return i.writeUInt8(e,0),t.copy(i,1),r&&(i[33]=1),i}e.exports={decode:function(e,t){return o(i.decode(e),t)},decodeRaw:o,encode:function(e,t,r){return"number"==typeof e?i.encode(s(e,t,r)):i.encode(s(e.version,e.privateKey,e.compressed))},encodeRaw:s}},3845:(e,t,r)=>{"use strict";var n=r(5636).Buffer;e.exports=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r>>0,c=new Uint8Array(s);r>>0,c[l]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");o=d,r++}for(var p=s-o;p!==s&&0===c[p];)p++;var b=n.allocUnsafe(i+(s-p));b.fill(0,0,i);for(var y=i;p!==s;)b[y++]=c[p++];return b}return{encode:function(t){if((Array.isArray(t)||t instanceof Uint8Array)&&(t=n.from(t)),!n.isBuffer(t))throw new TypeError("Expected Buffer");if(0===t.length)return"";for(var r=0,i=0,o=0,s=t.length;o!==s&&0===t[o];)o++,r++;for(var u=(s-o)*c+1>>>0,h=new Uint8Array(u);o!==s;){for(var d=t[o],l=0,p=u-1;(0!==d||l>>0,h[p]=d%a>>>0,d=d/a>>>0;if(0!==d)throw new Error("Non-zero carry");i=l,o++}for(var b=u-i;b!==u&&0===h[b];)b++;for(var y=f.repeat(r);b{var n=r(3845);e.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},8537:(e,t,r)=>{"use strict";var n=r(4154),i=r(5636).Buffer;e.exports=function(e){function t(t){var r=t.slice(0,-4),n=t.slice(-4),i=e(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(t){var r=e(t);return n.encode(i.concat([t,r],t.length+4))},decode:function(e){var r=t(n.decode(e));if(!r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(e){var r=n.decodeUnsafe(e);if(r)return t(r)}}}},4298:(e,t,r)=>{"use strict";var n=r(3257),i=r(8537);e.exports=i((function(e){var t=n("sha256").update(e).digest();return n("sha256").update(t).digest()}))},2028:()=>{},8379:()=>{},3553:()=>{},3011:()=>{},3951:()=>{},183:e=>{"use strict";e.exports={rE:"6.6.1"}},2231:e=>{"use strict";e.exports=JSON.parse('{"COMPRESSED_TYPE_INVALID":"compressed should be a boolean","EC_PRIVATE_KEY_TYPE_INVALID":"private key should be a Buffer","EC_PRIVATE_KEY_LENGTH_INVALID":"private key length is invalid","EC_PRIVATE_KEY_RANGE_INVALID":"private key range is invalid","EC_PRIVATE_KEY_TWEAK_ADD_FAIL":"tweak out of range or resulting private key is invalid","EC_PRIVATE_KEY_TWEAK_MUL_FAIL":"tweak out of range","EC_PRIVATE_KEY_EXPORT_DER_FAIL":"couldn\'t export to DER format","EC_PRIVATE_KEY_IMPORT_DER_FAIL":"couldn\'t import from DER format","EC_PUBLIC_KEYS_TYPE_INVALID":"public keys should be an Array","EC_PUBLIC_KEYS_LENGTH_INVALID":"public keys Array should have at least 1 element","EC_PUBLIC_KEY_TYPE_INVALID":"public key should be a Buffer","EC_PUBLIC_KEY_LENGTH_INVALID":"public key length is invalid","EC_PUBLIC_KEY_PARSE_FAIL":"the public key could not be parsed or is invalid","EC_PUBLIC_KEY_CREATE_FAIL":"private was invalid, try again","EC_PUBLIC_KEY_TWEAK_ADD_FAIL":"tweak out of range or resulting public key is invalid","EC_PUBLIC_KEY_TWEAK_MUL_FAIL":"tweak out of range","EC_PUBLIC_KEY_COMBINE_FAIL":"the sum of the public keys is not valid","ECDH_FAIL":"scalar was invalid (zero or overflow)","ECDSA_SIGNATURE_TYPE_INVALID":"signature should be a Buffer","ECDSA_SIGNATURE_LENGTH_INVALID":"signature length is invalid","ECDSA_SIGNATURE_PARSE_FAIL":"couldn\'t parse signature","ECDSA_SIGNATURE_PARSE_DER_FAIL":"couldn\'t parse DER signature","ECDSA_SIGNATURE_SERIALIZE_DER_FAIL":"couldn\'t serialize signature to DER format","ECDSA_SIGN_FAIL":"nonce generation function failed or private key is invalid","ECDSA_RECOVER_FAIL":"couldn\'t recover public key from signature","MSG32_TYPE_INVALID":"message should be a Buffer","MSG32_LENGTH_INVALID":"message length is invalid","OPTIONS_TYPE_INVALID":"options should be an Object","OPTIONS_DATA_TYPE_INVALID":"options.data should be a Buffer","OPTIONS_DATA_LENGTH_INVALID":"options.data length is invalid","OPTIONS_NONCEFN_TYPE_INVALID":"options.noncefn should be a Function","RECOVERY_ID_TYPE_INVALID":"recovery should be a Number","RECOVERY_ID_VALUE_INVALID":"recovery should have value between -1 and 4","TWEAK_TYPE_INVALID":"tweak should be a Buffer","TWEAK_LENGTH_INVALID":"tweak length is invalid"}')}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var o=t[n]={id:n,loaded:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.loaded=!0,o.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var n=r(1048).Buffer,i=r(7612),o=r(1075),s=r(242),a=r(4638),f=r(6989),u=r(3503),c=o.ECPairFactory(s),h=i.Psbt,d=i.payments,l=i.networks;function p(e,t){var r=t||"hex";return n.from(e,r)}function b(e){return c.fromPrivateKey(p(e,"hex"))}function y(e,t,r){var n="testnet"===r?l.testnet:l.bitcoin,i=p(e,"hex");return"p2pkh"===t?d.p2pkh({pubkey:i,network:n}):"p2sh"===t?d.p2sh({redeem:d.p2wpkh({pubkey:i,network:n})}):d.p2wpkh({pubkey:i,network:n})}function g(e){var t="";try{/^[0-9a-fA-F]+$/.test(e)?(h.fromHex(e),t=e):t=h.fromBase64(e).toHex()}catch(e){throw new Error("invalid psbt")}return t}function w(e){var t=g(e),r=h.fromHex(t);return JSON.stringify(r)}void 0!==r.g&&(r.g.Psbt=h,r.g.payments=d,r.g.networks=l,r.g.getPayment=y,r.g.getAddress=function(e,t,r){return y(e,t,r).address},r.g.createTx=function(e,t,r,n){var i="testnet"===n?l.testnet:l.bitcoin,o=new h({network:i}),s=b(r);return o.addInputs(e),o.addOutputs(t),o.signAllInputs(s).finalizeAllInputs().extractTransaction().toHex()},r.g.validateAddress=function(e,t){var r="testnet"===t||"regtest"===t?t:"mainnet";return a.validate(e,r)},r.g.formatPsbtHex=g,r.g.parsePsbt=w,r.g.signMessageECDSA=function(e,t){var r=b(t);return f.sign(e,p(t,"hex"),r.compressed,{segwitType:"p2wpkh"}).toString("base64")},r.g.signMessageBIP322=function(e,t,r){var n=b(t).toWIF(),i=u.Signer.sign(n,r,e),o="string"==typeof i?i:i.toString("base64");if(!o)throw new Error("Failed to sign message");return o},r.g.estimateMemoBytes=function(e){var t=w(e);if(!t)return 0;var r=t.txOutputs.find((function(e){try{var t=i.script.decompile(e.script);return t&&t[0]===i.opcodes.OP_RETURN}catch(e){return!1}}));return r?r.script.length:0},r.g.signPsbt=function(e,t){var r=g(e),n=h.fromHex(r).signAllInputs(b(t));if(!n.validateSignaturesOfAllInputs((function(e,t,r){return(n=e,c.fromPublicKey(n)).verify(t,r);var n})))throw new Error("Failed to sign transaction");return n.finalizeAllInputs().extractTransaction().toHex()},r.g.getInOutPuts=function(e,t){var r=g(e),n=h.fromHex(r),o="mainnet"===t?l.bitcoin:"testnet"===t?l.testnet:"regtest"===t?l.regtest:void 0,s=n.data.inputs.map((function(e){var t;if(e.witnessUtxo){var r=e.witnessUtxo.script;return{address:i.address.fromOutputScript(r,o),value:null===(t=e.witnessUtxo)||void 0===t?void 0:t.value}}})),a=n.txOutputs.map((function(e){return{address:i.address.fromOutputScript(e.script,o),value:e.value}})),f={inputs:s.filter((function(e){return!!e})),outputs:a};return JSON.stringify(f)},r.g.aTb=p,r.g.k=b,r.g.m=function(e){var t=p(e,"utf8");return{script:d.embed({data:[t]}).output,value:0}})})(); \ No newline at end of file diff --git a/app/src/main/assets/injectScript.js b/app/src/main/assets/injectScript.js index b77119e69..bcc44f5c5 100644 --- a/app/src/main/assets/injectScript.js +++ b/app/src/main/assets/injectScript.js @@ -1,2 +1,2 @@ /*! For license information please see bundle.js.LICENSE.txt */ -(()=>{var e={8253:(e,t)=>{function r(){return r=Object.assign?Object.assign.bind():function(e){for(var t=1;t{"use strict";t.byteLength=function(e){var t=a(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,i=a(e),s=i[0],c=i[1],u=new o(function(e,t,r){return 3*(t+r)/4-r}(0,s,c)),l=0,d=c>0?s-4:s;for(r=0;r>16&255,u[l++]=t>>8&255,u[l++]=255&t;return 2===c&&(t=n[e.charCodeAt(r)]<<2|n[e.charCodeAt(r+1)]>>4,u[l++]=255&t),1===c&&(t=n[e.charCodeAt(r)]<<10|n[e.charCodeAt(r+1)]<<4|n[e.charCodeAt(r+2)]>>2,u[l++]=t>>8&255,u[l++]=255&t),u},t.fromByteArray=function(e){for(var t,n=e.length,o=n%3,i=[],s=16383,a=0,u=n-o;au?u:a+s));return 1===o?(t=e[n-1],i.push(r[t>>2]+r[t<<4&63]+"==")):2===o&&(t=(e[n-2]<<8)+e[n-1],i.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"=")),i.join("")};for(var r=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)r[s]=i[s],n[i.charCodeAt(s)]=s;function a(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function c(e,t,n){for(var o,i,s=[],a=t;a>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return s.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},8764:(e,t,r)=>{"use strict";const n=r(9742),o=r(645),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.lW=c,t.h2=50;const s=2147483647;function a(e){if(e>s)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,c.prototype),t}function c(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return d(e)}return u(e,t,r)}function u(e,t,r){if("string"==typeof e)return function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!c.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const r=0|g(e,t);let n=a(r);const o=n.write(e,t);return o!==r&&(n=n.slice(0,o)),n}(e,t);if(ArrayBuffer.isView(e))return function(e){if($(e,Uint8Array)){const t=new Uint8Array(e);return h(t.buffer,t.byteOffset,t.byteLength)}return f(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if($(e,ArrayBuffer)||e&&$(e.buffer,ArrayBuffer))return h(e,t,r);if("undefined"!=typeof SharedArrayBuffer&&($(e,SharedArrayBuffer)||e&&$(e.buffer,SharedArrayBuffer)))return h(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return c.from(n,t,r);const o=function(e){if(c.isBuffer(e)){const t=0|p(e.length),r=a(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||J(e.length)?a(0):f(e):"Buffer"===e.type&&Array.isArray(e.data)?f(e.data):void 0}(e);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return c.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function l(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function d(e){return l(e),a(e<0?0:0|p(e))}function f(e){const t=e.length<0?0:0|p(e.length),r=a(t);for(let n=0;n=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|e}function g(e,t){if(c.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||$(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return F(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return H(e).length;default:if(o)return n?-1:F(e).length;t=(""+t).toLowerCase(),o=!0}}function y(e,t,r){let n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return j(this,t,r);case"utf8":case"utf-8":return P(this,t,r);case"ascii":return B(this,t,r);case"latin1":case"binary":return I(this,t,r);case"base64":return _(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function b(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function m(e,t,r,n,o){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),J(r=+r)&&(r=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof t&&(t=c.from(t,n)),c.isBuffer(t))return 0===t.length?-1:v(e,t,r,n,o);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):v(e,[t],r,n,o);throw new TypeError("val must be string, number or Buffer")}function v(e,t,r,n,o){let i,s=1,a=e.length,c=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,r/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){let n=-1;for(i=r;ia&&(r=a-c),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=t.length;let s;for(n>i/2&&(n=i/2),s=0;s>8,o=r%256,i.push(o),i.push(n);return i}(t,e.length-r),e,r,n)}function _(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function P(e,t,r){r=Math.min(e.length,r);const n=[];let o=t;for(;o239?4:t>223?3:t>191?2:1;if(o+s<=r){let r,n,a,c;switch(s){case 1:t<128&&(i=t);break;case 2:r=e[o+1],128==(192&r)&&(c=(31&t)<<6|63&r,c>127&&(i=c));break;case 3:r=e[o+1],n=e[o+2],128==(192&r)&&128==(192&n)&&(c=(15&t)<<12|(63&r)<<6|63&n,c>2047&&(c<55296||c>57343)&&(i=c));break;case 4:r=e[o+1],n=e[o+2],a=e[o+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(c=(15&t)<<18|(63&r)<<12|(63&n)<<6|63&a,c>65535&&c<1114112&&(i=c))}}null===i?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=s}return function(e){const t=e.length;if(t<=T)return String.fromCharCode.apply(String,e);let r="",n=0;for(;nn.length?(c.isBuffer(t)||(t=c.from(t)),t.copy(n,o)):Uint8Array.prototype.set.call(n,t,o);else{if(!c.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(n,o)}o+=t.length}return n},c.byteLength=g,c.prototype._isBuffer=!0,c.prototype.swap16=function(){const e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;tr&&(e+=" ... "),""},i&&(c.prototype[i]=c.prototype.inspect),c.prototype.compare=function(e,t,r,n,o){if($(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),!c.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),t<0||r>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=r)return 0;if(n>=o)return-1;if(t>=r)return 1;if(this===e)return 0;let i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0);const a=Math.min(i,s),u=this.slice(n,o),l=e.slice(t,r);for(let e=0;e>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-t;if((void 0===r||r>o)&&(r=o),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,e,t,r);case"utf8":case"utf-8":return O(this,e,t,r);case"ascii":case"latin1":case"binary":return E(this,e,t,r);case"base64":return A(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const T=4096;function B(e,t,r){let n="";r=Math.min(e.length,r);for(let o=t;on)&&(r=n);let o="";for(let n=t;nr)throw new RangeError("Trying to access beyond buffer length")}function M(e,t,r,n,o,i){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||te.length)throw new RangeError("Index out of range")}function C(e,t,r,n,o){W(t,n,o,e,r,7);let i=Number(t&BigInt(4294967295));e[r++]=i,i>>=8,e[r++]=i,i>>=8,e[r++]=i,i>>=8,e[r++]=i;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=s,s>>=8,e[r++]=s,s>>=8,e[r++]=s,s>>=8,e[r++]=s,r}function U(e,t,r,n,o){W(t,n,o,e,r,7);let i=Number(t&BigInt(4294967295));e[r+7]=i,i>>=8,e[r+6]=i,i>>=8,e[r+5]=i,i>>=8,e[r+4]=i;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=s,s>>=8,e[r+2]=s,s>>=8,e[r+1]=s,s>>=8,e[r]=s,r+8}function D(e,t,r,n,o,i){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function N(e,t,r,n,i){return t=+t,r>>>=0,i||D(e,0,r,4),o.write(e,t,r,n,23,4),r+4}function k(e,t,r,n,i){return t=+t,r>>>=0,i||D(e,0,r,8),o.write(e,t,r,n,52,8),r+8}c.prototype.slice=function(e,t){const r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t>>=0,t>>>=0,r||R(e,t,this.length);let n=this[e],o=1,i=0;for(;++i>>=0,t>>>=0,r||R(e,t,this.length);let n=this[e+--t],o=1;for(;t>0&&(o*=256);)n+=this[e+--t]*o;return n},c.prototype.readUint8=c.prototype.readUInt8=function(e,t){return e>>>=0,t||R(e,1,this.length),this[e]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(e,t){return e>>>=0,t||R(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(e,t){return e>>>=0,t||R(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(e,t){return e>>>=0,t||R(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(e,t){return e>>>=0,t||R(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readBigUInt64LE=X((function(e){q(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||G(e,this.length-8);const n=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,o=this[++e]+256*this[++e]+65536*this[++e]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||G(e,this.length-8);const n=t*2**24+65536*this[++e]+256*this[++e]+this[++e],o=this[++e]*2**24+65536*this[++e]+256*this[++e]+r;return(BigInt(n)<>>=0,t>>>=0,r||R(e,t,this.length);let n=this[e],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*t)),n},c.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||R(e,t,this.length);let n=t,o=1,i=this[e+--n];for(;n>0&&(o*=256);)i+=this[e+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*t)),i},c.prototype.readInt8=function(e,t){return e>>>=0,t||R(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){e>>>=0,t||R(e,2,this.length);const r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(e,t){e>>>=0,t||R(e,2,this.length);const r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(e,t){return e>>>=0,t||R(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return e>>>=0,t||R(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readBigInt64LE=X((function(e){q(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||G(e,this.length-8);const n=this[e+4]+256*this[e+5]+65536*this[e+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||G(e,this.length-8);const n=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(n)<>>=0,t||R(e,4,this.length),o.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return e>>>=0,t||R(e,4,this.length),o.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return e>>>=0,t||R(e,8,this.length),o.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return e>>>=0,t||R(e,8,this.length),o.read(this,e,!1,52,8)},c.prototype.writeUintLE=c.prototype.writeUIntLE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||M(this,e,t,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[t]=255&e;++i>>=0,r>>>=0,n||M(this,e,t,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+r},c.prototype.writeUint8=c.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,1,255,0),this[t]=255&e,t+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeBigUInt64LE=X((function(e,t=0){return C(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),c.prototype.writeBigUInt64BE=X((function(e,t=0){return U(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),c.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*r-1);M(this,e,t,r,n-1,-n)}let o=0,i=1,s=0;for(this[t]=255&e;++o>0)-s&255;return t+r},c.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*r-1);M(this,e,t,r,n-1,-n)}let o=r-1,i=1,s=0;for(this[t+o]=255&e;--o>=0&&(i*=256);)e<0&&0===s&&0!==this[t+o+1]&&(s=1),this[t+o]=(e/i>>0)-s&255;return t+r},c.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},c.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||M(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeBigInt64LE=X((function(e,t=0){return C(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),c.prototype.writeBigInt64BE=X((function(e,t=0){return U(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),c.prototype.writeFloatLE=function(e,t,r){return N(this,e,t,!0,r)},c.prototype.writeFloatBE=function(e,t,r){return N(this,e,t,!1,r)},c.prototype.writeDoubleLE=function(e,t,r){return k(this,e,t,!0,r)},c.prototype.writeDoubleBE=function(e,t,r){return k(this,e,t,!1,r)},c.prototype.copy=function(e,t,r,n){if(!c.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function W(e,t,r,n,o,i){if(e>r||e3?0===t||t===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${t}${n} and <= ${r}${n}`,new L.ERR_OUT_OF_RANGE("value",o,e)}!function(e,t,r){q(t,"offset"),void 0!==e[t]&&void 0!==e[t+r]||G(t,e.length-(r+1))}(n,o,i)}function q(e,t){if("number"!=typeof e)throw new L.ERR_INVALID_ARG_TYPE(t,"number",e)}function G(e,t,r){if(Math.floor(e)!==e)throw q(e,r),new L.ERR_OUT_OF_RANGE(r||"offset","an integer",e);if(t<0)throw new L.ERR_BUFFER_OUT_OF_BOUNDS;throw new L.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}z("ERR_BUFFER_OUT_OF_BOUNDS",(function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),z("ERR_INVALID_ARG_TYPE",(function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`}),TypeError),z("ERR_OUT_OF_RANGE",(function(e,t,r){let n=`The value of "${e}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=V(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=V(o)),o+="n"),n+=` It must be ${t}. Received ${o}`,n}),RangeError);const K=/[^+/0-9A-Za-z-_]/g;function F(e,t){let r;t=t||1/0;const n=e.length;let o=null;const i=[];for(let s=0;s55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function H(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(K,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Q(e,t,r,n){let o;for(o=0;o=t.length||o>=e.length);++o)t[o+r]=e[o];return o}function $(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function J(e){return e!=e}const Z=function(){const e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)t[n+o]=e[r]+e[o]}return t}();function X(e){return"undefined"==typeof BigInt?Y:e}function Y(){throw new Error("BigInt not supported")}},645:(e,t)=>{t.read=function(e,t,r,n,o){var i,s,a=8*o-n-1,c=(1<>1,l=-7,d=r?o-1:0,f=r?-1:1,h=e[t+d];for(d+=f,i=h&(1<<-l)-1,h>>=-l,l+=a;l>0;i=256*i+e[t+d],d+=f,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=n;l>0;s=256*s+e[t+d],d+=f,l-=8);if(0===i)i=1-u;else{if(i===c)return s?NaN:1/0*(h?-1:1);s+=Math.pow(2,n),i-=u}return(h?-1:1)*s*Math.pow(2,i-n)},t.write=function(e,t,r,n,o,i){var s,a,c,u=8*i-o-1,l=(1<>1,f=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:i-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+d>=1?f/c:f*Math.pow(2,1-d))*c>=2&&(s++,c/=2),s+d>=l?(a=0,s=l):s+d>=1?(a=(t*c-1)*Math.pow(2,o),s+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,o),s=0));o>=8;e[r+h]=255&a,h+=p,a/=256,o-=8);for(s=s<0;e[r+h]=255&s,h+=p,s/=256,u-=8);e[r+h-p]|=128*g}},9537:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RPC_ERROR_MESSAGE=t.RPC_ERROR=void 0,t.RPC_ERROR={INVALID_INPUT:-32e3,RESOURCE_NOT_FOUND:-32001,RESOURCE_UNAVAILABLE:-32002,TRANSACTION_REJECTED:-32003,METHOD_NOT_SUPPORTED:-32004,LIMIT_EXCEEDED:-32005,PARSE:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL:-32603,USER_REJECTED_REQUEST:4001,UNAUTHORIZED:4100,UNSUPPORTED_METHOD:4200,DISCONNECTED:4900,CHAIN_DISCONNECTED:4901,LEDGER_UNSUPPORTED_METHOD:5e3,LEDGER_UNSUPPORTED_CHAIN:5001},t.RPC_ERROR_MESSAGE={[t.RPC_ERROR.PARSE]:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text.",[t.RPC_ERROR.INVALID_REQUEST]:"The JSON sent is not a valid Request object.",[t.RPC_ERROR.METHOD_NOT_FOUND]:"The method does not exist / is not available.",[t.RPC_ERROR.INVALID_PARAMS]:"Invalid method parameter(s).",[t.RPC_ERROR.INTERNAL]:"Internal JSON-RPC error.",[t.RPC_ERROR.INVALID_INPUT]:"Invalid input.",[t.RPC_ERROR.RESOURCE_NOT_FOUND]:"Resource not found.",[t.RPC_ERROR.RESOURCE_UNAVAILABLE]:"Resource unavailable.",[t.RPC_ERROR.TRANSACTION_REJECTED]:"Transaction rejected.",[t.RPC_ERROR.METHOD_NOT_SUPPORTED]:"Method not supported.",[t.RPC_ERROR.LIMIT_EXCEEDED]:"Request limit exceeded.",[t.RPC_ERROR.USER_REJECTED_REQUEST]:"User rejected the request."}},9582:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.COSMOSTATION_RDNS=t.COSMOSTATION_WALLET_NAME=t.COSMOSTATION_ENCODED_LOGO_IMAGE=void 0,t.COSMOSTATION_ENCODED_LOGO_IMAGE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAvxSURBVHgB7Z1/aF1nGce/TbauKy5mRKVKq6cIVbSjjSto62C3LQytKW7Yjnagvdsf04HSbhRFIjPKClPGGpmgDmYbRTd00slKh4UmKcy1f1iTsDokIvdWw6bTuDST1nSO7nzPyWlvb++9531Oz/vr5nzgadK7c0bveZ/3eZ9f73sWwSxra+RD8z9JgIVJNZSZeZkIZbxG2oLuUPaEMhLKG6FcLERJ+KwOhVKGp5OjhHjQfXngrguV4U54QDmUCvx6uD5JZf4ZO0cJxcAvSEUIUJh6m3IAFn2E3SgcOxeEY1CGQejZ74ffD60dZT8MECCOUX16MAtJxqBxSQhQOHo+SAUalCBAMfgLVgkCFIO/oJWgWPP9FfoE3WhBJ1pDz9KLFGRBQ5aFsiSU3yEDZfil7YU0lz1owqImnwdQMB8F3sBycy/i8vMVdDS5YQDF4LcTHMsDqheX4Zd5K0RdSqij0RJQwcLt0Gl3qqGsrP2gfgkooxj8diZAXeGo3gJ4PfuXLu7Gqg+UcONit9yX6TermHxtFI5QRY0VuK7mPzDeD+AhHPi+W7+NTbfsgatQCU5MHsThU9+BZQLEvsAo/1KbCHo0lI/CMzj4/V8Yw8dXfAYus/SG2DqRydeOwzJBKEP8paPmg8/DQ7ZvGETPTQF8oe/WAawNrCdXS5gP8ztqPvCOnncFWL9qF3xj+/r9keWyTJl/JArgZb5/V+kAfIQWywF/JbL4iQLcDs9Yv6p8aU31kc237I4smEWiXVkd8794l/al1+8zDFW3bzDSxtcMjvlaKkAJnsHB98nxawadwVXvL8EikQIE8AiazU2r3Y33pVi2ZJECrIFH9K0biGLqdoF+jEWHMGAqmHX/tfAAzv5991RE90z/t4rp2SpM0tMViBy88xdm0P/LlTh3YQaGqTIV7M10emjriOh6Dv7jz2+M0rAm4bou+bfSIaQVOHxqAKbxxgdg2Cd1/I69/APjg09Y+DkxOSS6J3JszYeFQQc8ICn2SODsH355ELbgbJaadBuJLS8UYBOTJsLZf/gPdqtutDzDoQWSQIfQdFjovALQLLKAIoFlV4ptaIFoiSSYtgLOKwDDPinaa+5dXcCerwP3fbnlZVwCfv3Sg5BASydV+GvBaQVgpkxa7Rs+rdnx+9SngSOjsQJQut7d8vLx6nOYfHUUElgnMFUtdFoBWDaVQHN7TJfj97HVwDO/jWX5B+PPOPgpVoBILRLDws8ZyhA6qwBZwj46frnPfpr7h/fFs56zvx5ageUrWv4vGBZKHcLNYV7AhEPopALEjp887Mvd8ePsfnEsfZY/9kOkkSUsNFEncFIB6PhJZ//QyL3IDc7oIyPxzE9Z4yNoGRpZhxo4+FnCQt3tY84pQJY2L878XNuuZ2fVBr6Wx55IvYRWQBoW6m4fY1fwAByCcfCybllz8o+P3hUVVHJjbg6Y+juw9S71exKFOfn7lpdN/XsC6z9ShiqsfL719py2fQVOWQA6flKTRw9bS9h39EjqYF4FfYUUy8GBzBIW6qoTOKUAmfL9pzXm+we/L7o8GnxGBSkMHZf5Kzrbx5xRgCxtXgz7zs1prKHTAvz0J6JbIiuQ4hBmqRPoah9zQgFix68suUVP2NcIWoHZs6JbVKyAK2GhE07g3RsGxS3e+37Tm6/j1ww6hDcsSZ3VV8BM4Sungb/+peklb739P/w/dO4kW9poIc9dOIvK6yeRF9YtQNawz2ijB5eBqb+JbsHDj6Q6hExbSx3CraEVyDMstK4AD9xxSHQ9zabxHbZcAvZ+TXRLZAU01QnybCK1qgBc95e/R9aPOmypzStyCLOEhQp1AqkVyLN9zKoCZAn7bDROXuK7/aLL47DwG6mXMSy01T5mTQGyVvusQsdOGhZu26ElLGTreR6+gDUF2Lx6t+h6Nla40OalKyxUbR9LfCBGQXnsI7AWBt75yUdxfecS5eufeOGzZsK+NBgWUm7frH4PHUJGEbQgTWBYeH7ubMtUOCfAU8d2YiKcDLw+D6xZgPPCDN4a+6dqXIbLQIvBbIhCaTmqar46etXn/IwbXIZG783dAbamANJzcvKOf6+ZLA6hMCykif/ViQfx+OGN2qqB1pYAWgBJWZTLxXWhvDKV6eDr/GG5mM5d0h+oAvsKnz8U9xs0gX7A0sU340/h93xqeKc4RJTCzaEXYYldpYPiLCA3UUqbKrQRdQ6NyppHmEvY4c55XFbzAL5sn2oKrYA0LFRoHzOJVQXwZftUS6gA0rCQDqEjWK8F+LB9qiUcfKlDSF9AwSE0gfVyMOPZ/7x5Bus+vEP5nviEkEXunL/LkFDqEPauA34xFOcULOJEQ4jr26eU0NQ+phtnuoKnQyvgfVhIC0DzrgqtwLNPtwwLdWPOAnCLVQtc3j6lzOD35A6hwq4inehXAK6NL/4RePLnqZe6un1KGQ/DQn1LAJMkHPRkC7ViQeT6zhtF/YEsKU9NT+AfM3+GE/D7cUOJdGfR0Rdgg/wtQHJ4AjdV1mu2QkHExe1TIqKw8FuiW2xagHwVINlN28y7VSyISDd6OnL69mVS2sCugkuHJfJRAGowD05Q2U2rqU/OgdO3Y/jdpEkerxWAA/7kz9TNGK9X8HyzbJ/qW+eAQ8geQElCiDB6sMS1KwDXPA2eL+sE0pbp6B0CNsNCzv5t6hnNiGefaYMlQFNBhHUCr8JCaUzPqMji7Cf5hIHMZ//rdeCOLer3vPd9sdKMnWp6SdbtU8wqTk2Pwyic+fd9RXRLNHEshX8J+TaE0BGUhDRUgNs+kWo9HuobEeUGrJy+zWSXZO3n7Od3t0y+YaCmgojt7VOpRCeFSR0/4bPSRL4KwHYnOjUSfA8Ls4R9PH1E+pw0kX8mUFNBRLp9ilbASOMIwz5p2lfaQKKR/BVAU0HEyfYxD8O+evRUA7Psp1c4Zi1LWHi3zlez0emV4EDYV4+eaqCmY9YYFs6e+6foJLGupctyP1UjgjN/207RLZHpP/kSXELvvoB2DQtZ8eR+AA/Dvnr0NoQ4EBZy0PnuoEjV84IJH2nYJy0RG0JvTyCXAQ4qe99U4bVcBlo4SuwX6LlpJVb0tD5dRMdu2kuNLhLo+P1I5sCaQv/WMCoAs2Q5b59iA8gj91QaNoIwZ0AroaVtnCGr1PO/rdcpz78W/T2BWauFKXWFRqdv0zJwC7W23bT8d0kHn8ugo4NPzG0OzZIr37KxpUPI2d+/bSxK+lAZeGys1pNDs3wHWrJCAXC5a0gCZ0+KI7k89APo5Ws/OYwzX1ru3ftVZ1K+zTC7PTxLWLilZH8G0fGrfVeQCo6GffWY3RrGGSFB8Zg17WQJ++7/EnzArAJkqRMoHLOmlSzVPpp96RlCljC/OVTTMWvayGKBHMv3t4Kvj6/C5BvEOfhUAskhCbQAnIWso5uEoWibhX11VOkEVmDjFfLMpUt20vqAJ45fDeNcAiZgA4eaInLDkTYvATNUgCpskOX0bZeh0+d4zN+ACSqA4f7pGhgWSh1CV7n/i/CQql0FyBIWuohjbV4CRpMq+Ruh2NlfnaVa6BIe5PubwKLJzUkewJ4VyHLMmkv4O/ujw5oTBRBWaXKGD9FHhzBq8vTO8094jn8kCnAQtvHxQfo7+GSUfyQKMJN8YA1aAOmbuWzCwfcv7Eugxa/yl86aD8+EUoZNolj66dAh7I47b11zDOmvHB8G+vf6PPjkm6FEp2rV98raSQsXmKQaysrkL/XVQMuv5SowwBVj3KhbvrAC7UsVNbOfNOoHkJ3OVOATyhZ+BHGvYCHtIwfQgGYbpoJQxmArPVyQNwzze9Gg8tvZ4ga+yUD9dKYCl3kAGfM8g/DLzBVytQziGuASMAbgYiFeSi5FvgBxaOjLly4klgpyDOcDFEqwYAc/IUChBAt28BMCFD6ByzIOQ1ncIjpwTzgmRvM2ZcS9hD49pHYUjoG116UEiLuJfHpg7SQjcKRwV0bhIJqUSiglOEgZhSLoHvgyPIBHeR6CXw/XZRmBozM+jQCxxlIZCodRXfisRhA7d1o9+zzPz1SBJzuWECvGGsRfrhsLtwOpOv+T8fuZ+Z+JGOEd+e5WzUnmzPkAAAAASUVORK5CYII=",t.COSMOSTATION_WALLET_NAME="Cosmostation Wallet",t.COSMOSTATION_RDNS="io.cosmostation"},2891:function(e,t,r){"use strict";var n=r(8764).lW,o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.keplrAPIs=void 0;const i=r(7091),s=r(2753),a=e=>o(void 0,void 0,void 0,(function*(){try{const t=yield(0,s.request)({method:"cos_requestAccount",params:{chainName:e}});return{isNanoLedger:t.isLedger,isKeystone:t.isKeystone,algo:t.isEthermint?"ethsecp256k1":"secp256k1",pubKey:(0,i.hexToBytes)(t.publicKey),bech32Address:t.address,name:t.name,address:new Uint8Array}}catch(e){throw new Error(e.message||"Unknown Error")}})),c=(e,t,r,n)=>o(void 0,void 0,void 0,(function*(){var t,o,i,a,c,u;try{const l=yield(0,s.request)({method:"cos_signAmino",params:{chainName:e,isEditFee:!(null!==(t=null==n?void 0:n.preferNoSetFee)&&void 0!==t?t:null===(o=window.cosmostation.providers.keplr.defaultOptions.sign)||void 0===o?void 0:o.preferNoSetFee),isEditMemo:!(null!==(i=null==n?void 0:n.preferNoSetMemo)&&void 0!==i?i:null===(a=window.cosmostation.providers.keplr.defaultOptions.sign)||void 0===a?void 0:a.preferNoSetMemo),isCheckBalance:!(null!==(c=null==n?void 0:n.disableBalanceCheck)&&void 0!==c?c:null===(u=window.cosmostation.providers.keplr.defaultOptions.sign)||void 0===u?void 0:u.disableBalanceCheck),doc:r}});return{signed:l.signed_doc,signature:{pub_key:l.pub_key,signature:l.signature}}}catch(e){throw new Error(e.message||"Unknown Error")}})),u=(e,t,r,n)=>o(void 0,void 0,void 0,(function*(){var t,o,i,a,c,u;const l=yield(0,s.request)({method:"cos_signDirect",params:{chainName:e,doc:{account_number:String(r.accountNumber),auth_info_bytes:r.authInfoBytes,body_bytes:r.bodyBytes,chain_id:r.chainId},isEditFee:!(null!==(t=null==n?void 0:n.preferNoSetFee)&&void 0!==t?t:null===(o=window.cosmostation.providers.keplr.defaultOptions.sign)||void 0===o?void 0:o.preferNoSetFee),isEditMemo:!(null!==(i=null==n?void 0:n.preferNoSetMemo)&&void 0!==i?i:null===(a=window.cosmostation.providers.keplr.defaultOptions.sign)||void 0===a?void 0:a.preferNoSetMemo),isCheckBalance:!(null!==(c=null==n?void 0:n.disableBalanceCheck)&&void 0!==c?c:null===(u=window.cosmostation.providers.keplr.defaultOptions.sign)||void 0===u?void 0:u.disableBalanceCheck)}});return{signed:{accountNumber:l.signed_doc.account_number,chainId:l.signed_doc.chain_id,authInfoBytes:new Uint8Array(l.signed_doc.auth_info_bytes),bodyBytes:new Uint8Array(l.signed_doc.body_bytes)},signature:{pub_key:l.pub_key,signature:l.signature}}})),l=(e,t)=>({signAmino:(r,n)=>o(void 0,void 0,void 0,(function*(){return c(e,0,n,t)})),signDirect:(r,n)=>o(void 0,void 0,void 0,(function*(){return u(e,0,n,t)})),getAccounts:()=>o(void 0,void 0,void 0,(function*(){const t=yield a(e);return[{address:t.bech32Address,pubkey:t.pubKey,algo:t.algo}]})),chainId:e}),d=(e,t)=>({signAmino:(r,n)=>o(void 0,void 0,void 0,(function*(){return c(e,0,n,t)})),getAccounts:()=>o(void 0,void 0,void 0,(function*(){const t=yield a(e);return[{address:t.bech32Address,pubkey:t.pubKey,algo:t.algo}]})),chainId:e});t.keplrAPIs={enable:e=>o(void 0,void 0,void 0,(function*(){if(!e)throw new Error("chain id not set");const t="string"==typeof e?[e]:e,r=yield(0,s.request)({method:"cos_supportedChainIds",params:void 0}),n=[...r.official,...r.unofficial],o=t.find((e=>!n.includes(e)));if(o)throw new Error(`There is no chain info for ${o}`);yield(0,s.request)({method:"cos_requestAccount",params:{chainName:t[0]}})})),getKey:a,experimentalSuggestChain:e=>o(void 0,void 0,void 0,(function*(){try{const t=yield(0,s.request)({method:"cos_supportedChainIds",params:void 0});[...t.official,...t.unofficial].includes(e.chainId)}catch(e){throw new Error(e.message||"Unknown Error")}})),signAmino:c,signDirect:u,sendTx:(e,t,r)=>o(void 0,void 0,void 0,(function*(){try{const o=(()=>{if("number"==typeof r)return r;if("string"==typeof r){if("block"===r)return 1;if("sync"===r)return 2;if("async"===r)return 3}return 0})(),i=yield(0,s.request)({method:"cos_sendTransaction",params:{chainName:e,mode:o,txBytes:n.from(t).toString("base64")}});return n.from(i.tx_response.txhash,"hex")}catch(e){throw new Error(e.message||"Unknown Error")}})),getOfflineSigner:l,getOfflineSignerOnlyAmino:d,getOfflineSignerAuto:(e,t)=>o(void 0,void 0,void 0,(function*(){return(yield(0,s.request)({method:"cos_requestAccount",params:{chainName:e}})).isLedger?d(e,t):l(e,t)})),signArbitrary:(e,t,r)=>o(void 0,void 0,void 0,(function*(){const o="string"==typeof r?r:n.from(r).toString("utf8");return yield(0,s.request)({method:"cos_signMessage",params:{chainName:e,signer:t,message:o}})})),verifyArbitrary:(e,t,r,i)=>o(void 0,void 0,void 0,(function*(){const o="string"==typeof r?r:n.from(r).toString("utf8");return yield(0,s.request)({method:"cos_verifyMessage",params:{chainName:e,signer:t,message:o,publicKey:i.pub_key.value,signature:i.signature}})})),suggestToken:(e,t)=>o(void 0,void 0,void 0,(function*(){try{yield(0,s.request)({method:"cos_addTokensCW20",params:{chainName:e,tokens:[{contractAddress:t}]}})}catch(e){throw new Error(e.message||"Unknown Error")}}))}},6720:function(e,t,r){"use strict";var n=r(8764).lW,o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.walletsAPIs=void 0;const i=r(2753);t.walletsAPIs={connect:e=>o(void 0,void 0,void 0,(function*(){const t="string"==typeof e?[e]:e,r=yield(0,i.request)({method:"cos_supportedChainIds",params:void 0});if(!t.every((e=>r.official.includes(e)||r.unofficial.includes(e))))throw new Error("Unsupported chainId is exist");yield(0,i.request)({method:"cos_requestAccount",params:{chainName:t[0]}})})),getAccount:e=>o(void 0,void 0,void 0,(function*(){try{const t=yield(0,i.request)({method:"cos_requestAccount",params:{chainName:e}});return{name:t.name,is_ledger:!!t.isLedger,public_key:{type:t.isEthermint?"ethsecp256k1":"secp256k1",value:n.from(t.publicKey,"hex").toString("base64")},address:t.address}}catch(e){throw new Error(e.message||"Unknown Error")}})),signAmino:(e,t,r)=>o(void 0,void 0,void 0,(function*(){var n,o;try{const s=yield(0,i.request)({method:"cos_signAmino",params:{chainName:e,doc:t,isEditFee:null===(n=null==r?void 0:r.edit_mode)||void 0===n?void 0:n.fee,isEditMemo:null===(o=null==r?void 0:r.edit_mode)||void 0===o?void 0:o.memo,isCheckBalance:null==r?void 0:r.is_check_balance}});return{signature:s.signature,signed_doc:s.signed_doc}}catch(e){throw new Error(e.message||"Unknown Error")}})),signDirect:(e,t,r)=>o(void 0,void 0,void 0,(function*(){var o,s;const a="string"==typeof t.body_bytes?new Uint8Array(n.from(t.body_bytes,"hex")):new Uint8Array(t.body_bytes),c="string"==typeof t.auth_info_bytes?new Uint8Array(n.from(t.auth_info_bytes,"hex")):new Uint8Array(t.auth_info_bytes);try{const n=yield(0,i.request)({method:"cos_signDirect",params:{chainName:e,doc:Object.assign(Object.assign({},t),{body_bytes:a,auth_info_bytes:c}),isEditFee:null===(o=null==r?void 0:r.edit_mode)||void 0===o?void 0:o.fee,isEditMemo:null===(s=null==r?void 0:r.edit_mode)||void 0===s?void 0:s.memo,isCheckBalance:null==r?void 0:r.is_check_balance}});return{signature:n.signature,signed_doc:{auth_info_bytes:n.signed_doc.auth_info_bytes,body_bytes:n.signed_doc.body_bytes}}}catch(e){throw new Error(e.message||"Unknown Error")}})),sendTransaction:(e,t,r)=>o(void 0,void 0,void 0,(function*(){var o,s;const a=null!=r?r:2,c=yield(0,i.request)({method:"cos_sendTransaction",params:{chainName:e,mode:a,txBytes:t&&"object"==typeof t?n.from(t).toString("base64"):t}});if(0!==(null===(o=null==c?void 0:c.tx_response)||void 0===o?void 0:o.code))throw"string"==typeof(null===(s=null==c?void 0:c.tx_response)||void 0===s?void 0:s.raw_log)?new Error(c.tx_response.raw_log):new Error("Unknown Error");return c.tx_response.txhash})),signMessage:(e,t,r)=>o(void 0,void 0,void 0,(function*(){return{signature:(yield(0,i.request)({method:"cos_signMessage",params:{chainName:e,signer:r,message:t}})).signature}})),verifyMessage:(e,t,r,n,s)=>o(void 0,void 0,void 0,(function*(){return yield(0,i.request)({method:"cos_verifyMessage",params:{chainName:e,signer:r,message:t,publicKey:s,signature:n}})})),disconnect:()=>o(void 0,void 0,void 0,(function*(){yield(0,i.request)({method:"cos_disconnect",params:void 0})})),addChain:e=>o(void 0,void 0,void 0,(function*(){yield(0,i.request)({method:"cos_addChain",params:{addressPrefix:e.address_prefix,baseDenom:e.base_denom,chainId:e.chain_id,chainName:e.chain_name,coinType:e.coin_type,decimals:e.decimals,displayDenom:e.display_denom,gasRate:e.gas_rate,restURL:e.lcd_url,coinGeckoId:e.coingecko_id,cosmWasm:e.cosmwasm,imageURL:e.image_url,type:e.type}})})),getSupportedChainIds:()=>o(void 0,void 0,void 0,(function*(){const e=yield(0,i.request)({method:"cos_supportedChainIds",params:void 0});return[...e.official,...e.unofficial]})),on:(e,t)=>{"AccountChanged"===e&&window.addEventListener("cosmostation_keystorechange",t)},off:(e,t)=>{"AccountChanged"===e&&window.removeEventListener("cosmostation_keystorechange",t)}}},9392:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tendermint=t.cosmos=t.cosmosWallet=t.keplr=void 0;const n=r(2891),o=r(9582),i=r(2753),s=r(6720);t.keplr={mode:"extension",version:"0.0.0",defaultOptions:{sign:{disableBalanceCheck:!1,preferNoSetFee:!1,preferNoSetMemo:!1}},enable:n.keplrAPIs.enable,getKey:n.keplrAPIs.getKey,experimentalSuggestChain:n.keplrAPIs.experimentalSuggestChain,signAmino:n.keplrAPIs.signAmino,signDirect:n.keplrAPIs.signDirect,sendTx:n.keplrAPIs.sendTx,getOfflineSigner:n.keplrAPIs.getOfflineSigner,getOfflineSignerOnlyAmino:n.keplrAPIs.getOfflineSignerOnlyAmino,getOfflineSignerAuto:n.keplrAPIs.getOfflineSignerAuto,signArbitrary:n.keplrAPIs.signArbitrary,verifyArbitrary:n.keplrAPIs.verifyArbitrary,suggestToken:n.keplrAPIs.suggestToken},t.cosmosWallet={name:o.COSMOSTATION_WALLET_NAME,logo:o.COSMOSTATION_ENCODED_LOGO_IMAGE,methods:{connect:s.walletsAPIs.connect,getAccount:s.walletsAPIs.getAccount,signAmino:s.walletsAPIs.signAmino,signDirect:s.walletsAPIs.signDirect,sendTransaction:s.walletsAPIs.sendTransaction,signMessage:s.walletsAPIs.signMessage,verifyMessage:s.walletsAPIs.verifyMessage,disconnect:s.walletsAPIs.disconnect,addChain:s.walletsAPIs.addChain,getSupportedChainIds:s.walletsAPIs.getSupportedChainIds},events:{on:s.walletsAPIs.on,off:s.walletsAPIs.off}};const a=(e,t)=>{},c=(e,t)=>{};t.cosmos={on:a,off:c,request:i.request},t.tendermint={on:a,off:c,request:i.request}},2753:function(e,t,r){"use strict";var n=r(8764).lW,o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.request=t.executeRequest=void 0;const i=r(9537),s=r(7359),a=r(36),c=r(7091),u=r(2390);t.executeRequest=e=>new Promise(((t,r)=>{const n=(0,u.uuidv4)(),o=e=>{var i,s,a;if((null===(i=e.data)||void 0===i?void 0:i.isCosmostation)&&(null===(s=e.data)||void 0===s?void 0:s.messageId)===n){window.removeEventListener("message",o);const{data:n}=e;(null===(a=n.response)||void 0===a?void 0:a.error)?r(n.response.error):t(n.response.result)}};window.addEventListener("message",o),(0,a.sendMessageWebToApp)(e,n)})),t.request=e=>o(void 0,void 0,void 0,(function*(){var r,a,u,l;if("cos_requestAccount"===e.method||"cos_account"===e.method||"ten_requestAccount"===e.method||"ten_account"===e.method){const r=yield(0,t.executeRequest)(e),{publicKey:n}=r;return Object.assign(Object.assign({},r),{publicKey:(0,c.hexToBytes)(n)})}if("cos_requestAccounts"===e.method){const n=yield(0,t.executeRequest)({method:"cos_supportedChainIds",params:void 0});if(!(null===(a=null===(r=e.params)||void 0===r?void 0:r.chainIds)||void 0===a?void 0:a.every((e=>{var t,r;return(null===(t=null==n?void 0:n.official)||void 0===t?void 0:t.includes(e))||(null===(r=null==n?void 0:n.unofficial)||void 0===r?void 0:r.includes(e))}))))throw new s.CosmosRPCError(i.RPC_ERROR.INVALID_PARAMS,i.RPC_ERROR_MESSAGE[i.RPC_ERROR.INVALID_PARAMS]);const d=Object.assign(Object.assign({},e),{method:"cos_requestAccount",params:{chainName:null===(l=null===(u=e.params)||void 0===u?void 0:u.chainIds)||void 0===l?void 0:l[0]}});return yield(0,t.executeRequest)(d),(yield Promise.all(e.params.chainIds.map((e=>o(void 0,void 0,void 0,(function*(){return yield(0,t.executeRequest)({method:"cos_requestAccount",params:{chainName:e}})})))))).map((e=>{const{publicKey:t}=e;return Object.assign(Object.assign({},e),{publicKey:(0,c.hexToBytes)(t)})}))}if("cos_signDirect"===e.method||"ten_signDirect"===e.method){const{params:r}=e,n=null==r?void 0:r.doc,o=n?Object.assign(Object.assign({},n),{auth_info_bytes:(0,c.bytesToHex)(n.auth_info_bytes),body_bytes:(0,c.bytesToHex)(n.body_bytes)}):n,i=r?Object.assign(Object.assign({},r),{doc:o}):r,s=Object.assign(Object.assign({},e),{params:i}),a=yield(0,t.executeRequest)(s);return Object.assign(Object.assign({},a),{signed_doc:Object.assign(Object.assign({},a.signed_doc),{auth_info_bytes:(0,c.hexToBytes)(a.signed_doc.auth_info_bytes),body_bytes:(0,c.hexToBytes)(a.signed_doc.body_bytes)})})}if("cos_sendTransaction"===e.method){const{params:r}=e,o=(null==r?void 0:r.txBytes)&&"object"==typeof r.txBytes?n.from(r.txBytes).toString("base64"):r.txBytes,i=Object.assign(Object.assign({},r),{txBytes:o}),s=Object.assign(Object.assign({},e),{params:i});return(0,t.executeRequest)(s)}return(0,t.executeRequest)(e)}))},3180:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ethereumAPIs=void 0;const o=r(36),i=r(2390),s=r(8684);t.ethereumAPIs={on:(e,t)=>{const r=r=>{var o,i,a,c,u,l,d,f;(null===(o=r.data)||void 0===o?void 0:o.isCosmostation)&&(null===(i=r.data)||void 0===i?void 0:i.type)===e&&("accountsChanged"===e&&Array.isArray(null===(c=null===(a=r.data)||void 0===a?void 0:a.message)||void 0===c?void 0:c.result)&&0===(null===(l=null===(u=r.data)||void 0===u?void 0:u.message)||void 0===l?void 0:l.result.length)?n(void 0,void 0,void 0,(function*(){try{const e=yield(0,s.request)({method:"eth_requestAccounts",params:{}});t(e)}catch(e){t([])}})):t(null===(f=null===(d=r.data)||void 0===d?void 0:d.message)||void 0===f?void 0:f.result))};return window.addEventListener("message",r),window.cosmostation.handlerInfos.push({eventName:e,originHandler:t,handler:r}),r},off:(e,t)=>{if(void 0===t)window.removeEventListener("message",e);else{const r=window.cosmostation.handlerInfos.filter((r=>r.eventName===e&&r.originHandler===t)),n=window.cosmostation.handlerInfos.filter((r=>!(r.eventName===e&&r.originHandler===t)));r.forEach((e=>{window.removeEventListener("message",e.handler)})),window.cosmostation.handlerInfos=n}},send:(e,t)=>{const r=(0,i.uuidv4)();if("string"==typeof e)return new Promise(((n,i)=>{const s=e=>{var t,o,a;if((null===(t=e.data)||void 0===t?void 0:t.isCosmostation)&&(null===(o=e.data)||void 0===o?void 0:o.messageId)===r){window.removeEventListener("message",s);const{data:t}=e;(null===(a=t.response)||void 0===a?void 0:a.error)?i(t.response):n({result:t.response.result,jsonrpc:"2.0",id:void 0})}};window.addEventListener("message",s),(0,o.sendMessageWebToApp)({method:e,params:t},r)}));const n=o=>{var i,s,a;if((null===(i=o.data)||void 0===i?void 0:i.isCosmostation)&&(null===(s=o.data)||void 0===s?void 0:s.messageId)===r){window.removeEventListener("message",n);const{data:r}=o;"function"==typeof t&&((null===(a=r.response)||void 0===a?void 0:a.error)?t(r.response.error,{id:e.id,jsonrpc:"2.0",method:e.method,error:r.response.error}):t(null,{id:e.id,jsonrpc:"2.0",method:e.method,error:r.response.error,result:r.response.result}))}};window.addEventListener("message",n),(0,o.sendMessageWebToApp)({method:e.method,params:e.params},r)},sendAsync:(e,t)=>{const r=(0,i.uuidv4)(),n=o=>{var i,s,a;if((null===(i=o.data)||void 0===i?void 0:i.isCosmostation)&&(null===(s=o.data)||void 0===s?void 0:s.messageId)===r){window.removeEventListener("message",n);const{data:r}=o;(null===(a=r.response)||void 0===a?void 0:a.error)?t(r.response.error,{id:e.id,jsonrpc:"2.0",method:e.method,error:r.response.error}):t(null,{id:e.id,jsonrpc:"2.0",method:e.method,error:r.response.error,result:r.response.result})}};window.addEventListener("message",n),(0,o.sendMessageWebToApp)({method:e.method,params:e.params},r)},enable:()=>(0,s.request)({method:"eth_requestAccounts",params:[]})}},9360:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.announceEthereumProvider=t.ethereum=void 0;const n=r(2390),o=r(9582),i=r(8684),s=r(3180);t.ethereum={isMetaMask:!0,on:s.ethereumAPIs.on,addListener:s.ethereumAPIs.on,off:s.ethereumAPIs.off,removeListener:s.ethereumAPIs.off,request:i.request,send:s.ethereumAPIs.send,sendAsync:s.ethereumAPIs.sendAsync,enable:s.ethereumAPIs.enable};const a=(0,n.uuidv4)(),c=()=>{const e={uuid:a,name:o.COSMOSTATION_WALLET_NAME,icon:o.COSMOSTATION_ENCODED_LOGO_IMAGE,rdns:o.COSMOSTATION_RDNS};window.dispatchEvent(new CustomEvent("eip6963:announceProvider",{detail:Object.freeze({info:e,provider:t.ethereum})}))};t.announceEthereumProvider=()=>{window.addEventListener("eip6963:requestProvider",(()=>{c()})),c()}},8684:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.request=void 0;const n=r(36),o=r(2390);t.request=function(e){return new Promise(((t,r)=>{const i=(0,o.uuidv4)(),s=e=>{var n,o,a;if((null===(n=e.data)||void 0===n?void 0:n.isCosmostation)&&(null===(o=e.data)||void 0===o?void 0:o.messageId)===i){window.removeEventListener("message",s);const{data:n}=e;(null===(a=n.response)||void 0===a?void 0:a.error)?r(n.response.error):t(n.response.result)}};window.addEventListener("message",s),(0,n.sendMessageWebToApp)(e,i)}))}},1170:function(e,t,r){"use strict";var n=r(8764).lW,o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.suiAPIs=void 0;const i=r(9041),s=r(9108);t.suiAPIs={on:(e,t)=>o(void 0,void 0,void 0,(function*(){console.log(e,t)})),off:(e,t)=>o(void 0,void 0,void 0,(function*(){console.log(e,t)})),getAccounts:()=>o(void 0,void 0,void 0,(function*(){return[(yield(0,i.request)({method:"sui_getAccount",params:void 0})).address]})),getPublicKey:()=>o(void 0,void 0,void 0,(function*(){return(yield(0,i.request)({method:"sui_getAccount",params:void 0})).publicKey})),getChain:()=>o(void 0,void 0,void 0,(function*(){return yield(0,i.request)({method:"sui_getChain"})})),signTransactionBlock:e=>(0,i.request)({method:"sui_signTransactionBlock",params:{transactionBlockSerialized:e.transactionBlock.serialize()}}),signTransaction:e=>o(void 0,void 0,void 0,(function*(){const t={transactionBlockSerialized:yield e.transaction.toJSON(),signal:e.signal},r=yield(0,i.request)({method:"sui_signTransaction",params:t});return{bytes:r.transactionBlockBytes,signature:r.signature}})),signAndExecuteTransactionBlock:e=>(0,i.request)({method:"sui_signAndExecuteTransactionBlock",params:{transactionBlockSerialized:e.transactionBlock.serialize(),options:e.options,requestType:e.requestType}}),signAndExecuteTransaction:e=>o(void 0,void 0,void 0,(function*(){const t={transactionBlockSerialized:yield e.transaction.toJSON(),signal:e.signal,options:{showRawEffects:!0,showRawInput:!0}},r=yield(0,i.request)({method:"sui_signAndExecuteTransaction",params:t}),[{txSignatures:[o],intentMessage:{value:a}}]=s.bcs.SenderSignedData.parse(n.from(r.rawTransaction,"base64")),c=s.bcs.TransactionData.serialize(a).toBase64();return{digest:r.digest,effects:n.from(new Uint8Array(r.rawEffects)).toString("base64"),bytes:c,signature:o}})),signMessage:({message:e,account:t})=>(0,i.request)({method:"sui_signMessage",params:{message:n.from(e).toString("base64"),accountAddress:null==t?void 0:t.address}}),signPersonalMessage:({message:e,account:t})=>o(void 0,void 0,void 0,(function*(){const r=yield(0,i.request)({method:"sui_signPersonalMessage",params:{message:n.from(e).toString("base64"),accountAddress:null==t?void 0:t.address}});return{bytes:r.messageBytes,signature:r.signature}}))}},1641:function(e,t,r){"use strict";var n=r(8764).lW,o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.CosmostationWallet=void 0;const i=r(9582),s=r(1170),{on:a,getAccounts:c,getPublicKey:u,getChain:l,signTransactionBlock:d,signTransaction:f,signAndExecuteTransactionBlock:h,signAndExecuteTransaction:p,signMessage:g,signPersonalMessage:y}=s.suiAPIs;t.CosmostationWallet=class{constructor(){this.name=i.COSMOSTATION_WALLET_NAME,this.chains=[],this.features={},this.accounts=[],this.version="1.0.0",this.icon=i.COSMOSTATION_ENCODED_LOGO_IMAGE,this.chains=["sui:devnet","sui:testnet","sui:mainnet"],this.features={"standard:connect":{version:"1.0.0",connect:()=>o(this,void 0,void 0,(function*(){try{const e=yield c(),t=yield u(),r=yield l();if(e.length>0&&t&&r)return this.accounts=[{address:e[0],publicKey:new Uint8Array(n.from(t.substring(2),"hex")),chains:[`sui:${r}`],features:["sui:signAndExecuteTransactionBlock","sui:signMessage","sui:signTransactionBlock","sui:signTransaction","sui:signPersonalMessage","sui:signAndExecuteTransaction"]}],{accounts:this.accounts}}catch(e){return{accounts:[]}}}))},"standard:events":{version:"1.0.0",on:a},"sui:signTransactionBlock":{version:"1.0.0",signTransactionBlock:d},"sui:signTransaction":{version:"2.0.0",signTransaction:f},"sui:signAndExecuteTransactionBlock":{version:"1.0.0",signAndExecuteTransactionBlock:h},"sui:signAndExecuteTransaction":{version:"2.0.0",signAndExecuteTransaction:p},"sui:signMessage":{version:"1.0.0",signMessage:g},"sui:signPersonalMessage":{version:"2.0.0",signPersonalMessage:y}},(()=>{o(this,void 0,void 0,(function*(){try{const e=yield c(),t=yield u(),r=yield l();e.length>0&&t&&r&&(this.accounts=[{address:e[0],publicKey:new Uint8Array(n.from(t.substring(2),"hex")),chains:[`sui:${r}`],features:["sui:signAndExecuteTransactionBlock","sui:signMessage","sui:signTransactionBlock","sui:signTransaction","sui:signPersonalMessage","sui:signAndExecuteTransaction"]}])}catch(e){}}))})()}}},9041:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.request=void 0;const n=r(36),o=r(2390);t.request=function(e){return new Promise(((t,r)=>{const i=(0,o.uuidv4)(),s=e=>{var n,o,a;if((null===(n=e.data)||void 0===n?void 0:n.isCosmostation)&&(null===(o=e.data)||void 0===o?void 0:o.messageId)===i){window.removeEventListener("message",s);const{data:n}=e;(null===(a=n.response)||void 0===a?void 0:a.error)?r(n.response.error):t(n.response.result)}};window.addEventListener("message",s),(0,n.sendMessageWebToApp)(e,i)}))}},7359:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CosmosRPCError=void 0;class r extends Error{constructor(e,t){super(t),this.name="CosmosRPCError",this.code=e;const n={error:{code:e,message:t}};this.rpcMessage=n,Object.setPrototypeOf(this,r.prototype)}}t.CosmosRPCError=r},36:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sendMessageWebToApp=void 0,t.sendMessageWebToApp=function(e,t){const r={isCosmostation:!0,message:e,messageId:t};window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.station&&window.webkit.messageHandlers.station.postMessage(JSON.stringify(r)),window.station&&window.station.request(JSON.stringify(r))}},7091:(e,t,r)=>{"use strict";var n=r(8764).lW;Object.defineProperty(t,"__esModule",{value:!0}),t.bytesToHex=t.hexToBytes=void 0,t.hexToBytes=function(e){return new Uint8Array(n.from(e,"hex"))},t.bytesToHex=function(e){return n.from(e).toString("hex")}},2390:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uuidv4=void 0,t.uuidv4=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}},9002:(e,t,r)=>{"use strict";var n,o=Object.create,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty,l=(e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let o of a(t))u.call(e,o)||o===r||i(e,o,{get:()=>t[o],enumerable:!(n=s(t,o))||n.enumerable});return e},d={};((e,t)=>{for(var r in t)i(e,r,{get:t[r],enumerable:!0})})(d,{fromB58:()=>p,toB58:()=>h}),e.exports=(n=d,l(i({},"__esModule",{value:!0}),n));var f=((e,t,r)=>(r=null!=e?o(c(e)):{},l(e&&e.__esModule?r:i(r,"default",{value:e,enumerable:!0}),e)))(r(2949));const h=e=>f.default.encode(e),p=e=>f.default.decode(e)},2849:e=>{"use strict";var t,r=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,s={};function a(e){return Uint8Array.from(atob(e),(e=>e.charCodeAt(0)))}((e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})})(s,{fromB64:()=>a,toB64:()=>u}),e.exports=(t=s,((e,t,s,a)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of o(t))i.call(e,s)||undefined===s||r(e,s,{get:()=>t[s],enumerable:!(a=n(t,s))||a.enumerable});return e})(r({},"__esModule",{value:!0}),t));const c=8192;function u(e){if(e.length{"use strict";var n,o=Object.defineProperty,i=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,c=e=>{throw TypeError(e)},u=(e,t,r)=>t.has(e)||c("Cannot "+r),l=(e,t,r)=>(u(e,t,"read from private field"),r?r.call(e):t.get(e)),d=(e,t,r)=>t.has(e)?c("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),f=(e,t,r,n)=>(u(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),h={};((e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})})(h,{BcsType:()=>S,SerializedBcs:()=>T,bigUIntBcsType:()=>j,dynamicSizeBcsType:()=>x,fixedSizeBcsType:()=>B,isSerializedBcs:()=>P,lazyBcsType:()=>M,stringLikeBcsType:()=>R,uIntBcsType:()=>I}),e.exports=(n=h,((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of s(t))a.call(e,r)||undefined===r||o(e,r,{get:()=>t[r],enumerable:!(n=i(t,r))||n.enumerable});return e})(o({},"__esModule",{value:!0}),n));var p,g,y,b,m=r(9002),v=r(2849),w=r(5383),O=r(4994),E=r(7539),A=r(6236);p=new WeakMap,g=new WeakMap;let S=class e{constructor(e){d(this,p),d(this,g),this.name=e.name,this.read=e.read,this.serializedSize=e.serializedSize??(()=>null),f(this,p,e.write),f(this,g,e.serialize??((e,t)=>{const r=new A.BcsWriter({initialSize:this.serializedSize(e)??void 0,...t});return l(this,p).call(this,e,r),r.toBytes()})),this.validate=e.validate??(()=>{})}write(e,t){this.validate(e),l(this,p).call(this,e,t)}serialize(e,t){return this.validate(e),new T(this,l(this,g).call(this,e,t))}parse(e){const t=new O.BcsReader(e);return this.read(t)}fromHex(e){return this.parse((0,w.fromHEX)(e))}fromBase58(e){return this.parse((0,m.fromB58)(e))}fromBase64(e){return this.parse((0,v.fromB64)(e))}transform({name:t,input:r,output:n,validate:o}){return new e({name:t??this.name,read:e=>n(this.read(e)),write:(e,t)=>l(this,p).call(this,r(e),t),serializedSize:e=>this.serializedSize(r(e)),serialize:(e,t)=>l(this,g).call(this,r(e),t),validate:e=>{o?.(e),this.validate(r(e))}})}};const _=Symbol.for("@mysten/serialized-bcs");function P(e){return!!e&&"object"==typeof e&&!0===e[_]}class T{constructor(e,t){d(this,y),d(this,b),f(this,y,e),f(this,b,t)}get[_](){return!0}toBytes(){return l(this,b)}toHex(){return(0,w.toHEX)(l(this,b))}toBase64(){return(0,v.toB64)(l(this,b))}toBase58(){return(0,m.toB58)(l(this,b))}parse(){return l(this,y).parse(l(this,b))}}function B({size:e,...t}){return new S({...t,serializedSize:()=>e})}function I({readMethod:e,writeMethod:t,...r}){return B({...r,read:t=>t[e](),write:(e,r)=>r[t](e),validate:e=>{if(e<0||e>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${e}. Expected value in range 0-${r.maxValue}`);r.validate?.(e)}})}function j({readMethod:e,writeMethod:t,...r}){return B({...r,read:t=>t[e](),write:(e,r)=>r[t](BigInt(e)),validate:e=>{const t=BigInt(e);if(t<0||t>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${t}. Expected value in range 0-${r.maxValue}`);r.validate?.(t)}})}function x({serialize:e,...t}){const r=new S({...t,serialize:e,write:(e,t)=>{for(const n of r.serialize(e).toBytes())t.write8(n)}});return r}function R({toBytes:e,fromBytes:t,...r}){return new S({...r,read:e=>{const r=e.readULEB(),n=e.readBytes(r);return t(n)},write:(t,r)=>{const n=e(t);r.writeULEB(n.length);for(let e=0;e{const r=e(t),n=(0,E.ulebEncode)(r.length),o=new Uint8Array(n.length+r.length);return o.set(n,0),o.set(r,n.length),o},validate:e=>{if("string"!=typeof e)throw new TypeError(`Invalid ${r.name} value: ${e}. Expected string`);r.validate?.(e)}})}function M(e){let t=null;function r(){return t||(t=e()),t}return new S({name:"lazy",read:e=>r().read(e),serializedSize:e=>r().serializedSize(e),write:(e,t)=>r().write(e,t),serialize:(e,t)=>r().serialize(e,t).toBytes()})}y=new WeakMap,b=new WeakMap},9570:(e,t,r)=>{"use strict";var n,o=Object.defineProperty,i=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,c={};((e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})})(c,{bcs:()=>d}),e.exports=(n=c,((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of s(t))a.call(e,r)||undefined===r||o(e,r,{get:()=>t[r],enumerable:!(n=i(t,r))||n.enumerable});return e})(o({},"__esModule",{value:!0}),n));var u=r(5600),l=r(7539);const d={u8:e=>(0,u.uIntBcsType)({name:"u8",readMethod:"read8",writeMethod:"write8",size:1,maxValue:255,...e}),u16:e=>(0,u.uIntBcsType)({name:"u16",readMethod:"read16",writeMethod:"write16",size:2,maxValue:65535,...e}),u32:e=>(0,u.uIntBcsType)({name:"u32",readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...e}),u64:e=>(0,u.bigUIntBcsType)({name:"u64",readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...e}),u128:e=>(0,u.bigUIntBcsType)({name:"u128",readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...e}),u256:e=>(0,u.bigUIntBcsType)({name:"u256",readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...e}),bool:e=>(0,u.fixedSizeBcsType)({name:"bool",size:1,read:e=>1===e.read8(),write:(e,t)=>t.write8(e?1:0),...e,validate:t=>{if(e?.validate?.(t),"boolean"!=typeof t)throw new TypeError("Expected boolean, found "+typeof t)}}),uleb128:e=>(0,u.dynamicSizeBcsType)({name:"uleb128",read:e=>e.readULEB(),serialize:e=>Uint8Array.from((0,l.ulebEncode)(e)),...e}),bytes:(e,t)=>(0,u.fixedSizeBcsType)({name:`bytes[${e}]`,size:e,read:t=>t.readBytes(e),write:(t,r)=>{for(let n=0;n{if(t?.validate?.(r),!r||"object"!=typeof r||!("length"in r))throw new TypeError("Expected array, found "+typeof r);if(r.length!==e)throw new TypeError(`Expected array of length ${e}, found ${r.length}`)}}),string:e=>(0,u.stringLikeBcsType)({name:"string",toBytes:e=>(new TextEncoder).encode(e),fromBytes:e=>(new TextDecoder).decode(e),...e}),fixedArray:(e,t,r)=>new u.BcsType({name:`${t.name}[${e}]`,read:r=>{const n=new Array(e);for(let o=0;o{for(const n of e)t.write(n,r)},...r,validate:t=>{if(r?.validate?.(t),!t||"object"!=typeof t||!("length"in t))throw new TypeError("Expected array, found "+typeof t);if(t.length!==e)throw new TypeError(`Expected array of length ${e}, found ${t.length}`)}}),option:e=>d.enum(`Option<${e.name}>`,{None:null,Some:e}).transform({input:e=>null==e?{None:!0}:{Some:e},output:e=>"Some"===e.$kind?e.Some:null}),vector:(e,t)=>new u.BcsType({name:`vector<${e.name}>`,read:t=>{const r=t.readULEB(),n=new Array(r);for(let o=0;o{r.writeULEB(t.length);for(const n of t)e.write(n,r)},...t,validate:e=>{if(t?.validate?.(e),!e||"object"!=typeof e||!("length"in e))throw new TypeError("Expected array, found "+typeof e)}}),tuple:(e,t)=>new u.BcsType({name:`(${e.map((e=>e.name)).join(", ")})`,serializedSize:t=>{let r=0;for(let n=0;n{const r=[];for(const n of e)r.push(n.read(t));return r},write:(t,r)=>{for(let n=0;n{if(t?.validate?.(r),!Array.isArray(r))throw new TypeError("Expected array, found "+typeof r);if(r.length!==e.length)throw new TypeError(`Expected array of length ${e.length}, found ${r.length}`)}}),struct(e,t,r){const n=Object.entries(t);return new u.BcsType({name:e,serializedSize:e=>{let t=0;for(const[r,o]of n){const n=o.serializedSize(e[r]);if(null==n)return null;t+=n}return t},read:e=>{const t={};for(const[r,o]of n)t[r]=o.read(e);return t},write:(e,t)=>{for(const[r,o]of n)o.write(e[r],t)},...r,validate:e=>{if(r?.validate?.(e),"object"!=typeof e||null==e)throw new TypeError("Expected object, found "+typeof e)}})},enum(e,t,r){const n=Object.entries(t);return new u.BcsType({name:e,read:t=>{const r=t.readULEB(),o=n[r];if(!o)throw new TypeError(`Unknown value ${r} for enum ${e}`);const[i,s]=o;return{[i]:s?.read(t)??!0,$kind:i}},write:(e,r)=>{const[o,i]=Object.entries(e).filter((([e])=>Object.hasOwn(t,e)))[0];for(let e=0;e{if(r?.validate?.(n),"object"!=typeof n||null==n)throw new TypeError("Expected object, found "+typeof n);const o=Object.keys(n).filter((e=>void 0!==n[e]&&Object.hasOwn(t,e)));if(1!==o.length)throw new TypeError(`Expected object with one key, but found ${o.length} for type ${e}}`);const[i]=o;if(!Object.hasOwn(t,i))throw new TypeError(`Invalid enum variant ${i}`)}})},map:(e,t)=>d.vector(d.tuple([e,t])).transform({name:`Map<${e.name}, ${t.name}>`,input:e=>[...e.entries()],output:e=>{const t=new Map;for(const[r,n]of e)t.set(r,n);return t}}),lazy:e=>(0,u.lazyBcsType)(e)}},5383:e=>{"use strict";var t,r=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,s={};function a(e){const t=e.startsWith("0x")?e.slice(2):e,r=t.length%2==0?t:`0${t}}`,n=r.match(/.{2}/g)?.map((e=>parseInt(e,16)))??[];return Uint8Array.from(n)}function c(e){return e.reduce(((e,t)=>e+t.toString(16).padStart(2,"0")),"")}((e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})})(s,{fromHEX:()=>a,toHEX:()=>c}),e.exports=(t=s,((e,t,s,a)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of o(t))i.call(e,s)||undefined===s||r(e,s,{get:()=>t[s],enumerable:!(a=n(t,s))||a.enumerable});return e})(r({},"__esModule",{value:!0}),t))},4648:(e,t,r)=>{"use strict";var n,o=Object.defineProperty,i=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,c={};((e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})})(c,{BcsReader:()=>p.BcsReader,BcsType:()=>d.BcsType,BcsWriter:()=>y.BcsWriter,SerializedBcs:()=>d.SerializedBcs,bcs:()=>f.bcs,decodeStr:()=>g.decodeStr,encodeStr:()=>g.encodeStr,fromB58:()=>u.fromB58,fromB64:()=>l.fromB64,fromHEX:()=>h.fromHEX,isSerializedBcs:()=>d.isSerializedBcs,splitGenericParameters:()=>g.splitGenericParameters,toB58:()=>u.toB58,toB64:()=>l.toB64,toHEX:()=>h.toHEX}),e.exports=(n=c,((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of s(t))a.call(e,r)||undefined===r||o(e,r,{get:()=>t[r],enumerable:!(n=i(t,r))||n.enumerable});return e})(o({},"__esModule",{value:!0}),n));var u=r(9002),l=r(2849),d=r(5600),f=r(9570),h=r(5383),p=r(4994),g=r(543),y=r(6236)},4994:(e,t,r)=>{"use strict";var n,o=Object.defineProperty,i=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,c={};((e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})})(c,{BcsReader:()=>l}),e.exports=(n=c,((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of s(t))a.call(e,r)||undefined===r||o(e,r,{get:()=>t[r],enumerable:!(n=i(t,r))||n.enumerable});return e})(o({},"__esModule",{value:!0}),n));var u=r(7539);class l{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer)}shift(e){return this.bytePosition+=e,this}read8(){let e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){let e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){let e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){let e=this.read32(),t=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+t).toString(10)}read128(){let e=BigInt(this.read64()),t=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+t).toString(10)}read256(){let e=BigInt(this.read128()),t=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+t).toString(10)}readBytes(e){let t=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,t,e);return this.shift(e),r}readULEB(){let e=this.bytePosition+this.dataView.byteOffset,t=new Uint8Array(this.dataView.buffer,e),{value:r,length:n}=(0,u.ulebDecode)(t);return this.shift(n),r}readVec(e){let t=this.readULEB(),r=[];for(let n=0;n{"use strict";var t,r=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,s={};function a(e){let t=[],r=0;if(0===e)return[0];for(;e>0;)t[r]=127&e,(e>>=7)&&(t[r]|=128),r+=1;return t}function c(e){let t=0,r=0,n=0;for(;;){let o=e[n];if(n+=1,t|=(127&o)<{for(var n in t)r(e,n,{get:t[n],enumerable:!0})})(s,{ulebDecode:()=>c,ulebEncode:()=>a}),e.exports=(t=s,((e,t,s,a)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of o(t))i.call(e,s)||undefined===s||r(e,s,{get:()=>t[s],enumerable:!(a=n(t,s))||a.enumerable});return e})(r({},"__esModule",{value:!0}),t))},543:(e,t,r)=>{"use strict";var n,o=Object.defineProperty,i=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,c={};((e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})})(c,{decodeStr:()=>h,encodeStr:()=>f,splitGenericParameters:()=>p}),e.exports=(n=c,((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of s(t))a.call(e,r)||undefined===r||o(e,r,{get:()=>t[r],enumerable:!(n=i(t,r))||n.enumerable});return e})(o({},"__esModule",{value:!0}),n));var u=r(9002),l=r(2849),d=r(5383);function f(e,t){switch(t){case"base58":return(0,u.toB58)(e);case"base64":return(0,l.toB64)(e);case"hex":return(0,d.toHEX)(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function h(e,t){switch(t){case"base58":return(0,u.fromB58)(e);case"base64":return(0,l.fromB64)(e);case"hex":return(0,d.fromHEX)(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function p(e,t=["<",">"]){const[r,n]=t,o=[];let i="",s=0;for(let t=0;t{"use strict";var n,o=Object.defineProperty,i=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,c={};((e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})})(c,{BcsWriter:()=>d}),e.exports=(n=c,((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of s(t))a.call(e,r)||undefined===r||o(e,r,{get:()=>t[r],enumerable:!(n=i(t,r))||n.enumerable});return e})(o({},"__esModule",{value:!0}),n));var u=r(7539),l=r(543);class d{constructor({initialSize:e=1024,maxSize:t=1/0,allocateSize:r=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=t,this.allocateSize=r,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){const t=this.bytePosition+e;if(t>this.size){const e=Math.min(this.maxSize,this.size+this.allocateSize);if(t>e)throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${t}`);this.size=e;const r=new ArrayBuffer(this.size);new Uint8Array(r).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(r)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}write16(e){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(e),!0),this.shift(2)}write32(e){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(e),!0),this.shift(4)}write64(e){return f(BigInt(e),8).forEach((e=>this.write8(e))),this}write128(e){return f(BigInt(e),16).forEach((e=>this.write8(e))),this}write256(e){return f(BigInt(e),32).forEach((e=>this.write8(e))),this}writeULEB(e){return(0,u.ulebEncode)(e).forEach((e=>this.write8(e))),this}writeVec(e,t){return this.writeULEB(e.length),Array.from(e).forEach(((r,n)=>t(this,r,n,e.length))),this}*[Symbol.iterator](){for(let e=0;e0;)r[n]=Number(e%BigInt(256)),e/=BigInt(256),n+=1;return r}},9296:(e,t,r)=>{"use strict";var n,o=Object.defineProperty,i=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,c={};((e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})})(c,{Address:()=>f,AppId:()=>M,Argument:()=>w,CallArg:()=>b,Command:()=>E,CompressedSignature:()=>D,GasData:()=>B,Intent:()=>C,IntentMessage:()=>U,IntentScope:()=>x,IntentVersion:()=>R,MultiSig:()=>z,MultiSigPkMap:()=>k,MultiSigPublicKey:()=>L,ObjectArg:()=>y,ObjectDigest:()=>h,ProgrammableMoveCall:()=>O,ProgrammableTransaction:()=>S,PublicKey:()=>N,SenderSignedData:()=>q,SenderSignedTransaction:()=>W,SharedObjectRef:()=>g,StructTag:()=>T,SuiObjectRef:()=>p,TransactionData:()=>j,TransactionDataV1:()=>I,TransactionExpiration:()=>P,TransactionKind:()=>_,TypeTag:()=>v,base64String:()=>V}),e.exports=(n=c,((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of s(t))a.call(e,r)||undefined===r||o(e,r,{get:()=>t[r],enumerable:!(n=i(t,r))||n.enumerable});return e})(o({},"__esModule",{value:!0}),n));var u=r(4648),l=r(2501),d=r(8548);const f=u.bcs.bytes(l.SUI_ADDRESS_LENGTH).transform({validate:e=>{const t="string"==typeof e?e:(0,u.toHEX)(e);if(!t||!(0,l.isValidSuiAddress)((0,l.normalizeSuiAddress)(t)))throw new Error(`Invalid Sui address ${t}`)},input:e=>"string"==typeof e?(0,u.fromHEX)((0,l.normalizeSuiAddress)(e)):e,output:e=>(0,l.normalizeSuiAddress)((0,u.toHEX)(e))}),h=u.bcs.vector(u.bcs.u8()).transform({name:"ObjectDigest",input:e=>(0,u.fromB58)(e),output:e=>(0,u.toB58)(new Uint8Array(e)),validate:e=>{if(32!==(0,u.fromB58)(e).length)throw new Error("ObjectDigest must be 32 bytes")}}),p=u.bcs.struct("SuiObjectRef",{objectId:f,version:u.bcs.u64(),digest:h}),g=u.bcs.struct("SharedObjectRef",{objectId:f,initialSharedVersion:u.bcs.u64(),mutable:u.bcs.bool()}),y=u.bcs.enum("ObjectArg",{ImmOrOwnedObject:p,SharedObject:g,Receiving:p}),b=u.bcs.enum("CallArg",{Pure:u.bcs.struct("Pure",{bytes:u.bcs.vector(u.bcs.u8()).transform({input:e=>"string"==typeof e?(0,u.fromB64)(e):e,output:e=>(0,u.toB64)(new Uint8Array(e))})}),Object:y}),m=u.bcs.enum("TypeTag",{bool:null,u8:null,u64:null,u128:null,address:null,signer:null,vector:u.bcs.lazy((()=>m)),struct:u.bcs.lazy((()=>T)),u16:null,u32:null,u256:null}),v=m.transform({input:e=>"string"==typeof e?d.TypeTagSerializer.parseFromStr(e,!0):e,output:e=>d.TypeTagSerializer.tagToString(e)}),w=u.bcs.enum("Argument",{GasCoin:null,Input:u.bcs.u16(),Result:u.bcs.u16(),NestedResult:u.bcs.tuple([u.bcs.u16(),u.bcs.u16()])}),O=u.bcs.struct("ProgrammableMoveCall",{package:f,module:u.bcs.string(),function:u.bcs.string(),typeArguments:u.bcs.vector(v),arguments:u.bcs.vector(w)}),E=u.bcs.enum("Command",{MoveCall:O,TransferObjects:u.bcs.struct("TransferObjects",{objects:u.bcs.vector(w),address:w}),SplitCoins:u.bcs.struct("SplitCoins",{coin:w,amounts:u.bcs.vector(w)}),MergeCoins:u.bcs.struct("MergeCoins",{destination:w,sources:u.bcs.vector(w)}),Publish:u.bcs.struct("Publish",{modules:u.bcs.vector(u.bcs.vector(u.bcs.u8()).transform({input:e=>"string"==typeof e?(0,u.fromB64)(e):e,output:e=>(0,u.toB64)(new Uint8Array(e))})),dependencies:u.bcs.vector(f)}),MakeMoveVec:u.bcs.struct("MakeMoveVec",{type:(A=v,u.bcs.enum("Option",{None:null,Some:A})).transform({input:e=>null===e?{None:!0}:{Some:e},output:e=>e.Some??null}),elements:u.bcs.vector(w)}),Upgrade:u.bcs.struct("Upgrade",{modules:u.bcs.vector(u.bcs.vector(u.bcs.u8()).transform({input:e=>"string"==typeof e?(0,u.fromB64)(e):e,output:e=>(0,u.toB64)(new Uint8Array(e))})),dependencies:u.bcs.vector(f),package:f,ticket:w})});var A;const S=u.bcs.struct("ProgrammableTransaction",{inputs:u.bcs.vector(b),commands:u.bcs.vector(E)}),_=u.bcs.enum("TransactionKind",{ProgrammableTransaction:S,ChangeEpoch:null,Genesis:null,ConsensusCommitPrologue:null}),P=u.bcs.enum("TransactionExpiration",{None:null,Epoch:u.bcs.u64({name:"unsafe_u64"}).transform({input:e=>e,output:e=>Number(e)})});const T=u.bcs.struct("StructTag",{address:f,module:u.bcs.string(),name:u.bcs.string(),typeParams:u.bcs.vector(m)}),B=u.bcs.struct("GasData",{payment:u.bcs.vector(p),owner:f,price:u.bcs.u64(),budget:u.bcs.u64()}),I=u.bcs.struct("TransactionDataV1",{kind:_,sender:f,gasData:B,expiration:P}),j=u.bcs.enum("TransactionData",{V1:I}),x=u.bcs.enum("IntentScope",{TransactionData:null,TransactionEffects:null,CheckpointSummary:null,PersonalMessage:null}),R=u.bcs.enum("IntentVersion",{V0:null}),M=u.bcs.enum("AppId",{Sui:null}),C=u.bcs.struct("Intent",{scope:x,version:R,appId:M});function U(e){return u.bcs.struct(`IntentMessage<${e.name}>`,{intent:C,value:e})}const D=u.bcs.enum("CompressedSignature",{ED25519:u.bcs.fixedArray(64,u.bcs.u8()),Secp256k1:u.bcs.fixedArray(64,u.bcs.u8()),Secp256r1:u.bcs.fixedArray(64,u.bcs.u8()),ZkLogin:u.bcs.vector(u.bcs.u8())}),N=u.bcs.enum("PublicKey",{ED25519:u.bcs.fixedArray(32,u.bcs.u8()),Secp256k1:u.bcs.fixedArray(33,u.bcs.u8()),Secp256r1:u.bcs.fixedArray(33,u.bcs.u8()),ZkLogin:u.bcs.vector(u.bcs.u8())}),k=u.bcs.struct("MultiSigPkMap",{pubKey:N,weight:u.bcs.u8()}),L=u.bcs.struct("MultiSigPublicKey",{pk_map:u.bcs.vector(k),threshold:u.bcs.u16()}),z=u.bcs.struct("MultiSig",{sigs:u.bcs.vector(D),bitmap:u.bcs.u16(),multisig_pk:L}),V=u.bcs.vector(u.bcs.u8()).transform({input:e=>"string"==typeof e?(0,u.fromB64)(e):e,output:e=>(0,u.toB64)(new Uint8Array(e))}),W=u.bcs.struct("SenderSignedTransaction",{intentMessage:U(j),txSignatures:u.bcs.vector(V)}),q=u.bcs.vector(W,{name:"SenderSignedData"})},4320:(e,t,r)=>{"use strict";var n,o=Object.defineProperty,i=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,c={};((e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})})(c,{TransactionEffects:()=>B}),e.exports=(n=c,((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of s(t))a.call(e,r)||undefined===r||o(e,r,{get:()=>t[r],enumerable:!(n=i(t,r))||n.enumerable});return e})(o({},"__esModule",{value:!0}),n));var u=r(4648),l=r(9296);const d=u.bcs.enum("PackageUpgradeError",{UnableToFetchPackage:u.bcs.struct("UnableToFetchPackage",{packageId:l.Address}),NotAPackage:u.bcs.struct("NotAPackage",{objectId:l.Address}),IncompatibleUpgrade:null,DigestDoesNotMatch:u.bcs.struct("DigestDoesNotMatch",{digest:u.bcs.vector(u.bcs.u8())}),UnknownUpgradePolicy:u.bcs.struct("UnknownUpgradePolicy",{policy:u.bcs.u8()}),PackageIDDoesNotMatch:u.bcs.struct("PackageIDDoesNotMatch",{packageId:l.Address,ticketId:l.Address})}),f=u.bcs.struct("ModuleId",{address:l.Address,name:u.bcs.string()}),h=u.bcs.struct("MoveLocation",{module:f,function:u.bcs.u16(),instruction:u.bcs.u16(),functionName:u.bcs.option(u.bcs.string())}),p=u.bcs.enum("CommandArgumentError",{TypeMismatch:null,InvalidBCSBytes:null,InvalidUsageOfPureArg:null,InvalidArgumentToPrivateEntryFunction:null,IndexOutOfBounds:u.bcs.struct("IndexOutOfBounds",{idx:u.bcs.u16()}),SecondaryIndexOutOfBounds:u.bcs.struct("SecondaryIndexOutOfBounds",{resultIdx:u.bcs.u16(),secondaryIdx:u.bcs.u16()}),InvalidResultArity:u.bcs.struct("InvalidResultArity",{resultIdx:u.bcs.u16()}),InvalidGasCoinUsage:null,InvalidValueUsage:null,InvalidObjectByValue:null,InvalidObjectByMutRef:null,SharedObjectOperationNotAllowed:null}),g=u.bcs.enum("TypeArgumentError",{TypeNotFound:null,ConstraintNotSatisfied:null}),y=u.bcs.enum("ExecutionFailureStatus",{InsufficientGas:null,InvalidGasObject:null,InvariantViolation:null,FeatureNotYetSupported:null,MoveObjectTooBig:u.bcs.struct("MoveObjectTooBig",{objectSize:u.bcs.u64(),maxObjectSize:u.bcs.u64()}),MovePackageTooBig:u.bcs.struct("MovePackageTooBig",{objectSize:u.bcs.u64(),maxObjectSize:u.bcs.u64()}),CircularObjectOwnership:u.bcs.struct("CircularObjectOwnership",{object:l.Address}),InsufficientCoinBalance:null,CoinBalanceOverflow:null,PublishErrorNonZeroAddress:null,SuiMoveVerificationError:null,MovePrimitiveRuntimeError:u.bcs.option(h),MoveAbort:u.bcs.tuple([h,u.bcs.u64()]),VMVerificationOrDeserializationError:null,VMInvariantViolation:null,FunctionNotFound:null,ArityMismatch:null,TypeArityMismatch:null,NonEntryFunctionInvoked:null,CommandArgumentError:u.bcs.struct("CommandArgumentError",{argIdx:u.bcs.u16(),kind:p}),TypeArgumentError:u.bcs.struct("TypeArgumentError",{argumentIdx:u.bcs.u16(),kind:g}),UnusedValueWithoutDrop:u.bcs.struct("UnusedValueWithoutDrop",{resultIdx:u.bcs.u16(),secondaryIdx:u.bcs.u16()}),InvalidPublicFunctionReturnType:u.bcs.struct("InvalidPublicFunctionReturnType",{idx:u.bcs.u16()}),InvalidTransferObject:null,EffectsTooLarge:u.bcs.struct("EffectsTooLarge",{currentSize:u.bcs.u64(),maxSize:u.bcs.u64()}),PublishUpgradeMissingDependency:null,PublishUpgradeDependencyDowngrade:null,PackageUpgradeError:u.bcs.struct("PackageUpgradeError",{upgradeError:d}),WrittenObjectsTooLarge:u.bcs.struct("WrittenObjectsTooLarge",{currentSize:u.bcs.u64(),maxSize:u.bcs.u64()}),CertificateDenied:null,SuiMoveVerificationTimedout:null,SharedObjectOperationNotAllowed:null,InputObjectDeleted:null}),b=u.bcs.enum("ExecutionStatus",{Success:null,Failed:u.bcs.struct("ExecutionFailed",{error:y,command:u.bcs.option(u.bcs.u64())})}),m=u.bcs.struct("GasCostSummary",{computationCost:u.bcs.u64(),storageCost:u.bcs.u64(),storageRebate:u.bcs.u64(),nonRefundableStorageFee:u.bcs.u64()}),v=u.bcs.enum("Owner",{AddressOwner:l.Address,ObjectOwner:l.Address,Shared:u.bcs.struct("Shared",{initialSharedVersion:u.bcs.u64()}),Immutable:null}),w=u.bcs.struct("TransactionEffectsV1",{status:b,executedEpoch:u.bcs.u64(),gasUsed:m,modifiedAtVersions:u.bcs.vector(u.bcs.tuple([l.Address,u.bcs.u64()])),sharedObjects:u.bcs.vector(l.SuiObjectRef),transactionDigest:l.ObjectDigest,created:u.bcs.vector(u.bcs.tuple([l.SuiObjectRef,v])),mutated:u.bcs.vector(u.bcs.tuple([l.SuiObjectRef,v])),unwrapped:u.bcs.vector(u.bcs.tuple([l.SuiObjectRef,v])),deleted:u.bcs.vector(l.SuiObjectRef),unwrappedThenDeleted:u.bcs.vector(l.SuiObjectRef),wrapped:u.bcs.vector(l.SuiObjectRef),gasObject:u.bcs.tuple([l.SuiObjectRef,v]),eventsDigest:u.bcs.option(l.ObjectDigest),dependencies:u.bcs.vector(l.ObjectDigest)}),O=u.bcs.tuple([u.bcs.u64(),l.ObjectDigest]),E=u.bcs.enum("ObjectIn",{NotExist:null,Exist:u.bcs.tuple([O,v])}),A=u.bcs.enum("ObjectOut",{NotExist:null,ObjectWrite:u.bcs.tuple([l.ObjectDigest,v]),PackageWrite:O}),S=u.bcs.enum("IDOperation",{None:null,Created:null,Deleted:null}),_=u.bcs.struct("EffectsObjectChange",{inputState:E,outputState:A,idOperation:S}),P=u.bcs.enum("UnchangedSharedKind",{ReadOnlyRoot:O,MutateDeleted:u.bcs.u64(),ReadDeleted:u.bcs.u64(),Cancelled:u.bcs.u64(),PerEpochConfig:null}),T=u.bcs.struct("TransactionEffectsV2",{status:b,executedEpoch:u.bcs.u64(),gasUsed:m,transactionDigest:l.ObjectDigest,gasObjectIndex:u.bcs.option(u.bcs.u32()),eventsDigest:u.bcs.option(l.ObjectDigest),dependencies:u.bcs.vector(l.ObjectDigest),lamportVersion:u.bcs.u64(),changedObjects:u.bcs.vector(u.bcs.tuple([l.Address,_])),unchangedSharedObjects:u.bcs.vector(u.bcs.tuple([l.Address,P])),auxDataDigest:u.bcs.option(l.ObjectDigest)}),B=u.bcs.enum("TransactionEffects",{V1:w,V2:T})},9108:(e,t,r)=>{"use strict";var n,o=Object.defineProperty,i=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,c={};((e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})})(c,{BcsType:()=>h.BcsType,TypeTagSerializer:()=>f.TypeTagSerializer,bcs:()=>p}),e.exports=(n=c,((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of s(t))a.call(e,r)||undefined===r||o(e,r,{get:()=>t[r],enumerable:!(n=i(t,r))||n.enumerable});return e})(o({},"__esModule",{value:!0}),n));var u=r(4648),l=r(9296),d=r(4320),f=r(8548),h=r(4648);const p={...u.bcs,U8:u.bcs.u8(),U16:u.bcs.u16(),U32:u.bcs.u32(),U64:u.bcs.u64(),U128:u.bcs.u128(),U256:u.bcs.u256(),ULEB128:u.bcs.uleb128(),Bool:u.bcs.bool(),String:u.bcs.string(),Address:l.Address,AppId:l.AppId,Argument:l.Argument,CallArg:l.CallArg,CompressedSignature:l.CompressedSignature,GasData:l.GasData,Intent:l.Intent,IntentMessage:l.IntentMessage,IntentScope:l.IntentScope,IntentVersion:l.IntentVersion,MultiSig:l.MultiSig,MultiSigPkMap:l.MultiSigPkMap,MultiSigPublicKey:l.MultiSigPublicKey,ObjectArg:l.ObjectArg,ObjectDigest:l.ObjectDigest,ProgrammableMoveCall:l.ProgrammableMoveCall,ProgrammableTransaction:l.ProgrammableTransaction,PublicKey:l.PublicKey,SenderSignedData:l.SenderSignedData,SenderSignedTransaction:l.SenderSignedTransaction,SharedObjectRef:l.SharedObjectRef,StructTag:l.StructTag,SuiObjectRef:l.SuiObjectRef,Command:l.Command,TransactionData:l.TransactionData,TransactionDataV1:l.TransactionDataV1,TransactionExpiration:l.TransactionExpiration,TransactionKind:l.TransactionKind,TypeTag:l.TypeTag,TransactionEffects:d.TransactionEffects}},8548:(e,t,r)=>{"use strict";var n,o=Object.defineProperty,i=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,c={};((e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})})(c,{TypeTagSerializer:()=>h}),e.exports=(n=c,((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of s(t))a.call(e,r)||undefined===r||o(e,r,{get:()=>t[r],enumerable:!(n=i(t,r))||n.enumerable});return e})(o({},"__esModule",{value:!0}),n));var u=r(4648),l=r(2501);const d=/^vector<(.+)>$/,f=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;class h{static parseFromStr(e,t=!1){if("address"===e)return{address:null};if("bool"===e)return{bool:null};if("u8"===e)return{u8:null};if("u16"===e)return{u16:null};if("u32"===e)return{u32:null};if("u64"===e)return{u64:null};if("u128"===e)return{u128:null};if("u256"===e)return{u256:null};if("signer"===e)return{signer:null};const r=e.match(d);if(r)return{vector:h.parseFromStr(r[1],t)};const n=e.match(f);if(n)return{struct:{address:t?(0,l.normalizeSuiAddress)(n[1]):n[1],module:n[2],name:n[3],typeParams:void 0===n[5]?[]:h.parseStructTypeArgs(n[5],t)}};throw new Error(`Encountered unexpected token when parsing type args for ${e}`)}static parseStructTypeArgs(e,t=!1){return(0,u.splitGenericParameters)(e).map((e=>h.parseFromStr(e,t)))}static tagToString(e){if("bool"in e)return"bool";if("u8"in e)return"u8";if("u16"in e)return"u16";if("u32"in e)return"u32";if("u64"in e)return"u64";if("u128"in e)return"u128";if("u256"in e)return"u256";if("address"in e)return"address";if("signer"in e)return"signer";if("vector"in e)return`vector<${h.tagToString(e.vector)}>`;if("struct"in e){const t=e.struct,r=t.typeParams.map(h.tagToString).join(", ");return`${t.address}::${t.module}::${t.name}${r?`<${r}>`:""}`}throw new Error("Invalid TypeTag")}}},2501:(e,t,r)=>{"use strict";var n,o=Object.defineProperty,i=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,c={};((e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})})(c,{SUI_ADDRESS_LENGTH:()=>f,isValidSuiAddress:()=>h,isValidSuiObjectId:()=>p,isValidTransactionDigest:()=>d,normalizeStructTag:()=>y,normalizeSuiAddress:()=>b,normalizeSuiObjectId:()=>m,parseStructTag:()=>g}),e.exports=(n=c,((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of s(t))a.call(e,r)||undefined===r||o(e,r,{get:()=>t[r],enumerable:!(n=i(t,r))||n.enumerable});return e})(o({},"__esModule",{value:!0}),n));var u=r(4648);const l=32;function d(e){try{return(0,u.fromB58)(e).length===l}catch(e){return!1}}const f=32;function h(e){return function(e){return/^(0x|0X)?[a-fA-F0-9]+$/.test(e)&&e.length%2==0}(e)&&function(e){return/^(0x|0X)/.test(e)?(e.length-2)/2:e.length/2}(e)===f}function p(e){return h(e)}function g(e){const[t,r]=e.split("::"),n=e.slice(t.length+r.length+4),o=n.includes("<")?n.slice(0,n.indexOf("<")):n,i=n.includes("<")?(0,u.splitGenericParameters)(n.slice(n.indexOf("<")+1,n.lastIndexOf(">"))).map((e=>function(e){return e.includes("::")?g(e):e}(e.trim()))):[];return{address:b(t),module:r,name:o,typeParams:i}}function y(e){const{address:t,module:r,name:n,typeParams:o}="string"==typeof e?g(e):e;return`${t}::${r}::${n}${o?.length>0?`<${o.map((e=>"string"==typeof e?e:y(e))).join(",")}>`:""}`}function b(e,t=!1){let r=e.toLowerCase();return!t&&r.startsWith("0x")&&(r=r.slice(2)),`0x${r.padStart(2*f,"0")}`}function m(e,t=!1){return b(e,t)}},3732:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(1345),t)},1345:function(e,t){"use strict";var r,n=this&&this.__classPrivateFieldSet||function(e,t,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,r):o?o.value=r:t.set(e,r),r},o=this&&this.__classPrivateFieldGet||function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)};let i;Object.defineProperty(t,"__esModule",{value:!0}),t.DEPRECATED_getWallets=t.getWallets=void 0;const s=new Set,a={};function c(){if(i)return i;if(i=Object.freeze({register:u,get:l,on:d}),"undefined"==typeof window)return i;const e=Object.freeze({register:u});try{window.addEventListener("wallet-standard:register-wallet",(({detail:t})=>t(e)))}catch(e){console.error("wallet-standard:register-wallet event listener could not be added\n",e)}try{window.dispatchEvent(new h(e))}catch(e){console.error("wallet-standard:app-ready event could not be dispatched\n",e)}return i}function u(...e){var t;return(e=e.filter((e=>!s.has(e)))).length?(e.forEach((e=>s.add(e))),null===(t=a.register)||void 0===t||t.forEach((t=>f((()=>t(...e))))),function(){var t;e.forEach((e=>s.delete(e))),null===(t=a.unregister)||void 0===t||t.forEach((t=>f((()=>t(...e)))))}):()=>{}}function l(){return[...s]}function d(e,t){var r;return(null===(r=a[e])||void 0===r?void 0:r.push(t))||(a[e]=[t]),function(){var r;a[e]=null===(r=a[e])||void 0===r?void 0:r.filter((e=>t!==e))}}function f(e){try{e()}catch(e){console.error(e)}}t.getWallets=c;class h extends Event{constructor(e){super("wallet-standard:app-ready",{bubbles:!1,cancelable:!1,composed:!1}),r.set(this,void 0),n(this,r,e,"f")}get detail(){return o(this,r,"f")}get type(){return"wallet-standard:app-ready"}preventDefault(){throw new Error("preventDefault cannot be called")}stopImmediatePropagation(){throw new Error("stopImmediatePropagation cannot be called")}stopPropagation(){throw new Error("stopPropagation cannot be called")}}r=new WeakMap,t.DEPRECATED_getWallets=function(){if(i)return i;if(i=c(),"undefined"==typeof window)return i;const e=window.navigator.wallets||[];if(!Array.isArray(e))return console.error("window.navigator.wallets is not an array"),i;const{register:t}=i,r=(...e)=>e.forEach((e=>f((()=>e({register:t})))));try{Object.defineProperty(window.navigator,"wallets",{value:Object.freeze({push:r})})}catch(e){return console.error("window.navigator.wallets could not be set"),i}return r(...e),i}},6401:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},2904:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(6401),t),o(r(1782),t),o(r(8225),t)},1782:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},8225:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},3902:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(3732),t),o(r(2904),t),o(r(988),t),o(r(1283),t)},3204:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Connect=t.StandardConnect=void 0,t.StandardConnect="standard:connect",t.Connect=t.StandardConnect},7381:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Disconnect=t.StandardDisconnect=void 0,t.StandardDisconnect="standard:disconnect",t.Disconnect=t.StandardDisconnect},5177:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Events=t.StandardEvents=void 0,t.StandardEvents="standard:events",t.Events=t.StandardEvents},988:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(3204),t),o(r(7381),t),o(r(5177),t)},1283:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(9510),t),o(r(331),t)},9510:function(e,t){"use strict";var r,n=this&&this.__classPrivateFieldSet||function(e,t,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,r):o?o.value=r:t.set(e,r),r},o=this&&this.__classPrivateFieldGet||function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)};function i(e){const t=({register:t})=>t(e);try{window.dispatchEvent(new s(t))}catch(e){console.error("wallet-standard:register-wallet event could not be dispatched\n",e)}try{window.addEventListener("wallet-standard:app-ready",(({detail:e})=>t(e)))}catch(e){console.error("wallet-standard:app-ready event listener could not be added\n",e)}}Object.defineProperty(t,"__esModule",{value:!0}),t.DEPRECATED_registerWallet=t.registerWallet=void 0,t.registerWallet=i;class s extends Event{constructor(e){super("wallet-standard:register-wallet",{bubbles:!1,cancelable:!1,composed:!1}),r.set(this,void 0),n(this,r,e,"f")}get detail(){return o(this,r,"f")}get type(){return"wallet-standard:register-wallet"}preventDefault(){throw new Error("preventDefault cannot be called")}stopImmediatePropagation(){throw new Error("stopImmediatePropagation cannot be called")}stopPropagation(){throw new Error("stopPropagation cannot be called")}}r=new WeakMap,t.DEPRECATED_registerWallet=function(e){var t;i(e);try{((t=window.navigator).wallets||(t.wallets=[])).push((({register:t})=>t(e)))}catch(e){console.error("window.navigator.wallets could not be pushed\n",e)}}},331:function(e,t){"use strict";var r,n,o,i,s,a,c=this&&this.__classPrivateFieldSet||function(e,t,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,r):o?o.value=r:t.set(e,r),r},u=this&&this.__classPrivateFieldGet||function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.guard=t.pick=t.concatBytes=t.bytesEqual=t.arraysEqual=t.ReadonlyWalletAccount=void 0;class l{constructor(e){r.set(this,void 0),n.set(this,void 0),o.set(this,void 0),i.set(this,void 0),s.set(this,void 0),a.set(this,void 0),new.target===l&&Object.freeze(this),c(this,r,e.address,"f"),c(this,n,e.publicKey.slice(),"f"),c(this,o,e.chains.slice(),"f"),c(this,i,e.features.slice(),"f"),c(this,s,e.label,"f"),c(this,a,e.icon,"f")}get address(){return u(this,r,"f")}get publicKey(){return u(this,n,"f").slice()}get chains(){return u(this,o,"f").slice()}get features(){return u(this,i,"f").slice()}get label(){return u(this,s,"f")}get icon(){return u(this,a,"f")}}function d(e,t){if(e===t)return!0;const r=e.length;if(r!==t.length)return!1;for(let n=0;ne+t.length),e.length),n=new Uint8Array(r);n.set(e,0);for(const e of t)n.set(e,n.length);return n},t.pick=function(e,...t){const r={};for(const n of t)r[n]=e[n];return r},t.guard=function(e){try{e()}catch(e){console.error(e)}}},9176:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");const t=new Uint8Array(256);for(let e=0;e>>0,u=new Uint8Array(c);for(;e[i];){let n=t[e.charCodeAt(i)];if(255===n)return;let o=0;for(let e=c-1;(0!==n||o>>0,u[e]=n%256>>>0,n=n/256>>>0;if(0!==n)throw new Error("Non-zero carry");a=o,i++}let l=c-a;for(;l!==c&&0===u[l];)l++;const d=new Uint8Array(s+(c-l));let f=s;for(;l!==c;)d[f++]=u[l++];return d}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";let o=0,s=0,a=0;const c=t.length;for(;a!==c&&0===t[a];)a++,o++;const u=(c-a)*i+1>>>0,l=new Uint8Array(u);for(;a!==c;){let e=t[a],n=0;for(let t=u-1;(0!==e||n>>0,l[t]=e%r>>>0,e=e/r>>>0;if(0!==e)throw new Error("Non-zero carry");s=n,a++}let d=u-s;for(;d!==u&&0===l[d];)d++;let f=n.repeat(o);for(;d{"use strict";const e=r(8253),t=r(9360),n=r(9392),o=r(1641),i=r(3902);(()=>{window.cosmostation={version:"0.4.11",handlerInfos:[],cosmos:n.cosmos,ethereum:t.ethereum,tendermint:n.tendermint,providers:{keplr:n.keplr,metamask:t.ethereum},mode:"mobile-web"},window.keplr=n.keplr,window.getOfflineSigner=window.keplr.getOfflineSigner,window.getOfflineSignerOnlyAmino=window.keplr.getOfflineSignerOnlyAmino,window.getOfflineSignerAuto=window.keplr.getOfflineSignerAuto,window.ethereum=window.cosmostation.providers.metamask;const r=new o.CosmostationWallet;(0,i.registerWallet)(r),(0,e.registerCosmosWallet)(n.cosmosWallet),(0,t.announceEthereumProvider)()})()})()})(); \ No newline at end of file +(()=>{var e={8253:(e,t)=>{function r(){return r=Object.assign?Object.assign.bind():function(e){for(var t=1;t{"use strict";t.byteLength=function(e){var t=a(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,i=a(e),s=i[0],c=i[1],u=new o(function(e,t,r){return 3*(t+r)/4-r}(0,s,c)),d=0,l=c>0?s-4:s;for(r=0;r>16&255,u[d++]=t>>8&255,u[d++]=255&t;return 2===c&&(t=n[e.charCodeAt(r)]<<2|n[e.charCodeAt(r+1)]>>4,u[d++]=255&t),1===c&&(t=n[e.charCodeAt(r)]<<10|n[e.charCodeAt(r+1)]<<4|n[e.charCodeAt(r+2)]>>2,u[d++]=t>>8&255,u[d++]=255&t),u},t.fromByteArray=function(e){for(var t,n=e.length,o=n%3,i=[],s=16383,a=0,u=n-o;au?u:a+s));return 1===o?(t=e[n-1],i.push(r[t>>2]+r[t<<4&63]+"==")):2===o&&(t=(e[n-2]<<8)+e[n-1],i.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"=")),i.join("")};for(var r=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)r[s]=i[s],n[i.charCodeAt(s)]=s;function a(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function c(e,t,n){for(var o,i,s=[],a=t;a>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return s.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},8764:(e,t,r)=>{"use strict";const n=r(9742),o=r(645),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.lW=c,t.h2=50;const s=2147483647;function a(e){if(e>s)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,c.prototype),t}function c(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return l(e)}return u(e,t,r)}function u(e,t,r){if("string"==typeof e)return function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!c.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const r=0|g(e,t);let n=a(r);const o=n.write(e,t);return o!==r&&(n=n.slice(0,o)),n}(e,t);if(ArrayBuffer.isView(e))return function(e){if($(e,Uint8Array)){const t=new Uint8Array(e);return h(t.buffer,t.byteOffset,t.byteLength)}return f(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if($(e,ArrayBuffer)||e&&$(e.buffer,ArrayBuffer))return h(e,t,r);if("undefined"!=typeof SharedArrayBuffer&&($(e,SharedArrayBuffer)||e&&$(e.buffer,SharedArrayBuffer)))return h(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return c.from(n,t,r);const o=function(e){if(c.isBuffer(e)){const t=0|p(e.length),r=a(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||J(e.length)?a(0):f(e):"Buffer"===e.type&&Array.isArray(e.data)?f(e.data):void 0}(e);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return c.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function d(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function l(e){return d(e),a(e<0?0:0|p(e))}function f(e){const t=e.length<0?0:0|p(e.length),r=a(t);for(let n=0;n=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|e}function g(e,t){if(c.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||$(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);const r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let o=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return F(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return H(e).length;default:if(o)return n?-1:F(e).length;t=(""+t).toLowerCase(),o=!0}}function y(e,t,r){let n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return j(this,t,r);case"utf8":case"utf-8":return P(this,t,r);case"ascii":return B(this,t,r);case"latin1":case"binary":return I(this,t,r);case"base64":return S(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function b(e,t,r){const n=e[t];e[t]=e[r],e[r]=n}function m(e,t,r,n,o){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),J(r=+r)&&(r=o?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(o)return-1;r=e.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof t&&(t=c.from(t,n)),c.isBuffer(t))return 0===t.length?-1:v(e,t,r,n,o);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):v(e,[t],r,n,o);throw new TypeError("val must be string, number or Buffer")}function v(e,t,r,n,o){let i,s=1,a=e.length,c=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,r/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(o){let n=-1;for(i=r;ia&&(r=a-c),i=r;i>=0;i--){let r=!0;for(let n=0;no&&(n=o):n=o;const i=t.length;let s;for(n>i/2&&(n=i/2),s=0;s>8,o=r%256,i.push(o),i.push(n);return i}(t,e.length-r),e,r,n)}function S(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function P(e,t,r){r=Math.min(e.length,r);const n=[];let o=t;for(;o239?4:t>223?3:t>191?2:1;if(o+s<=r){let r,n,a,c;switch(s){case 1:t<128&&(i=t);break;case 2:r=e[o+1],128==(192&r)&&(c=(31&t)<<6|63&r,c>127&&(i=c));break;case 3:r=e[o+1],n=e[o+2],128==(192&r)&&128==(192&n)&&(c=(15&t)<<12|(63&r)<<6|63&n,c>2047&&(c<55296||c>57343)&&(i=c));break;case 4:r=e[o+1],n=e[o+2],a=e[o+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(c=(15&t)<<18|(63&r)<<12|(63&n)<<6|63&a,c>65535&&c<1114112&&(i=c))}}null===i?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),o+=s}return function(e){const t=e.length;if(t<=T)return String.fromCharCode.apply(String,e);let r="",n=0;for(;nn.length?(c.isBuffer(t)||(t=c.from(t)),t.copy(n,o)):Uint8Array.prototype.set.call(n,t,o);else{if(!c.isBuffer(t))throw new TypeError('"list" argument must be an Array of Buffers');t.copy(n,o)}o+=t.length}return n},c.byteLength=g,c.prototype._isBuffer=!0,c.prototype.swap16=function(){const e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let t=0;tr&&(e+=" ... "),""},i&&(c.prototype[i]=c.prototype.inspect),c.prototype.compare=function(e,t,r,n,o){if($(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),!c.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),t<0||r>e.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&t>=r)return 0;if(n>=o)return-1;if(t>=r)return 1;if(this===e)return 0;let i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0);const a=Math.min(i,s),u=this.slice(n,o),d=e.slice(t,r);for(let e=0;e>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const o=this.length-t;if((void 0===r||r>o)&&(r=o),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let i=!1;for(;;)switch(n){case"hex":return w(this,e,t,r);case"utf8":case"utf-8":return O(this,e,t,r);case"ascii":case"latin1":case"binary":return A(this,e,t,r);case"base64":return E(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const T=4096;function B(e,t,r){let n="";r=Math.min(e.length,r);for(let o=t;on)&&(r=n);let o="";for(let n=t;nr)throw new RangeError("Trying to access beyond buffer length")}function C(e,t,r,n,o,i){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||te.length)throw new RangeError("Index out of range")}function R(e,t,r,n,o){q(t,n,o,e,r,7);let i=Number(t&BigInt(4294967295));e[r++]=i,i>>=8,e[r++]=i,i>>=8,e[r++]=i,i>>=8,e[r++]=i;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=s,s>>=8,e[r++]=s,s>>=8,e[r++]=s,s>>=8,e[r++]=s,r}function U(e,t,r,n,o){q(t,n,o,e,r,7);let i=Number(t&BigInt(4294967295));e[r+7]=i,i>>=8,e[r+6]=i,i>>=8,e[r+5]=i,i>>=8,e[r+4]=i;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=s,s>>=8,e[r+2]=s,s>>=8,e[r+1]=s,s>>=8,e[r]=s,r+8}function D(e,t,r,n,o,i){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function N(e,t,r,n,i){return t=+t,r>>>=0,i||D(e,0,r,4),o.write(e,t,r,n,23,4),r+4}function k(e,t,r,n,i){return t=+t,r>>>=0,i||D(e,0,r,8),o.write(e,t,r,n,52,8),r+8}c.prototype.slice=function(e,t){const r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t>>=0,t>>>=0,r||M(e,t,this.length);let n=this[e],o=1,i=0;for(;++i>>=0,t>>>=0,r||M(e,t,this.length);let n=this[e+--t],o=1;for(;t>0&&(o*=256);)n+=this[e+--t]*o;return n},c.prototype.readUint8=c.prototype.readUInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),this[e]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(e,t){return e>>>=0,t||M(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readBigUInt64LE=X((function(e){W(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||K(e,this.length-8);const n=t+256*this[++e]+65536*this[++e]+this[++e]*2**24,o=this[++e]+256*this[++e]+65536*this[++e]+r*2**24;return BigInt(n)+(BigInt(o)<>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||K(e,this.length-8);const n=t*2**24+65536*this[++e]+256*this[++e]+this[++e],o=this[++e]*2**24+65536*this[++e]+256*this[++e]+r;return(BigInt(n)<>>=0,t>>>=0,r||M(e,t,this.length);let n=this[e],o=1,i=0;for(;++i=o&&(n-=Math.pow(2,8*t)),n},c.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||M(e,t,this.length);let n=t,o=1,i=this[e+--n];for(;n>0&&(o*=256);)i+=this[e+--n]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*t)),i},c.prototype.readInt8=function(e,t){return e>>>=0,t||M(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){e>>>=0,t||M(e,2,this.length);const r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(e,t){e>>>=0,t||M(e,2,this.length);const r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return e>>>=0,t||M(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readBigInt64LE=X((function(e){W(e>>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||K(e,this.length-8);const n=this[e+4]+256*this[e+5]+65536*this[e+6]+(r<<24);return(BigInt(n)<>>=0,"offset");const t=this[e],r=this[e+7];void 0!==t&&void 0!==r||K(e,this.length-8);const n=(t<<24)+65536*this[++e]+256*this[++e]+this[++e];return(BigInt(n)<>>=0,t||M(e,4,this.length),o.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return e>>>=0,t||M(e,4,this.length),o.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return e>>>=0,t||M(e,8,this.length),o.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return e>>>=0,t||M(e,8,this.length),o.read(this,e,!1,52,8)},c.prototype.writeUintLE=c.prototype.writeUIntLE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||C(this,e,t,r,Math.pow(2,8*r)-1,0);let o=1,i=0;for(this[t]=255&e;++i>>=0,r>>>=0,n||C(this,e,t,r,Math.pow(2,8*r)-1,0);let o=r-1,i=1;for(this[t+o]=255&e;--o>=0&&(i*=256);)this[t+o]=e/i&255;return t+r},c.prototype.writeUint8=c.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||C(this,e,t,1,255,0),this[t]=255&e,t+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||C(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||C(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||C(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||C(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeBigUInt64LE=X((function(e,t=0){return R(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),c.prototype.writeBigUInt64BE=X((function(e,t=0){return U(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))})),c.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*r-1);C(this,e,t,r,n-1,-n)}let o=0,i=1,s=0;for(this[t]=255&e;++o>0)-s&255;return t+r},c.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){const n=Math.pow(2,8*r-1);C(this,e,t,r,n-1,-n)}let o=r-1,i=1,s=0;for(this[t+o]=255&e;--o>=0&&(i*=256);)e<0&&0===s&&0!==this[t+o+1]&&(s=1),this[t+o]=(e/i>>0)-s&255;return t+r},c.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||C(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||C(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||C(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||C(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},c.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||C(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeBigInt64LE=X((function(e,t=0){return R(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),c.prototype.writeBigInt64BE=X((function(e,t=0){return U(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),c.prototype.writeFloatLE=function(e,t,r){return N(this,e,t,!0,r)},c.prototype.writeFloatBE=function(e,t,r){return N(this,e,t,!1,r)},c.prototype.writeDoubleLE=function(e,t,r){return k(this,e,t,!0,r)},c.prototype.writeDoubleBE=function(e,t,r){return k(this,e,t,!1,r)},c.prototype.copy=function(e,t,r,n){if(!c.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function q(e,t,r,n,o,i){if(e>r||e3?0===t||t===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(i+1)}${n}`:`>= -(2${n} ** ${8*(i+1)-1}${n}) and < 2 ** ${8*(i+1)-1}${n}`:`>= ${t}${n} and <= ${r}${n}`,new L.ERR_OUT_OF_RANGE("value",o,e)}!function(e,t,r){W(t,"offset"),void 0!==e[t]&&void 0!==e[t+r]||K(t,e.length-(r+1))}(n,o,i)}function W(e,t){if("number"!=typeof e)throw new L.ERR_INVALID_ARG_TYPE(t,"number",e)}function K(e,t,r){if(Math.floor(e)!==e)throw W(e,r),new L.ERR_OUT_OF_RANGE(r||"offset","an integer",e);if(t<0)throw new L.ERR_BUFFER_OUT_OF_BOUNDS;throw new L.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}z("ERR_BUFFER_OUT_OF_BOUNDS",(function(e){return e?`${e} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),z("ERR_INVALID_ARG_TYPE",(function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`}),TypeError),z("ERR_OUT_OF_RANGE",(function(e,t,r){let n=`The value of "${e}" is out of range.`,o=r;return Number.isInteger(r)&&Math.abs(r)>2**32?o=V(String(r)):"bigint"==typeof r&&(o=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(o=V(o)),o+="n"),n+=` It must be ${t}. Received ${o}`,n}),RangeError);const G=/[^+/0-9A-Za-z-_]/g;function F(e,t){let r;t=t||1/0;const n=e.length;let o=null;const i=[];for(let s=0;s55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function H(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(G,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Q(e,t,r,n){let o;for(o=0;o=t.length||o>=e.length);++o)t[o+r]=e[o];return o}function $(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function J(e){return e!=e}const Z=function(){const e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let o=0;o<16;++o)t[n+o]=e[r]+e[o]}return t}();function X(e){return"undefined"==typeof BigInt?Y:e}function Y(){throw new Error("BigInt not supported")}},645:(e,t)=>{t.read=function(e,t,r,n,o){var i,s,a=8*o-n-1,c=(1<>1,d=-7,l=r?o-1:0,f=r?-1:1,h=e[t+l];for(l+=f,i=h&(1<<-d)-1,h>>=-d,d+=a;d>0;i=256*i+e[t+l],l+=f,d-=8);for(s=i&(1<<-d)-1,i>>=-d,d+=n;d>0;s=256*s+e[t+l],l+=f,d-=8);if(0===i)i=1-u;else{if(i===c)return s?NaN:1/0*(h?-1:1);s+=Math.pow(2,n),i-=u}return(h?-1:1)*s*Math.pow(2,i-n)},t.write=function(e,t,r,n,o,i){var s,a,c,u=8*i-o-1,d=(1<>1,f=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:i-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=d):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+l>=1?f/c:f*Math.pow(2,1-l))*c>=2&&(s++,c/=2),s+l>=d?(a=0,s=d):s+l>=1?(a=(t*c-1)*Math.pow(2,o),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,o),s=0));o>=8;e[r+h]=255&a,h+=p,a/=256,o-=8);for(s=s<0;e[r+h]=255&s,h+=p,s/=256,u-=8);e[r+h-p]|=128*g}},9537:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RPC_ERROR_MESSAGE=t.RPC_ERROR=void 0,t.RPC_ERROR={INVALID_INPUT:-32e3,RESOURCE_NOT_FOUND:-32001,RESOURCE_UNAVAILABLE:-32002,TRANSACTION_REJECTED:-32003,METHOD_NOT_SUPPORTED:-32004,LIMIT_EXCEEDED:-32005,PARSE:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL:-32603,USER_REJECTED_REQUEST:4001,UNAUTHORIZED:4100,UNSUPPORTED_METHOD:4200,DISCONNECTED:4900,CHAIN_DISCONNECTED:4901,LEDGER_UNSUPPORTED_METHOD:5e3,LEDGER_UNSUPPORTED_CHAIN:5001},t.RPC_ERROR_MESSAGE={[t.RPC_ERROR.PARSE]:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text.",[t.RPC_ERROR.INVALID_REQUEST]:"The JSON sent is not a valid Request object.",[t.RPC_ERROR.METHOD_NOT_FOUND]:"The method does not exist / is not available.",[t.RPC_ERROR.INVALID_PARAMS]:"Invalid method parameter(s).",[t.RPC_ERROR.INTERNAL]:"Internal JSON-RPC error.",[t.RPC_ERROR.INVALID_INPUT]:"Invalid input.",[t.RPC_ERROR.RESOURCE_NOT_FOUND]:"Resource not found.",[t.RPC_ERROR.RESOURCE_UNAVAILABLE]:"Resource unavailable.",[t.RPC_ERROR.TRANSACTION_REJECTED]:"Transaction rejected.",[t.RPC_ERROR.METHOD_NOT_SUPPORTED]:"Method not supported.",[t.RPC_ERROR.LIMIT_EXCEEDED]:"Request limit exceeded.",[t.RPC_ERROR.USER_REJECTED_REQUEST]:"User rejected the request."}},9582:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.COSMOSTATION_RDNS=t.COSMOSTATION_WALLET_NAME=t.COSMOSTATION_ENCODED_LOGO_IMAGE=void 0,t.COSMOSTATION_ENCODED_LOGO_IMAGE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAvxSURBVHgB7Z1/aF1nGce/TbauKy5mRKVKq6cIVbSjjSto62C3LQytKW7Yjnagvdsf04HSbhRFIjPKClPGGpmgDmYbRTd00slKh4UmKcy1f1iTsDokIvdWw6bTuDST1nSO7nzPyWlvb++9531Oz/vr5nzgadK7c0bveZ/3eZ9f73sWwSxra+RD8z9JgIVJNZSZeZkIZbxG2oLuUPaEMhLKG6FcLERJ+KwOhVKGp5OjhHjQfXngrguV4U54QDmUCvx6uD5JZf4ZO0cJxcAvSEUIUJh6m3IAFn2E3SgcOxeEY1CGQejZ74ffD60dZT8MECCOUX16MAtJxqBxSQhQOHo+SAUalCBAMfgLVgkCFIO/oJWgWPP9FfoE3WhBJ1pDz9KLFGRBQ5aFsiSU3yEDZfil7YU0lz1owqImnwdQMB8F3sBycy/i8vMVdDS5YQDF4LcTHMsDqheX4Zd5K0RdSqij0RJQwcLt0Gl3qqGsrP2gfgkooxj8diZAXeGo3gJ4PfuXLu7Gqg+UcONit9yX6TermHxtFI5QRY0VuK7mPzDeD+AhHPi+W7+NTbfsgatQCU5MHsThU9+BZQLEvsAo/1KbCHo0lI/CMzj4/V8Yw8dXfAYus/SG2DqRydeOwzJBKEP8paPmg8/DQ7ZvGETPTQF8oe/WAawNrCdXS5gP8ztqPvCOnncFWL9qF3xj+/r9keWyTJl/JArgZb5/V+kAfIQWywF/JbL4iQLcDs9Yv6p8aU31kc237I4smEWiXVkd8794l/al1+8zDFW3bzDSxtcMjvlaKkAJnsHB98nxawadwVXvL8EikQIE8AiazU2r3Y33pVi2ZJECrIFH9K0biGLqdoF+jEWHMGAqmHX/tfAAzv5991RE90z/t4rp2SpM0tMViBy88xdm0P/LlTh3YQaGqTIV7M10emjriOh6Dv7jz2+M0rAm4bou+bfSIaQVOHxqAKbxxgdg2Cd1/I69/APjg09Y+DkxOSS6J3JszYeFQQc8ICn2SODsH355ELbgbJaadBuJLS8UYBOTJsLZf/gPdqtutDzDoQWSQIfQdFjovALQLLKAIoFlV4ptaIFoiSSYtgLOKwDDPinaa+5dXcCerwP3fbnlZVwCfv3Sg5BASydV+GvBaQVgpkxa7Rs+rdnx+9SngSOjsQJQut7d8vLx6nOYfHUUElgnMFUtdFoBWDaVQHN7TJfj97HVwDO/jWX5B+PPOPgpVoBILRLDws8ZyhA6qwBZwj46frnPfpr7h/fFs56zvx5ageUrWv4vGBZKHcLNYV7AhEPopALEjp887Mvd8ePsfnEsfZY/9kOkkSUsNFEncFIB6PhJZ//QyL3IDc7oIyPxzE9Z4yNoGRpZhxo4+FnCQt3tY84pQJY2L878XNuuZ2fVBr6Wx55IvYRWQBoW6m4fY1fwAByCcfCybllz8o+P3hUVVHJjbg6Y+juw9S71exKFOfn7lpdN/XsC6z9ShiqsfL719py2fQVOWQA6flKTRw9bS9h39EjqYF4FfYUUy8GBzBIW6qoTOKUAmfL9pzXm+we/L7o8GnxGBSkMHZf5Kzrbx5xRgCxtXgz7zs1prKHTAvz0J6JbIiuQ4hBmqRPoah9zQgFix68suUVP2NcIWoHZs6JbVKyAK2GhE07g3RsGxS3e+37Tm6/j1ww6hDcsSZ3VV8BM4Sungb/+peklb739P/w/dO4kW9poIc9dOIvK6yeRF9YtQNawz2ijB5eBqb+JbsHDj6Q6hExbSx3CraEVyDMstK4AD9xxSHQ9zabxHbZcAvZ+TXRLZAU01QnybCK1qgBc95e/R9aPOmypzStyCLOEhQp1AqkVyLN9zKoCZAn7bDROXuK7/aLL47DwG6mXMSy01T5mTQGyVvusQsdOGhZu26ElLGTreR6+gDUF2Lx6t+h6Nla40OalKyxUbR9LfCBGQXnsI7AWBt75yUdxfecS5eufeOGzZsK+NBgWUm7frH4PHUJGEbQgTWBYeH7ubMtUOCfAU8d2YiKcDLw+D6xZgPPCDN4a+6dqXIbLQIvBbIhCaTmqar46etXn/IwbXIZG783dAbamANJzcvKOf6+ZLA6hMCykif/ViQfx+OGN2qqB1pYAWgBJWZTLxXWhvDKV6eDr/GG5mM5d0h+oAvsKnz8U9xs0gX7A0sU340/h93xqeKc4RJTCzaEXYYldpYPiLCA3UUqbKrQRdQ6NyppHmEvY4c55XFbzAL5sn2oKrYA0LFRoHzOJVQXwZftUS6gA0rCQDqEjWK8F+LB9qiUcfKlDSF9AwSE0gfVyMOPZ/7x5Bus+vEP5nviEkEXunL/LkFDqEPauA34xFOcULOJEQ4jr26eU0NQ+phtnuoKnQyvgfVhIC0DzrgqtwLNPtwwLdWPOAnCLVQtc3j6lzOD35A6hwq4inehXAK6NL/4RePLnqZe6un1KGQ/DQn1LAJMkHPRkC7ViQeT6zhtF/YEsKU9NT+AfM3+GE/D7cUOJdGfR0Rdgg/wtQHJ4AjdV1mu2QkHExe1TIqKw8FuiW2xagHwVINlN28y7VSyISDd6OnL69mVS2sCugkuHJfJRAGowD05Q2U2rqU/OgdO3Y/jdpEkerxWAA/7kz9TNGK9X8HyzbJ/qW+eAQ8geQElCiDB6sMS1KwDXPA2eL+sE0pbp6B0CNsNCzv5t6hnNiGefaYMlQFNBhHUCr8JCaUzPqMji7Cf5hIHMZ//rdeCOLer3vPd9sdKMnWp6SdbtU8wqTk2Pwyic+fd9RXRLNHEshX8J+TaE0BGUhDRUgNs+kWo9HuobEeUGrJy+zWSXZO3n7Od3t0y+YaCmgojt7VOpRCeFSR0/4bPSRL4KwHYnOjUSfA8Ls4R9PH1E+pw0kX8mUFNBRLp9ilbASOMIwz5p2lfaQKKR/BVAU0HEyfYxD8O+evRUA7Psp1c4Zi1LWHi3zlez0emV4EDYV4+eaqCmY9YYFs6e+6foJLGupctyP1UjgjN/207RLZHpP/kSXELvvoB2DQtZ8eR+AA/Dvnr0NoQ4EBZy0PnuoEjV84IJH2nYJy0RG0JvTyCXAQ4qe99U4bVcBlo4SuwX6LlpJVb0tD5dRMdu2kuNLhLo+P1I5sCaQv/WMCoAs2Q5b59iA8gj91QaNoIwZ0AroaVtnCGr1PO/rdcpz78W/T2BWauFKXWFRqdv0zJwC7W23bT8d0kHn8ugo4NPzG0OzZIr37KxpUPI2d+/bSxK+lAZeGys1pNDs3wHWrJCAXC5a0gCZ0+KI7k89APo5Ws/OYwzX1ru3ftVZ1K+zTC7PTxLWLilZH8G0fGrfVeQCo6GffWY3RrGGSFB8Zg17WQJ++7/EnzArAJkqRMoHLOmlSzVPpp96RlCljC/OVTTMWvayGKBHMv3t4Kvj6/C5BvEOfhUAskhCbQAnIWso5uEoWibhX11VOkEVmDjFfLMpUt20vqAJ45fDeNcAiZgA4eaInLDkTYvATNUgCpskOX0bZeh0+d4zN+ACSqA4f7pGhgWSh1CV7n/i/CQql0FyBIWuohjbV4CRpMq+Ruh2NlfnaVa6BIe5PubwKLJzUkewJ4VyHLMmkv4O/ujw5oTBRBWaXKGD9FHhzBq8vTO8094jn8kCnAQtvHxQfo7+GSUfyQKMJN8YA1aAOmbuWzCwfcv7Eugxa/yl86aD8+EUoZNolj66dAh7I47b11zDOmvHB8G+vf6PPjkm6FEp2rV98raSQsXmKQaysrkL/XVQMuv5SowwBVj3KhbvrAC7UsVNbOfNOoHkJ3OVOATyhZ+BHGvYCHtIwfQgGYbpoJQxmArPVyQNwzze9Gg8tvZ4ga+yUD9dKYCl3kAGfM8g/DLzBVytQziGuASMAbgYiFeSi5FvgBxaOjLly4klgpyDOcDFEqwYAc/IUChBAt28BMCFD6ByzIOQ1ncIjpwTzgmRvM2ZcS9hD49pHYUjoG116UEiLuJfHpg7SQjcKRwV0bhIJqUSiglOEgZhSLoHvgyPIBHeR6CXw/XZRmBozM+jQCxxlIZCodRXfisRhA7d1o9+zzPz1SBJzuWECvGGsRfrhsLtwOpOv+T8fuZ+Z+JGOEd+e5WzUnmzPkAAAAASUVORK5CYII=",t.COSMOSTATION_WALLET_NAME="Cosmostation Wallet",t.COSMOSTATION_RDNS="io.cosmostation"},7101:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.bitcoinAPIs=t.on=void 0;const o=r(9582),i=r(5);t.on=(e,t)=>{},t.bitcoinAPIs={on:t.on,off:(e,t)=>{},connectWallet:()=>n(void 0,void 0,void 0,(function*(){return yield(0,i.request)({method:"bit_requestAccount",params:void 0})})),getAccounts:()=>n(void 0,void 0,void 0,(function*(){return[yield(0,i.request)({method:"bit_getAddress",params:void 0})]})),getAddress:()=>n(void 0,void 0,void 0,(function*(){return yield(0,i.request)({method:"bit_getAddress",params:void 0})})),getBalance:()=>n(void 0,void 0,void 0,(function*(){return yield(0,i.request)({method:"bit_getBalance",params:void 0})})),getPublicKey:()=>n(void 0,void 0,void 0,(function*(){return yield(0,i.request)({method:"bit_getPublicKeyHex",params:void 0})})),getPublicKeyHex:()=>n(void 0,void 0,void 0,(function*(){return yield(0,i.request)({method:"bit_getPublicKeyHex",params:void 0})})),switchNetwork:e=>n(void 0,void 0,void 0,(function*(){return yield(0,i.request)({method:"bit_switchNetwork",params:[e]})})),getNetwork:()=>n(void 0,void 0,void 0,(function*(){return yield(0,i.request)({method:"bit_getNetwork",params:void 0})})),sendBitcoin:(e,t)=>n(void 0,void 0,void 0,(function*(){return yield(0,i.request)({method:"bit_sendBitcoin",params:{to:e,satAmount:t}})})),pushTx:e=>n(void 0,void 0,void 0,(function*(){return yield(0,i.request)({method:"bit_pushTx",params:[e]})})),signMessage:(e,t)=>n(void 0,void 0,void 0,(function*(){return yield(0,i.request)({method:"bit_signMessage",params:{message:e,type:t}})})),signMessageBIP322:e=>n(void 0,void 0,void 0,(function*(){return yield(0,i.request)({method:"bit_signMessage",params:{message:e,type:"bip322-simple"}})})),signPsbt:e=>n(void 0,void 0,void 0,(function*(){return yield(0,i.request)({method:"bit_signPsbt",params:e})})),signPsbts:e=>n(void 0,void 0,void 0,(function*(){return yield(0,i.request)({method:"bit_signPsbts",params:e})})),getWalletProviderName:()=>n(void 0,void 0,void 0,(function*(){return o.COSMOSTATION_WALLET_NAME})),getWalletProviderIcon:()=>n(void 0,void 0,void 0,(function*(){return o.COSMOSTATION_ENCODED_LOGO_IMAGE}))}},9477:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bitcoin=void 0;const n=r(7101),{connectWallet:o,getAccounts:i,getAddress:s,getBalance:a,getPublicKey:c,getPublicKeyHex:u,signMessage:d,signMessageBIP322:l,signPsbt:f,signPsbts:h,sendBitcoin:p,on:g,off:y,switchNetwork:b,getNetwork:m,pushTx:v,getWalletProviderName:w,getWalletProviderIcon:O}=n.bitcoinAPIs;t.bitcoin={requestAccounts:o,connectWallet:o,getAccounts:i,getAddress:s,getBalance:a,getPublicKey:c,getPublicKeyHex:u,signMessage:d,signMessageBIP322:l,signPsbt:f,signPsbts:h,sendBitcoin:p,on:g,off:y,switchNetwork:b,getNetwork:m,pushTx:v,getWalletProviderName:w,getWalletProviderIcon:O}},5:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.request=void 0;const n=r(36),o=r(2390);t.request=e=>new Promise(((t,r)=>{const i=(0,o.uuidv4)(),s=e=>{var n,o,a;if((null===(n=e.data)||void 0===n?void 0:n.isCosmostation)&&(null===(o=e.data)||void 0===o?void 0:o.messageId)===i){window.removeEventListener("message",s);const{data:n}=e;(null===(a=n.response)||void 0===a?void 0:a.error)?r(n.response.error):t(n.response.result)}};window.addEventListener("message",s),(0,n.sendMessageWebToApp)(e,i)}))},2891:function(e,t,r){"use strict";var n=r(8764).lW,o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.keplrAPIs=void 0;const i=r(7091),s=r(2753),a=e=>o(void 0,void 0,void 0,(function*(){try{const t=yield(0,s.request)({method:"cos_requestAccount",params:{chainName:e}});return{isNanoLedger:t.isLedger,isKeystone:t.isKeystone,algo:t.isEthermint?"ethsecp256k1":"secp256k1",pubKey:(0,i.hexToBytes)(t.publicKey),bech32Address:t.address,name:t.name,address:new Uint8Array}}catch(e){throw new Error(e.message||"Unknown Error")}})),c=(e,t,r,n)=>o(void 0,void 0,void 0,(function*(){var t,o,i,a,c,u;try{const d=yield(0,s.request)({method:"cos_signAmino",params:{chainName:e,isEditFee:!(null!==(t=null==n?void 0:n.preferNoSetFee)&&void 0!==t?t:null===(o=window.cosmostation.providers.keplr.defaultOptions.sign)||void 0===o?void 0:o.preferNoSetFee),isEditMemo:!(null!==(i=null==n?void 0:n.preferNoSetMemo)&&void 0!==i?i:null===(a=window.cosmostation.providers.keplr.defaultOptions.sign)||void 0===a?void 0:a.preferNoSetMemo),isCheckBalance:!(null!==(c=null==n?void 0:n.disableBalanceCheck)&&void 0!==c?c:null===(u=window.cosmostation.providers.keplr.defaultOptions.sign)||void 0===u?void 0:u.disableBalanceCheck),doc:r}});return{signed:d.signed_doc,signature:{pub_key:d.pub_key,signature:d.signature}}}catch(e){throw new Error(e.message||"Unknown Error")}})),u=(e,t,r,n)=>o(void 0,void 0,void 0,(function*(){var t,o,i,a,c,u;const d=yield(0,s.request)({method:"cos_signDirect",params:{chainName:e,doc:{account_number:String(r.accountNumber),auth_info_bytes:r.authInfoBytes,body_bytes:r.bodyBytes,chain_id:r.chainId},isEditFee:!(null!==(t=null==n?void 0:n.preferNoSetFee)&&void 0!==t?t:null===(o=window.cosmostation.providers.keplr.defaultOptions.sign)||void 0===o?void 0:o.preferNoSetFee),isEditMemo:!(null!==(i=null==n?void 0:n.preferNoSetMemo)&&void 0!==i?i:null===(a=window.cosmostation.providers.keplr.defaultOptions.sign)||void 0===a?void 0:a.preferNoSetMemo),isCheckBalance:!(null!==(c=null==n?void 0:n.disableBalanceCheck)&&void 0!==c?c:null===(u=window.cosmostation.providers.keplr.defaultOptions.sign)||void 0===u?void 0:u.disableBalanceCheck)}});return{signed:{accountNumber:d.signed_doc.account_number,chainId:d.signed_doc.chain_id,authInfoBytes:new Uint8Array(d.signed_doc.auth_info_bytes),bodyBytes:new Uint8Array(d.signed_doc.body_bytes)},signature:{pub_key:d.pub_key,signature:d.signature}}})),d=(e,t)=>({signAmino:(r,n)=>o(void 0,void 0,void 0,(function*(){return c(e,0,n,t)})),signDirect:(r,n)=>o(void 0,void 0,void 0,(function*(){return u(e,0,n,t)})),getAccounts:()=>o(void 0,void 0,void 0,(function*(){const t=yield a(e);return[{address:t.bech32Address,pubkey:t.pubKey,algo:t.algo}]})),chainId:e}),l=(e,t)=>({signAmino:(r,n)=>o(void 0,void 0,void 0,(function*(){return c(e,0,n,t)})),getAccounts:()=>o(void 0,void 0,void 0,(function*(){const t=yield a(e);return[{address:t.bech32Address,pubkey:t.pubKey,algo:t.algo}]})),chainId:e});t.keplrAPIs={enable:e=>o(void 0,void 0,void 0,(function*(){if(!e)throw new Error("chain id not set");const t="string"==typeof e?[e]:e,r=yield(0,s.request)({method:"cos_supportedChainIds",params:void 0}),n=[...r.official,...r.unofficial],o=t.find((e=>!n.includes(e)));if(o)throw new Error(`There is no chain info for ${o}`);yield(0,s.request)({method:"cos_requestAccount",params:{chainName:t[0]}})})),getKey:a,experimentalSuggestChain:e=>o(void 0,void 0,void 0,(function*(){try{const t=yield(0,s.request)({method:"cos_supportedChainIds",params:void 0});[...t.official,...t.unofficial].includes(e.chainId)}catch(e){throw new Error(e.message||"Unknown Error")}})),signAmino:c,signDirect:u,sendTx:(e,t,r)=>o(void 0,void 0,void 0,(function*(){try{const o=(()=>{if("number"==typeof r)return r;if("string"==typeof r){if("block"===r)return 1;if("sync"===r)return 2;if("async"===r)return 3}return 0})(),i=yield(0,s.request)({method:"cos_sendTransaction",params:{chainName:e,mode:o,txBytes:n.from(t).toString("base64")}});return n.from(i.tx_response.txhash,"hex")}catch(e){throw new Error(e.message||"Unknown Error")}})),getOfflineSigner:d,getOfflineSignerOnlyAmino:l,getOfflineSignerAuto:(e,t)=>o(void 0,void 0,void 0,(function*(){return(yield(0,s.request)({method:"cos_requestAccount",params:{chainName:e}})).isLedger?l(e,t):d(e,t)})),signArbitrary:(e,t,r)=>o(void 0,void 0,void 0,(function*(){const o="string"==typeof r?r:n.from(r).toString("utf8");return yield(0,s.request)({method:"cos_signMessage",params:{chainName:e,signer:t,message:o}})})),verifyArbitrary:(e,t,r,i)=>o(void 0,void 0,void 0,(function*(){const o="string"==typeof r?r:n.from(r).toString("utf8");return yield(0,s.request)({method:"cos_verifyMessage",params:{chainName:e,signer:t,message:o,publicKey:i.pub_key.value,signature:i.signature}})})),suggestToken:(e,t)=>o(void 0,void 0,void 0,(function*(){try{yield(0,s.request)({method:"cos_addTokensCW20",params:{chainName:e,tokens:[{contractAddress:t}]}})}catch(e){throw new Error(e.message||"Unknown Error")}}))}},6720:function(e,t,r){"use strict";var n=r(8764).lW,o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.walletsAPIs=void 0;const i=r(2753);t.walletsAPIs={connect:e=>o(void 0,void 0,void 0,(function*(){const t="string"==typeof e?[e]:e,r=yield(0,i.request)({method:"cos_supportedChainIds",params:void 0});if(!t.every((e=>r.official.includes(e)||r.unofficial.includes(e))))throw new Error("Unsupported chainId is exist");yield(0,i.request)({method:"cos_requestAccount",params:{chainName:t[0]}})})),getAccount:e=>o(void 0,void 0,void 0,(function*(){try{const t=yield(0,i.request)({method:"cos_requestAccount",params:{chainName:e}});return{name:t.name,is_ledger:!!t.isLedger,public_key:{type:t.isEthermint?"ethsecp256k1":"secp256k1",value:n.from(t.publicKey,"hex").toString("base64")},address:t.address}}catch(e){throw new Error(e.message||"Unknown Error")}})),signAmino:(e,t,r)=>o(void 0,void 0,void 0,(function*(){var n,o;try{const s=yield(0,i.request)({method:"cos_signAmino",params:{chainName:e,doc:t,isEditFee:null===(n=null==r?void 0:r.edit_mode)||void 0===n?void 0:n.fee,isEditMemo:null===(o=null==r?void 0:r.edit_mode)||void 0===o?void 0:o.memo,isCheckBalance:null==r?void 0:r.is_check_balance}});return{signature:s.signature,signed_doc:s.signed_doc}}catch(e){throw new Error(e.message||"Unknown Error")}})),signDirect:(e,t,r)=>o(void 0,void 0,void 0,(function*(){var o,s;const a="string"==typeof t.body_bytes?new Uint8Array(n.from(t.body_bytes,"hex")):new Uint8Array(t.body_bytes),c="string"==typeof t.auth_info_bytes?new Uint8Array(n.from(t.auth_info_bytes,"hex")):new Uint8Array(t.auth_info_bytes);try{const n=yield(0,i.request)({method:"cos_signDirect",params:{chainName:e,doc:Object.assign(Object.assign({},t),{body_bytes:a,auth_info_bytes:c}),isEditFee:null===(o=null==r?void 0:r.edit_mode)||void 0===o?void 0:o.fee,isEditMemo:null===(s=null==r?void 0:r.edit_mode)||void 0===s?void 0:s.memo,isCheckBalance:null==r?void 0:r.is_check_balance}});return{signature:n.signature,signed_doc:{auth_info_bytes:n.signed_doc.auth_info_bytes,body_bytes:n.signed_doc.body_bytes}}}catch(e){throw new Error(e.message||"Unknown Error")}})),sendTransaction:(e,t,r)=>o(void 0,void 0,void 0,(function*(){var o,s;const a=null!=r?r:2,c=yield(0,i.request)({method:"cos_sendTransaction",params:{chainName:e,mode:a,txBytes:t&&"object"==typeof t?n.from(t).toString("base64"):t}});if(0!==(null===(o=null==c?void 0:c.tx_response)||void 0===o?void 0:o.code))throw"string"==typeof(null===(s=null==c?void 0:c.tx_response)||void 0===s?void 0:s.raw_log)?new Error(c.tx_response.raw_log):new Error("Unknown Error");return c.tx_response.txhash})),signMessage:(e,t,r)=>o(void 0,void 0,void 0,(function*(){return{signature:(yield(0,i.request)({method:"cos_signMessage",params:{chainName:e,signer:r,message:t}})).signature}})),verifyMessage:(e,t,r,n,s)=>o(void 0,void 0,void 0,(function*(){return yield(0,i.request)({method:"cos_verifyMessage",params:{chainName:e,signer:r,message:t,publicKey:s,signature:n}})})),disconnect:()=>o(void 0,void 0,void 0,(function*(){yield(0,i.request)({method:"cos_disconnect",params:void 0})})),addChain:e=>o(void 0,void 0,void 0,(function*(){yield(0,i.request)({method:"cos_addChain",params:{addressPrefix:e.address_prefix,baseDenom:e.base_denom,chainId:e.chain_id,chainName:e.chain_name,coinType:e.coin_type,decimals:e.decimals,displayDenom:e.display_denom,gasRate:e.gas_rate,restURL:e.lcd_url,coinGeckoId:e.coingecko_id,cosmWasm:e.cosmwasm,imageURL:e.image_url,type:e.type}})})),getSupportedChainIds:()=>o(void 0,void 0,void 0,(function*(){const e=yield(0,i.request)({method:"cos_supportedChainIds",params:void 0});return[...e.official,...e.unofficial]})),on:(e,t)=>{"AccountChanged"===e&&window.addEventListener("cosmostation_keystorechange",t)},off:(e,t)=>{"AccountChanged"===e&&window.removeEventListener("cosmostation_keystorechange",t)}}},9392:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tendermint=t.cosmos=t.cosmosWallet=t.keplr=void 0;const n=r(2891),o=r(9582),i=r(2753),s=r(6720);t.keplr={mode:"extension",version:"0.0.0",defaultOptions:{sign:{disableBalanceCheck:!1,preferNoSetFee:!1,preferNoSetMemo:!1}},enable:n.keplrAPIs.enable,getKey:n.keplrAPIs.getKey,experimentalSuggestChain:n.keplrAPIs.experimentalSuggestChain,signAmino:n.keplrAPIs.signAmino,signDirect:n.keplrAPIs.signDirect,sendTx:n.keplrAPIs.sendTx,getOfflineSigner:n.keplrAPIs.getOfflineSigner,getOfflineSignerOnlyAmino:n.keplrAPIs.getOfflineSignerOnlyAmino,getOfflineSignerAuto:n.keplrAPIs.getOfflineSignerAuto,signArbitrary:n.keplrAPIs.signArbitrary,verifyArbitrary:n.keplrAPIs.verifyArbitrary,suggestToken:n.keplrAPIs.suggestToken},t.cosmosWallet={name:o.COSMOSTATION_WALLET_NAME,logo:o.COSMOSTATION_ENCODED_LOGO_IMAGE,methods:{connect:s.walletsAPIs.connect,getAccount:s.walletsAPIs.getAccount,signAmino:s.walletsAPIs.signAmino,signDirect:s.walletsAPIs.signDirect,sendTransaction:s.walletsAPIs.sendTransaction,signMessage:s.walletsAPIs.signMessage,verifyMessage:s.walletsAPIs.verifyMessage,disconnect:s.walletsAPIs.disconnect,addChain:s.walletsAPIs.addChain,getSupportedChainIds:s.walletsAPIs.getSupportedChainIds},events:{on:s.walletsAPIs.on,off:s.walletsAPIs.off}};const a=(e,t)=>{},c=(e,t)=>{};t.cosmos={on:a,off:c,request:i.request},t.tendermint={on:a,off:c,request:i.request}},2753:function(e,t,r){"use strict";var n=r(8764).lW,o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.request=t.executeRequest=void 0;const i=r(9537),s=r(7359),a=r(36),c=r(7091),u=r(2390);t.executeRequest=e=>new Promise(((t,r)=>{const n=(0,u.uuidv4)(),o=e=>{var i,s,a;if((null===(i=e.data)||void 0===i?void 0:i.isCosmostation)&&(null===(s=e.data)||void 0===s?void 0:s.messageId)===n){window.removeEventListener("message",o);const{data:n}=e;(null===(a=n.response)||void 0===a?void 0:a.error)?r(n.response.error):t(n.response.result)}};window.addEventListener("message",o),(0,a.sendMessageWebToApp)(e,n)})),t.request=e=>o(void 0,void 0,void 0,(function*(){var r,a,u,d;if("cos_requestAccount"===e.method||"cos_account"===e.method||"ten_requestAccount"===e.method||"ten_account"===e.method){const r=yield(0,t.executeRequest)(e),{publicKey:n}=r;return Object.assign(Object.assign({},r),{publicKey:(0,c.hexToBytes)(n)})}if("cos_requestAccounts"===e.method){const n=yield(0,t.executeRequest)({method:"cos_supportedChainIds",params:void 0});if(!(null===(a=null===(r=e.params)||void 0===r?void 0:r.chainIds)||void 0===a?void 0:a.every((e=>{var t,r;return(null===(t=null==n?void 0:n.official)||void 0===t?void 0:t.includes(e))||(null===(r=null==n?void 0:n.unofficial)||void 0===r?void 0:r.includes(e))}))))throw new s.CosmosRPCError(i.RPC_ERROR.INVALID_PARAMS,i.RPC_ERROR_MESSAGE[i.RPC_ERROR.INVALID_PARAMS]);const l=Object.assign(Object.assign({},e),{method:"cos_requestAccount",params:{chainName:null===(d=null===(u=e.params)||void 0===u?void 0:u.chainIds)||void 0===d?void 0:d[0]}});return yield(0,t.executeRequest)(l),(yield Promise.all(e.params.chainIds.map((e=>o(void 0,void 0,void 0,(function*(){return yield(0,t.executeRequest)({method:"cos_requestAccount",params:{chainName:e}})})))))).map((e=>{const{publicKey:t}=e;return Object.assign(Object.assign({},e),{publicKey:(0,c.hexToBytes)(t)})}))}if("cos_signDirect"===e.method||"ten_signDirect"===e.method){const{params:r}=e,n=null==r?void 0:r.doc,o=n?Object.assign(Object.assign({},n),{auth_info_bytes:(0,c.bytesToHex)(n.auth_info_bytes),body_bytes:(0,c.bytesToHex)(n.body_bytes)}):n,i=r?Object.assign(Object.assign({},r),{doc:o}):r,s=Object.assign(Object.assign({},e),{params:i}),a=yield(0,t.executeRequest)(s);return Object.assign(Object.assign({},a),{signed_doc:Object.assign(Object.assign({},a.signed_doc),{auth_info_bytes:(0,c.hexToBytes)(a.signed_doc.auth_info_bytes),body_bytes:(0,c.hexToBytes)(a.signed_doc.body_bytes)})})}if("cos_sendTransaction"===e.method){const{params:r}=e,o=(null==r?void 0:r.txBytes)&&"object"==typeof r.txBytes?n.from(r.txBytes).toString("base64"):r.txBytes,i=Object.assign(Object.assign({},r),{txBytes:o}),s=Object.assign(Object.assign({},e),{params:i});return(0,t.executeRequest)(s)}return(0,t.executeRequest)(e)}))},3180:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ethereumAPIs=void 0;const o=r(36),i=r(2390),s=r(8684);t.ethereumAPIs={on:(e,t)=>{const r=r=>{var o,i,a,c,u,d,l,f;(null===(o=r.data)||void 0===o?void 0:o.isCosmostation)&&(null===(i=r.data)||void 0===i?void 0:i.type)===e&&("accountsChanged"===e&&Array.isArray(null===(c=null===(a=r.data)||void 0===a?void 0:a.message)||void 0===c?void 0:c.result)&&0===(null===(d=null===(u=r.data)||void 0===u?void 0:u.message)||void 0===d?void 0:d.result.length)?n(void 0,void 0,void 0,(function*(){try{const e=yield(0,s.request)({method:"eth_requestAccounts",params:{}});t(e)}catch(e){t([])}})):t(null===(f=null===(l=r.data)||void 0===l?void 0:l.message)||void 0===f?void 0:f.result))};return window.addEventListener("message",r),window.cosmostation.handlerInfos.push({eventName:e,originHandler:t,handler:r}),r},off:(e,t)=>{if(void 0===t)window.removeEventListener("message",e);else{const r=window.cosmostation.handlerInfos.filter((r=>r.eventName===e&&r.originHandler===t)),n=window.cosmostation.handlerInfos.filter((r=>!(r.eventName===e&&r.originHandler===t)));r.forEach((e=>{window.removeEventListener("message",e.handler)})),window.cosmostation.handlerInfos=n}},send:(e,t)=>{const r=(0,i.uuidv4)();if("string"==typeof e)return new Promise(((n,i)=>{const s=e=>{var t,o,a;if((null===(t=e.data)||void 0===t?void 0:t.isCosmostation)&&(null===(o=e.data)||void 0===o?void 0:o.messageId)===r){window.removeEventListener("message",s);const{data:t}=e;(null===(a=t.response)||void 0===a?void 0:a.error)?i(t.response):n({result:t.response.result,jsonrpc:"2.0",id:void 0})}};window.addEventListener("message",s),(0,o.sendMessageWebToApp)({method:e,params:t},r)}));const n=o=>{var i,s,a;if((null===(i=o.data)||void 0===i?void 0:i.isCosmostation)&&(null===(s=o.data)||void 0===s?void 0:s.messageId)===r){window.removeEventListener("message",n);const{data:r}=o;"function"==typeof t&&((null===(a=r.response)||void 0===a?void 0:a.error)?t(r.response.error,{id:e.id,jsonrpc:"2.0",method:e.method,error:r.response.error}):t(null,{id:e.id,jsonrpc:"2.0",method:e.method,error:r.response.error,result:r.response.result}))}};window.addEventListener("message",n),(0,o.sendMessageWebToApp)({method:e.method,params:e.params},r)},sendAsync:(e,t)=>{const r=(0,i.uuidv4)(),n=o=>{var i,s,a;if((null===(i=o.data)||void 0===i?void 0:i.isCosmostation)&&(null===(s=o.data)||void 0===s?void 0:s.messageId)===r){window.removeEventListener("message",n);const{data:r}=o;(null===(a=r.response)||void 0===a?void 0:a.error)?t(r.response.error,{id:e.id,jsonrpc:"2.0",method:e.method,error:r.response.error}):t(null,{id:e.id,jsonrpc:"2.0",method:e.method,error:r.response.error,result:r.response.result})}};window.addEventListener("message",n),(0,o.sendMessageWebToApp)({method:e.method,params:e.params},r)},enable:()=>(0,s.request)({method:"eth_requestAccounts",params:[]})}},9360:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.announceEthereumProvider=t.ethereum=void 0;const n=r(2390),o=r(9582),i=r(8684),s=r(3180);t.ethereum={isMetaMask:!0,on:s.ethereumAPIs.on,addListener:s.ethereumAPIs.on,off:s.ethereumAPIs.off,removeListener:s.ethereumAPIs.off,request:i.request,send:s.ethereumAPIs.send,sendAsync:s.ethereumAPIs.sendAsync,enable:s.ethereumAPIs.enable};const a=(0,n.uuidv4)(),c=()=>{const e={uuid:a,name:o.COSMOSTATION_WALLET_NAME,icon:o.COSMOSTATION_ENCODED_LOGO_IMAGE,rdns:o.COSMOSTATION_RDNS};window.dispatchEvent(new CustomEvent("eip6963:announceProvider",{detail:Object.freeze({info:e,provider:t.ethereum})}))};t.announceEthereumProvider=()=>{window.addEventListener("eip6963:requestProvider",(()=>{c()})),c()}},8684:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.request=void 0;const n=r(36),o=r(2390);t.request=function(e){return new Promise(((t,r)=>{const i=(0,o.uuidv4)(),s=e=>{var n,o,a;if((null===(n=e.data)||void 0===n?void 0:n.isCosmostation)&&(null===(o=e.data)||void 0===o?void 0:o.messageId)===i){window.removeEventListener("message",s);const{data:n}=e;(null===(a=n.response)||void 0===a?void 0:a.error)?r(n.response.error):t(n.response.result)}};window.addEventListener("message",s),(0,n.sendMessageWebToApp)(e,i)}))}},1170:function(e,t,r){"use strict";var n=r(8764).lW,o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.suiAPIs=void 0;const i=r(9041),s=r(9108);t.suiAPIs={on:(e,t)=>o(void 0,void 0,void 0,(function*(){console.log(e,t)})),off:(e,t)=>o(void 0,void 0,void 0,(function*(){console.log(e,t)})),getAccounts:()=>o(void 0,void 0,void 0,(function*(){return[(yield(0,i.request)({method:"sui_getAccount",params:void 0})).address]})),getPublicKey:()=>o(void 0,void 0,void 0,(function*(){return(yield(0,i.request)({method:"sui_getAccount",params:void 0})).publicKey})),getChain:()=>o(void 0,void 0,void 0,(function*(){return yield(0,i.request)({method:"sui_getChain"})})),signTransactionBlock:e=>(0,i.request)({method:"sui_signTransactionBlock",params:{transactionBlockSerialized:e.transactionBlock.serialize()}}),signTransaction:e=>o(void 0,void 0,void 0,(function*(){const t={transactionBlockSerialized:yield e.transaction.toJSON(),signal:e.signal},r=yield(0,i.request)({method:"sui_signTransaction",params:t});return{bytes:r.transactionBlockBytes,signature:r.signature}})),signAndExecuteTransactionBlock:e=>(0,i.request)({method:"sui_signAndExecuteTransactionBlock",params:{transactionBlockSerialized:e.transactionBlock.serialize(),options:e.options,requestType:e.requestType}}),signAndExecuteTransaction:e=>o(void 0,void 0,void 0,(function*(){const t={transactionBlockSerialized:yield e.transaction.toJSON(),signal:e.signal,options:{showRawEffects:!0,showRawInput:!0}},r=yield(0,i.request)({method:"sui_signAndExecuteTransaction",params:t}),[{txSignatures:[o],intentMessage:{value:a}}]=s.bcs.SenderSignedData.parse(n.from(r.rawTransaction,"base64")),c=s.bcs.TransactionData.serialize(a).toBase64();return{digest:r.digest,effects:n.from(new Uint8Array(r.rawEffects)).toString("base64"),bytes:c,signature:o}})),signMessage:({message:e,account:t})=>(0,i.request)({method:"sui_signMessage",params:{message:n.from(e).toString("base64"),accountAddress:null==t?void 0:t.address}}),signPersonalMessage:({message:e,account:t})=>o(void 0,void 0,void 0,(function*(){const r=yield(0,i.request)({method:"sui_signPersonalMessage",params:{message:n.from(e).toString("base64"),accountAddress:null==t?void 0:t.address}});return{bytes:r.messageBytes,signature:r.signature}}))}},1641:function(e,t,r){"use strict";var n=r(8764).lW,o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.CosmostationWallet=void 0;const i=r(9582),s=r(1170),{on:a,getAccounts:c,getPublicKey:u,getChain:d,signTransactionBlock:l,signTransaction:f,signAndExecuteTransactionBlock:h,signAndExecuteTransaction:p,signMessage:g,signPersonalMessage:y}=s.suiAPIs;t.CosmostationWallet=class{constructor(){this.name=i.COSMOSTATION_WALLET_NAME,this.chains=[],this.features={},this.accounts=[],this.version="1.0.0",this.icon=i.COSMOSTATION_ENCODED_LOGO_IMAGE,this.chains=["sui:devnet","sui:testnet","sui:mainnet"],this.features={"standard:connect":{version:"1.0.0",connect:()=>o(this,void 0,void 0,(function*(){try{const e=yield c(),t=yield u(),r=yield d();if(e.length>0&&t&&r)return this.accounts=[{address:e[0],publicKey:new Uint8Array(n.from(t.substring(2),"hex")),chains:[`sui:${r}`],features:["sui:signAndExecuteTransactionBlock","sui:signMessage","sui:signTransactionBlock","sui:signTransaction","sui:signPersonalMessage","sui:signAndExecuteTransaction"]}],{accounts:this.accounts}}catch(e){return{accounts:[]}}}))},"standard:events":{version:"1.0.0",on:a},"sui:signTransactionBlock":{version:"1.0.0",signTransactionBlock:l},"sui:signTransaction":{version:"2.0.0",signTransaction:f},"sui:signAndExecuteTransactionBlock":{version:"1.0.0",signAndExecuteTransactionBlock:h},"sui:signAndExecuteTransaction":{version:"2.0.0",signAndExecuteTransaction:p},"sui:signMessage":{version:"1.0.0",signMessage:g},"sui:signPersonalMessage":{version:"2.0.0",signPersonalMessage:y}},(()=>{o(this,void 0,void 0,(function*(){try{const e=yield c(),t=yield u(),r=yield d();e.length>0&&t&&r&&(this.accounts=[{address:e[0],publicKey:new Uint8Array(n.from(t.substring(2),"hex")),chains:[`sui:${r}`],features:["sui:signAndExecuteTransactionBlock","sui:signMessage","sui:signTransactionBlock","sui:signTransaction","sui:signPersonalMessage","sui:signAndExecuteTransaction"]}])}catch(e){}}))})()}}},9041:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.request=void 0;const n=r(36),o=r(2390);t.request=function(e){return new Promise(((t,r)=>{const i=(0,o.uuidv4)(),s=e=>{var n,o,a;if((null===(n=e.data)||void 0===n?void 0:n.isCosmostation)&&(null===(o=e.data)||void 0===o?void 0:o.messageId)===i){window.removeEventListener("message",s);const{data:n}=e;(null===(a=n.response)||void 0===a?void 0:a.error)?r(n.response.error):t(n.response.result)}};window.addEventListener("message",s),(0,n.sendMessageWebToApp)(e,i)}))}},7359:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CosmosRPCError=void 0;class r extends Error{constructor(e,t){super(t),this.name="CosmosRPCError",this.code=e;const n={error:{code:e,message:t}};this.rpcMessage=n,Object.setPrototypeOf(this,r.prototype)}}t.CosmosRPCError=r},36:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sendMessageWebToApp=void 0,t.sendMessageWebToApp=function(e,t){const r={isCosmostation:!0,message:e,messageId:t};window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.station&&window.webkit.messageHandlers.station.postMessage(JSON.stringify(r)),window.station&&window.station.request(JSON.stringify(r))}},7091:(e,t,r)=>{"use strict";var n=r(8764).lW;Object.defineProperty(t,"__esModule",{value:!0}),t.bytesToHex=t.hexToBytes=void 0,t.hexToBytes=function(e){return new Uint8Array(n.from(e,"hex"))},t.bytesToHex=function(e){return n.from(e).toString("hex")}},2390:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uuidv4=void 0,t.uuidv4=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}},9002:(e,t,r)=>{"use strict";var n,o=Object.create,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,c=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty,d=(e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let o of a(t))u.call(e,o)||o===r||i(e,o,{get:()=>t[o],enumerable:!(n=s(t,o))||n.enumerable});return e},l={};((e,t)=>{for(var r in t)i(e,r,{get:t[r],enumerable:!0})})(l,{fromB58:()=>p,toB58:()=>h}),e.exports=(n=l,d(i({},"__esModule",{value:!0}),n));var f=((e,t,r)=>(r=null!=e?o(c(e)):{},d(e&&e.__esModule?r:i(r,"default",{value:e,enumerable:!0}),e)))(r(2949));const h=e=>f.default.encode(e),p=e=>f.default.decode(e)},2849:e=>{"use strict";var t,r=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,s={};function a(e){return Uint8Array.from(atob(e),(e=>e.charCodeAt(0)))}((e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})})(s,{fromB64:()=>a,toB64:()=>u}),e.exports=(t=s,((e,t,s,a)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of o(t))i.call(e,s)||undefined===s||r(e,s,{get:()=>t[s],enumerable:!(a=n(t,s))||a.enumerable});return e})(r({},"__esModule",{value:!0}),t));const c=8192;function u(e){if(e.length{"use strict";var n,o=Object.defineProperty,i=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,c=e=>{throw TypeError(e)},u=(e,t,r)=>t.has(e)||c("Cannot "+r),d=(e,t,r)=>(u(e,t,"read from private field"),r?r.call(e):t.get(e)),l=(e,t,r)=>t.has(e)?c("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),f=(e,t,r,n)=>(u(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),h={};((e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})})(h,{BcsType:()=>_,SerializedBcs:()=>T,bigUIntBcsType:()=>j,dynamicSizeBcsType:()=>x,fixedSizeBcsType:()=>B,isSerializedBcs:()=>P,lazyBcsType:()=>C,stringLikeBcsType:()=>M,uIntBcsType:()=>I}),e.exports=(n=h,((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of s(t))a.call(e,r)||undefined===r||o(e,r,{get:()=>t[r],enumerable:!(n=i(t,r))||n.enumerable});return e})(o({},"__esModule",{value:!0}),n));var p,g,y,b,m=r(9002),v=r(2849),w=r(5383),O=r(4994),A=r(7539),E=r(6236);p=new WeakMap,g=new WeakMap;let _=class e{constructor(e){l(this,p),l(this,g),this.name=e.name,this.read=e.read,this.serializedSize=e.serializedSize??(()=>null),f(this,p,e.write),f(this,g,e.serialize??((e,t)=>{const r=new E.BcsWriter({initialSize:this.serializedSize(e)??void 0,...t});return d(this,p).call(this,e,r),r.toBytes()})),this.validate=e.validate??(()=>{})}write(e,t){this.validate(e),d(this,p).call(this,e,t)}serialize(e,t){return this.validate(e),new T(this,d(this,g).call(this,e,t))}parse(e){const t=new O.BcsReader(e);return this.read(t)}fromHex(e){return this.parse((0,w.fromHEX)(e))}fromBase58(e){return this.parse((0,m.fromB58)(e))}fromBase64(e){return this.parse((0,v.fromB64)(e))}transform({name:t,input:r,output:n,validate:o}){return new e({name:t??this.name,read:e=>n(this.read(e)),write:(e,t)=>d(this,p).call(this,r(e),t),serializedSize:e=>this.serializedSize(r(e)),serialize:(e,t)=>d(this,g).call(this,r(e),t),validate:e=>{o?.(e),this.validate(r(e))}})}};const S=Symbol.for("@mysten/serialized-bcs");function P(e){return!!e&&"object"==typeof e&&!0===e[S]}class T{constructor(e,t){l(this,y),l(this,b),f(this,y,e),f(this,b,t)}get[S](){return!0}toBytes(){return d(this,b)}toHex(){return(0,w.toHEX)(d(this,b))}toBase64(){return(0,v.toB64)(d(this,b))}toBase58(){return(0,m.toB58)(d(this,b))}parse(){return d(this,y).parse(d(this,b))}}function B({size:e,...t}){return new _({...t,serializedSize:()=>e})}function I({readMethod:e,writeMethod:t,...r}){return B({...r,read:t=>t[e](),write:(e,r)=>r[t](e),validate:e=>{if(e<0||e>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${e}. Expected value in range 0-${r.maxValue}`);r.validate?.(e)}})}function j({readMethod:e,writeMethod:t,...r}){return B({...r,read:t=>t[e](),write:(e,r)=>r[t](BigInt(e)),validate:e=>{const t=BigInt(e);if(t<0||t>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${t}. Expected value in range 0-${r.maxValue}`);r.validate?.(t)}})}function x({serialize:e,...t}){const r=new _({...t,serialize:e,write:(e,t)=>{for(const n of r.serialize(e).toBytes())t.write8(n)}});return r}function M({toBytes:e,fromBytes:t,...r}){return new _({...r,read:e=>{const r=e.readULEB(),n=e.readBytes(r);return t(n)},write:(t,r)=>{const n=e(t);r.writeULEB(n.length);for(let e=0;e{const r=e(t),n=(0,A.ulebEncode)(r.length),o=new Uint8Array(n.length+r.length);return o.set(n,0),o.set(r,n.length),o},validate:e=>{if("string"!=typeof e)throw new TypeError(`Invalid ${r.name} value: ${e}. Expected string`);r.validate?.(e)}})}function C(e){let t=null;function r(){return t||(t=e()),t}return new _({name:"lazy",read:e=>r().read(e),serializedSize:e=>r().serializedSize(e),write:(e,t)=>r().write(e,t),serialize:(e,t)=>r().serialize(e,t).toBytes()})}y=new WeakMap,b=new WeakMap},9570:(e,t,r)=>{"use strict";var n,o=Object.defineProperty,i=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,c={};((e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})})(c,{bcs:()=>l}),e.exports=(n=c,((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of s(t))a.call(e,r)||undefined===r||o(e,r,{get:()=>t[r],enumerable:!(n=i(t,r))||n.enumerable});return e})(o({},"__esModule",{value:!0}),n));var u=r(5600),d=r(7539);const l={u8:e=>(0,u.uIntBcsType)({name:"u8",readMethod:"read8",writeMethod:"write8",size:1,maxValue:255,...e}),u16:e=>(0,u.uIntBcsType)({name:"u16",readMethod:"read16",writeMethod:"write16",size:2,maxValue:65535,...e}),u32:e=>(0,u.uIntBcsType)({name:"u32",readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...e}),u64:e=>(0,u.bigUIntBcsType)({name:"u64",readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...e}),u128:e=>(0,u.bigUIntBcsType)({name:"u128",readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...e}),u256:e=>(0,u.bigUIntBcsType)({name:"u256",readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...e}),bool:e=>(0,u.fixedSizeBcsType)({name:"bool",size:1,read:e=>1===e.read8(),write:(e,t)=>t.write8(e?1:0),...e,validate:t=>{if(e?.validate?.(t),"boolean"!=typeof t)throw new TypeError("Expected boolean, found "+typeof t)}}),uleb128:e=>(0,u.dynamicSizeBcsType)({name:"uleb128",read:e=>e.readULEB(),serialize:e=>Uint8Array.from((0,d.ulebEncode)(e)),...e}),bytes:(e,t)=>(0,u.fixedSizeBcsType)({name:`bytes[${e}]`,size:e,read:t=>t.readBytes(e),write:(t,r)=>{for(let n=0;n{if(t?.validate?.(r),!r||"object"!=typeof r||!("length"in r))throw new TypeError("Expected array, found "+typeof r);if(r.length!==e)throw new TypeError(`Expected array of length ${e}, found ${r.length}`)}}),string:e=>(0,u.stringLikeBcsType)({name:"string",toBytes:e=>(new TextEncoder).encode(e),fromBytes:e=>(new TextDecoder).decode(e),...e}),fixedArray:(e,t,r)=>new u.BcsType({name:`${t.name}[${e}]`,read:r=>{const n=new Array(e);for(let o=0;o{for(const n of e)t.write(n,r)},...r,validate:t=>{if(r?.validate?.(t),!t||"object"!=typeof t||!("length"in t))throw new TypeError("Expected array, found "+typeof t);if(t.length!==e)throw new TypeError(`Expected array of length ${e}, found ${t.length}`)}}),option:e=>l.enum(`Option<${e.name}>`,{None:null,Some:e}).transform({input:e=>null==e?{None:!0}:{Some:e},output:e=>"Some"===e.$kind?e.Some:null}),vector:(e,t)=>new u.BcsType({name:`vector<${e.name}>`,read:t=>{const r=t.readULEB(),n=new Array(r);for(let o=0;o{r.writeULEB(t.length);for(const n of t)e.write(n,r)},...t,validate:e=>{if(t?.validate?.(e),!e||"object"!=typeof e||!("length"in e))throw new TypeError("Expected array, found "+typeof e)}}),tuple:(e,t)=>new u.BcsType({name:`(${e.map((e=>e.name)).join(", ")})`,serializedSize:t=>{let r=0;for(let n=0;n{const r=[];for(const n of e)r.push(n.read(t));return r},write:(t,r)=>{for(let n=0;n{if(t?.validate?.(r),!Array.isArray(r))throw new TypeError("Expected array, found "+typeof r);if(r.length!==e.length)throw new TypeError(`Expected array of length ${e.length}, found ${r.length}`)}}),struct(e,t,r){const n=Object.entries(t);return new u.BcsType({name:e,serializedSize:e=>{let t=0;for(const[r,o]of n){const n=o.serializedSize(e[r]);if(null==n)return null;t+=n}return t},read:e=>{const t={};for(const[r,o]of n)t[r]=o.read(e);return t},write:(e,t)=>{for(const[r,o]of n)o.write(e[r],t)},...r,validate:e=>{if(r?.validate?.(e),"object"!=typeof e||null==e)throw new TypeError("Expected object, found "+typeof e)}})},enum(e,t,r){const n=Object.entries(t);return new u.BcsType({name:e,read:t=>{const r=t.readULEB(),o=n[r];if(!o)throw new TypeError(`Unknown value ${r} for enum ${e}`);const[i,s]=o;return{[i]:s?.read(t)??!0,$kind:i}},write:(e,r)=>{const[o,i]=Object.entries(e).filter((([e])=>Object.hasOwn(t,e)))[0];for(let e=0;e{if(r?.validate?.(n),"object"!=typeof n||null==n)throw new TypeError("Expected object, found "+typeof n);const o=Object.keys(n).filter((e=>void 0!==n[e]&&Object.hasOwn(t,e)));if(1!==o.length)throw new TypeError(`Expected object with one key, but found ${o.length} for type ${e}}`);const[i]=o;if(!Object.hasOwn(t,i))throw new TypeError(`Invalid enum variant ${i}`)}})},map:(e,t)=>l.vector(l.tuple([e,t])).transform({name:`Map<${e.name}, ${t.name}>`,input:e=>[...e.entries()],output:e=>{const t=new Map;for(const[r,n]of e)t.set(r,n);return t}}),lazy:e=>(0,u.lazyBcsType)(e)}},5383:e=>{"use strict";var t,r=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,s={};function a(e){const t=e.startsWith("0x")?e.slice(2):e,r=t.length%2==0?t:`0${t}}`,n=r.match(/.{2}/g)?.map((e=>parseInt(e,16)))??[];return Uint8Array.from(n)}function c(e){return e.reduce(((e,t)=>e+t.toString(16).padStart(2,"0")),"")}((e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})})(s,{fromHEX:()=>a,toHEX:()=>c}),e.exports=(t=s,((e,t,s,a)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of o(t))i.call(e,s)||undefined===s||r(e,s,{get:()=>t[s],enumerable:!(a=n(t,s))||a.enumerable});return e})(r({},"__esModule",{value:!0}),t))},4648:(e,t,r)=>{"use strict";var n,o=Object.defineProperty,i=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,c={};((e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})})(c,{BcsReader:()=>p.BcsReader,BcsType:()=>l.BcsType,BcsWriter:()=>y.BcsWriter,SerializedBcs:()=>l.SerializedBcs,bcs:()=>f.bcs,decodeStr:()=>g.decodeStr,encodeStr:()=>g.encodeStr,fromB58:()=>u.fromB58,fromB64:()=>d.fromB64,fromHEX:()=>h.fromHEX,isSerializedBcs:()=>l.isSerializedBcs,splitGenericParameters:()=>g.splitGenericParameters,toB58:()=>u.toB58,toB64:()=>d.toB64,toHEX:()=>h.toHEX}),e.exports=(n=c,((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of s(t))a.call(e,r)||undefined===r||o(e,r,{get:()=>t[r],enumerable:!(n=i(t,r))||n.enumerable});return e})(o({},"__esModule",{value:!0}),n));var u=r(9002),d=r(2849),l=r(5600),f=r(9570),h=r(5383),p=r(4994),g=r(543),y=r(6236)},4994:(e,t,r)=>{"use strict";var n,o=Object.defineProperty,i=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,c={};((e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})})(c,{BcsReader:()=>d}),e.exports=(n=c,((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of s(t))a.call(e,r)||undefined===r||o(e,r,{get:()=>t[r],enumerable:!(n=i(t,r))||n.enumerable});return e})(o({},"__esModule",{value:!0}),n));var u=r(7539);class d{constructor(e){this.bytePosition=0,this.dataView=new DataView(e.buffer)}shift(e){return this.bytePosition+=e,this}read8(){let e=this.dataView.getUint8(this.bytePosition);return this.shift(1),e}read16(){let e=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),e}read32(){let e=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),e}read64(){let e=this.read32(),t=this.read32().toString(16)+e.toString(16).padStart(8,"0");return BigInt("0x"+t).toString(10)}read128(){let e=BigInt(this.read64()),t=BigInt(this.read64()).toString(16)+e.toString(16).padStart(16,"0");return BigInt("0x"+t).toString(10)}read256(){let e=BigInt(this.read128()),t=BigInt(this.read128()).toString(16)+e.toString(16).padStart(32,"0");return BigInt("0x"+t).toString(10)}readBytes(e){let t=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,t,e);return this.shift(e),r}readULEB(){let e=this.bytePosition+this.dataView.byteOffset,t=new Uint8Array(this.dataView.buffer,e),{value:r,length:n}=(0,u.ulebDecode)(t);return this.shift(n),r}readVec(e){let t=this.readULEB(),r=[];for(let n=0;n{"use strict";var t,r=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,s={};function a(e){let t=[],r=0;if(0===e)return[0];for(;e>0;)t[r]=127&e,(e>>=7)&&(t[r]|=128),r+=1;return t}function c(e){let t=0,r=0,n=0;for(;;){let o=e[n];if(n+=1,t|=(127&o)<{for(var n in t)r(e,n,{get:t[n],enumerable:!0})})(s,{ulebDecode:()=>c,ulebEncode:()=>a}),e.exports=(t=s,((e,t,s,a)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let s of o(t))i.call(e,s)||undefined===s||r(e,s,{get:()=>t[s],enumerable:!(a=n(t,s))||a.enumerable});return e})(r({},"__esModule",{value:!0}),t))},543:(e,t,r)=>{"use strict";var n,o=Object.defineProperty,i=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,c={};((e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})})(c,{decodeStr:()=>h,encodeStr:()=>f,splitGenericParameters:()=>p}),e.exports=(n=c,((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of s(t))a.call(e,r)||undefined===r||o(e,r,{get:()=>t[r],enumerable:!(n=i(t,r))||n.enumerable});return e})(o({},"__esModule",{value:!0}),n));var u=r(9002),d=r(2849),l=r(5383);function f(e,t){switch(t){case"base58":return(0,u.toB58)(e);case"base64":return(0,d.toB64)(e);case"hex":return(0,l.toHEX)(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function h(e,t){switch(t){case"base58":return(0,u.fromB58)(e);case"base64":return(0,d.fromB64)(e);case"hex":return(0,l.fromHEX)(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function p(e,t=["<",">"]){const[r,n]=t,o=[];let i="",s=0;for(let t=0;t{"use strict";var n,o=Object.defineProperty,i=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,c={};((e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})})(c,{BcsWriter:()=>l}),e.exports=(n=c,((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of s(t))a.call(e,r)||undefined===r||o(e,r,{get:()=>t[r],enumerable:!(n=i(t,r))||n.enumerable});return e})(o({},"__esModule",{value:!0}),n));var u=r(7539),d=r(543);class l{constructor({initialSize:e=1024,maxSize:t=1/0,allocateSize:r=1024}={}){this.bytePosition=0,this.size=e,this.maxSize=t,this.allocateSize=r,this.dataView=new DataView(new ArrayBuffer(e))}ensureSizeOrGrow(e){const t=this.bytePosition+e;if(t>this.size){const e=Math.min(this.maxSize,this.size+this.allocateSize);if(t>e)throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${t}`);this.size=e;const r=new ArrayBuffer(this.size);new Uint8Array(r).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(r)}}shift(e){return this.bytePosition+=e,this}write8(e){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(e)),this.shift(1)}write16(e){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(e),!0),this.shift(2)}write32(e){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(e),!0),this.shift(4)}write64(e){return f(BigInt(e),8).forEach((e=>this.write8(e))),this}write128(e){return f(BigInt(e),16).forEach((e=>this.write8(e))),this}write256(e){return f(BigInt(e),32).forEach((e=>this.write8(e))),this}writeULEB(e){return(0,u.ulebEncode)(e).forEach((e=>this.write8(e))),this}writeVec(e,t){return this.writeULEB(e.length),Array.from(e).forEach(((r,n)=>t(this,r,n,e.length))),this}*[Symbol.iterator](){for(let e=0;e0;)r[n]=Number(e%BigInt(256)),e/=BigInt(256),n+=1;return r}},9296:(e,t,r)=>{"use strict";var n,o=Object.defineProperty,i=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,c={};((e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})})(c,{Address:()=>f,AppId:()=>C,Argument:()=>w,CallArg:()=>b,Command:()=>A,CompressedSignature:()=>D,GasData:()=>B,Intent:()=>R,IntentMessage:()=>U,IntentScope:()=>x,IntentVersion:()=>M,MultiSig:()=>z,MultiSigPkMap:()=>k,MultiSigPublicKey:()=>L,ObjectArg:()=>y,ObjectDigest:()=>h,ProgrammableMoveCall:()=>O,ProgrammableTransaction:()=>_,PublicKey:()=>N,SenderSignedData:()=>W,SenderSignedTransaction:()=>q,SharedObjectRef:()=>g,StructTag:()=>T,SuiObjectRef:()=>p,TransactionData:()=>j,TransactionDataV1:()=>I,TransactionExpiration:()=>P,TransactionKind:()=>S,TypeTag:()=>v,base64String:()=>V}),e.exports=(n=c,((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of s(t))a.call(e,r)||undefined===r||o(e,r,{get:()=>t[r],enumerable:!(n=i(t,r))||n.enumerable});return e})(o({},"__esModule",{value:!0}),n));var u=r(4648),d=r(2501),l=r(8548);const f=u.bcs.bytes(d.SUI_ADDRESS_LENGTH).transform({validate:e=>{const t="string"==typeof e?e:(0,u.toHEX)(e);if(!t||!(0,d.isValidSuiAddress)((0,d.normalizeSuiAddress)(t)))throw new Error(`Invalid Sui address ${t}`)},input:e=>"string"==typeof e?(0,u.fromHEX)((0,d.normalizeSuiAddress)(e)):e,output:e=>(0,d.normalizeSuiAddress)((0,u.toHEX)(e))}),h=u.bcs.vector(u.bcs.u8()).transform({name:"ObjectDigest",input:e=>(0,u.fromB58)(e),output:e=>(0,u.toB58)(new Uint8Array(e)),validate:e=>{if(32!==(0,u.fromB58)(e).length)throw new Error("ObjectDigest must be 32 bytes")}}),p=u.bcs.struct("SuiObjectRef",{objectId:f,version:u.bcs.u64(),digest:h}),g=u.bcs.struct("SharedObjectRef",{objectId:f,initialSharedVersion:u.bcs.u64(),mutable:u.bcs.bool()}),y=u.bcs.enum("ObjectArg",{ImmOrOwnedObject:p,SharedObject:g,Receiving:p}),b=u.bcs.enum("CallArg",{Pure:u.bcs.struct("Pure",{bytes:u.bcs.vector(u.bcs.u8()).transform({input:e=>"string"==typeof e?(0,u.fromB64)(e):e,output:e=>(0,u.toB64)(new Uint8Array(e))})}),Object:y}),m=u.bcs.enum("TypeTag",{bool:null,u8:null,u64:null,u128:null,address:null,signer:null,vector:u.bcs.lazy((()=>m)),struct:u.bcs.lazy((()=>T)),u16:null,u32:null,u256:null}),v=m.transform({input:e=>"string"==typeof e?l.TypeTagSerializer.parseFromStr(e,!0):e,output:e=>l.TypeTagSerializer.tagToString(e)}),w=u.bcs.enum("Argument",{GasCoin:null,Input:u.bcs.u16(),Result:u.bcs.u16(),NestedResult:u.bcs.tuple([u.bcs.u16(),u.bcs.u16()])}),O=u.bcs.struct("ProgrammableMoveCall",{package:f,module:u.bcs.string(),function:u.bcs.string(),typeArguments:u.bcs.vector(v),arguments:u.bcs.vector(w)}),A=u.bcs.enum("Command",{MoveCall:O,TransferObjects:u.bcs.struct("TransferObjects",{objects:u.bcs.vector(w),address:w}),SplitCoins:u.bcs.struct("SplitCoins",{coin:w,amounts:u.bcs.vector(w)}),MergeCoins:u.bcs.struct("MergeCoins",{destination:w,sources:u.bcs.vector(w)}),Publish:u.bcs.struct("Publish",{modules:u.bcs.vector(u.bcs.vector(u.bcs.u8()).transform({input:e=>"string"==typeof e?(0,u.fromB64)(e):e,output:e=>(0,u.toB64)(new Uint8Array(e))})),dependencies:u.bcs.vector(f)}),MakeMoveVec:u.bcs.struct("MakeMoveVec",{type:(E=v,u.bcs.enum("Option",{None:null,Some:E})).transform({input:e=>null===e?{None:!0}:{Some:e},output:e=>e.Some??null}),elements:u.bcs.vector(w)}),Upgrade:u.bcs.struct("Upgrade",{modules:u.bcs.vector(u.bcs.vector(u.bcs.u8()).transform({input:e=>"string"==typeof e?(0,u.fromB64)(e):e,output:e=>(0,u.toB64)(new Uint8Array(e))})),dependencies:u.bcs.vector(f),package:f,ticket:w})});var E;const _=u.bcs.struct("ProgrammableTransaction",{inputs:u.bcs.vector(b),commands:u.bcs.vector(A)}),S=u.bcs.enum("TransactionKind",{ProgrammableTransaction:_,ChangeEpoch:null,Genesis:null,ConsensusCommitPrologue:null}),P=u.bcs.enum("TransactionExpiration",{None:null,Epoch:u.bcs.u64({name:"unsafe_u64"}).transform({input:e=>e,output:e=>Number(e)})});const T=u.bcs.struct("StructTag",{address:f,module:u.bcs.string(),name:u.bcs.string(),typeParams:u.bcs.vector(m)}),B=u.bcs.struct("GasData",{payment:u.bcs.vector(p),owner:f,price:u.bcs.u64(),budget:u.bcs.u64()}),I=u.bcs.struct("TransactionDataV1",{kind:S,sender:f,gasData:B,expiration:P}),j=u.bcs.enum("TransactionData",{V1:I}),x=u.bcs.enum("IntentScope",{TransactionData:null,TransactionEffects:null,CheckpointSummary:null,PersonalMessage:null}),M=u.bcs.enum("IntentVersion",{V0:null}),C=u.bcs.enum("AppId",{Sui:null}),R=u.bcs.struct("Intent",{scope:x,version:M,appId:C});function U(e){return u.bcs.struct(`IntentMessage<${e.name}>`,{intent:R,value:e})}const D=u.bcs.enum("CompressedSignature",{ED25519:u.bcs.fixedArray(64,u.bcs.u8()),Secp256k1:u.bcs.fixedArray(64,u.bcs.u8()),Secp256r1:u.bcs.fixedArray(64,u.bcs.u8()),ZkLogin:u.bcs.vector(u.bcs.u8())}),N=u.bcs.enum("PublicKey",{ED25519:u.bcs.fixedArray(32,u.bcs.u8()),Secp256k1:u.bcs.fixedArray(33,u.bcs.u8()),Secp256r1:u.bcs.fixedArray(33,u.bcs.u8()),ZkLogin:u.bcs.vector(u.bcs.u8())}),k=u.bcs.struct("MultiSigPkMap",{pubKey:N,weight:u.bcs.u8()}),L=u.bcs.struct("MultiSigPublicKey",{pk_map:u.bcs.vector(k),threshold:u.bcs.u16()}),z=u.bcs.struct("MultiSig",{sigs:u.bcs.vector(D),bitmap:u.bcs.u16(),multisig_pk:L}),V=u.bcs.vector(u.bcs.u8()).transform({input:e=>"string"==typeof e?(0,u.fromB64)(e):e,output:e=>(0,u.toB64)(new Uint8Array(e))}),q=u.bcs.struct("SenderSignedTransaction",{intentMessage:U(j),txSignatures:u.bcs.vector(V)}),W=u.bcs.vector(q,{name:"SenderSignedData"})},4320:(e,t,r)=>{"use strict";var n,o=Object.defineProperty,i=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,c={};((e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})})(c,{TransactionEffects:()=>B}),e.exports=(n=c,((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of s(t))a.call(e,r)||undefined===r||o(e,r,{get:()=>t[r],enumerable:!(n=i(t,r))||n.enumerable});return e})(o({},"__esModule",{value:!0}),n));var u=r(4648),d=r(9296);const l=u.bcs.enum("PackageUpgradeError",{UnableToFetchPackage:u.bcs.struct("UnableToFetchPackage",{packageId:d.Address}),NotAPackage:u.bcs.struct("NotAPackage",{objectId:d.Address}),IncompatibleUpgrade:null,DigestDoesNotMatch:u.bcs.struct("DigestDoesNotMatch",{digest:u.bcs.vector(u.bcs.u8())}),UnknownUpgradePolicy:u.bcs.struct("UnknownUpgradePolicy",{policy:u.bcs.u8()}),PackageIDDoesNotMatch:u.bcs.struct("PackageIDDoesNotMatch",{packageId:d.Address,ticketId:d.Address})}),f=u.bcs.struct("ModuleId",{address:d.Address,name:u.bcs.string()}),h=u.bcs.struct("MoveLocation",{module:f,function:u.bcs.u16(),instruction:u.bcs.u16(),functionName:u.bcs.option(u.bcs.string())}),p=u.bcs.enum("CommandArgumentError",{TypeMismatch:null,InvalidBCSBytes:null,InvalidUsageOfPureArg:null,InvalidArgumentToPrivateEntryFunction:null,IndexOutOfBounds:u.bcs.struct("IndexOutOfBounds",{idx:u.bcs.u16()}),SecondaryIndexOutOfBounds:u.bcs.struct("SecondaryIndexOutOfBounds",{resultIdx:u.bcs.u16(),secondaryIdx:u.bcs.u16()}),InvalidResultArity:u.bcs.struct("InvalidResultArity",{resultIdx:u.bcs.u16()}),InvalidGasCoinUsage:null,InvalidValueUsage:null,InvalidObjectByValue:null,InvalidObjectByMutRef:null,SharedObjectOperationNotAllowed:null}),g=u.bcs.enum("TypeArgumentError",{TypeNotFound:null,ConstraintNotSatisfied:null}),y=u.bcs.enum("ExecutionFailureStatus",{InsufficientGas:null,InvalidGasObject:null,InvariantViolation:null,FeatureNotYetSupported:null,MoveObjectTooBig:u.bcs.struct("MoveObjectTooBig",{objectSize:u.bcs.u64(),maxObjectSize:u.bcs.u64()}),MovePackageTooBig:u.bcs.struct("MovePackageTooBig",{objectSize:u.bcs.u64(),maxObjectSize:u.bcs.u64()}),CircularObjectOwnership:u.bcs.struct("CircularObjectOwnership",{object:d.Address}),InsufficientCoinBalance:null,CoinBalanceOverflow:null,PublishErrorNonZeroAddress:null,SuiMoveVerificationError:null,MovePrimitiveRuntimeError:u.bcs.option(h),MoveAbort:u.bcs.tuple([h,u.bcs.u64()]),VMVerificationOrDeserializationError:null,VMInvariantViolation:null,FunctionNotFound:null,ArityMismatch:null,TypeArityMismatch:null,NonEntryFunctionInvoked:null,CommandArgumentError:u.bcs.struct("CommandArgumentError",{argIdx:u.bcs.u16(),kind:p}),TypeArgumentError:u.bcs.struct("TypeArgumentError",{argumentIdx:u.bcs.u16(),kind:g}),UnusedValueWithoutDrop:u.bcs.struct("UnusedValueWithoutDrop",{resultIdx:u.bcs.u16(),secondaryIdx:u.bcs.u16()}),InvalidPublicFunctionReturnType:u.bcs.struct("InvalidPublicFunctionReturnType",{idx:u.bcs.u16()}),InvalidTransferObject:null,EffectsTooLarge:u.bcs.struct("EffectsTooLarge",{currentSize:u.bcs.u64(),maxSize:u.bcs.u64()}),PublishUpgradeMissingDependency:null,PublishUpgradeDependencyDowngrade:null,PackageUpgradeError:u.bcs.struct("PackageUpgradeError",{upgradeError:l}),WrittenObjectsTooLarge:u.bcs.struct("WrittenObjectsTooLarge",{currentSize:u.bcs.u64(),maxSize:u.bcs.u64()}),CertificateDenied:null,SuiMoveVerificationTimedout:null,SharedObjectOperationNotAllowed:null,InputObjectDeleted:null}),b=u.bcs.enum("ExecutionStatus",{Success:null,Failed:u.bcs.struct("ExecutionFailed",{error:y,command:u.bcs.option(u.bcs.u64())})}),m=u.bcs.struct("GasCostSummary",{computationCost:u.bcs.u64(),storageCost:u.bcs.u64(),storageRebate:u.bcs.u64(),nonRefundableStorageFee:u.bcs.u64()}),v=u.bcs.enum("Owner",{AddressOwner:d.Address,ObjectOwner:d.Address,Shared:u.bcs.struct("Shared",{initialSharedVersion:u.bcs.u64()}),Immutable:null}),w=u.bcs.struct("TransactionEffectsV1",{status:b,executedEpoch:u.bcs.u64(),gasUsed:m,modifiedAtVersions:u.bcs.vector(u.bcs.tuple([d.Address,u.bcs.u64()])),sharedObjects:u.bcs.vector(d.SuiObjectRef),transactionDigest:d.ObjectDigest,created:u.bcs.vector(u.bcs.tuple([d.SuiObjectRef,v])),mutated:u.bcs.vector(u.bcs.tuple([d.SuiObjectRef,v])),unwrapped:u.bcs.vector(u.bcs.tuple([d.SuiObjectRef,v])),deleted:u.bcs.vector(d.SuiObjectRef),unwrappedThenDeleted:u.bcs.vector(d.SuiObjectRef),wrapped:u.bcs.vector(d.SuiObjectRef),gasObject:u.bcs.tuple([d.SuiObjectRef,v]),eventsDigest:u.bcs.option(d.ObjectDigest),dependencies:u.bcs.vector(d.ObjectDigest)}),O=u.bcs.tuple([u.bcs.u64(),d.ObjectDigest]),A=u.bcs.enum("ObjectIn",{NotExist:null,Exist:u.bcs.tuple([O,v])}),E=u.bcs.enum("ObjectOut",{NotExist:null,ObjectWrite:u.bcs.tuple([d.ObjectDigest,v]),PackageWrite:O}),_=u.bcs.enum("IDOperation",{None:null,Created:null,Deleted:null}),S=u.bcs.struct("EffectsObjectChange",{inputState:A,outputState:E,idOperation:_}),P=u.bcs.enum("UnchangedSharedKind",{ReadOnlyRoot:O,MutateDeleted:u.bcs.u64(),ReadDeleted:u.bcs.u64(),Cancelled:u.bcs.u64(),PerEpochConfig:null}),T=u.bcs.struct("TransactionEffectsV2",{status:b,executedEpoch:u.bcs.u64(),gasUsed:m,transactionDigest:d.ObjectDigest,gasObjectIndex:u.bcs.option(u.bcs.u32()),eventsDigest:u.bcs.option(d.ObjectDigest),dependencies:u.bcs.vector(d.ObjectDigest),lamportVersion:u.bcs.u64(),changedObjects:u.bcs.vector(u.bcs.tuple([d.Address,S])),unchangedSharedObjects:u.bcs.vector(u.bcs.tuple([d.Address,P])),auxDataDigest:u.bcs.option(d.ObjectDigest)}),B=u.bcs.enum("TransactionEffects",{V1:w,V2:T})},9108:(e,t,r)=>{"use strict";var n,o=Object.defineProperty,i=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,c={};((e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})})(c,{BcsType:()=>h.BcsType,TypeTagSerializer:()=>f.TypeTagSerializer,bcs:()=>p}),e.exports=(n=c,((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of s(t))a.call(e,r)||undefined===r||o(e,r,{get:()=>t[r],enumerable:!(n=i(t,r))||n.enumerable});return e})(o({},"__esModule",{value:!0}),n));var u=r(4648),d=r(9296),l=r(4320),f=r(8548),h=r(4648);const p={...u.bcs,U8:u.bcs.u8(),U16:u.bcs.u16(),U32:u.bcs.u32(),U64:u.bcs.u64(),U128:u.bcs.u128(),U256:u.bcs.u256(),ULEB128:u.bcs.uleb128(),Bool:u.bcs.bool(),String:u.bcs.string(),Address:d.Address,AppId:d.AppId,Argument:d.Argument,CallArg:d.CallArg,CompressedSignature:d.CompressedSignature,GasData:d.GasData,Intent:d.Intent,IntentMessage:d.IntentMessage,IntentScope:d.IntentScope,IntentVersion:d.IntentVersion,MultiSig:d.MultiSig,MultiSigPkMap:d.MultiSigPkMap,MultiSigPublicKey:d.MultiSigPublicKey,ObjectArg:d.ObjectArg,ObjectDigest:d.ObjectDigest,ProgrammableMoveCall:d.ProgrammableMoveCall,ProgrammableTransaction:d.ProgrammableTransaction,PublicKey:d.PublicKey,SenderSignedData:d.SenderSignedData,SenderSignedTransaction:d.SenderSignedTransaction,SharedObjectRef:d.SharedObjectRef,StructTag:d.StructTag,SuiObjectRef:d.SuiObjectRef,Command:d.Command,TransactionData:d.TransactionData,TransactionDataV1:d.TransactionDataV1,TransactionExpiration:d.TransactionExpiration,TransactionKind:d.TransactionKind,TypeTag:d.TypeTag,TransactionEffects:l.TransactionEffects}},8548:(e,t,r)=>{"use strict";var n,o=Object.defineProperty,i=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,c={};((e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})})(c,{TypeTagSerializer:()=>h}),e.exports=(n=c,((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of s(t))a.call(e,r)||undefined===r||o(e,r,{get:()=>t[r],enumerable:!(n=i(t,r))||n.enumerable});return e})(o({},"__esModule",{value:!0}),n));var u=r(4648),d=r(2501);const l=/^vector<(.+)>$/,f=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;class h{static parseFromStr(e,t=!1){if("address"===e)return{address:null};if("bool"===e)return{bool:null};if("u8"===e)return{u8:null};if("u16"===e)return{u16:null};if("u32"===e)return{u32:null};if("u64"===e)return{u64:null};if("u128"===e)return{u128:null};if("u256"===e)return{u256:null};if("signer"===e)return{signer:null};const r=e.match(l);if(r)return{vector:h.parseFromStr(r[1],t)};const n=e.match(f);if(n)return{struct:{address:t?(0,d.normalizeSuiAddress)(n[1]):n[1],module:n[2],name:n[3],typeParams:void 0===n[5]?[]:h.parseStructTypeArgs(n[5],t)}};throw new Error(`Encountered unexpected token when parsing type args for ${e}`)}static parseStructTypeArgs(e,t=!1){return(0,u.splitGenericParameters)(e).map((e=>h.parseFromStr(e,t)))}static tagToString(e){if("bool"in e)return"bool";if("u8"in e)return"u8";if("u16"in e)return"u16";if("u32"in e)return"u32";if("u64"in e)return"u64";if("u128"in e)return"u128";if("u256"in e)return"u256";if("address"in e)return"address";if("signer"in e)return"signer";if("vector"in e)return`vector<${h.tagToString(e.vector)}>`;if("struct"in e){const t=e.struct,r=t.typeParams.map(h.tagToString).join(", ");return`${t.address}::${t.module}::${t.name}${r?`<${r}>`:""}`}throw new Error("Invalid TypeTag")}}},2501:(e,t,r)=>{"use strict";var n,o=Object.defineProperty,i=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,c={};((e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})})(c,{SUI_ADDRESS_LENGTH:()=>f,isValidSuiAddress:()=>h,isValidSuiObjectId:()=>p,isValidTransactionDigest:()=>l,normalizeStructTag:()=>y,normalizeSuiAddress:()=>b,normalizeSuiObjectId:()=>m,parseStructTag:()=>g}),e.exports=(n=c,((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of s(t))a.call(e,r)||undefined===r||o(e,r,{get:()=>t[r],enumerable:!(n=i(t,r))||n.enumerable});return e})(o({},"__esModule",{value:!0}),n));var u=r(4648);const d=32;function l(e){try{return(0,u.fromB58)(e).length===d}catch(e){return!1}}const f=32;function h(e){return function(e){return/^(0x|0X)?[a-fA-F0-9]+$/.test(e)&&e.length%2==0}(e)&&function(e){return/^(0x|0X)/.test(e)?(e.length-2)/2:e.length/2}(e)===f}function p(e){return h(e)}function g(e){const[t,r]=e.split("::"),n=e.slice(t.length+r.length+4),o=n.includes("<")?n.slice(0,n.indexOf("<")):n,i=n.includes("<")?(0,u.splitGenericParameters)(n.slice(n.indexOf("<")+1,n.lastIndexOf(">"))).map((e=>function(e){return e.includes("::")?g(e):e}(e.trim()))):[];return{address:b(t),module:r,name:o,typeParams:i}}function y(e){const{address:t,module:r,name:n,typeParams:o}="string"==typeof e?g(e):e;return`${t}::${r}::${n}${o?.length>0?`<${o.map((e=>"string"==typeof e?e:y(e))).join(",")}>`:""}`}function b(e,t=!1){let r=e.toLowerCase();return!t&&r.startsWith("0x")&&(r=r.slice(2)),`0x${r.padStart(2*f,"0")}`}function m(e,t=!1){return b(e,t)}},3732:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(1345),t)},1345:function(e,t){"use strict";var r,n=this&&this.__classPrivateFieldSet||function(e,t,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,r):o?o.value=r:t.set(e,r),r},o=this&&this.__classPrivateFieldGet||function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)};let i;Object.defineProperty(t,"__esModule",{value:!0}),t.DEPRECATED_getWallets=t.getWallets=void 0;const s=new Set,a={};function c(){if(i)return i;if(i=Object.freeze({register:u,get:d,on:l}),"undefined"==typeof window)return i;const e=Object.freeze({register:u});try{window.addEventListener("wallet-standard:register-wallet",(({detail:t})=>t(e)))}catch(e){console.error("wallet-standard:register-wallet event listener could not be added\n",e)}try{window.dispatchEvent(new h(e))}catch(e){console.error("wallet-standard:app-ready event could not be dispatched\n",e)}return i}function u(...e){var t;return(e=e.filter((e=>!s.has(e)))).length?(e.forEach((e=>s.add(e))),null===(t=a.register)||void 0===t||t.forEach((t=>f((()=>t(...e))))),function(){var t;e.forEach((e=>s.delete(e))),null===(t=a.unregister)||void 0===t||t.forEach((t=>f((()=>t(...e)))))}):()=>{}}function d(){return[...s]}function l(e,t){var r;return(null===(r=a[e])||void 0===r?void 0:r.push(t))||(a[e]=[t]),function(){var r;a[e]=null===(r=a[e])||void 0===r?void 0:r.filter((e=>t!==e))}}function f(e){try{e()}catch(e){console.error(e)}}t.getWallets=c;class h extends Event{constructor(e){super("wallet-standard:app-ready",{bubbles:!1,cancelable:!1,composed:!1}),r.set(this,void 0),n(this,r,e,"f")}get detail(){return o(this,r,"f")}get type(){return"wallet-standard:app-ready"}preventDefault(){throw new Error("preventDefault cannot be called")}stopImmediatePropagation(){throw new Error("stopImmediatePropagation cannot be called")}stopPropagation(){throw new Error("stopPropagation cannot be called")}}r=new WeakMap,t.DEPRECATED_getWallets=function(){if(i)return i;if(i=c(),"undefined"==typeof window)return i;const e=window.navigator.wallets||[];if(!Array.isArray(e))return console.error("window.navigator.wallets is not an array"),i;const{register:t}=i,r=(...e)=>e.forEach((e=>f((()=>e({register:t})))));try{Object.defineProperty(window.navigator,"wallets",{value:Object.freeze({push:r})})}catch(e){return console.error("window.navigator.wallets could not be set"),i}return r(...e),i}},6401:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},2904:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(6401),t),o(r(1782),t),o(r(8225),t)},1782:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},8225:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},3902:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(3732),t),o(r(2904),t),o(r(988),t),o(r(1283),t)},3204:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Connect=t.StandardConnect=void 0,t.StandardConnect="standard:connect",t.Connect=t.StandardConnect},7381:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Disconnect=t.StandardDisconnect=void 0,t.StandardDisconnect="standard:disconnect",t.Disconnect=t.StandardDisconnect},5177:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Events=t.StandardEvents=void 0,t.StandardEvents="standard:events",t.Events=t.StandardEvents},988:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(3204),t),o(r(7381),t),o(r(5177),t)},1283:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(9510),t),o(r(331),t)},9510:function(e,t){"use strict";var r,n=this&&this.__classPrivateFieldSet||function(e,t,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,r):o?o.value=r:t.set(e,r),r},o=this&&this.__classPrivateFieldGet||function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)};function i(e){const t=({register:t})=>t(e);try{window.dispatchEvent(new s(t))}catch(e){console.error("wallet-standard:register-wallet event could not be dispatched\n",e)}try{window.addEventListener("wallet-standard:app-ready",(({detail:e})=>t(e)))}catch(e){console.error("wallet-standard:app-ready event listener could not be added\n",e)}}Object.defineProperty(t,"__esModule",{value:!0}),t.DEPRECATED_registerWallet=t.registerWallet=void 0,t.registerWallet=i;class s extends Event{constructor(e){super("wallet-standard:register-wallet",{bubbles:!1,cancelable:!1,composed:!1}),r.set(this,void 0),n(this,r,e,"f")}get detail(){return o(this,r,"f")}get type(){return"wallet-standard:register-wallet"}preventDefault(){throw new Error("preventDefault cannot be called")}stopImmediatePropagation(){throw new Error("stopImmediatePropagation cannot be called")}stopPropagation(){throw new Error("stopPropagation cannot be called")}}r=new WeakMap,t.DEPRECATED_registerWallet=function(e){var t;i(e);try{((t=window.navigator).wallets||(t.wallets=[])).push((({register:t})=>t(e)))}catch(e){console.error("window.navigator.wallets could not be pushed\n",e)}}},331:function(e,t){"use strict";var r,n,o,i,s,a,c=this&&this.__classPrivateFieldSet||function(e,t,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,r):o?o.value=r:t.set(e,r),r},u=this&&this.__classPrivateFieldGet||function(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)};Object.defineProperty(t,"__esModule",{value:!0}),t.guard=t.pick=t.concatBytes=t.bytesEqual=t.arraysEqual=t.ReadonlyWalletAccount=void 0;class d{constructor(e){r.set(this,void 0),n.set(this,void 0),o.set(this,void 0),i.set(this,void 0),s.set(this,void 0),a.set(this,void 0),new.target===d&&Object.freeze(this),c(this,r,e.address,"f"),c(this,n,e.publicKey.slice(),"f"),c(this,o,e.chains.slice(),"f"),c(this,i,e.features.slice(),"f"),c(this,s,e.label,"f"),c(this,a,e.icon,"f")}get address(){return u(this,r,"f")}get publicKey(){return u(this,n,"f").slice()}get chains(){return u(this,o,"f").slice()}get features(){return u(this,i,"f").slice()}get label(){return u(this,s,"f")}get icon(){return u(this,a,"f")}}function l(e,t){if(e===t)return!0;const r=e.length;if(r!==t.length)return!1;for(let n=0;ne+t.length),e.length),n=new Uint8Array(r);n.set(e,0);for(const e of t)n.set(e,n.length);return n},t.pick=function(e,...t){const r={};for(const n of t)r[n]=e[n];return r},t.guard=function(e){try{e()}catch(e){console.error(e)}}},9176:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");const t=new Uint8Array(256);for(let e=0;e>>0,u=new Uint8Array(c);for(;e[i];){let n=t[e.charCodeAt(i)];if(255===n)return;let o=0;for(let e=c-1;(0!==n||o>>0,u[e]=n%256>>>0,n=n/256>>>0;if(0!==n)throw new Error("Non-zero carry");a=o,i++}let d=c-a;for(;d!==c&&0===u[d];)d++;const l=new Uint8Array(s+(c-d));let f=s;for(;d!==c;)l[f++]=u[d++];return l}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";let o=0,s=0,a=0;const c=t.length;for(;a!==c&&0===t[a];)a++,o++;const u=(c-a)*i+1>>>0,d=new Uint8Array(u);for(;a!==c;){let e=t[a],n=0;for(let t=u-1;(0!==e||n>>0,d[t]=e%r>>>0,e=e/r>>>0;if(0!==e)throw new Error("Non-zero carry");s=n,a++}let l=u-s;for(;l!==u&&0===d[l];)l++;let f=n.repeat(o);for(;l{"use strict";const e=r(8253),t=r(9360),n=r(9392),o=r(1641),i=r(3902),s=r(9477),a=r(9582);(()=>{window.cosmostation={version:"0.4.11",handlerInfos:[],cosmos:n.cosmos,ethereum:t.ethereum,bitcoin:s.bitcoin,tendermint:n.tendermint,providers:{keplr:n.keplr,metamask:t.ethereum},mode:"mobile-web"},window.keplr=n.keplr,window.getOfflineSigner=window.keplr.getOfflineSigner,window.getOfflineSignerOnlyAmino=window.keplr.getOfflineSignerOnlyAmino,window.getOfflineSignerAuto=window.keplr.getOfflineSignerAuto,window.injectedTomo={info:{name:a.COSMOSTATION_WALLET_NAME,logo:a.COSMOSTATION_ENCODED_LOGO_IMAGE},bitcoin:s.bitcoin,cosmos:n.keplr},window.ethereum=window.cosmostation.providers.metamask;const r=new o.CosmostationWallet;(0,i.registerWallet)(r),(0,e.registerCosmosWallet)(n.cosmosWallet),(0,t.announceEthereumProvider)()})()})()})(); \ No newline at end of file diff --git a/app/src/main/java/wannabit/io/cosmostaion/chain/BaseChain.kt b/app/src/main/java/wannabit/io/cosmostaion/chain/BaseChain.kt index db67e514c..8a0b482d5 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/chain/BaseChain.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/chain/BaseChain.kt @@ -43,6 +43,7 @@ import wannabit.io.cosmostaion.chain.cosmosClass.ChainFetchAi60Old import wannabit.io.cosmostaion.chain.cosmosClass.ChainFetchAi60Secp import wannabit.io.cosmostaion.chain.cosmosClass.ChainFinschia import wannabit.io.cosmostaion.chain.cosmosClass.ChainFirma +import wannabit.io.cosmostaion.chain.testnetClass.ChainGnoTestnet import wannabit.io.cosmostaion.chain.cosmosClass.ChainGovgen import wannabit.io.cosmostaion.chain.cosmosClass.ChainGravityBridge import wannabit.io.cosmostaion.chain.cosmosClass.ChainInjective @@ -139,6 +140,7 @@ import wannabit.io.cosmostaion.chain.majorClass.ChainBitCoin44 import wannabit.io.cosmostaion.chain.majorClass.ChainBitCoin49 import wannabit.io.cosmostaion.chain.majorClass.ChainBitCoin84 import wannabit.io.cosmostaion.chain.majorClass.ChainSui +import wannabit.io.cosmostaion.chain.testnetClass.ChainBabylonTestnet import wannabit.io.cosmostaion.chain.testnetClass.ChainBitcoin44Testnet import wannabit.io.cosmostaion.chain.testnetClass.ChainBitcoin49Testnet import wannabit.io.cosmostaion.chain.testnetClass.ChainBitcoin84Testnet @@ -485,6 +487,18 @@ open class BaseChain : Parcelable { return getChainListParam()?.get("is_support_cw721")?.asBoolean ?: false } + fun isSupportGrc20(): Boolean { + return getChainListParam()?.get("is_support_grc20")?.asBoolean ?: false + } + + fun isSupportStaking(): Boolean { + return getChainListParam()?.getAsJsonObject("btc_staking")?.get("is_support_staking")?.asBoolean ?: false + } + + fun btcStakingDapp(): String { + return getChainListParam()?.getAsJsonObject("btc_staking")?.get("url")?.asString ?: "" + } + fun explorerAccount(address: String): Uri? { getChainListParam()?.getAsJsonObject("explorer") ?.get("account")?.asString?.let { urlString -> @@ -604,8 +618,8 @@ fun allChains(): MutableList { chains.add(ChainCoreum()) chains.add(ChainCronos()) chains.add(ChainCryptoorg()) - chains.add(ChainDHealth()) chains.add(ChainDesmos()) + chains.add(ChainDHealth()) chains.add(ChainDoravota()) chains.add(ChainDungeon()) chains.add(ChainDydx()) @@ -701,9 +715,11 @@ fun allChains(): MutableList { // chains.add(ChainCosmosTestnet()) // chains.add(ChainArtelaTestnet()) - chains.add(ChainBitcoin44Testnet()) - chains.add(ChainBitcoin49Testnet()) +// chains.add(ChainBitcoin44Testnet()) +// chains.add(ChainBitcoin49Testnet()) + chains.add(ChainBabylonTestnet()) chains.add(ChainBitcoin84Testnet()) + chains.add(ChainGnoTestnet()) chains.add(ChainInitiaTestnet()) chains.add(ChainMantraTestnet()) chains.add(ChainNeutronTestnet()) @@ -745,6 +761,6 @@ val EVM_BASE_FEE = BigDecimal("588000000000000") enum class PubKeyType { ETH_KECCAK256, COSMOS_SECP256K1, BERA_SECP256K1, SUI_ED25519, BTC_LEGACY, BTC_NESTED_SEGWIT, BTC_NATIVE_SEGWIT, NONE } -enum class CosmosEndPointType { UNKNOWN, USE_GRPC, USE_LCD } +enum class CosmosEndPointType { UNKNOWN, USE_GRPC, USE_LCD, USE_RPC } enum class FetchState { IDLE, BUSY, SUCCESS, FAIL } \ No newline at end of file diff --git a/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainBitcanna.kt b/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainBitcanna.kt index c5d172b1c..1c0673a0c 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainBitcanna.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainBitcanna.kt @@ -27,6 +27,6 @@ class ChainBitcanna : BaseChain(), Parcelable { override var cosmosEndPointType: CosmosEndPointType? = CosmosEndPointType.USE_GRPC override var stakeDenom: String = "ubcna" override var accountPrefix: String = "bcna" - override var grpcHost: String = "grpc-bitcanna.cosmostation.io" - override var lcdUrl: String = "https://lcd-bitcanna.cosmostation.io/" + override var grpcHost: String = "grpc-bitcanna.io" + override var lcdUrl: String = "https://lcd-bitcanna.io/" } \ No newline at end of file diff --git a/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainCosmos.kt b/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainCosmos.kt index 194e8b865..dc9a67d7a 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainCosmos.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/chain/cosmosClass/ChainCosmos.kt @@ -13,7 +13,7 @@ import wannabit.io.cosmostaion.chain.PubKeyType @Parcelize class ChainCosmos : BaseChain(), Parcelable { - override var name: String = "Cosmos" + override var name: String = "Cosmos Hub" override var tag: String = "cosmos118" override var logo: Int = R.drawable.chain_cosmos override var swipeLogo: Int = R.drawable.chain_swipe_cosmos diff --git a/app/src/main/java/wannabit/io/cosmostaion/chain/evmClass/ChainRouterchainEvm.kt b/app/src/main/java/wannabit/io/cosmostaion/chain/evmClass/ChainRouterchainEvm.kt index aec5131c8..79c84d8b0 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/chain/evmClass/ChainRouterchainEvm.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/chain/evmClass/ChainRouterchainEvm.kt @@ -13,7 +13,7 @@ import wannabit.io.cosmostaion.chain.PubKeyType @Parcelize class ChainRouterchainEvm : BaseChain(), Parcelable { - override var name: String = "Routerchain" + override var name: String = "RouterChain" override var tag: String = "routerchain60" override var logo: Int = R.drawable.chain_routerchain override var apiName: String = "routerchain" diff --git a/app/src/main/java/wannabit/io/cosmostaion/chain/fetcher/BtcFetcher.kt b/app/src/main/java/wannabit/io/cosmostaion/chain/fetcher/BtcFetcher.kt index 5e17c21af..c773553eb 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/chain/fetcher/BtcFetcher.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/chain/fetcher/BtcFetcher.kt @@ -28,7 +28,7 @@ class BtcFetcher(private val chain: BaseChain) : CosmosFetcher(chain) { fun mempoolUrl(): String { if (chain.isTestnet) { - return "https://mempool.space/testnet4/" + return "https://mempool.space/signet/" } return "https://mempool.space/" } diff --git a/app/src/main/java/wannabit/io/cosmostaion/chain/fetcher/CosmosFetcher.kt b/app/src/main/java/wannabit/io/cosmostaion/chain/fetcher/CosmosFetcher.kt index ab2c1c1bb..5b512d790 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/chain/fetcher/CosmosFetcher.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/chain/fetcher/CosmosFetcher.kt @@ -50,6 +50,7 @@ open class CosmosFetcher(private val chain: BaseChain) { var cosmosBaseFees = mutableListOf() var tokens = mutableListOf() + var grc20Tokens = mutableListOf() var cw721s = mutableListOf() var cw721Fetched = false var cw721Models = mutableListOf() @@ -76,13 +77,34 @@ open class CosmosFetcher(private val chain: BaseChain) { } } + fun grc20TokenValue(address: String, isUsd: Boolean? = false): BigDecimal { + grc20Tokens.firstOrNull { it.contract == address }?.let { tokenInfo -> + val price = BaseData.getPrice(tokenInfo.coinGeckoId, isUsd) + return price.multiply(tokenInfo.amount?.toBigDecimal()) + .movePointLeft(tokenInfo.decimals).setScale(6, RoundingMode.DOWN) + } ?: run { + return BigDecimal.ZERO + } + } + fun allTokenValue(isUsd: Boolean? = false): BigDecimal { var result = BigDecimal.ZERO - tokens.forEach { token -> - val price = BaseData.getPrice(token.coinGeckoId, isUsd) - val value = price.multiply(token.amount?.toBigDecimal()).movePointLeft(token.decimals) - .setScale(6, RoundingMode.DOWN) - result = result.add(value) + if (tokens.isNotEmpty()) { + tokens.forEach { token -> + val price = BaseData.getPrice(token.coinGeckoId, isUsd) + val value = price.multiply(token.amount?.toBigDecimal()).movePointLeft(token.decimals) + .setScale(6, RoundingMode.DOWN) + result = result.add(value) + } + } + + if (grc20Tokens.isNotEmpty()) { + grc20Tokens.forEach { token -> + val price = BaseData.getPrice(token.coinGeckoId, isUsd) + val value = price.multiply(token.amount?.toBigDecimal()).movePointLeft(token.decimals) + .setScale(6, RoundingMode.DOWN) + result = result.add(value) + } } return result } @@ -100,6 +122,10 @@ open class CosmosFetcher(private val chain: BaseChain) { return tokens.count { BigDecimal.ZERO < it.amount?.toBigDecimal() } } + fun valueGrc20TokenCnt(): Int { + return grc20Tokens.count { BigDecimal.ZERO < it.amount?.toBigDecimal() } + } + fun balanceAmount(denom: String): BigDecimal { if (cosmosBalances?.isNotEmpty() == true) { return cosmosBalances?.firstOrNull { it.denom == denom }?.amount?.toBigDecimal() diff --git a/app/src/main/java/wannabit/io/cosmostaion/chain/majorClass/ChainBitCoin44.kt b/app/src/main/java/wannabit/io/cosmostaion/chain/majorClass/ChainBitCoin44.kt index 38ca762fb..c616edee0 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/chain/majorClass/ChainBitCoin44.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/chain/majorClass/ChainBitCoin44.kt @@ -6,14 +6,13 @@ import kotlinx.parcelize.Parcelize import org.bitcoinj.crypto.ChildNumber import wannabit.io.cosmostaion.R import wannabit.io.cosmostaion.chain.AccountKeyType -import wannabit.io.cosmostaion.chain.BaseChain import wannabit.io.cosmostaion.chain.PubKeyType import wannabit.io.cosmostaion.common.BaseKey @Parcelize class ChainBitCoin44 : ChainBitCoin84(), Parcelable { - override var name: String = "BitCoin" + override var name: String = "Bitcoin" override var tag: String = "bitcoin44" override var logo: Int = R.drawable.chain_bitcoin override var isDefault: Boolean = false diff --git a/app/src/main/java/wannabit/io/cosmostaion/chain/majorClass/ChainBitCoin49.kt b/app/src/main/java/wannabit/io/cosmostaion/chain/majorClass/ChainBitCoin49.kt index 1c08fece2..2cbdade38 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/chain/majorClass/ChainBitCoin49.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/chain/majorClass/ChainBitCoin49.kt @@ -6,14 +6,13 @@ import kotlinx.parcelize.Parcelize import org.bitcoinj.crypto.ChildNumber import wannabit.io.cosmostaion.R import wannabit.io.cosmostaion.chain.AccountKeyType -import wannabit.io.cosmostaion.chain.BaseChain import wannabit.io.cosmostaion.chain.PubKeyType import wannabit.io.cosmostaion.common.BaseKey @Parcelize class ChainBitCoin49 : ChainBitCoin84(), Parcelable { - override var name: String = "BitCoin" + override var name: String = "Bitcoin" override var tag: String = "bitcoin49" override var logo: Int = R.drawable.chain_bitcoin override var isDefault: Boolean = false diff --git a/app/src/main/java/wannabit/io/cosmostaion/chain/majorClass/ChainBitCoin84.kt b/app/src/main/java/wannabit/io/cosmostaion/chain/majorClass/ChainBitCoin84.kt index 1bf8d39e8..2b90bcb23 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/chain/majorClass/ChainBitCoin84.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/chain/majorClass/ChainBitCoin84.kt @@ -22,7 +22,7 @@ open class ChainBitCoin84 : BaseChain(), Parcelable { open var scriptHash: Byte = 0x05 open var bech32PrefixPattern: String = "bc" - override var name: String = "BitCoin" + override var name: String = "Bitcoin" override var tag: String = "bitcoin84" override var logo: Int = R.drawable.chain_bitcoin override var apiName: String = "bitcoin" diff --git a/app/src/main/java/wannabit/io/cosmostaion/chain/testnetClass/ChainBabylonTestnet.kt b/app/src/main/java/wannabit/io/cosmostaion/chain/testnetClass/ChainBabylonTestnet.kt new file mode 100644 index 000000000..1bdf7482b --- /dev/null +++ b/app/src/main/java/wannabit/io/cosmostaion/chain/testnetClass/ChainBabylonTestnet.kt @@ -0,0 +1,32 @@ +package wannabit.io.cosmostaion.chain.testnetClass + +import android.os.Parcelable +import com.google.common.collect.ImmutableList +import kotlinx.parcelize.Parcelize +import org.bitcoinj.crypto.ChildNumber +import wannabit.io.cosmostaion.R +import wannabit.io.cosmostaion.chain.AccountKeyType +import wannabit.io.cosmostaion.chain.BaseChain +import wannabit.io.cosmostaion.chain.CosmosEndPointType +import wannabit.io.cosmostaion.chain.PubKeyType + +@Parcelize +class ChainBabylonTestnet : BaseChain(), Parcelable { + + override var name: String = "Babylon Testnet" + override var tag: String = "babylon118_T" + override var logo: Int = R.drawable.chain_babylon_testnet + override var isTestnet: Boolean = true + override var apiName: String = "babylon-testnet" + + override var accountKeyType = AccountKeyType(PubKeyType.COSMOS_SECP256K1, "m/44'/118'/0'/0/X") + override var setParentPath: List = ImmutableList.of( + ChildNumber(44, true), ChildNumber(118, true), ChildNumber.ZERO_HARDENED, ChildNumber.ZERO + ) + + override var cosmosEndPointType: CosmosEndPointType? = CosmosEndPointType.USE_GRPC + override var stakeDenom: String = "ubbn" + override var accountPrefix: String = "bbn" + override var grpcHost: String = "grpc-office-babylon.cosmostation.io" + override var lcdUrl: String = "https://lcd-office.cosmostation.io/babylon-testnet/" +} \ No newline at end of file diff --git a/app/src/main/java/wannabit/io/cosmostaion/chain/testnetClass/ChainBitcoin44Testnet.kt b/app/src/main/java/wannabit/io/cosmostaion/chain/testnetClass/ChainBitcoin44Testnet.kt index 0ebeda941..ebfc4eda5 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/chain/testnetClass/ChainBitcoin44Testnet.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/chain/testnetClass/ChainBitcoin44Testnet.kt @@ -12,7 +12,7 @@ import wannabit.io.cosmostaion.common.BaseKey @Parcelize class ChainBitcoin44Testnet : ChainBitcoin84Testnet(), Parcelable { - override var name: String = "BitCoin Testnet" + override var name: String = "Bitcoin Testnet" override var tag: String = "bitcoin44_T" override var logo: Int = R.drawable.chain_bitcoin_testnet override var isDefault: Boolean = false diff --git a/app/src/main/java/wannabit/io/cosmostaion/chain/testnetClass/ChainBitcoin49Testnet.kt b/app/src/main/java/wannabit/io/cosmostaion/chain/testnetClass/ChainBitcoin49Testnet.kt index b38e92ffb..56be60c29 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/chain/testnetClass/ChainBitcoin49Testnet.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/chain/testnetClass/ChainBitcoin49Testnet.kt @@ -12,7 +12,7 @@ import wannabit.io.cosmostaion.common.BaseKey @Parcelize class ChainBitcoin49Testnet : ChainBitcoin84Testnet(), Parcelable { - override var name: String = "BitCoin Testnet" + override var name: String = "Bitcoin Testnet" override var tag: String = "bitcoin49_T" override var logo: Int = R.drawable.chain_bitcoin_testnet override var isDefault: Boolean = false diff --git a/app/src/main/java/wannabit/io/cosmostaion/chain/testnetClass/ChainBitcoin84Testnet.kt b/app/src/main/java/wannabit/io/cosmostaion/chain/testnetClass/ChainBitcoin84Testnet.kt index dae92ff72..cd4a58a73 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/chain/testnetClass/ChainBitcoin84Testnet.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/chain/testnetClass/ChainBitcoin84Testnet.kt @@ -17,9 +17,9 @@ open class ChainBitcoin84Testnet : ChainBitCoin84(), Parcelable { override var scriptHash: Byte = (-60).toByte() override var bech32PrefixPattern: String = "tb" - override var name: String = "BitCoin Testnet" + override var name: String = "Bitcoin Signet" override var tag: String = "bitcoin84_T" - override var logo: Int = R.drawable.chain_bitcoin_testnet + override var logo: Int = R.drawable.chain_bitcoin_signet override var isTestnet: Boolean = true override var apiName: String = "bitcoin-testnet" diff --git a/app/src/main/java/wannabit/io/cosmostaion/chain/testnetClass/ChainGnoTestnet.kt b/app/src/main/java/wannabit/io/cosmostaion/chain/testnetClass/ChainGnoTestnet.kt new file mode 100644 index 000000000..d5af85de7 --- /dev/null +++ b/app/src/main/java/wannabit/io/cosmostaion/chain/testnetClass/ChainGnoTestnet.kt @@ -0,0 +1,31 @@ +package wannabit.io.cosmostaion.chain.testnetClass + +import android.os.Parcelable +import com.google.common.collect.ImmutableList +import kotlinx.parcelize.Parcelize +import org.bitcoinj.crypto.ChildNumber +import wannabit.io.cosmostaion.R +import wannabit.io.cosmostaion.chain.AccountKeyType +import wannabit.io.cosmostaion.chain.BaseChain +import wannabit.io.cosmostaion.chain.CosmosEndPointType +import wannabit.io.cosmostaion.chain.PubKeyType + +@Parcelize +class ChainGnoTestnet : BaseChain(), Parcelable { + + override var name: String = "Gno Testnet" + override var tag: String = "gno118_T" + override var logo: Int = R.drawable.chain_gno_testnet + override var isTestnet: Boolean = true + override var apiName: String = "gno-testnet" + + override var accountKeyType = AccountKeyType(PubKeyType.COSMOS_SECP256K1, "m/44'/118'/0'/0/X") + override var setParentPath: List = ImmutableList.of( + ChildNumber(44, true), ChildNumber(118, true), ChildNumber.ZERO_HARDENED, ChildNumber.ZERO + ) + + override var cosmosEndPointType: CosmosEndPointType? = CosmosEndPointType.USE_RPC + override var stakeDenom: String = "ugnot" + override var accountPrefix: String = "g" + override var mainUrl: String = "https://rpc.test5.gno.land" +} \ No newline at end of file diff --git a/app/src/main/java/wannabit/io/cosmostaion/common/Extensions.kt b/app/src/main/java/wannabit/io/cosmostaion/common/Extensions.kt index 8ae1b508d..92b619328 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/common/Extensions.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/common/Extensions.kt @@ -893,3 +893,17 @@ fun com.initia.mstaking.v1.StakingProto.Validator.isActiveValidator(chain: Chain } } +fun String.regexWithNumberAndChar(): Pair { + val regex = Regex("[0-9]*\\.?[0-9]*") + val matchResult = regex.find(this) + return if (matchResult != null) { + val amount = matchResult.value + val denomIndex = amount.length + val denom = this.substring(denomIndex) + Pair(denom, amount) + + } else { + Pair("", "") + } +} + diff --git a/app/src/main/java/wannabit/io/cosmostaion/data/api/MintscanApi.kt b/app/src/main/java/wannabit/io/cosmostaion/data/api/MintscanApi.kt index 646718285..8c8031643 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/data/api/MintscanApi.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/data/api/MintscanApi.kt @@ -47,6 +47,9 @@ interface MintscanApi { @GET("v11/assets/{chain}/erc20/info") suspend fun erc20token(@Path("chain") chain: String): MutableList + @GET("v11/assets/{chain}/grc20/info") + suspend fun grc20token(@Path("chain") chain: String): MutableList + @GET("v11/assets/{chain}/cw721") suspend fun cw721Info(@Path("chain") chain: String): JsonObject diff --git a/app/src/main/java/wannabit/io/cosmostaion/data/model/req/SignPayload.kt b/app/src/main/java/wannabit/io/cosmostaion/data/model/req/SignPayload.kt new file mode 100644 index 000000000..71953381a --- /dev/null +++ b/app/src/main/java/wannabit/io/cosmostaion/data/model/req/SignPayload.kt @@ -0,0 +1,54 @@ +package wannabit.io.cosmostaion.data.model.req + +import com.fasterxml.jackson.annotation.JsonInclude +import com.google.gson.GsonBuilder +import com.google.gson.annotations.SerializedName + + +data class SignPayload( + val chain_id: String, + val account_number: String, + val sequence: String, + val fee: Fee, + val msgs: MutableList?, + val memo: String? = "" +) { + fun toJson(): String { + val gson = GsonBuilder().setPrettyPrinting().create() + return gson.toJson(this) + } +} + +data class Fee( + val gas_wanted: String, + val gas_fee: String +) + +data class Msgs( + @SerializedName("@type") + val type: String, + + @JsonInclude(JsonInclude.Include.NON_NULL) + val from_address: String? = null, + + @JsonInclude(JsonInclude.Include.NON_NULL) + val to_address: String? = null, + + @JsonInclude(JsonInclude.Include.NON_NULL) + val amount: String? = null, + + @JsonInclude(JsonInclude.Include.NON_NULL) + val send: String? = null, + + @JsonInclude(JsonInclude.Include.NON_NULL) + val caller: String? = null, + + @JsonInclude(JsonInclude.Include.NON_NULL) + val pkg_path: String? = null, + + @JsonInclude(JsonInclude.Include.NON_NULL) + val func: String? = null, + + @JsonInclude(JsonInclude.Include.NON_NULL) + val args: List? = null, +) diff --git a/app/src/main/java/wannabit/io/cosmostaion/data/model/res/Coin.kt b/app/src/main/java/wannabit/io/cosmostaion/data/model/res/Coin.kt index 1d6b9faa8..757aea858 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/data/model/res/Coin.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/data/model/res/Coin.kt @@ -2,4 +2,4 @@ package wannabit.io.cosmostaion.data.model.res data class Coin(val denom: String, val amount: String, val type: CoinType) -enum class CoinType { STAKE, NATIVE, IBC, BRIDGE, ETC, CW20, ERC20 } +enum class CoinType { STAKE, NATIVE, IBC, BRIDGE, ETC, CW20, ERC20, GRC20 } diff --git a/app/src/main/java/wannabit/io/cosmostaion/data/repository/tx/TxRepository.kt b/app/src/main/java/wannabit/io/cosmostaion/data/repository/tx/TxRepository.kt index 0fb115f5c..de5ae3aea 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/data/repository/tx/TxRepository.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/data/repository/tx/TxRepository.kt @@ -2,6 +2,8 @@ package wannabit.io.cosmostaion.data.repository.tx import com.cosmos.base.abci.v1beta1.AbciProto import com.cosmos.tx.v1beta1.TxProto.Fee +import com.gno.bank.BankProto.MsgSend +import com.gno.vm.VmProto.MsgCall import com.google.gson.JsonObject import com.ibc.applications.transfer.v1.TxProto.MsgTransfer import io.grpc.ManagedChannel @@ -9,12 +11,12 @@ import org.web3j.protocol.Web3j import wannabit.io.cosmostaion.chain.BaseChain import wannabit.io.cosmostaion.chain.fetcher.SuiFetcher import wannabit.io.cosmostaion.chain.majorClass.ChainBitCoin84 -import wannabit.io.cosmostaion.sign.BitCoinJS import wannabit.io.cosmostaion.data.model.req.LFee import wannabit.io.cosmostaion.data.model.req.Msg import wannabit.io.cosmostaion.data.model.res.LegacyRes import wannabit.io.cosmostaion.data.model.res.NetworkResult import wannabit.io.cosmostaion.data.model.res.Token +import wannabit.io.cosmostaion.sign.BitCoinJS import wannabit.io.cosmostaion.ui.tx.genTx.SendAssetType interface TxRepository { @@ -251,4 +253,12 @@ interface TxRepository { opReturn: String?, utxo: MutableList?, ): String? + + suspend fun broadcastSendRpcTx( + msgSend: MsgSend, fee: Fee?, memo: String, selectedChain: BaseChain + ): AbciProto.TxResponse? + + suspend fun broadcastCallRpcTx( + msgCall: MsgCall, fee: Fee?, memo: String, selectedChain: BaseChain + ): AbciProto.TxResponse? } \ No newline at end of file diff --git a/app/src/main/java/wannabit/io/cosmostaion/data/repository/tx/TxRepositoryImpl.kt b/app/src/main/java/wannabit/io/cosmostaion/data/repository/tx/TxRepositoryImpl.kt index 3634dd750..f673fa793 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/data/repository/tx/TxRepositoryImpl.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/data/repository/tx/TxRepositoryImpl.kt @@ -9,6 +9,8 @@ import com.cosmos.tx.v1beta1.ServiceProto import com.cosmos.tx.v1beta1.ServiceProto.BroadcastMode import com.cosmos.tx.v1beta1.TxProto.Fee import com.fasterxml.jackson.databind.ObjectMapper +import com.gno.bank.BankProto.MsgSend +import com.gno.vm.VmProto import com.google.gson.Gson import com.google.gson.JsonObject import com.google.protobuf.ByteString @@ -49,6 +51,7 @@ import wannabit.io.cosmostaion.chain.majorClass.SUI_MAIN_DENOM import wannabit.io.cosmostaion.common.BaseConstant.ICNS_OSMOSIS_ADDRESS import wannabit.io.cosmostaion.common.BaseConstant.NS_ARCHWAY_ADDRESS import wannabit.io.cosmostaion.common.BaseConstant.NS_STARGZE_ADDRESS +import wannabit.io.cosmostaion.common.formatJsonString import wannabit.io.cosmostaion.common.jsonRpcResponse import wannabit.io.cosmostaion.common.percentile import wannabit.io.cosmostaion.common.safeApiCall @@ -146,7 +149,25 @@ class TxRepositoryImpl : TxRepository { override suspend fun auth( managedChannel: ManagedChannel?, chain: BaseChain ) { - return if (chain.cosmosFetcher()?.endPointType(chain) == CosmosEndPointType.USE_GRPC) { + return if (chain.cosmosFetcher()?.endPointType(chain) == CosmosEndPointType.USE_RPC) { + val authRequest = JsonRpcRequest( + method = "abci_query", + params = listOf("auth/accounts/${chain.address}", "", "0", true) + ) + val authResponse = jsonRpcResponse(chain.mainUrl, authRequest) + val jsonResponse = Gson().fromJson( + authResponse.body?.string(), JsonObject::class.java + ) + val data = + jsonResponse["result"].asJsonObject["response"].asJsonObject["ResponseBase"].asJsonObject["Data"].asString + val decodeData = formatJsonString(String(Base64.decode(data))) + val dataJson = Gson().fromJson(decodeData, JsonObject::class.java) + val accountData = dataJson["BaseAccount"].asJsonObject + chain.cosmosFetcher()?.cosmosAccountNumber = + accountData["account_number"].asString.toLong() + chain.cosmosFetcher()?.cosmosSequence = accountData["sequence"].asString.toLong() + + } else if (chain.cosmosFetcher()?.endPointType(chain) == CosmosEndPointType.USE_GRPC) { val stub = QueryGrpc.newBlockingStub(managedChannel) .withDeadlineAfter(duration, TimeUnit.SECONDS) val request = QueryAccountRequest.newBuilder().setAddress(chain.address).build() @@ -1910,8 +1931,7 @@ class TxRepositoryImpl : TxRepository { val sendRawTransactionRequest = JsonRpcRequest( method = "sendrawtransaction", params = listOf(txHex) ) - val sendRawTransactionResponse = - jsonRpcResponse(chain.mainUrl, sendRawTransactionRequest) + val sendRawTransactionResponse = jsonRpcResponse(chain.mainUrl, sendRawTransactionRequest) val sendRawTransactionJsonObject = Gson().fromJson( sendRawTransactionResponse.body?.string(), JsonObject::class.java ) @@ -1963,4 +1983,55 @@ class TxRepositoryImpl : TxRepository { } return "" } + + override suspend fun broadcastSendRpcTx( + msgSend: MsgSend, fee: Fee?, memo: String, selectedChain: BaseChain + ): TxResponse? { + return try { + val broadcastTx = Signer.signRpcSendBroadcastTx(msgSend, fee, memo, selectedChain) + val txByte = Base64.toBase64String(broadcastTx.toByteArray()) + val broadcastRequest = JsonRpcRequest( + method = "broadcast_tx_async", params = listOf(txByte) + ) + val broadcastResponse = jsonRpcResponse(selectedChain.mainUrl, broadcastRequest) + val broadcastJsonObject = Gson().fromJson( + broadcastResponse.body?.string(), JsonObject::class.java + ) + val result = broadcastJsonObject["result"].asJsonObject + return if (result["error"].isJsonNull) { + TxResponse.newBuilder().setCode(0).setTxhash(result["hash"].asString).build() + } else { + TxResponse.newBuilder().setCode(-1).setTxhash(result["hash"].asString).build() + } + } catch (e: Exception) { + null + } + } + + override suspend fun broadcastCallRpcTx( + msgCall: VmProto.MsgCall, + fee: Fee?, + memo: String, + selectedChain: BaseChain + ): TxResponse? { + return try { + val broadcastTx = Signer.signRpcCallBroadcastTx(msgCall, fee, memo, selectedChain) + val txByte = Base64.toBase64String(broadcastTx.toByteArray()) + val broadcastRequest = JsonRpcRequest( + method = "broadcast_tx_async", params = listOf(txByte) + ) + val broadcastResponse = jsonRpcResponse(selectedChain.mainUrl, broadcastRequest) + val broadcastJsonObject = Gson().fromJson( + broadcastResponse.body?.string(), JsonObject::class.java + ) + val result = broadcastJsonObject["result"].asJsonObject + return if (result["error"].isJsonNull) { + TxResponse.newBuilder().setCode(0).setTxhash(result["hash"].asString).build() + } else { + TxResponse.newBuilder().setCode(-1).setTxhash(result["hash"].asString).build() + } + } catch (e: Exception) { + null + } + } } \ No newline at end of file diff --git a/app/src/main/java/wannabit/io/cosmostaion/data/repository/wallet/WalletRepository.kt b/app/src/main/java/wannabit/io/cosmostaion/data/repository/wallet/WalletRepository.kt index affa99261..2c65de059 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/data/repository/wallet/WalletRepository.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/data/repository/wallet/WalletRepository.kt @@ -87,6 +87,10 @@ interface WalletRepository { chain: BaseChain, token: Token ) + suspend fun grc20Balance( + chain: BaseChain, grc20Token: Token + ) + //neutron suspend fun vestingData( channel: ManagedChannel?, chain: BaseChain @@ -182,4 +186,6 @@ interface WalletRepository { ): NetworkResult> suspend fun bitBalance(chain: ChainBitCoin84): NetworkResult + + suspend fun rpcAuth(chain: BaseChain): NetworkResult } \ No newline at end of file diff --git a/app/src/main/java/wannabit/io/cosmostaion/data/repository/wallet/WalletRepositoryImpl.kt b/app/src/main/java/wannabit/io/cosmostaion/data/repository/wallet/WalletRepositoryImpl.kt index 4afc68954..5796c8226 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/data/repository/wallet/WalletRepositoryImpl.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/data/repository/wallet/WalletRepositoryImpl.kt @@ -53,9 +53,9 @@ import wannabit.io.cosmostaion.chain.fetcher.validators import wannabit.io.cosmostaion.chain.majorClass.ChainBitCoin84 import wannabit.io.cosmostaion.chain.majorClass.ChainSui import wannabit.io.cosmostaion.chain.testnetClass.ChainInitiaTestnet +import wannabit.io.cosmostaion.common.formatJsonString import wannabit.io.cosmostaion.common.jsonRpcResponse import wannabit.io.cosmostaion.common.safeApiCall -import wannabit.io.cosmostaion.data.api.RetrofitInstance.baseApi import wannabit.io.cosmostaion.data.api.RetrofitInstance.bitApi import wannabit.io.cosmostaion.data.api.RetrofitInstance.ecoApi import wannabit.io.cosmostaion.data.api.RetrofitInstance.lcdApi @@ -134,6 +134,8 @@ class WalletRepositoryImpl : WalletRepository { mintscanApi.cw20token(chain.apiName) } else if (chain.isSupportErc20()) { mintscanApi.erc20token(chain.apiName) + } else if (chain.isSupportGrc20()) { + mintscanApi.grc20token(chain.apiName) } else { mutableListOf() } @@ -306,9 +308,11 @@ class WalletRepositoryImpl : WalletRepository { return if (chain.cosmosFetcher?.endPointType(chain) == CosmosEndPointType.USE_GRPC) { channel?.let { managedChannel -> val pageRequest = PaginationProto.PageRequest.newBuilder().setLimit(500).build() - val stub = newBlockingStub(managedChannel).withDeadlineAfter(duration, TimeUnit.SECONDS) - val request = com.cosmos.staking.v1beta1.QueryProto.QueryValidatorsRequest.newBuilder() - .setPagination(pageRequest).setStatus("BOND_STATUS_UNBONDED").build() + val stub = + newBlockingStub(managedChannel).withDeadlineAfter(duration, TimeUnit.SECONDS) + val request = + com.cosmos.staking.v1beta1.QueryProto.QueryValidatorsRequest.newBuilder() + .setPagination(pageRequest).setStatus("BOND_STATUS_UNBONDED").build() safeApiCall(Dispatchers.IO) { stub.validators(request).validatorsList } @@ -333,9 +337,11 @@ class WalletRepositoryImpl : WalletRepository { return if (chain.cosmosFetcher?.endPointType(chain) == CosmosEndPointType.USE_GRPC) { channel?.let { managedChannel -> val pageRequest = PaginationProto.PageRequest.newBuilder().setLimit(500).build() - val stub = newBlockingStub(managedChannel).withDeadlineAfter(duration, TimeUnit.SECONDS) - val request = com.cosmos.staking.v1beta1.QueryProto.QueryValidatorsRequest.newBuilder() - .setPagination(pageRequest).setStatus("BOND_STATUS_UNBONDING").build() + val stub = + newBlockingStub(managedChannel).withDeadlineAfter(duration, TimeUnit.SECONDS) + val request = + com.cosmos.staking.v1beta1.QueryProto.QueryValidatorsRequest.newBuilder() + .setPagination(pageRequest).setStatus("BOND_STATUS_UNBONDING").build() safeApiCall(Dispatchers.IO) { stub.validators(request).validatorsList } @@ -425,6 +431,44 @@ class WalletRepositoryImpl : WalletRepository { } } + override suspend fun grc20Balance(chain: BaseChain, grc20Token: Token) { + val queryData = grc20Token.contract + ".BalanceOf(\"${chain.address}\")" + val queryDataBase64 = Base64.toBase64String(queryData.toByteArray()) + val grc20BalanceRequest = JsonRpcRequest( + method = "abci_query", params = listOf("vm/qeval", queryDataBase64, "0", false) + ) + val grc20BalanceResponse = jsonRpcResponse(chain.mainUrl, grc20BalanceRequest) + try { + if (grc20BalanceResponse.isSuccessful) { + val grc20BalanceJsonObject = Gson().fromJson( + grc20BalanceResponse.body?.string(), JsonObject::class.java + ) + if (!grc20BalanceJsonObject.has("error")) { + val balanceResult = + grc20BalanceJsonObject["result"].asJsonObject["response"].asJsonObject["ResponseBase"].asJsonObject + val balanceData = balanceResult["Data"].asString + val decodeData = formatJsonString(String(Base64.decode(balanceData))) + val regex = "\\d+".toRegex() + val match = regex.find(decodeData) + grc20Token.amount = match?.value?.toLong().toString() + grc20Token.fetched = true + + } else { + grc20Token.amount = "0" + grc20Token.fetched = true + } + + } else { + grc20Token.amount = "0" + grc20Token.fetched = true + } + + } catch (e: Exception) { + grc20Token.amount = "0" + grc20Token.fetched = true + } + } + override suspend fun vestingData( channel: ManagedChannel?, chain: BaseChain ): NetworkResult { @@ -525,8 +569,7 @@ class WalletRepositoryImpl : WalletRepository { } override suspend fun initiaBondedValidator( - channel: ManagedChannel?, - chain: ChainInitiaTestnet + channel: ManagedChannel?, chain: ChainInitiaTestnet ): NetworkResult> { return if (chain.initiaFetcher()?.endPointType(chain) == CosmosEndPointType.USE_GRPC) { val pageRequest = PaginationProto.PageRequest.newBuilder().setLimit(500).build() @@ -540,14 +583,14 @@ class WalletRepositoryImpl : WalletRepository { } else { safeApiCall(Dispatchers.IO) { - lcdApi(chain).lcdInitiaBondedValidatorInfo().initiaValidators(com.initia.mstaking.v1.StakingProto.BondStatus.BOND_STATUS_BONDED) + lcdApi(chain).lcdInitiaBondedValidatorInfo() + .initiaValidators(com.initia.mstaking.v1.StakingProto.BondStatus.BOND_STATUS_BONDED) } } } override suspend fun initiaUnBondedValidator( - channel: ManagedChannel?, - chain: ChainInitiaTestnet + channel: ManagedChannel?, chain: ChainInitiaTestnet ): NetworkResult> { return if (chain.initiaFetcher()?.endPointType(chain) == CosmosEndPointType.USE_GRPC) { val pageRequest = PaginationProto.PageRequest.newBuilder().setLimit(500).build() @@ -560,14 +603,14 @@ class WalletRepositoryImpl : WalletRepository { } } else { safeApiCall(Dispatchers.IO) { - lcdApi(chain).lcdInitiaUnBondedValidatorInfo().initiaValidators(com.initia.mstaking.v1.StakingProto.BondStatus.BOND_STATUS_UNBONDED) + lcdApi(chain).lcdInitiaUnBondedValidatorInfo() + .initiaValidators(com.initia.mstaking.v1.StakingProto.BondStatus.BOND_STATUS_UNBONDED) } } } override suspend fun initiaUnBondingValidator( - channel: ManagedChannel?, - chain: ChainInitiaTestnet + channel: ManagedChannel?, chain: ChainInitiaTestnet ): NetworkResult> { return if (chain.initiaFetcher()?.endPointType(chain) == CosmosEndPointType.USE_GRPC) { val pageRequest = PaginationProto.PageRequest.newBuilder().setLimit(500).build() @@ -580,7 +623,8 @@ class WalletRepositoryImpl : WalletRepository { } } else { safeApiCall(Dispatchers.IO) { - lcdApi(chain).lcdInitiaUnBondingValidatorInfo().initiaValidators(com.initia.mstaking.v1.StakingProto.BondStatus.BOND_STATUS_UNBONDING) + lcdApi(chain).lcdInitiaUnBondingValidatorInfo() + .initiaValidators(com.initia.mstaking.v1.StakingProto.BondStatus.BOND_STATUS_UNBONDING) } } } @@ -886,4 +930,13 @@ class WalletRepositoryImpl : WalletRepository { bitApi(chain).bitBalance(chain.mainAddress) } } + + override suspend fun rpcAuth(chain: BaseChain): NetworkResult { + val authRequest = JsonRpcRequest( + method = "abci_query", params = listOf("auth/accounts/${chain.address}", "", "0", false) + ) + return safeApiCall(Dispatchers.IO) { + jsonRpcResponse(chain.mainUrl, authRequest) + } + } } \ No newline at end of file diff --git a/app/src/main/java/wannabit/io/cosmostaion/data/viewmodel/ApplicationViewModel.kt b/app/src/main/java/wannabit/io/cosmostaion/data/viewmodel/ApplicationViewModel.kt index 5b9566323..eebc20639 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/data/viewmodel/ApplicationViewModel.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/data/viewmodel/ApplicationViewModel.kt @@ -1,6 +1,7 @@ package wannabit.io.cosmostaion.data.viewmodel import android.app.Application +import android.util.Log import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData @@ -16,9 +17,11 @@ import kotlinx.coroutines.awaitAll import kotlinx.coroutines.delay import kotlinx.coroutines.launch import kotlinx.coroutines.withContext +import org.bouncycastle.util.encoders.Base64 import org.web3j.protocol.Web3j import org.web3j.protocol.http.HttpService import wannabit.io.cosmostaion.chain.BaseChain +import wannabit.io.cosmostaion.chain.CosmosEndPointType import wannabit.io.cosmostaion.chain.FetchState import wannabit.io.cosmostaion.chain.cosmosClass.ChainNeutron import wannabit.io.cosmostaion.chain.cosmosClass.ChainOkt996Keccak @@ -31,6 +34,8 @@ import wannabit.io.cosmostaion.chain.testnetClass.ChainInitiaTestnet import wannabit.io.cosmostaion.common.BaseData import wannabit.io.cosmostaion.common.BaseUtils import wannabit.io.cosmostaion.common.ByteUtils +import wannabit.io.cosmostaion.common.formatJsonString +import wannabit.io.cosmostaion.common.regexWithNumberAndChar import wannabit.io.cosmostaion.data.model.res.NetworkResult import wannabit.io.cosmostaion.data.model.res.Token import wannabit.io.cosmostaion.data.model.res.VestingData @@ -203,6 +208,18 @@ class ApplicationViewModel( } } + if (isSupportGrc20()) { + when (val response = walletRepository.token(this)) { + is NetworkResult.Success -> { + cosmosFetcher?.grc20Tokens = response.data + } + + is NetworkResult.Error -> { + _chainDataErrorMessage.postValue("error type : ${response.errorType} error message : ${response.errorMessage}") + } + } + } + if (isSupportCw721()) { when (val response = walletRepository.cw721Info(apiName)) { is NetworkResult.Success -> { @@ -226,7 +243,9 @@ class ApplicationViewModel( } else if (this is ChainSui) { loadSuiData(baseAccountId, this, isEdit) } else { - if (supportCosmos() && this !is ChainOktEvm) { + if (this.cosmosFetcher?.endPointType(this) == CosmosEndPointType.USE_RPC) { + loadRpcData(this, baseAccountId, isEdit) + } else if (supportCosmos() && this !is ChainOktEvm) { loadGrpcAuthData(this, baseAccountId, isEdit) } else { loadEvmChainData(this, baseAccountId, isEdit) @@ -1229,4 +1248,158 @@ class ApplicationViewModel( } } } + + private fun loadRpcData(chain: BaseChain, id: Long, isEdit: Boolean) = + CoroutineScope(Dispatchers.IO).launch { + chain.apply { + when (val response = walletRepository.rpcAuth(chain)) { + is NetworkResult.Success -> { + cosmosFetcher()?.let { fetcher -> + if (response.data.isSuccessful) { + val tempBalances: MutableList = mutableListOf() + val jsonResponse = Gson().fromJson( + response.data.body?.string(), JsonObject::class.java + ) + val data = + jsonResponse["result"].asJsonObject["response"].asJsonObject["ResponseBase"].asJsonObject["Data"].asString + val decodeData = formatJsonString(String(Base64.decode(data))) + + if (decodeData == "null") { + tempBalances.add( + CoinProto.Coin.newBuilder().setDenom(stakeDenom) + .setAmount("0").build() + ) + fetcher.cosmosBalances = tempBalances + + val refAddress = RefAddress( + id, + tag, + address, + "", + fetcher.allAssetValue(true).toString(), + "0", + "0", + 0 + ) + BaseData.updateRefAddressesMain(refAddress) + coinCnt = 0 + + } else { + val dataJson = + Gson().fromJson(decodeData, JsonObject::class.java) + val accountData = dataJson["BaseAccount"].asJsonObject + if (accountData["coins"].asString.isNotEmpty()) { + tempBalances.add( + CoinProto.Coin.newBuilder() + .setDenom(accountData["coins"].asString.regexWithNumberAndChar().first) + .setAmount(accountData["coins"].asString.regexWithNumberAndChar().second) + .build() + ) + } else { + tempBalances.add( + CoinProto.Coin.newBuilder() + .setDenom(stakeDenom) + .setAmount("0") + .build() + ) + } + + fetcher.cosmosBalances = tempBalances + fetcher.cosmosAccountNumber = + accountData["account_number"].asString.toLong() + fetcher.cosmosSequence = + accountData["sequence"].asString.toLong() + + val refAddress = RefAddress( + id, + tag, + address, + "", + fetcher.allAssetValue(true).toString(), + "0", + "0", + if (fetcher.cosmosBalances?.get(0)?.amount?.toBigDecimal() == BigDecimal.ZERO) 0 else 1 + ) + BaseData.updateRefAddressesMain(refAddress) + coinCnt = + if (fetcher.cosmosBalances?.get(0)?.amount?.toBigDecimal() == BigDecimal.ZERO) 0 else 1 + } + + withContext(Dispatchers.Main) { + if (isEdit) { + editFetchedResult.value = tag + } else { + fetchedResult.value = tag + txFetchedResult.value = tag + } + } + + if (isSupportGrc20()) { + val userDisplayToken = Prefs.getDisplayGrc20s(id, tag) + val tokenBalanceDeferredList = if (userDisplayToken == null) { + cosmosFetcher?.grc20Tokens?.filter { it.wallet_preload ?: false } + ?.map { token -> + async { walletRepository.grc20Balance(chain, token) } + } + + } else { + cosmosFetcher?.grc20Tokens?.filter { userDisplayToken.contains(it.contract) } + ?.map { token -> + async { walletRepository.grc20Balance(chain, token) } + } + } + + tokenBalanceDeferredList?.awaitAll() + val grcRefAddress = RefAddress( + id, + tag, + address, + "", + "0", + "0", + cosmosFetcher?.allTokenValue(true)?.toPlainString(), + 0 + ) + BaseData.updateRefAddressesToken(grcRefAddress) + tokenCnt = chain.cosmosFetcher()?.valueGrc20TokenCnt() ?: 0 + fetchState = FetchState.SUCCESS + + withContext(Dispatchers.Main) { + if (isEdit) { + editFetchedTokenResult.value = tag + } else { + fetchedTokenResult.value = tag + } + } + fetchedTotalResult.postValue(tag) + } + + } else { + fetchState = FetchState.FAIL + withContext(Dispatchers.Main) { + if (isEdit) { + editFetchedResult.value = tag + } else { + fetchedResult.value = tag + txFetchedResult.value = tag + } + } + } + } + } + + is NetworkResult.Error -> { + fetchState = FetchState.FAIL + withContext(Dispatchers.Main) { + if (isEdit) { + editFetchedResult.value = tag + } else { + fetchedResult.value = tag + txFetchedResult.value = tag + } + } + } + } + } + } } \ No newline at end of file diff --git a/app/src/main/java/wannabit/io/cosmostaion/data/viewmodel/intro/WalletViewModel.kt b/app/src/main/java/wannabit/io/cosmostaion/data/viewmodel/intro/WalletViewModel.kt index a4e722afc..5a04534f4 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/data/viewmodel/intro/WalletViewModel.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/data/viewmodel/intro/WalletViewModel.kt @@ -4,7 +4,9 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import com.cosmos.base.v1beta1.CoinProto import com.cosmos.staking.v1beta1.StakingProto +import com.google.gson.Gson import com.google.gson.JsonObject import io.grpc.ManagedChannel import kotlinx.coroutines.CoroutineScope @@ -13,9 +15,11 @@ import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.launch import kotlinx.coroutines.withContext +import org.bouncycastle.util.encoders.Base64 import org.web3j.protocol.Web3j import org.web3j.protocol.http.HttpService import wannabit.io.cosmostaion.chain.BaseChain +import wannabit.io.cosmostaion.chain.CosmosEndPointType import wannabit.io.cosmostaion.chain.FetchState import wannabit.io.cosmostaion.chain.evmClass.ChainOktEvm import wannabit.io.cosmostaion.chain.majorClass.ChainBitCoin84 @@ -25,6 +29,8 @@ import wannabit.io.cosmostaion.chain.testnetClass.ChainInitiaTestnet import wannabit.io.cosmostaion.common.BaseConstant import wannabit.io.cosmostaion.common.BaseData import wannabit.io.cosmostaion.common.CosmostationConstants +import wannabit.io.cosmostaion.common.formatJsonString +import wannabit.io.cosmostaion.common.regexWithNumberAndChar import wannabit.io.cosmostaion.data.model.req.Cw721Model import wannabit.io.cosmostaion.data.model.req.Cw721TokenModel import wannabit.io.cosmostaion.data.model.req.MoonPayReq @@ -338,6 +344,18 @@ class WalletViewModel(private val walletRepository: WalletRepository) : ViewMode } } + private val _editGrc20Balance = MutableLiveData() + val editGrc20Balance: LiveData get() = _editGrc20Balance + + fun grc20Balance(chain: BaseChain, token: Token) { + viewModelScope.launch(Dispatchers.IO) { + walletRepository.grc20Balance(chain, token) + withContext(Dispatchers.Main) { + _editGrc20Balance.value = token.contract + } + } + } + private var _balanceResult = MutableLiveData() val balanceResult: LiveData get() = _balanceResult @@ -479,22 +497,85 @@ class WalletViewModel(private val walletRepository: WalletRepository) : ViewMode else -> { chain.cosmosFetcher()?.let { cosmosFetcher -> - val channel = cosmosFetcher.getChannel() - when (val response = walletRepository.balance(channel, chain)) { - is NetworkResult.Success -> { - chain.cosmosFetcher?.cosmosBalances = response.data - chain.fetchState = FetchState.SUCCESS - chain.coinCnt = chain.cosmosFetcher()?.valueCoinCnt() ?: 0 - withContext(Dispatchers.Main) { - _balanceResult.value = chain.tag + if (cosmosFetcher.endPointType(chain) == CosmosEndPointType.USE_RPC) { + when (val response = walletRepository.rpcAuth(chain)) { + is NetworkResult.Success -> { + if (response.data.isSuccessful) { + val tempBalances: MutableList = mutableListOf() + val jsonResponse = Gson().fromJson( + response.data.body?.string(), JsonObject::class.java + ) + val data = + jsonResponse["result"].asJsonObject["response"].asJsonObject["ResponseBase"].asJsonObject["Data"].asString + val decodeData = formatJsonString(String(Base64.decode(data))) + if (decodeData == "null") { + tempBalances.add( + CoinProto.Coin.newBuilder().setDenom(chain.stakeDenom) + .setAmount("0").build() + ) + cosmosFetcher.cosmosBalances = tempBalances + chain.fetchState = FetchState.SUCCESS + chain.coinCnt = 0 + withContext(Dispatchers.Main) { + _balanceResult.value = chain.tag + } + + } else { + val dataJson = + Gson().fromJson(decodeData, JsonObject::class.java) + + val accountData = dataJson["BaseAccount"].asJsonObject + tempBalances.add( + CoinProto.Coin.newBuilder() + .setDenom(accountData["coins"].asString.regexWithNumberAndChar().first) + .setAmount(accountData["coins"].asString.regexWithNumberAndChar().second) + .build() + ) + cosmosFetcher.cosmosBalances = tempBalances + chain.fetchState = FetchState.SUCCESS + chain.coinCnt = + if (cosmosFetcher.cosmosBalances?.get(0)?.amount?.toBigDecimal() == BigDecimal.ZERO) 0 else 1 + withContext(Dispatchers.Main) { + _balanceResult.value = chain.tag + } + } + + } else { + chain.cosmosFetcher?.cosmosBalances = null + chain.fetchState = FetchState.FAIL + withContext(Dispatchers.Main) { + _balanceResult.value = chain.tag + } + } + } + + is NetworkResult.Error -> { + chain.cosmosFetcher?.cosmosBalances = null + chain.fetchState = FetchState.FAIL + withContext(Dispatchers.Main) { + _balanceResult.value = chain.tag + } } } - is NetworkResult.Error -> { - chain.cosmosFetcher?.cosmosBalances = null - chain.fetchState = FetchState.FAIL - withContext(Dispatchers.Main) { - _balanceResult.value = chain.tag + } else { + val channel = cosmosFetcher.getChannel() + when (val response = walletRepository.balance(channel, chain)) { + is NetworkResult.Success -> { + chain.cosmosFetcher?.cosmosBalances = response.data + chain.fetchState = FetchState.SUCCESS + chain.coinCnt = chain.cosmosFetcher()?.valueCoinCnt() ?: 0 + withContext(Dispatchers.Main) { + _balanceResult.value = chain.tag + } + } + + is NetworkResult.Error -> { + chain.cosmosFetcher?.cosmosBalances = null + chain.fetchState = FetchState.FAIL + withContext(Dispatchers.Main) { + _balanceResult.value = chain.tag + } } } } diff --git a/app/src/main/java/wannabit/io/cosmostaion/data/viewmodel/tx/TxViewModel.kt b/app/src/main/java/wannabit/io/cosmostaion/data/viewmodel/tx/TxViewModel.kt index f4d06ae80..64ceace62 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/data/viewmodel/tx/TxViewModel.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/data/viewmodel/tx/TxViewModel.kt @@ -7,6 +7,8 @@ import androidx.lifecycle.viewModelScope import com.cosmos.base.abci.v1beta1.AbciProto import com.cosmos.base.v1beta1.CoinProto import com.cosmos.tx.v1beta1.TxProto.Fee +import com.gno.bank.BankProto.MsgSend +import com.gno.vm.VmProto.MsgCall import com.google.gson.JsonObject import com.google.protobuf.Any import com.ibc.applications.transfer.v1.TxProto.MsgTransfer @@ -691,4 +693,34 @@ class TxViewModel(private val txRepository: TxRepository) : ViewModel() { errorMessage.postValue(e.message.toString()) } } + + fun rpcSendBroadcast( + msgSend: MsgSend, fee: Fee?, memo: String, selectedChain: BaseChain + ) = viewModelScope.launch(Dispatchers.IO) { + try { + txRepository.auth(null, selectedChain) + val response = txRepository.broadcastSendRpcTx(msgSend,fee, memo, selectedChain) + broadcast.postValue(response) + } catch (e: Exception) { + val errorResponse = txRepository.broadcastSendRpcTx( + msgSend, fee, memo, selectedChain + ) + errorMessage.postValue(errorResponse?.rawLog) + } + } + + fun rpcCallBroadcast( + msgCall: MsgCall, fee: Fee?, memo: String, selectedChain: BaseChain + ) = viewModelScope.launch(Dispatchers.IO) { + try { + txRepository.auth(null, selectedChain) + val response = txRepository.broadcastCallRpcTx(msgCall,fee, memo, selectedChain) + broadcast.postValue(response) + } catch (e: Exception) { + val errorResponse = txRepository.broadcastCallRpcTx( + msgCall, fee, memo, selectedChain + ) + errorMessage.postValue(errorResponse?.rawLog) + } + } } \ No newline at end of file diff --git a/app/src/main/java/wannabit/io/cosmostaion/database/Prefs.kt b/app/src/main/java/wannabit/io/cosmostaion/database/Prefs.kt index 6129b05ec..360541462 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/database/Prefs.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/database/Prefs.kt @@ -38,6 +38,7 @@ object Prefs { private const val FOREGROUND_TO_BACKGROUND = "PRE_FOREGROUND_TO_BACKGROUND" private const val DISPLAY_ERC20_TOKENS = "PRE_DISPLAY_ERC20_TOKENS" private const val DISPLAY_CW20_TOKENS = "PRE_DISPLAY_CW20_TOKENS" + private const val DISPLAY_GRC20_TOKENS = "PRE_DISPLAY_GRC20_TOKENS" private const val GRPC_ENDPOINT = "PRE_GRPC_ENDPOINT" private const val EVM_RPC_ENDPOINT = "PRE_EVM_RPC_ENDPOINT" private const val LCD_ENDPOINT = "PRE_LCD_ENDPOINT" @@ -264,6 +265,41 @@ object Prefs { return null } + fun setDisplayGrc20s( + baseAccountId: Long, chainTag: String, contractAddresses: List + ) { + val encoded = try { + val jsonString = JSONArray(contractAddresses).toString() + jsonString.toByteArray(Charsets.UTF_8) + } catch (e: JSONException) { + null + } + + if (encoded != null) { + val key = "$baseAccountId $chainTag $DISPLAY_GRC20_TOKENS" + preference.edit().putString(key, String(encoded)).apply() + } + } + + fun getDisplayGrc20s(baseAccountId: Long, chainTag: String): MutableList? { + val key = "$baseAccountId $chainTag $DISPLAY_GRC20_TOKENS" + val savedDataString = preference.getString(key, null) + + if (!savedDataString.isNullOrEmpty()) { + try { + val jsonArray = JSONArray(savedDataString) + val result = ArrayList() + for (i in 0 until jsonArray.length()) { + result.add(jsonArray.getString(i)) + } + return result + } catch (e: JSONException) { + e.printStackTrace() + } + } + return null + } + fun setEndpointType(chain: BaseChain?, endpoint: CosmosEndPointType) { val key = ENDPOINT_TYPE + ":" + chain?.name preference.edit().putString(key, endpoint.name).apply() diff --git a/app/src/main/java/wannabit/io/cosmostaion/sign/BitcoinJs.kt b/app/src/main/java/wannabit/io/cosmostaion/sign/BitcoinJs.kt index ce39bcf25..6ea33fb97 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/sign/BitcoinJs.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/sign/BitcoinJs.kt @@ -12,7 +12,7 @@ class BitCoinJS(private val context: Context) { private var isServiceBind = false private lateinit var sandbox: JavaScriptSandbox - private lateinit var jsIsolate: JavaScriptIsolate + private var jsIsolate: JavaScriptIsolate? = null init { if (!isServiceBind) { @@ -24,7 +24,7 @@ class BitCoinJS(private val context: Context) { isServiceBind = true } val jsCode = readJavaScriptFile() - jsIsolate.evaluateJavaScriptAsync(jsCode).get() + jsIsolate?.evaluateJavaScriptAsync(jsCode)?.get() } catch (e: Exception) { e.printStackTrace() @@ -37,12 +37,12 @@ class BitCoinJS(private val context: Context) { return context.assets.open("bitcoin.js").bufferedReader().use { it.readText() } } - fun executeFunction(functionCall: String): String { - return jsIsolate.evaluateJavaScriptAsync(functionCall).get() + fun executeFunction(functionCall: String): String? { + return jsIsolate?.evaluateJavaScriptAsync(functionCall)?.get() } fun mergeFunction(createTx: String) { - jsIsolate.evaluateJavaScriptAsync(createTx).get() + jsIsolate?.evaluateJavaScriptAsync(createTx)?.get() } fun unbindService() { diff --git a/app/src/main/java/wannabit/io/cosmostaion/sign/Signer.kt b/app/src/main/java/wannabit/io/cosmostaion/sign/Signer.kt index c303bf1eb..0b35d1a5c 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/sign/Signer.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/sign/Signer.kt @@ -27,6 +27,10 @@ import com.cosmos.tx.v1beta1.TxProto.TxBody import com.cosmos.tx.v1beta1.TxProto.TxRaw import com.cosmwasm.wasm.v1.TxProto.MsgExecuteContract import com.ethermint.crypto.v1.ethsecp256k1.KeysProto +import com.fasterxml.jackson.databind.ObjectMapper +import com.fasterxml.jackson.databind.SerializationFeature +import com.gno.bank.BankProto +import com.gno.vm.VmProto.MsgCall import com.google.protobuf.Any import com.google.protobuf.ByteString import com.ibc.applications.transfer.v1.TxProto.MsgTransfer @@ -44,6 +48,9 @@ import com.kava.incentive.v1beta1.TxProto.MsgClaimHardReward import com.kava.incentive.v1beta1.TxProto.MsgClaimSwapReward import com.kava.incentive.v1beta1.TxProto.MsgClaimUSDXMintingReward import com.kava.incentive.v1beta1.TxProto.Selection +import com.tm2.tx.TxProto.Tx +import com.tm2.tx.TxProto.TxFee +import com.tm2.tx.TxProto.TxSignature import net.i2p.crypto.eddsa.EdDSAEngine import net.i2p.crypto.eddsa.EdDSAPrivateKey import net.i2p.crypto.eddsa.spec.EdDSANamedCurveTable @@ -73,6 +80,7 @@ import wannabit.io.cosmostaion.chain.fetcher.hardRewardDenoms import wannabit.io.cosmostaion.chain.fetcher.hasUsdxMinting import wannabit.io.cosmostaion.chain.fetcher.swapRewardDenoms import wannabit.io.cosmostaion.chain.testnetClass.ChainArtelaTestnet +import wannabit.io.cosmostaion.chain.testnetClass.ChainGnoTestnet import wannabit.io.cosmostaion.chain.testnetClass.ChainInitiaTestnet import wannabit.io.cosmostaion.common.BaseConstant.COSMOS_AUTH_TYPE_STDTX import wannabit.io.cosmostaion.common.BaseConstant.COSMOS_KEY_TYPE_PUBLIC @@ -87,6 +95,8 @@ import wannabit.io.cosmostaion.data.model.req.BroadcastReq import wannabit.io.cosmostaion.data.model.req.LCoin import wannabit.io.cosmostaion.data.model.req.LFee import wannabit.io.cosmostaion.data.model.req.Msg +import wannabit.io.cosmostaion.data.model.req.Msgs +import wannabit.io.cosmostaion.data.model.req.SignPayload import wannabit.io.cosmostaion.data.model.req.Signature import wannabit.io.cosmostaion.data.model.req.StdSignMsg import wannabit.io.cosmostaion.data.model.req.StdTx @@ -96,7 +106,9 @@ import java.math.BigDecimal import java.math.BigInteger import java.math.RoundingMode import java.nio.charset.Charset +import java.nio.charset.StandardCharsets import java.security.MessageDigest +import java.util.TreeMap import java.util.concurrent.TimeUnit object Signer { @@ -125,8 +137,15 @@ object Signer { fun thorchainSendMsg(msgSend: com.types.MsgSendProto.MsgSend?): MutableList { val msgAnys: MutableList = mutableListOf() msgAnys.add( - Any.newBuilder().setTypeUrl("/types.MsgSend") - .setValue(msgSend?.toByteString()).build() + Any.newBuilder().setTypeUrl("/types.MsgSend").setValue(msgSend?.toByteString()).build() + ) + return msgAnys + } + + private fun gnoSendMsg(msgSend: BankProto.MsgSend?): MutableList { + val msgAnys: MutableList = mutableListOf() + msgAnys.add( + Any.newBuilder().setTypeUrl("/bank.MsgSend").setValue(msgSend?.toByteString()).build() ) return msgAnys } @@ -163,6 +182,14 @@ object Signer { return msgAnys } + fun msgCallMsg(msgCall: MsgCall?): MutableList { + val msgAnys: MutableList = mutableListOf() + msgAnys.add( + Any.newBuilder().setTypeUrl("/vm.m_call").setValue(msgCall?.toByteString()).build() + ) + return msgAnys + } + fun delegateMsg(msgDelegate: MsgDelegate?): MutableList { val msgAnys: MutableList = mutableListOf() msgAnys.add( @@ -560,7 +587,13 @@ object Signer { private fun generateGrpcPubKeyFromPriv(chain: BaseChain?, privateKey: String): Any { val ecKey = ECKey.fromPrivate(BigInteger(privateKey, 16)) - return if (chain is ChainInjective) { + return if (chain is ChainGnoTestnet) { + val pubKey = com.tm2.tx.TxProto.PubKeySecp256k1.newBuilder() + .setKey(ByteString.copyFrom(ecKey.pubKey)).build() + Any.newBuilder().setTypeUrl("/tm.PubKeySecp256k1").setValue(pubKey.toByteString()) + .build() + + } else if (chain is ChainInjective) { val pubKey = com.injective.crypto.v1beta1.ethsecp256k1.KeysProto.PubKey.newBuilder() .setKey(ByteString.copyFrom(ecKey.pubKey)).build() Any.newBuilder().setTypeUrl("/injective.crypto.v1beta1.ethsecp256k1.PubKey") @@ -630,6 +663,92 @@ object Signer { return null } + fun signRpcSendBroadcastTx( + msgSend: BankProto.MsgSend, fee: Fee?, memo: String, chain: BaseChain + ): Tx { + val msgs: MutableList = mutableListOf() + val msg = Msgs( + "/bank.MsgSend", + from_address = chain.address, + to_address = msgSend.toAddress, + amount = msgSend.amount + ) + msgs.add(msg) + val txFee = TxFee.newBuilder().setGasWanted(fee?.gasLimit ?: 10000000L) + .setGasFee(fee?.getAmount(0)?.amount + fee?.getAmount(0)?.denom).build() + val pubKey = + generateGrpcPubKeyFromPriv(chain, ECKey.fromPrivate(chain.privateKey).privateKeyAsHex) + + val signPayload = SignPayload( + chain.chainIdCosmos, + chain.cosmosFetcher()?.cosmosAccountNumber.toString(), + chain.cosmosFetcher()?.cosmosSequence.toString(), + wannabit.io.cosmostaion.data.model.req.Fee(txFee.gasWanted.toString(), txFee.gasFee), + msgs + ) + + val mapper = ObjectMapper() + mapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true) + val signPayloadDoc = mapper.writeValueAsString( + mapper.readValue(signPayload.toJson(), TreeMap::class.java) + ) + + val sigByte = grpcByteSignature(chain, signPayloadDoc.toByteArray(StandardCharsets.UTF_8)) + val signatures = + TxSignature.newBuilder().setPubKey(pubKey).setSignature(ByteString.copyFrom(sigByte)) + .build() + + val builder = Tx.newBuilder() + gnoSendMsg(msgSend).forEach { msgAny -> + builder.addMessages(msgAny) + } + return builder.setFee(txFee).addSignatures(signatures).setMemo(memo).build() + } + + fun signRpcCallBroadcastTx( + msgCall: MsgCall?, fee: Fee?, memo: String, chain: BaseChain + ): Tx { + val msgs: MutableList = mutableListOf() + val msg = Msgs( + "/vm.m_call", + send = "", + caller = chain.address, + pkg_path = msgCall?.pkgPath, + func = "Transfer", + args = listOf(msgCall?.getArgs(0).toString(), msgCall?.getArgs(1).toString()) + ) + msgs.add(msg) + val txFee = TxFee.newBuilder().setGasWanted(fee?.gasLimit ?: 10000000L) + .setGasFee(fee?.getAmount(0)?.amount + fee?.getAmount(0)?.denom).build() + val pubKey = + generateGrpcPubKeyFromPriv(chain, ECKey.fromPrivate(chain.privateKey).privateKeyAsHex) + + val signPayload = SignPayload( + chain.chainIdCosmos, + chain.cosmosFetcher()?.cosmosAccountNumber.toString(), + chain.cosmosFetcher()?.cosmosSequence.toString(), + wannabit.io.cosmostaion.data.model.req.Fee(txFee.gasWanted.toString(), txFee.gasFee), + msgs + ) + + val mapper = ObjectMapper() + mapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true) + val signPayloadDoc = mapper.writeValueAsString( + mapper.readValue(signPayload.toJson(), TreeMap::class.java) + ) + + val sigByte = grpcByteSignature(chain, signPayloadDoc.toByteArray(StandardCharsets.UTF_8)) + val signatures = + TxSignature.newBuilder().setPubKey(pubKey).setSignature(ByteString.copyFrom(sigByte)) + .build() + + val builder = Tx.newBuilder() + msgCallMsg(msgCall).forEach { msgAny -> + builder.addMessages(msgAny) + } + return builder.setFee(txFee).addSignatures(signatures).setMemo(memo).build() + } + private fun grpcTxBody( msgsAny: List?, memo: String, height: Long, chain: BaseChain? ): TxBody? { @@ -643,7 +762,8 @@ object Signer { private fun grpcSignerInfo( chain: BaseChain? ): SignerInfo { - val pubKey = generateGrpcPubKeyFromPriv(chain, ECKey.fromPrivate(chain?.privateKey).privateKeyAsHex) + val pubKey = + generateGrpcPubKeyFromPriv(chain, ECKey.fromPrivate(chain?.privateKey).privateKeyAsHex) val singleMode = ModeInfo.Single.newBuilder().setMode(SigningProto.SignMode.SIGN_MODE_DIRECT).build() val modeInfo = ModeInfo.newBuilder().setSingle(singleMode).build() diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/init/WalletSelectFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/init/WalletSelectFragment.kt index 8c2dc9d72..be4c37d9b 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/init/WalletSelectFragment.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/init/WalletSelectFragment.kt @@ -19,6 +19,7 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import net.i2p.crypto.eddsa.Utils import wannabit.io.cosmostaion.chain.BaseChain +import wannabit.io.cosmostaion.chain.CosmosEndPointType import wannabit.io.cosmostaion.chain.FetchState import wannabit.io.cosmostaion.chain.allChains import wannabit.io.cosmostaion.chain.majorClass.ChainBitCoin84 @@ -28,14 +29,14 @@ import wannabit.io.cosmostaion.common.BaseData import wannabit.io.cosmostaion.common.BaseKey import wannabit.io.cosmostaion.common.concurrentForEach import wannabit.io.cosmostaion.common.updateButtonView +import wannabit.io.cosmostaion.data.viewmodel.ApplicationViewModel +import wannabit.io.cosmostaion.data.viewmodel.account.AccountViewModel +import wannabit.io.cosmostaion.data.viewmodel.intro.WalletViewModel import wannabit.io.cosmostaion.database.Prefs import wannabit.io.cosmostaion.database.model.BaseAccount import wannabit.io.cosmostaion.database.model.BaseAccountType import wannabit.io.cosmostaion.databinding.FragmentWalletSelectBinding import wannabit.io.cosmostaion.ui.main.MainActivity -import wannabit.io.cosmostaion.data.viewmodel.ApplicationViewModel -import wannabit.io.cosmostaion.data.viewmodel.account.AccountViewModel -import wannabit.io.cosmostaion.data.viewmodel.intro.WalletViewModel class WalletSelectFragment : Fragment() { @@ -192,7 +193,9 @@ class WalletSelectFragment : Fragment() { } if (chain.fetchState == FetchState.IDLE || chain.fetchState == FetchState.BUSY) { - if (chain.supportCosmos() || chain is ChainSui || chain is ChainBitCoin84) { + if (chain.supportCosmos() || chain is ChainSui || chain is ChainBitCoin84 || chain.cosmosFetcher() + ?.endPointType(chain) == CosmosEndPointType.USE_RPC + ) { walletViewModel.balance(chain) } else { walletViewModel.evmBalance(chain) @@ -212,7 +215,8 @@ class WalletSelectFragment : Fragment() { } if (chain.fetchState == FetchState.IDLE || chain.fetchState == FetchState.BUSY) { - if (chain.supportCosmos() || chain is ChainSui || chain is ChainBitCoin84) { + if (chain.supportCosmos() || chain is ChainSui || chain is ChainBitCoin84 || chain.cosmosFetcher() + ?.endPointType(chain) == CosmosEndPointType.USE_RPC) { walletViewModel.balance(chain) } else { walletViewModel.evmBalance(chain) diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/init/WalletSelectViewHolder.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/init/WalletSelectViewHolder.kt index 8c9071dfe..0ad46e1a3 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/init/WalletSelectViewHolder.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/init/WalletSelectViewHolder.kt @@ -4,12 +4,14 @@ import android.content.Context import android.graphics.Color import android.os.Handler import android.os.Looper +import android.util.Log import android.view.View import android.widget.TextView import androidx.core.content.ContextCompat import androidx.recyclerview.widget.RecyclerView import wannabit.io.cosmostaion.R import wannabit.io.cosmostaion.chain.BaseChain +import wannabit.io.cosmostaion.chain.CosmosEndPointType import wannabit.io.cosmostaion.chain.FetchState import wannabit.io.cosmostaion.chain.PubKeyType import wannabit.io.cosmostaion.chain.evmClass.ChainOktEvm @@ -51,7 +53,7 @@ class WalletSelectViewHolder( ) { binding.apply { chainImg.setImageResource(chain.logo) - chainName.text = chain.name.uppercase() + chainName.text = chain.name if (chain.isEvmCosmos()) { chainAddress.text = chain.address @@ -233,7 +235,7 @@ class WalletSelectViewHolder( ) { binding.apply { chainImg.setImageResource(chain.logo) - chainName.text = chain.name.uppercase() + chainName.text = chain.name chainTypeBadge.visibility = View.GONE if (chain.isEvmCosmos()) { @@ -288,6 +290,7 @@ class WalletSelectViewHolder( } else { chainLegacy.visibility = View.GONE } + Log.e("Test12345 : ", chain.fetchState.toString()) when (chain.fetchState) { FetchState.SUCCESS -> { @@ -320,7 +323,7 @@ class WalletSelectViewHolder( chainDenom.text = chain.coinSymbol } - } else if (chain.supportCosmos()) { + } else if (chain.supportCosmos() || chain.cosmosFetcher()?.endPointType(chain) == CosmosEndPointType.USE_RPC) { BaseData.getAsset(chain.apiName, chain.stakeDenom)?.let { asset -> val availableAmount = chain.cosmosFetcher?.balanceAmount(chain.stakeDenom) diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/ChainEditViewHolder.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/ChainEditViewHolder.kt index 71c403b81..b98cc0b7f 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/main/ChainEditViewHolder.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/ChainEditViewHolder.kt @@ -46,7 +46,7 @@ class ChainEditViewHolder( binding.apply { updateView(chain, displayChains) chainImg.setImageResource(chain.logo) - chainName.text = chain.name.uppercase() + chainName.text = chain.name skeletonChainValue.visibility = View.VISIBLE skeletonAssetCnt.visibility = View.VISIBLE respondLayout.visibility = View.GONE @@ -162,7 +162,7 @@ class ChainEditViewHolder( binding.apply { updateView(chain, displayChains) chainImg.setImageResource(chain.logo) - chainName.text = chain.name.uppercase() + chainName.text = chain.name if (chain is ChainBitCoin84) { chainLegacy.visibility = View.VISIBLE diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/DashboardViewHolder.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/DashboardViewHolder.kt index 331e9c463..4b1e72bf0 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/main/DashboardViewHolder.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/DashboardViewHolder.kt @@ -50,7 +50,7 @@ class DashboardViewHolder( binding.apply { dashView.setBackgroundResource(R.drawable.item_bg) chainImg.setImageResource(chain.logo) - chainName.text = chain.name.uppercase() + chainName.text = chain.name dashView.heightInDp(114) proLayout.visibility = View.VISIBLE @@ -187,7 +187,7 @@ class DashboardViewHolder( binding.apply { dashView.setBackgroundResource(R.drawable.item_bg) chainImg.setImageResource(chain.logo) - chainName.text = chain.name.uppercase() + chainName.text = chain.name dashView.heightInDp(114) proLayout.visibility = View.VISIBLE @@ -316,7 +316,7 @@ class DashboardViewHolder( binding.apply { dashView.setBackgroundResource(R.drawable.item_bg) chainImg.setImageResource(chain.logo) - chainName.text = chain.name.uppercase() + chainName.text = chain.name handler.removeCallbacks(starEvmAddressAnimation) dashView.heightInDp(68) @@ -392,7 +392,7 @@ class DashboardViewHolder( binding.apply { dashView.setBackgroundResource(R.drawable.item_bg) chainImg.setImageResource(chain.logo) - chainName.text = chain.name.uppercase() + chainName.text = chain.name handler.removeCallbacks(starEvmAddressAnimation) dashView.heightInDp(68) diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/TokenEditAdapter.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/TokenEditAdapter.kt index a5bfe8284..333abb0e3 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/main/TokenEditAdapter.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/TokenEditAdapter.kt @@ -18,7 +18,7 @@ class TokenEditAdapter( private val selectChain: BaseChain, private val tokens: MutableList?, private val displayTokens: MutableList? -): RecyclerView.Adapter() { +) : RecyclerView.Adapter() { private var onItemClickListener: ((MutableList) -> Unit)? = null @@ -55,6 +55,14 @@ class TokenEditAdapter( } } + walletViewModel.editGrc20Balance.observe(lifecycleOwner) { contract -> + if (contract == token.contract) { + Handler(Looper.getMainLooper()).post { + notifyItemChanged(position) + } + } + } + holder.itemView.setOnClickListener { if (displayTokens?.contains(token.contract) == true) { displayTokens.removeIf { it == token.contract } diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/TokenEditFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/TokenEditFragment.kt index e0a21b7aa..f5ee3bef8 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/main/TokenEditFragment.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/TokenEditFragment.kt @@ -201,7 +201,13 @@ class TokenEditFragment : BottomSheetDialogFragment() { recycler.setHasFixedSize(true) recycler.layoutManager = LinearLayoutManager(requireContext()) tokenEditAdapter = - TokenEditAdapter(walletViewModel, viewLifecycleOwner, fromChain, searchTokens, displayTokens) + TokenEditAdapter( + walletViewModel, + viewLifecycleOwner, + fromChain, + searchTokens, + displayTokens + ) recycler.adapter = tokenEditAdapter tokenEditAdapter.setOnItemClickListener { selectDisplayTokens -> @@ -230,7 +236,10 @@ class TokenEditFragment : BottomSheetDialogFragment() { newText?.let { searchTxt -> allTokens?.filter { it.type == tokenTypes[tokenSegment.position] } ?.filter { token -> - token.symbol.contains(searchTxt, ignoreCase = true) || token.contract.contains(searchTxt, ignoreCase = true) + token.symbol.contains( + searchTxt, + ignoreCase = true + ) || token.contract.contains(searchTxt, ignoreCase = true) }?.let { searchTokens?.addAll(it) } } } @@ -251,7 +260,10 @@ class TokenEditFragment : BottomSheetDialogFragment() { newText?.let { searchTxt -> allTokens?.let { tokens -> searchTokens?.addAll(tokens.filter { - it.symbol.contains(searchTxt, ignoreCase = true) || it.contract.contains(searchTxt, ignoreCase = true) + it.symbol.contains( + searchTxt, + ignoreCase = true + ) || it.contract.contains(searchTxt, ignoreCase = true) }) } } @@ -298,6 +310,9 @@ class TokenEditFragment : BottomSheetDialogFragment() { } else if (fromChain.isSupportCw20()) { Prefs.setDisplayCw20s(account.id, fromChain.tag, tokenList) + } else if (fromChain.isSupportGrc20()) { + Prefs.setDisplayGrc20s(account.id, fromChain.tag, tokenList) + } else { Prefs.setDisplayErc20s(account.id, fromChain.tag, tokenList) } diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/TokenEditViewHolder.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/TokenEditViewHolder.kt index e00810e09..60eaad6fb 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/main/TokenEditViewHolder.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/TokenEditViewHolder.kt @@ -41,6 +41,10 @@ class TokenEditViewHolder( } } else { + skeletonTokenAmount.visibility = View.VISIBLE + skeletonTokenValue.visibility = View.VISIBLE + tokenAmount.text = "" + tokenValue.text = "" CoroutineScope(Dispatchers.IO).launch { val channel = chain.cosmosFetcher?.getChannel() walletViewModel.cw20Balance(channel, chain, token) @@ -67,6 +71,32 @@ class TokenEditViewHolder( } } } + + } ?: run { + chain.cosmosFetcher()?.grc20Tokens?.firstOrNull { it.chain == chain.apiName && it.contract == token.contract } + ?.let { token -> + token.amount?.toBigDecimal()?.movePointLeft(token.decimals) + ?.setScale(6, RoundingMode.DOWN)?.let { amount -> + if (token.fetched) { + skeletonTokenAmount.visibility = View.GONE + skeletonTokenValue.visibility = View.GONE + tokenAmount.text = formatAmount(amount.toPlainString(), 6) + chain.cosmosFetcher?.let { + tokenValue.text = + formatAssetValue(it.grc20TokenValue(token.contract)) + } + + } else { + skeletonTokenAmount.visibility = View.VISIBLE + skeletonTokenValue.visibility = View.VISIBLE + tokenAmount.text = "" + tokenValue.text = "" + CoroutineScope(Dispatchers.IO).launch { + walletViewModel.grc20Balance(chain, token) + } + } + } + } } } } diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/AboutFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/AboutFragment.kt index 2255ede27..1c7cafd99 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/AboutFragment.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/AboutFragment.kt @@ -87,7 +87,7 @@ class AboutFragment : Fragment() { } chainParam = selectedChain.getChainParam() - chainName.text = selectedChain.name.uppercase() + chainName.text = selectedChain.name chainParam?.getAsJsonObject("params")?.getAsJsonObject("chainlist_params")?.let { if (Prefs.language == BaseUtils.LANGUAGE_KOREAN || Locale.getDefault().language == "ko") { chainDescription.text = it.getAsJsonObject("description")?.get("ko")?.asString diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/CoinAdapter.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/CoinAdapter.kt index 6217a6516..174a0bf6f 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/CoinAdapter.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/CoinAdapter.kt @@ -26,6 +26,7 @@ class CoinAdapter( private val etcCoins: MutableList, private val cw20TokenCoins: MutableList, private val erc20TokenCoins: MutableList, + private val grc20TokenCoins: MutableList, ) : RecyclerView.Adapter() { private var onItemClickListener: ((BaseChain, String, Int, CoinType) -> Unit)? = null @@ -44,6 +45,8 @@ class CoinAdapter( const val VIEW_TYPE_CW20TOKEN_ITEM = 10 const val VIEW_TYPE_ERC20TOKEN_HEADER = 11 const val VIEW_TYPE_ERC20TOKEN_ITEM = 12 + const val VIEW_TYPE_GRC20TOKEN_HEADER = 13 + const val VIEW_TYPE_GRC20TOKEN_ITEM = 14 } private var items: MutableList = mutableListOf() @@ -60,7 +63,7 @@ class CoinAdapter( else -> { setItems( - stakeCoins, nativeCoins, ibcCoins, bridgeCoins, cw20TokenCoins, erc20TokenCoins + stakeCoins, nativeCoins, ibcCoins, bridgeCoins, cw20TokenCoins, erc20TokenCoins, grc20TokenCoins ) } } @@ -113,7 +116,8 @@ class CoinAdapter( ibcCoins: MutableList, bridgeCoins: MutableList, cw20TokenCoins: MutableList, - erc20TokenCoins: MutableList + erc20TokenCoins: MutableList, + grc20TokenCoins: MutableList ) { val tempList = mutableListOf() if (stakeCoins.isNotEmpty()) { @@ -139,13 +143,17 @@ class CoinAdapter( tempList.add(ListItem(ItemType.ERC20TOKEN_HEADER)) erc20TokenCoins.forEach { tempList.add(ListItem(ItemType.ERC20TOKEN_ITEM, it)) } } + if (grc20TokenCoins.isNotEmpty()) { + tempList.add(ListItem(ItemType.GRC20TOKEN_HEADER)) + grc20TokenCoins.forEach { tempList.add(ListItem(ItemType.GRC20TOKEN_ITEM, it)) } + } items = tempList notifyDataSetChanged() } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { return when (viewType) { - VIEW_TYPE_NATIVE_HEADER, VIEW_TYPE_IBC_HEADER, VIEW_TYPE_BRIDGE_HEADER, VIEW_TYPE_ETC_HEADER, VIEW_TYPE_CW20TOKEN_HEADER, VIEW_TYPE_ERC20TOKEN_HEADER -> { + VIEW_TYPE_NATIVE_HEADER, VIEW_TYPE_IBC_HEADER, VIEW_TYPE_BRIDGE_HEADER, VIEW_TYPE_ETC_HEADER, VIEW_TYPE_CW20TOKEN_HEADER, VIEW_TYPE_ERC20TOKEN_HEADER, VIEW_TYPE_GRC20TOKEN_HEADER -> { val binding = ItemHeaderBinding.inflate( LayoutInflater.from(parent.context), parent, false ) @@ -173,7 +181,7 @@ class CoinAdapter( CoinEtcViewHolder(parent.context, binding) } - VIEW_TYPE_CW20TOKEN_ITEM, VIEW_TYPE_ERC20TOKEN_ITEM -> { + VIEW_TYPE_CW20TOKEN_ITEM, VIEW_TYPE_ERC20TOKEN_ITEM, VIEW_TYPE_GRC20TOKEN_ITEM -> { val binding = ItemCosmosLineTokenBinding.inflate( LayoutInflater.from(parent.context), parent, false ) @@ -281,6 +289,8 @@ class CoinAdapter( ItemType.CW20TOKEN_ITEM -> VIEW_TYPE_CW20TOKEN_ITEM ItemType.ERC20TOKEN_HEADER -> VIEW_TYPE_ERC20TOKEN_HEADER ItemType.ERC20TOKEN_ITEM -> VIEW_TYPE_ERC20TOKEN_ITEM + ItemType.GRC20TOKEN_HEADER -> VIEW_TYPE_GRC20TOKEN_HEADER + ItemType.GRC20TOKEN_ITEM -> VIEW_TYPE_GRC20TOKEN_ITEM } } @@ -314,6 +324,10 @@ class CoinAdapter( headerTitle.text = context.getString(R.string.str_contract_tokens) headerCnt.text = cw20TokenCoins.size.toString() + } else if (getItemViewType(position) == VIEW_TYPE_GRC20TOKEN_HEADER) { + headerTitle.text = context.getString(R.string.str_grc20_tokens) + headerCnt.text = grc20TokenCoins.size.toString() + } else { headerTitle.text = if (chain is ChainOktEvm) { context.getString(R.string.str_kip20_tokens) @@ -332,7 +346,7 @@ class CoinAdapter( } enum class ItemType { - STAKE_ITEM, NATIVE_HEADER, NATIVE_ITEM, IBC_HEADER, IBC_ITEM, BRIDGE_HEADER, BRIDGE_ITEM, ETC_HEADER, ETC_ITEM, CW20TOKEN_HEADER, CW20TOKEN_ITEM, ERC20TOKEN_HEADER, ERC20TOKEN_ITEM + STAKE_ITEM, NATIVE_HEADER, NATIVE_ITEM, IBC_HEADER, IBC_ITEM, BRIDGE_HEADER, BRIDGE_ITEM, ETC_HEADER, ETC_ITEM, CW20TOKEN_HEADER, CW20TOKEN_ITEM, ERC20TOKEN_HEADER, ERC20TOKEN_ITEM, GRC20TOKEN_HEADER, GRC20TOKEN_ITEM } data class ListItem(val type: ItemType, val coin: Coin? = null) \ No newline at end of file diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/CoinFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/CoinFragment.kt index 621ef9891..5da0e9bde 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/CoinFragment.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/CoinFragment.kt @@ -6,6 +6,7 @@ import android.os.Build import android.os.Bundle import android.os.Handler import android.os.Looper +import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -76,6 +77,11 @@ class CoinFragment : Fragment(), CoinFragmentInteraction { private var displayErc20TokenCoins = mutableListOf() private val searchErc20TokenCoins = mutableListOf() + private val grc20TokenCoins = mutableListOf() + private val allGrc20TokenCoins = mutableListOf() + private var displayGrc20TokenCoins = mutableListOf() + private val searchGrc20TokenCoins = mutableListOf() + private var isClickable = true companion object { @@ -146,6 +152,13 @@ class CoinFragment : Fragment(), CoinFragmentInteraction { searchErc20TokenCoins.clear() displayErc20TokenCoins.clear() + val grc20Tokens = mutableListOf() + grc20Tokens.clear() + grc20TokenCoins.clear() + allGrc20TokenCoins.clear() + searchGrc20TokenCoins.clear() + displayGrc20TokenCoins.clear() + when (selectedChain) { is ChainOktEvm -> { (selectedChain as ChainOktEvm).oktFetcher?.oktAccountInfo?.get("value")?.asJsonObject?.get( @@ -389,6 +402,81 @@ class CoinFragment : Fragment(), CoinFragmentInteraction { searchCw20TokenCoins.addAll(cw20TokenCoins) } } + + if (selectedChain.cosmosFetcher?.grc20Tokens?.isNotEmpty() == true) { + selectedChain.cosmosFetcher?.grc20Tokens?.let { grc20Tokens.addAll(it) } + grc20Tokens.sortBy { it.symbol.lowercase() } + + Prefs.getDisplayGrc20s(account.id, selectedChain.tag)?.let { userCustomTokens -> + grc20Tokens.sortWith { o1, o2 -> + val address0 = o1.contract + val address1 = o2.contract + + val containsToken0 = userCustomTokens.contains(address0) + val containsToken1 = userCustomTokens.contains(address1) + + when { + containsToken0 && !containsToken1 -> -1 + !containsToken0 && containsToken1 -> 1 + else -> { + val value0 = selectedChain.cosmosFetcher?.grc20TokenValue(address0) + ?: BigDecimal.ZERO + val value1 = selectedChain.cosmosFetcher?.grc20TokenValue(address1) + ?: BigDecimal.ZERO + value1.compareTo(value0) + } + } + } + + grc20Tokens.forEach { token -> + if (userCustomTokens.contains(token.contract) && !displayGrc20TokenCoins.contains( + token + ) + ) { + displayGrc20TokenCoins.add(token) + grc20TokenCoins.add( + Coin( + token.contract, token.amount.toString(), CoinType.GRC20 + ) + ) + } + } + allGrc20TokenCoins.addAll(grc20Tokens) + searchGrc20TokenCoins.addAll(grc20TokenCoins) + + } ?: run { + grc20Tokens.sortWith { o1, o2 -> + when { + BigDecimal.ZERO < o1.amount?.toBigDecimal() && BigDecimal.ZERO >= o2.amount?.toBigDecimal() -> -1 + BigDecimal.ZERO >= o1.amount?.toBigDecimal() && BigDecimal.ZERO < o2.amount?.toBigDecimal() -> 1 + else -> { + val value0 = selectedChain.cosmosFetcher?.grc20TokenValue(o1.contract) + ?: BigDecimal.ZERO + val value1 = selectedChain.cosmosFetcher?.grc20TokenValue(o2.contract) + ?: BigDecimal.ZERO + value1.compareTo(value0) + } + } + } + + grc20Tokens.forEach { token -> + if (BigDecimal.ZERO < token.amount?.toBigDecimal() && !displayGrc20TokenCoins.contains( + token + ) && token.wallet_preload == true + ) { + displayGrc20TokenCoins.add(token) + grc20TokenCoins.add( + Coin( + token.contract, token.amount.toString(), CoinType.GRC20 + ) + ) + } + } + allGrc20TokenCoins.addAll(grc20Tokens) + searchGrc20TokenCoins.addAll(grc20TokenCoins) + Log.e("Test12345 : ", searchGrc20TokenCoins.toString()) + } + } } initRecyclerView() @@ -405,7 +493,8 @@ class CoinFragment : Fragment(), CoinFragmentInteraction { searchIbcCoins, searchEtcCoins, searchCw20TokenCoins, - searchErc20TokenCoins + searchErc20TokenCoins, + searchGrc20TokenCoins ) binding.recycler.apply { setHasFixedSize(true) @@ -433,6 +522,10 @@ class CoinFragment : Fragment(), CoinFragmentInteraction { SendAssetType.ONLY_EVM_ERC20 } + CoinType.GRC20 -> { + SendAssetType.ONLY_COSMOS_GRC20 + } + else -> { SendAssetType.ONLY_COSMOS_COIN } @@ -456,7 +549,7 @@ class CoinFragment : Fragment(), CoinFragmentInteraction { private fun initSearchView() { binding.apply { - searchBar.visibleOrGone(searchStakeCoins.size + searchNativeCoins.size + searchBridgeCoins.size + searchIbcCoins.size + searchEtcCoins.size + searchCw20TokenCoins.size + searchErc20TokenCoins.size > 15) + searchBar.visibleOrGone(searchStakeCoins.size + searchNativeCoins.size + searchBridgeCoins.size + searchIbcCoins.size + searchEtcCoins.size + searchCw20TokenCoins.size + searchErc20TokenCoins.size + searchGrc20TokenCoins.size > 15) searchView.setQuery("", false) searchView.clearFocus() searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener { @@ -472,6 +565,7 @@ class CoinFragment : Fragment(), CoinFragmentInteraction { searchEtcCoins.clear() searchCw20TokenCoins.clear() searchErc20TokenCoins.clear() + searchGrc20TokenCoins.clear() if (StringUtils.isEmpty(newText)) { searchStakeCoins.addAll(stakeCoins) @@ -481,6 +575,7 @@ class CoinFragment : Fragment(), CoinFragmentInteraction { searchEtcCoins.addAll(etcCoins) searchCw20TokenCoins.addAll(cw20TokenCoins) searchErc20TokenCoins.addAll(erc20TokenCoins) + searchGrc20TokenCoins.addAll(grc20TokenCoins) } else { newText?.let { searchTxt -> @@ -528,10 +623,16 @@ class CoinFragment : Fragment(), CoinFragmentInteraction { selectedChain, selectedChain.apiName, coin.denom )?.symbol?.contains(searchTxt, ignoreCase = true) ?: false }) + + searchGrc20TokenCoins.addAll(grc20TokenCoins.filter { coin -> + BaseData.getToken( + selectedChain, selectedChain.apiName, coin.denom + )?.symbol?.contains(searchTxt, ignoreCase = true) ?: false + }) } } - if (searchStakeCoins.isEmpty() && searchNativeCoins.isEmpty() && searchBridgeCoins.isEmpty() && searchIbcCoins.isEmpty() && searchEtcCoins.isEmpty() && searchErc20TokenCoins.isEmpty()) { + if (searchStakeCoins.isEmpty() && searchNativeCoins.isEmpty() && searchBridgeCoins.isEmpty() && searchIbcCoins.isEmpty() && searchEtcCoins.isEmpty() && searchErc20TokenCoins.isEmpty() && searchGrc20TokenCoins.isEmpty()) { emptyLayout.visibility = View.VISIBLE recycler.visibility = View.GONE } else { @@ -558,7 +659,8 @@ class CoinFragment : Fragment(), CoinFragmentInteraction { searchIbcCoins, searchBridgeCoins, searchCw20TokenCoins, - searchErc20TokenCoins + searchErc20TokenCoins, + searchGrc20TokenCoins ) } } @@ -600,6 +702,7 @@ class CoinFragment : Fragment(), CoinFragmentInteraction { ) ) } + bitStaking.visibility = View.GONE } } @@ -629,7 +732,7 @@ class CoinFragment : Fragment(), CoinFragmentInteraction { ApplicationViewModel.shared.fetchedResult.observe(viewLifecycleOwner) { tag -> if (selectedChain.tag == tag) { - if (selectedChain.isSupportCw20() || selectedChain.isSupportErc20()) { + if (selectedChain.isSupportCw20() || selectedChain.isSupportErc20() || selectedChain.isSupportGrc20()) { ApplicationViewModel.shared.fetchedTokenResult.observe(viewLifecycleOwner) { initData() binding.loading.visibility = View.GONE @@ -672,6 +775,8 @@ class CoinFragment : Fragment(), CoinFragmentInteraction { (allCw20TokenCoins + allErc20TokenCoins).toMutableList() } else if (selectedChain.isSupportCw20()) { allCw20TokenCoins + } else if (selectedChain.isSupportGrc20()) { + allGrc20TokenCoins } else { allErc20TokenCoins } @@ -679,6 +784,8 @@ class CoinFragment : Fragment(), CoinFragmentInteraction { (displayCw20TokenCoins.map { it.contract } + displayErc20TokenCoins.map { it.contract }).toMutableList() } else if (selectedChain.isSupportCw20()) { displayCw20TokenCoins.map { it.contract } + } else if (selectedChain.isSupportGrc20()) { + displayGrc20TokenCoins.map { it.contract } } else { displayErc20TokenCoins.map { it.contract } } diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/CosmosDetailFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/CosmosDetailFragment.kt index 5cc4c5f0d..52bc7ee3d 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/CosmosDetailFragment.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/CosmosDetailFragment.kt @@ -235,7 +235,7 @@ class CosmosDetailFragment : Fragment() { } } - val supportToken = selectedChain.isSupportCw20() || selectedChain.isSupportErc20() + val supportToken = selectedChain.isSupportCw20() || selectedChain.isSupportErc20() || selectedChain.isSupportGrc20() btnAddToken.visibleOrGone(supportToken) val tableTitles = mutableListOf() diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/HistoryViewHolder.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/HistoryViewHolder.kt index 4f3bf8a73..9db6b8fae 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/HistoryViewHolder.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/HistoryViewHolder.kt @@ -3,6 +3,7 @@ package wannabit.io.cosmostaion.ui.main.chain.cosmos import android.content.Context import android.graphics.Color import android.graphics.PorterDuff +import android.util.Log import android.view.View import androidx.core.content.ContextCompat import androidx.recyclerview.widget.RecyclerView @@ -294,14 +295,21 @@ class HistoryViewHolder( txTime.text = dpTimeToMonth(historyGroup.second["txTime"].asString.toLong()) if (historyGroup.second["tokenAddress"].asString.isEmpty()) { - val amount = historyGroup.second["amount"].asString.toBigDecimal() - if (amount > BigDecimal.ZERO) { - txAmount.text = formatAmount( - historyGroup.second["amount"].asString, 18 - ) - txDenom.text = chain.coinSymbol.uppercase() - txDenom.setTextColor(Color.parseColor("#ffffff")) + if (historyGroup.second["amount"].asString.isNotEmpty()) { + val amount = historyGroup.second["amount"].asString.toBigDecimal() + if (amount > BigDecimal.ZERO) { + txAmount.text = formatAmount( + historyGroup.second["amount"].asString, 18 + ) + txDenom.text = chain.coinSymbol.uppercase() + txDenom.setTextColor(Color.parseColor("#ffffff")) + } else { + txAmount.text = "" + txDenom.text = "-" + txDenom.setTextColor(Color.parseColor("#ffffff")) + txCnt.visibility = View.GONE + } } else { txAmount.text = "" txDenom.text = "-" diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/TokenViewHolder.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/TokenViewHolder.kt index 06b59a47b..a8f6f66da 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/TokenViewHolder.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/cosmos/TokenViewHolder.kt @@ -100,6 +100,39 @@ class TokenViewHolder( } } } + + } ?: run { + chain.cosmosFetcher()?.grc20Tokens?.firstOrNull { token -> token.chain == chain.apiName && token.contract == coin.denom } + ?.let { token -> + tokenImg.setTokenImg(token.image) + tokenImg.clipToOutline = true + tokenName.text = token.symbol + + tokenPrice.text = formatAssetValue(BaseData.getPrice(token.coinGeckoId)) + BaseData.lastUpDown(token.coinGeckoId).let { lastUpDown -> + tokenPriceChange.priceChangeStatusColor(lastUpDown) + tokenPriceChange.text = priceChangeStatus(lastUpDown) + } + + token.amount?.toBigDecimal()?.movePointLeft(token.decimals) + ?.setScale(6, RoundingMode.DOWN)?.let { amount -> + if (Prefs.hideValue) { + coinAmount.visibility = View.GONE + coinAmountValue.visibility = View.GONE + hideValue.visibility = View.VISIBLE + } else { + coinAmount.visibility = View.VISIBLE + coinAmountValue.visibility = View.VISIBLE + hideValue.visibility = View.GONE + + coinAmount.text = formatAmount(amount.toPlainString(), 6) + chain.cosmosFetcher?.let { + coinAmountValue.text = + formatAssetValue(it.grc20TokenValue(token.contract)) + } + } + } + } } } } diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/evm/EvmAboutFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/evm/EvmAboutFragment.kt index c222fcb41..992229a35 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/evm/EvmAboutFragment.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/evm/EvmAboutFragment.kt @@ -73,7 +73,7 @@ class EvmAboutFragment : Fragment() { } chainParam = selectedEvmChain.getChainParam() - chainName.text = selectedEvmChain.name.uppercase() + chainName.text = selectedEvmChain.name chainParam?.getAsJsonObject("params")?.getAsJsonObject("chainlist_params")?.let { if (Prefs.language == BaseUtils.LANGUAGE_KOREAN || Locale.getDefault().language == "ko") { chainDescription.text = it.getAsJsonObject("description")?.get("ko")?.asString diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/major/MajorAboutFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/major/MajorAboutFragment.kt index 6a817cc86..79c9e64dc 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/major/MajorAboutFragment.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/major/MajorAboutFragment.kt @@ -81,7 +81,7 @@ class MajorAboutFragment : Fragment() { } chainParam = selectedChain.getChainParam() - chainName.text = selectedChain.name.uppercase() + chainName.text = selectedChain.name chainParam?.getAsJsonObject("params")?.getAsJsonObject("chainlist_params")?.let { if (Prefs.language == BaseUtils.LANGUAGE_KOREAN || Locale.getDefault().language == "ko") { chainDescription.text = it.getAsJsonObject("description")?.get("ko")?.asString diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/major/MajorCryptoFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/major/MajorCryptoFragment.kt index 2411043f9..53ca91814 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/major/MajorCryptoFragment.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/chain/major/MajorCryptoFragment.kt @@ -1,9 +1,11 @@ package wannabit.io.cosmostaion.ui.main.chain.major +import android.content.Intent import android.os.Build import android.os.Bundle import android.os.Handler import android.os.Looper +import android.os.Parcelable import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -19,6 +21,7 @@ import org.apache.commons.lang3.StringUtils import wannabit.io.cosmostaion.R import wannabit.io.cosmostaion.chain.BaseChain import wannabit.io.cosmostaion.chain.FetchState +import wannabit.io.cosmostaion.chain.PubKeyType import wannabit.io.cosmostaion.chain.fetcher.suiCoinSymbol import wannabit.io.cosmostaion.chain.majorClass.ChainBitCoin84 import wannabit.io.cosmostaion.chain.majorClass.ChainSui @@ -28,6 +31,7 @@ import wannabit.io.cosmostaion.common.makeToast import wannabit.io.cosmostaion.common.visibleOrGone import wannabit.io.cosmostaion.data.viewmodel.ApplicationViewModel import wannabit.io.cosmostaion.databinding.FragmentCoinBinding +import wannabit.io.cosmostaion.ui.main.dapp.DappActivity import wannabit.io.cosmostaion.ui.tx.genTx.CommonTransferFragment import wannabit.io.cosmostaion.ui.tx.genTx.SendAssetType import java.math.BigDecimal @@ -90,6 +94,17 @@ class MajorCryptoFragment : Fragment() { binding.apply { dropMoney.visibility = View.GONE dydxTrade.visibility = View.GONE + bitStaking.visibleOrGone(selectedChain.isSupportStaking() && selectedChain.accountKeyType.pubkeyType == PubKeyType.BTC_NATIVE_SEGWIT) + + bitStaking.setOnClickListener { + if (selectedChain.btcStakingDapp().isNotEmpty()) { + Intent(requireActivity(), DappActivity::class.java).apply { + putExtra("dapp", selectedChain.btcStakingDapp()) + putExtra("selectedChain", selectedChain as Parcelable) + startActivity(this) + } + } + } } } diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/dapp/DappActivity.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/dapp/DappActivity.kt index 0c5504ca3..1c5735519 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/main/dapp/DappActivity.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/dapp/DappActivity.kt @@ -22,6 +22,7 @@ import android.webkit.WebView import android.webkit.WebViewClient import androidx.appcompat.app.AlertDialog import androidx.core.content.ContextCompat +import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.lifecycleScope import com.cosmos.tx.v1beta1.ServiceGrpc import com.cosmos.tx.v1beta1.ServiceProto.BroadcastTxRequest @@ -53,9 +54,12 @@ import org.web3j.protocol.http.HttpService import wannabit.io.cosmostaion.BuildConfig import wannabit.io.cosmostaion.R import wannabit.io.cosmostaion.chain.BaseChain +import wannabit.io.cosmostaion.chain.PubKeyType import wannabit.io.cosmostaion.chain.allChains import wannabit.io.cosmostaion.chain.cosmosClass.ChainInjective +import wannabit.io.cosmostaion.chain.majorClass.ChainBitCoin84 import wannabit.io.cosmostaion.chain.majorClass.ChainSui +import wannabit.io.cosmostaion.chain.testnetClass.ChainBitcoin84Testnet import wannabit.io.cosmostaion.common.BaseActivity import wannabit.io.cosmostaion.common.BaseConstant.COSMOS_KEY_TYPE_PUBLIC import wannabit.io.cosmostaion.common.BaseConstant.ETHERMINT_KEY_TYPE_PUBLIC @@ -74,6 +78,12 @@ import wannabit.io.cosmostaion.data.model.req.JsonRpcRequest import wannabit.io.cosmostaion.data.model.req.PubKey import wannabit.io.cosmostaion.data.model.req.Signature import wannabit.io.cosmostaion.data.model.res.NetworkResult +import wannabit.io.cosmostaion.data.repository.tx.TxRepositoryImpl +import wannabit.io.cosmostaion.data.repository.wallet.WalletRepositoryImpl +import wannabit.io.cosmostaion.data.viewmodel.intro.WalletViewModel +import wannabit.io.cosmostaion.data.viewmodel.intro.WalletViewModelProviderFactory +import wannabit.io.cosmostaion.data.viewmodel.tx.TxViewModel +import wannabit.io.cosmostaion.data.viewmodel.tx.TxViewModelProviderFactory import wannabit.io.cosmostaion.database.model.BaseAccountType import wannabit.io.cosmostaion.databinding.ActivityDappBinding import wannabit.io.cosmostaion.sign.Signer @@ -92,9 +102,11 @@ class DappActivity : BaseActivity() { private var selectChain: BaseChain? = null private var selectEvmChain: BaseChain? = null private var selectMajorChain: BaseChain? = null + private var selectBitcoin: BaseChain? = null private var rpcUrl: String? = null private var web3j: Web3j? = null private var wcUrl: String? = "" + private var bitNetwork: String = "mainnet" private var walletConnectURI: String? = null private var currentV2PairingUri: String? = null @@ -105,11 +117,21 @@ class DappActivity : BaseActivity() { private var currentEvmChainId: String? = null + private var currentMessageJson: JSONObject = JSONObject() + private var currentMessageId: String = "" + private var bitToAddress: String = "" + private var bitSatAmount: String = "" + + private lateinit var walletViewModel: WalletViewModel + private lateinit var txViewModel: TxViewModel + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding = ActivityDappBinding.inflate(layoutInflater) setContentView(binding.root) + initViewModel() + setUpObserve() allChains = initAllKeyData() } @@ -130,6 +152,25 @@ class DappActivity : BaseActivity() { (intent.getParcelableExtra("selectedEvmChain")) as? BaseChain } selectEvmChain = allChains?.firstOrNull { it.name == ecoChain?.name } + + val ecoMajorChain = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + intent.getParcelableExtra("selectedChain", BaseChain::class.java) + } else { + (intent.getParcelableExtra("selectedChain")) as? BaseChain + } + selectBitcoin = allChains?.firstOrNull { it.tag == ecoMajorChain?.tag } + } + + private fun initViewModel() { + val walletRepository = WalletRepositoryImpl() + val walletViewModelProviderFactory = WalletViewModelProviderFactory(walletRepository) + walletViewModel = ViewModelProvider( + this, walletViewModelProviderFactory + )[WalletViewModel::class.java] + + val txRepository = TxRepositoryImpl() + val txViewModelProviderFactory = TxViewModelProviderFactory(txRepository) + txViewModel = ViewModelProvider(this, txViewModelProviderFactory)[TxViewModel::class.java] } private fun initAllKeyData(): MutableList { @@ -437,8 +478,7 @@ class DappActivity : BaseActivity() { "cosmos_signDirect" -> { val signBundle = signBundle(id, params, "sign_direct") - showSignDialog( - signBundle, + showSignDialog(signBundle, object : PopUpCosmosSignFragment.WcSignRawDataListener { override fun sign(id: Long, data: String) { approveSignDirectV2Request(id, data, sessionRequest) @@ -452,8 +492,7 @@ class DappActivity : BaseActivity() { "cosmos_signAmino" -> { val signBundle = signBundle(id, params, "sign_amino") - showSignDialog( - signBundle, + showSignDialog(signBundle, object : PopUpCosmosSignFragment.WcSignRawDataListener { override fun sign(id: Long, data: String) { approveSignAminoV2Request(id, data, sessionRequest) @@ -650,6 +689,23 @@ class DappActivity : BaseActivity() { } } + private fun showBitSignDialog( + bundle: Bundle, + signListener: PopUpBitSignFragment.WcSignRawDataListener + ) { + bundle.getString("data")?.let { data -> + PopUpBitSignFragment( + selectBitcoin, + bundle.getLong("id"), + data, + bundle.getString("method"), + signListener + ).show( + supportFragmentManager, PopUpSuiSignFragment::class.java.name + ) + } + } + private val dappWebViewClient = object : WebViewClient() { override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) { super.onPageStarted(view, url, favicon) @@ -897,8 +953,7 @@ class DappActivity : BaseActivity() { "cos_signMessage" -> { val params = messageJson.getJSONObject("params") val signBundle = signBundle(0, params.toString(), "sign_message") - showSignDialog( - signBundle, + showSignDialog(signBundle, object : PopUpCosmosSignFragment.WcSignRawDataListener { override fun sign(id: Long, data: String) { approveSignMessageRequest(messageJson, messageId, data) @@ -915,8 +970,7 @@ class DappActivity : BaseActivity() { "cos_signAmino" -> { val params = messageJson.getJSONObject("params") val signBundle = signBundle(0, params.toString(), "sign_amino") - showSignDialog( - signBundle, + showSignDialog(signBundle, object : PopUpCosmosSignFragment.WcSignRawDataListener { override fun sign(id: Long, data: String) { approveSignAminoInjectRequest(messageJson, messageId, data) @@ -933,8 +987,7 @@ class DappActivity : BaseActivity() { "cos_signDirect" -> { val params = messageJson.getJSONObject("params") val signBundle = signBundle(0, params.toString(), "sign_direct") - showSignDialog( - signBundle, + showSignDialog(signBundle, object : PopUpCosmosSignFragment.WcSignRawDataListener { override fun sign(id: Long, data: String) { approveSignDirectInjectRequest(messageJson, messageId, data) @@ -979,8 +1032,7 @@ class DappActivity : BaseActivity() { // evm method "eth_requestAccounts", "wallet_requestPermissions" -> { - val address = - allChains?.firstOrNull { chain -> chain.supportEvm }?.evmAddress + val address = allChains?.firstOrNull { chain -> chain.supportEvm }?.evmAddress appToWebResult( messageJson, JSONArray(listOf(address)), messageId ) @@ -988,7 +1040,8 @@ class DappActivity : BaseActivity() { "wallet_switchEthereumChain" -> { lifecycleScope.launch(Dispatchers.IO) { - val evmChainIds = allChains?.map { chain -> chain.chainIdEvm.uppercase() }?.distinct() + val evmChainIds = + allChains?.map { chain -> chain.chainIdEvm.uppercase() }?.distinct() val chainId = (messageJson.getJSONArray("params") .get(0) as JSONObject).getString("chainId") @@ -1233,7 +1286,8 @@ class DappActivity : BaseActivity() { "personal_sign" -> { val params = messageJson.getJSONArray("params") val signBundle = signBundle(0, params.toString(), "personal_sign") - showEvmSignDialog(signBundle, + showEvmSignDialog( + signBundle, object : PopUpEvmSignFragment.WcSignRawDataListener { override fun sign(id: Long, data: String) { appToWebResult( @@ -1256,8 +1310,7 @@ class DappActivity : BaseActivity() { return } val signBundle = signBundle(0, params.toString(), "eth_signTypedData") - showEvmSignDialog( - signBundle, + showEvmSignDialog(signBundle, object : PopUpEvmSignFragment.WcSignRawDataListener { override fun sign(id: Long, data: String) { appToWebResult( @@ -1275,8 +1328,7 @@ class DappActivity : BaseActivity() { "eth_sendTransaction" -> { val params = messageJson.getJSONArray("params") val signBundle = signBundle(0, params[0].toString(), "eth_sendTransaction") - showEvmSignDialog( - signBundle, + showEvmSignDialog(signBundle, object : PopUpEvmSignFragment.WcSignRawDataListener { override fun sign(id: Long, data: String) { lifecycleScope.launch(Dispatchers.IO) { @@ -1366,8 +1418,7 @@ class DappActivity : BaseActivity() { "sui_signTransaction", "sui_signTransactionBlock" -> { val params = messageJson.getJSONObject("params") val signBundle = signBundle(0, params.toString(), "sui_signTransaction") - showSuiSignDialog( - signBundle, + showSuiSignDialog(signBundle, object : PopUpSuiSignFragment.WcSignRawDataListener { override fun sign(id: Long, data: String, signature: String) { val signed = JSONObject() @@ -1388,8 +1439,7 @@ class DappActivity : BaseActivity() { val params = messageJson.getJSONObject("params") val signBundle = signBundle(0, params.toString(), "sui_signAndExecuteTransactionBlock") - showSuiSignDialog( - signBundle, + showSuiSignDialog(signBundle, object : PopUpSuiSignFragment.WcSignRawDataListener { override fun sign(id: Long, data: String, signature: String) { approveSuiSignExecuteRequest( @@ -1412,8 +1462,7 @@ class DappActivity : BaseActivity() { return } val signBundle = signBundle(0, params.toString(), "sui_signMessage") - showSuiSignDialog( - signBundle, + showSuiSignDialog(signBundle, object : PopUpSuiSignFragment.WcSignRawDataListener { override fun sign(id: Long, data: String, signature: String) { val signed = JSONObject() @@ -1430,6 +1479,237 @@ class DappActivity : BaseActivity() { }) } + //babylon + "bit_requestAccount" -> { + if (selectBitcoin == null) { + selectBitcoin = + allChains?.find { it is ChainBitCoin84 && it.accountKeyType.pubkeyType == PubKeyType.BTC_NATIVE_SEGWIT } + } + + if (selectBitcoin?.mainAddress?.isNotEmpty() == true) { + appToWebResult( + messageJson, listOf(selectBitcoin?.mainAddress), messageId + ) + } else { + appToWebError(messageJson, messageId, "None Address") + } + } + + "bit_getPublicKeyHex" -> { + if (selectBitcoin == null) { + selectBitcoin = + allChains?.find { it is ChainBitCoin84 && it.accountKeyType.pubkeyType == PubKeyType.BTC_NATIVE_SEGWIT } + } + appToWebResult( + messageJson, + Base64.encodeToString(selectBitcoin?.publicKey, Base64.NO_WRAP), + messageId + ) + } + + "bit_getNetwork" -> { + if (selectBitcoin == null) { + selectBitcoin = + allChains?.find { it is ChainBitCoin84 && it.accountKeyType.pubkeyType == PubKeyType.BTC_NATIVE_SEGWIT } + } + bitNetwork = if (selectBitcoin is ChainBitcoin84Testnet) { + "signet" + } else { + "mainnet" + } + appToWebResult( + messageJson, bitNetwork, messageId + ) + } + + "bit_switchNetwork" -> { + val params = messageJson.getJSONArray("params") + if (params.length() > 0) { + bitNetwork = params.get(0).toString() + selectBitcoin = if (bitNetwork == "mainnet") { + allChains?.find { + it is ChainBitCoin84 && it.accountKeyType.pubkeyType == PubKeyType.BTC_NATIVE_SEGWIT && it.isDefault + } + } else { + allChains?.find { + it is ChainBitCoin84 && it.accountKeyType.pubkeyType == PubKeyType.BTC_NATIVE_SEGWIT && it.name.uppercase() + .contains(bitNetwork.uppercase()) + } + } + appToWebResult( + messageJson, bitNetwork, messageId + ) + } else { + appToWebError(messageJson, messageId, "Error : No Network") + } + } + + "bit_getAddress" -> { + if (selectBitcoin == null) { + selectBitcoin = + allChains?.find { it is ChainBitCoin84 && it.accountKeyType.pubkeyType == PubKeyType.BTC_NATIVE_SEGWIT } + } + + if (selectBitcoin?.mainAddress?.isNotEmpty() == true) { + appToWebResult( + messageJson, selectBitcoin?.mainAddress, messageId + ) + } else { + appToWebError(messageJson, messageId, "None Address") + } + } + + "bit_getBalance" -> { + currentMessageJson = messageJson + currentMessageId = messageId + + selectBitcoin?.let { chain -> + walletViewModel.balance(chain) + } ?: run { + appToWebError( + messageJson, messageId, getString(R.string.error_not_support) + ) + } + } + + "bit_pushTx" -> { + val params = messageJson.getJSONArray("params") + if (params.length() > 0) { + val txHex = params.get(0).toString() + val pushTxRequest = JsonRpcRequest( + method = "sendrawtransaction", params = listOf(txHex) + ) + val pushTxResponse = + jsonRpcResponse(selectBitcoin?.mainUrl ?: "", pushTxRequest) + val pushTxJsonObject = Gson().fromJson( + pushTxResponse.body?.string(), JsonObject::class.java + ) + try { + val result = pushTxJsonObject["result"].asString + appToWebResult( + messageJson, result, messageId + ) + + } catch (e: Exception) { + val errorMessage = + pushTxJsonObject["error"].asJsonObject["message"].asString + appToWebError( + messageJson, messageId, errorMessage + ) + } + + } else { + appToWebError( + messageJson, messageId, "No Param Data" + ) + } + } + + "bit_sendBitcoin" -> { + lifecycleScope.launch(Dispatchers.IO) { + val params = messageJson.getJSONObject("params") + currentMessageJson = messageJson + currentMessageId = messageId + bitToAddress = params.getString("to") + bitSatAmount = params.getLong("satAmount").toString() + + if (selectBitcoin?.mainAddress?.lowercase() == bitToAddress.lowercase()) { + appToWebError(messageJson, messageId, "Wrong address") + return@launch + } + + val signBundle = signBundle(0, params.toString(), "bit_sendBitcoin") + showBitSignDialog( + signBundle, + object : PopUpBitSignFragment.WcSignRawDataListener { + override fun sign(id: Long, txHex: String) { + lifecycleScope.launch(Dispatchers.IO) { + val bitSendTxRequest = JsonRpcRequest( + method = "sendrawtransaction", params = listOf(txHex) + ) + val bitSendTxResponse = + jsonRpcResponse( + selectBitcoin?.mainUrl ?: "", + bitSendTxRequest + ) + val bitSendTxJsonObject = Gson().fromJson( + bitSendTxResponse.body?.string(), JsonObject::class.java + ) + try { + val result = bitSendTxJsonObject["result"].asString + appToWebResult( + currentMessageJson, result, currentMessageId + ) + + } catch (e: Exception) { + val errorMessage = + bitSendTxJsonObject["error"].asJsonObject["message"].asString + appToWebError( + currentMessageJson, currentMessageId, errorMessage + ) + } + } + } + + override fun cancel(id: Long) { + appToWebError( + messageJson, + messageId, + "User rejected the request." + ) + } + }) + } + } + + "bit_signMessage" -> { + lifecycleScope.launch(Dispatchers.IO) { + val params = messageJson.getJSONObject("params") + val signBundle = signBundle(0, params.toString(), "bit_signMessage") + showBitSignDialog( + signBundle, + object : PopUpBitSignFragment.WcSignRawDataListener { + override fun sign(id: Long, txHex: String) { + appToWebResult( + messageJson, txHex, messageId + ) + } + + override fun cancel(id: Long) { + appToWebError( + messageJson, + messageId, + "User rejected the request." + ) + } + }) + } + } + + "bit_signPsbt" -> { + lifecycleScope.launch(Dispatchers.IO) { + val params = messageJson.getString("params") + val signBundle = signBundle(0, params, "bit_signPsbt") + showBitSignDialog( + signBundle, + object : PopUpBitSignFragment.WcSignRawDataListener { + override fun sign(id: Long, txHex: String) { + appToWebResult( + messageJson, txHex, messageId + ) + } + + override fun cancel(id: Long) { + appToWebError( + messageJson, + messageId, + "User rejected the request." + ) + } + }) + } + } + else -> { appToWebError(messageJson, messageId, "Not implemented") } @@ -1696,6 +1976,16 @@ class DappActivity : BaseActivity() { } } + private fun setUpObserve() { + walletViewModel.balanceResult.observe(this) { + appToWebResult( + currentMessageJson, + (selectBitcoin as ChainBitCoin84).btcFetcher()?.btcBalances, + currentMessageId + ) + } + } + inner class DappJavascriptInterface { @JavascriptInterface fun request(message: String) { diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/dapp/PopUpBitSignFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/dapp/PopUpBitSignFragment.kt new file mode 100644 index 000000000..2b70b8b41 --- /dev/null +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/dapp/PopUpBitSignFragment.kt @@ -0,0 +1,316 @@ +package wannabit.io.cosmostaion.ui.main.dapp + +import android.content.DialogInterface +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.core.content.ContextCompat +import androidx.core.view.isVisible +import androidx.lifecycle.lifecycleScope +import com.google.gson.JsonParser +import com.trustwallet.walletconnect.extensions.toHex +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext +import org.json.JSONObject +import wannabit.io.cosmostaion.R +import wannabit.io.cosmostaion.chain.BaseChain +import wannabit.io.cosmostaion.chain.majorClass.ChainBitCoin84 +import wannabit.io.cosmostaion.chain.testnetClass.ChainBitcoin84Testnet +import wannabit.io.cosmostaion.common.BaseData +import wannabit.io.cosmostaion.common.formatAmount +import wannabit.io.cosmostaion.common.formatAssetValue +import wannabit.io.cosmostaion.common.formatJsonString +import wannabit.io.cosmostaion.common.setImg +import wannabit.io.cosmostaion.common.updateButtonView +import wannabit.io.cosmostaion.databinding.FragmentBitSignBinding +import wannabit.io.cosmostaion.sign.BitCoinJS +import wannabit.io.cosmostaion.ui.tx.genTx.BaseTxFragment +import java.math.BigDecimal +import java.math.RoundingMode + +class PopUpBitSignFragment( + var selectedChain: BaseChain?, + private val id: Long, + private val data: String, + private val method: String?, + val listener: WcSignRawDataListener +) : BaseTxFragment() { + + private var _binding: FragmentBitSignBinding? = null + private val binding get() = _binding!! + + private var bitcoinJS: BitCoinJS? = null + + private var bitToAddress: String = "" + private var bitSatAmount: String = "" + private var message: String = "" + + private var updateData: String? = null + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? + ): View { + _binding = FragmentBitSignBinding.inflate(layoutInflater, container, false) + return binding.root + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + initViewResource() + parsingRequest() + setUpObserve() + setUpClickAction() + } + + private fun initViewResource() { + binding.apply { + lifecycleScope.launch(Dispatchers.IO) { + bitcoinJS = BitCoinJS(requireContext()) + withContext(Dispatchers.Main) { + signView.setBackgroundResource(R.drawable.cell_bg) + feeView.setBackgroundResource(R.drawable.cell_bg) + if (method == "bit_signMessage") { + dialogTitle.text = getString(R.string.str_permit_request) + warnMsg.visibility = View.GONE + feeView.visibility = View.INVISIBLE + + } else { + dialogTitle.text = getString(R.string.str_tx_request) + warnMsg.visibility = View.VISIBLE + warnMsg.text = getString(R.string.str_affect_danger_msg) + warnMsg.setTextColor( + ContextCompat.getColorStateList( + requireContext(), R.color.color_accent_red + ) + ) + dappFeeTokenImg.setImg(R.drawable.token_btc) + dappFeeToken.text = "BIT" + } + } + } + } + } + + private fun parsingRequest() { + lifecycleScope.launch(Dispatchers.IO) { + (selectedChain as ChainBitCoin84).apply { + when (method) { + "bit_sendBitcoin" -> { + val txJsonObject = JsonParser.parseString(data).asJsonObject + bitToAddress = txJsonObject["to"].asString + bitSatAmount = txJsonObject["satAmount"].asLong.toString() + message = JSONObject( + mapOf( + "From" to selectedChain?.mainAddress, + "To" to bitToAddress, + "Amount" to bitSatAmount.toBigDecimal().movePointLeft(8) + .setScale(8, RoundingMode.DOWN).toPlainString() + ) + ).toString(4) + withContext(Dispatchers.Main) { + txViewModel.bitTxData(this@apply) + } + } + + else -> { + txViewModel.bitTxData(this@apply) + } + } + } + } + } + + private fun setUpObserve() { + txViewModel.bitTxDataResult.observe(this) { bitData -> + (selectedChain as ChainBitCoin84).apply { + lifecycleScope.launch(Dispatchers.IO) { + when (method) { + "bit_signMessage" -> { + val txJsonObject = JsonParser.parseString(data).asJsonObject + val message = txJsonObject["message"].asString + val type = txJsonObject["type"].asString + val privateKey = selectedChain?.privateKey?.toHex() + + if (type == "ecdsa") { + val signMessageFunction = """function signMessageFunction() { + const signMessage = signMessageECDSA('${message}', '${privateKey}'); + return signMessage; + }""".trimMargin() + bitcoinJS?.mergeFunction(signMessageFunction) + updateData = bitcoinJS?.executeFunction("signMessageFunction()") + + } else { + val signMessageFunction = """function signMessageFunction() { + const signMessage = signMessageBIP322('${message}', '${privateKey}', '${selectedChain?.mainAddress}'); + return signMessage; + }""".trimMargin() + bitcoinJS?.mergeFunction(signMessageFunction) + updateData = bitcoinJS?.executeFunction("signMessageFunction()") + } + + withContext(Dispatchers.Main) { + binding.apply { + btnConfirm.isEnabled = true + loading.visibility = View.GONE + signData.text = message + } + } + } + + "bit_sendBitcoin" -> { + val bitVByteFee = btcFetcher()?.bitVBytesFee(bitData.first, "") + val bitFee = bitData.second.toBigDecimal().multiply(bitVByteFee) + .movePointRight(5).setScale(0, RoundingMode.UP) + var btcBalance = BigDecimal.ZERO + bitData.first?.forEach { utxo -> + btcBalance = btcBalance.add(utxo["value"].asLong.toBigDecimal()) + } + + withContext(Dispatchers.Main) { + binding.apply { + val price = BaseData.getPrice(coinGeckoId) + val amount = + bitFee.movePointLeft(8).setScale(8, RoundingMode.UP) + val value = price.multiply(amount) + + loading.visibility = View.GONE + signData.text = message + feeAmount.text = formatAmount(amount.toPlainString(), 8) + feeValue.text = formatAssetValue(value) + + if (bitFee.add(bitSatAmount.toBigDecimal()) > btcBalance) { + btnConfirm.updateButtonView(false) + noTxTxt.visibility = View.VISIBLE + + } else { + btnConfirm.updateButtonView(true) + noTxTxt.visibility = View.GONE + + txViewModel.bitSendSimulate( + (selectedChain as ChainBitCoin84), + bitcoinJS, + mainAddress, + bitToAddress, + bitSatAmount, + btcBalance.subtract(bitSatAmount.toBigDecimal()) + ?.subtract(bitFee).toString(), + "", + bitData.first + ) + } + } + } + } + + "bit_signPsbt" -> { + val privateKey = selectedChain?.privateKey?.toHex() + val network = if (selectedChain is ChainBitcoin84Testnet) { + "testnet" + } else { + "mainnet" + } + val bitVByteFee = btcFetcher()?.bitVBytesFee(bitData.first, "") + val bitFee = bitData.second.toBigDecimal().multiply(bitVByteFee) + .movePointRight(5).setScale(0, RoundingMode.UP) + var btcBalance = BigDecimal.ZERO + bitData.first?.forEach { utxo -> + btcBalance = btcBalance.add(utxo["value"].asLong.toBigDecimal()) + } + + val signPsbtFunction = """function signPsbtFunction() { + const txHex = signPsbt('${data}', '${privateKey}'); + return txHex; + }""".trimMargin() + bitcoinJS?.mergeFunction(signPsbtFunction) + updateData = bitcoinJS?.executeFunction("signPsbtFunction()") + + val getInOutPutsFunction = """function getInOutPutsFunction() { + const inputOutput = getInOutPuts('${data}', '${network}'); + return inputOutput; + }""".trimMargin() + bitcoinJS?.mergeFunction(getInOutPutsFunction) + val messageData = + bitcoinJS?.executeFunction("getInOutPutsFunction()").toString() + val messageJsonObject = JsonParser.parseString(messageData).asJsonObject + val outputs = messageJsonObject["outputs"].asJsonArray + var outputBalance = BigDecimal.ZERO + outputs.forEach { output -> + if (output.asJsonObject["address"].asString != selectedChain?.mainAddress) { + outputBalance = outputBalance.add(output.asJsonObject["value"].asString.toBigDecimal()) + } + } + + withContext(Dispatchers.Main) { + binding.apply { + val price = BaseData.getPrice(coinGeckoId) + val amount = + bitFee.movePointLeft(8).setScale(8, RoundingMode.UP) + val value = price.multiply(amount) + + btnConfirm.isEnabled = true + loading.visibility = View.GONE + signData.text = formatJsonString(messageData) + feeAmount.text = formatAmount(amount.toPlainString(), 8) + feeValue.text = formatAssetValue(value) + + if (bitFee.add(outputBalance) > btcBalance) { + btnConfirm.updateButtonView(false) + noTxTxt.visibility = View.VISIBLE + } else { + btnConfirm.updateButtonView(true) + noTxTxt.visibility = View.GONE + } + } + } + } + } + } + } + } + + txViewModel.simulate.observe(this) { txHex -> + updateData = txHex + } + } + + private fun setUpClickAction() { + binding.apply { + btnCancel.setOnClickListener { + if (!loading.isVisible) { + listener.cancel(id) + dismiss() + } + } + + btnConfirm.setOnClickListener { + if (!loading.isVisible && btnConfirm.isEnabled) { + listener.sign(id, updateData.toString()) + dismiss() + } + } + } + } + + override fun onDismiss(dialog: DialogInterface) { + super.onDismiss(dialog) + binding.apply { + if (!loading.isVisible) { + listener.cancel(id) + } + } + } + + interface WcSignRawDataListener { + fun sign(id: Long, txHex: String) + fun cancel(id: Long) + } + + override fun onDestroyView() { + _binding = null + super.onDestroyView() + bitcoinJS?.unbindService() + } +} \ No newline at end of file diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/setting/wallet/account/PrivateViewHolder.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/setting/wallet/account/PrivateViewHolder.kt index 04a85a073..9537453ae 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/main/setting/wallet/account/PrivateViewHolder.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/setting/wallet/account/PrivateViewHolder.kt @@ -30,7 +30,7 @@ class PrivateViewHolder( binding.apply { privateView.setBackgroundResource(R.drawable.item_bg) chainImg.setImageResource(chain.logo) - chainName.text = chain.name.uppercase() + chainName.text = chain.name chainPath.text = chain.getHDPath(account.lastHDPath) chainPrivateKey.text = "0x" + chain.privateKey?.toHex() diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/setting/wallet/chain/ChainManageFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/setting/wallet/chain/ChainManageFragment.kt index 0e4dd4fa2..84863a45f 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/main/setting/wallet/chain/ChainManageFragment.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/setting/wallet/chain/ChainManageFragment.kt @@ -19,6 +19,7 @@ import wannabit.io.cosmostaion.chain.majorClass.ChainSui import wannabit.io.cosmostaion.chain.allChains import wannabit.io.cosmostaion.chain.evmClass.ChainOktEvm import wannabit.io.cosmostaion.chain.majorClass.ChainBitCoin84 +import wannabit.io.cosmostaion.chain.testnetClass.ChainGnoTestnet import wannabit.io.cosmostaion.database.Prefs import wannabit.io.cosmostaion.databinding.FragmentChainManageBinding import wannabit.io.cosmostaion.ui.main.SettingType @@ -90,7 +91,7 @@ class ChainManageFragment : Fragment() { if (isClickable) { isClickable = false - if (chain is ChainOktEvm || chain is ChainBitCoin84) { + if (chain is ChainOktEvm || chain is ChainBitCoin84 || chain is ChainGnoTestnet) { isClickable = true return } diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/main/setting/wallet/chain/ChainManageViewHolder.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/main/setting/wallet/chain/ChainManageViewHolder.kt index 1c00670d9..6e36fc496 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/main/setting/wallet/chain/ChainManageViewHolder.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/main/setting/wallet/chain/ChainManageViewHolder.kt @@ -17,7 +17,7 @@ class ChainManageViewHolder( binding.apply { chainView.setBackgroundResource(R.drawable.item_bg) chainImg.setImageResource(chain.logo) - chainName.text = chain.name.uppercase() + chainName.text = chain.name if (chain is ChainBitCoin84) { grpcLayout.visibility = View.GONE @@ -71,13 +71,18 @@ class ChainManageViewHolder( binding.apply { chainView.setBackgroundResource(R.drawable.item_bg) chainImg.setImageResource(chain.logo) - chainName.text = chain.name.uppercase() + chainName.text = chain.name if (chain is ChainBitCoin84) { grpcLayout.visibility = View.GONE rpcEndpointType.text = "API" rpcEndpoint.text = chain.btcFetcher()?.mempoolUrl()?.replace("https://", "") + } else if (chain.cosmosFetcher()?.endPointType(chain) == CosmosEndPointType.USE_RPC) { + grpcLayout.visibility = View.GONE + rpcEndpointType.text = "RPC" + rpcEndpoint.text = chain.mainUrl + } else if (chain.cosmosFetcher()?.endPointType(chain) == CosmosEndPointType.USE_GRPC) { if (chain.isEvmCosmos()) { grpcLayout.visibility = View.VISIBLE diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/TransferTxResultActivity.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/TransferTxResultActivity.kt index 3b9bdeb15..b04933cff 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/TransferTxResultActivity.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/TransferTxResultActivity.kt @@ -13,6 +13,7 @@ import com.cosmos.base.abci.v1beta1.AbciProto.TxResponse import com.cosmos.tx.v1beta1.ServiceGrpc import com.cosmos.tx.v1beta1.ServiceProto import com.cosmos.tx.v1beta1.ServiceProto.GetTxResponse +import com.google.gson.Gson import com.google.gson.JsonObject import com.google.gson.JsonParser import io.grpc.stub.StreamObserver @@ -29,9 +30,11 @@ import wannabit.io.cosmostaion.chain.majorClass.ChainBitCoin84 import wannabit.io.cosmostaion.common.BaseActivity import wannabit.io.cosmostaion.common.BaseData import wannabit.io.cosmostaion.common.historyToMintscan +import wannabit.io.cosmostaion.common.jsonRpcResponse import wannabit.io.cosmostaion.common.updateButtonView import wannabit.io.cosmostaion.common.visibleOrGone import wannabit.io.cosmostaion.data.api.RetrofitInstance +import wannabit.io.cosmostaion.data.model.req.JsonRpcRequest import wannabit.io.cosmostaion.data.repository.address.AddressRepositoryImpl import wannabit.io.cosmostaion.data.viewmodel.ApplicationViewModel import wannabit.io.cosmostaion.data.viewmodel.address.AddressBookViewModel @@ -114,8 +117,7 @@ class TransferTxResultActivity : BaseActivity() { toMemo = intent.getStringExtra("memo") ?: "" intent.getStringExtra("suiResult")?.let { intentData -> - suiResult = JsonParser.parseString(intentData).asJsonObject - ?: JsonObject() + suiResult = JsonParser.parseString(intentData).asJsonObject ?: JsonObject() } transferStyle = enumValues()[intent.getIntExtra("transferStyle", -1)] @@ -187,7 +189,7 @@ class TransferTxResultActivity : BaseActivity() { } } else { - if (isSuccess) { + if (isSuccess && txResponse?.txResponse?.code == 0) { loading.visibility = View.GONE successLayout.visibility = View.VISIBLE successHash.text = txHash @@ -248,7 +250,67 @@ class TransferTxResultActivity : BaseActivity() { private fun loadHistoryTx() { lifecycleScope.launch(Dispatchers.IO) { fromChain.apply { - if (cosmosFetcher?.endPointType(this) == CosmosEndPointType.USE_GRPC) { + if (cosmosFetcher?.endPointType(this) == CosmosEndPointType.USE_RPC) { + val txStatusRequest = JsonRpcRequest( + method = "tx", params = listOf(txHash) + ) + val txStatusResponse = jsonRpcResponse(mainUrl, txStatusRequest) + if (txStatusResponse.isSuccessful) { + val txStatusJsonObject = Gson().fromJson( + txStatusResponse.body?.string(), JsonObject::class.java + ) + + if (!txStatusJsonObject.has("error")) { + val txResult = + txStatusJsonObject["result"].asJsonObject["tx_result"].asJsonObject["ResponseBase"].asJsonObject + val txResultResponse = if (txResult["Error"].isJsonNull) { + TxResponse.newBuilder().setTxhash(txHash).setCode(0).setRawLog("") + .build() + + } else { + errorMsg = try { + txResult["Error"].asJsonObject["value"].asString + } catch (e: Exception) { + txResult["Log"].asString + } + TxResponse.newBuilder().setTxhash(txHash).setCode(-1) + .setRawLog(errorMsg).build() + } + txResponse = + GetTxResponse.newBuilder().setTxResponse(txResultResponse).build() + Handler(Looper.getMainLooper()).postDelayed({ + updateView() + }, 0) + + } else { + fetchCnt -= 1 + if (isSuccess && fetchCnt > 0) { + Handler(Looper.getMainLooper()).postDelayed({ + loadHistoryTx() + }, 6000) + + } else { + runOnUiThread { + showMoreWait() + } + } + } + + } else { + fetchCnt -= 1 + if (isSuccess && fetchCnt > 0) { + Handler(Looper.getMainLooper()).postDelayed({ + loadHistoryTx() + }, 6000) + + } else { + runOnUiThread { + showMoreWait() + } + } + } + + } else if (cosmosFetcher?.endPointType(this) == CosmosEndPointType.USE_GRPC) { val channel = fromChain.cosmosFetcher?.getChannel() val stub = ServiceGrpc.newStub(channel) val request = ServiceProto.GetTxRequest.newBuilder().setHash(txHash).build() diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/genTx/CommonTransferFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/genTx/CommonTransferFragment.kt index 6a4c796d6..bba7d7117 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/genTx/CommonTransferFragment.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/genTx/CommonTransferFragment.kt @@ -34,6 +34,7 @@ import org.web3j.protocol.Web3j import org.web3j.protocol.http.HttpService import wannabit.io.cosmostaion.R import wannabit.io.cosmostaion.chain.BaseChain +import wannabit.io.cosmostaion.chain.CosmosEndPointType import wannabit.io.cosmostaion.chain.EVM_BASE_FEE import wannabit.io.cosmostaion.chain.allChains import wannabit.io.cosmostaion.chain.cosmosClass.ChainThorchain @@ -234,7 +235,8 @@ class CommonTransferFragment : BaseTxFragment() { availableAmount = fromChain.cosmosFetcher?.balanceAmount(toSendDenom) if (cosmosTxFee?.amountList?.isNotEmpty() == true) { if (cosmosTxFee?.getAmount(0)?.denom == toSendDenom) { - val feeAmount = cosmosTxFee?.getAmount(0)?.amount?.toBigDecimal() ?: BigDecimal.ZERO + val feeAmount = cosmosTxFee?.getAmount(0)?.amount?.toBigDecimal() + ?: BigDecimal.ZERO availableAmount = if (feeAmount >= availableAmount) { BigDecimal.ZERO } else { @@ -251,11 +253,13 @@ class CommonTransferFragment : BaseTxFragment() { SendAssetType.ONLY_COSMOS_COIN -> { toSendAsset = BaseData.getAsset(fromChain.apiName, toSendDenom) - availableAmount = fromChain.cosmosFetcher?.balanceAmount(toSendDenom) ?: BigDecimal.ZERO + availableAmount = + fromChain.cosmosFetcher?.balanceAmount(toSendDenom) ?: BigDecimal.ZERO if (cosmosTxFee?.amountList?.isNotEmpty() == true) { if (cosmosTxFee?.getAmount(0)?.denom == toSendDenom) { - val feeAmount = cosmosTxFee?.getAmount(0)?.amount?.toBigDecimal() ?: BigDecimal.ZERO + val feeAmount = + cosmosTxFee?.getAmount(0)?.amount?.toBigDecimal() ?: BigDecimal.ZERO availableAmount = if (feeAmount >= availableAmount) { BigDecimal.ZERO } else { @@ -322,6 +326,20 @@ class CommonTransferFragment : BaseTxFragment() { } } + SendAssetType.ONLY_COSMOS_GRC20 -> { + fromChain.cosmosFetcher?.let { fetcher -> + fetcher.grc20Tokens.firstOrNull { it.contract == toSendDenom } + ?.let { token -> + toSendToken = token + } + } + availableAmount = toSendToken?.amount?.toBigDecimal() + transferImg.setTokenImg(toSendToken?.image ?: "") + sendTitle.text = getString( + R.string.title_asset_send, toSendToken?.symbol + ) + } + else -> {} } } @@ -495,7 +513,7 @@ class CommonTransferFragment : BaseTxFragment() { private fun initData() { recipientAbleChains.add(fromChain) - if (sendAssetType == SendAssetType.ONLY_COSMOS_COIN || sendAssetType == SendAssetType.COSMOS_EVM_COIN || sendAssetType == SendAssetType.ONLY_COSMOS_CW20) { + if (sendAssetType == SendAssetType.ONLY_COSMOS_COIN || sendAssetType == SendAssetType.COSMOS_EVM_COIN || sendAssetType == SendAssetType.ONLY_COSMOS_CW20 || sendAssetType == SendAssetType.ONLY_COSMOS_GRC20) { BaseData.assets?.forEach { asset -> if (sendAssetType == SendAssetType.ONLY_COSMOS_COIN || sendAssetType == SendAssetType.COSMOS_EVM_COIN) { if (asset.chain == fromChain.apiName && asset.denom?.lowercase() == toSendDenom.lowercase()) { @@ -504,7 +522,6 @@ class CommonTransferFragment : BaseTxFragment() { } else if (asset.justBeforeChain() == fromChain.apiName && asset.ibc_info?.counterparty?.dpDenom?.lowercase() == toSendDenom.lowercase()) { addRecipientChainIfNotExists(asset.chain) } - } else { if (asset.ibc_info?.counterparty?.chain == fromChain.apiName && asset.ibc_info.counterparty.dpDenom?.lowercase() == toSendDenom.lowercase()) { addRecipientChainIfNotExists(asset.chain) @@ -700,7 +717,7 @@ class CommonTransferFragment : BaseTxFragment() { } } - SendAssetType.ONLY_COSMOS_CW20, SendAssetType.ONLY_EVM_ERC20 -> { + SendAssetType.ONLY_COSMOS_CW20, SendAssetType.ONLY_EVM_ERC20, SendAssetType.ONLY_COSMOS_GRC20 -> { toSendToken?.let { token -> val price = BaseData.getPrice(token.coinGeckoId) val dpAmount = toAmount.toBigDecimal().amountHandlerLeft(token.decimals) @@ -1218,24 +1235,31 @@ class CommonTransferFragment : BaseTxFragment() { } private fun onBindSendMsg(): MutableList { - return if (fromChain is ChainThorchain) { - val fromAddressByteArray = convertBits(Bech32.decode(fromChain.address).data, 5, 8, false) - val toAddressByteArray = convertBits(Bech32.decode(toAddress).data, 5, 8, false) - - val sendCoin = - CoinProto.Coin.newBuilder().setAmount(toSendAmount).setDenom(toSendDenom).build() - val msgSend = com.types.MsgSendProto.MsgSend.newBuilder() - .setFromAddress(ByteString.copyFrom(fromAddressByteArray)) - .setToAddress(ByteString.copyFrom(toAddressByteArray)).addAmount(sendCoin).build() - Signer.thorchainSendMsg(msgSend) - - } else { - val sendCoin = - CoinProto.Coin.newBuilder().setAmount(toSendAmount).setDenom(toSendDenom).build() - val msgSend = - MsgSend.newBuilder().setFromAddress(fromChain.address).setToAddress(toAddress) - .addAmount(sendCoin).build() - Signer.sendMsg(msgSend) + return when (fromChain) { + is ChainThorchain -> { + val fromAddressByteArray = + convertBits(Bech32.decode(fromChain.address).data, 5, 8, false) + val toAddressByteArray = convertBits(Bech32.decode(toAddress).data, 5, 8, false) + + val sendCoin = + CoinProto.Coin.newBuilder().setAmount(toSendAmount).setDenom(toSendDenom) + .build() + val msgSend = com.types.MsgSendProto.MsgSend.newBuilder() + .setFromAddress(ByteString.copyFrom(fromAddressByteArray)) + .setToAddress(ByteString.copyFrom(toAddressByteArray)).addAmount(sendCoin) + .build() + Signer.thorchainSendMsg(msgSend) + } + + else -> { + val sendCoin = + CoinProto.Coin.newBuilder().setAmount(toSendAmount).setDenom(toSendDenom) + .build() + val msgSend = + MsgSend.newBuilder().setFromAddress(fromChain.address).setToAddress(toAddress) + .addAmount(sendCoin).build() + Signer.sendMsg(msgSend) + } } } @@ -1318,15 +1342,35 @@ class CommonTransferFragment : BaseTxFragment() { txMemo, this ) + } else if (sendAssetType == SendAssetType.ONLY_COSMOS_GRC20) { + val msgCall = + com.gno.vm.VmProto.MsgCall.newBuilder().setSend("") + .setCaller(fromChain.address) + .setPkgPath(toSendToken?.contract).setFunc("Transfer") + .addAllArgs(listOf(toAddress, toSendAmount)).build() + txViewModel.rpcCallBroadcast( + msgCall, cosmosTxFee, txMemo, this + ) } else { - txViewModel.broadcast( - cosmosFetcher?.getChannel(), - onBindSendMsg(), - cosmosTxFee, - txMemo, - this - ) + if (cosmosFetcher?.endPointType(this) == CosmosEndPointType.USE_RPC) { + val msgSend = com.gno.bank.BankProto.MsgSend.newBuilder() + .setFromAddress(fromChain.address) + .setToAddress(toAddress) + .setAmount(toSendAmount + toSendDenom).build() + txViewModel.rpcSendBroadcast( + msgSend, cosmosTxFee, txMemo, this + ) + + } else { + txViewModel.broadcast( + cosmosFetcher?.getChannel(), + onBindSendMsg(), + cosmosTxFee, + txMemo, + this + ) + } } } else { @@ -1558,6 +1602,6 @@ class CommonTransferFragment : BaseTxFragment() { } } -enum class SendAssetType { ONLY_EVM_COIN, COSMOS_EVM_COIN, ONLY_COSMOS_COIN, ONLY_COSMOS_CW20, ONLY_EVM_ERC20, SUI_COIN, SUI_NFT, BIT_COIN } +enum class SendAssetType { ONLY_EVM_COIN, COSMOS_EVM_COIN, ONLY_COSMOS_COIN, ONLY_COSMOS_CW20, ONLY_EVM_ERC20, SUI_COIN, SUI_NFT, BIT_COIN, ONLY_COSMOS_GRC20 } enum class TransferStyle { COSMOS_STYLE, WEB3_STYLE, SUI_STYLE, BIT_COIN_STYLE } enum class SuiTxType { SUI_SEND_COIN, SUI_SEND_NFT, SUI_STAKE, SUI_UNSTAKE } \ No newline at end of file diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/genTx/service/AllChainAllVoteAdapter.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/genTx/service/AllChainAllVoteAdapter.kt index 54d5b3c51..d61261051 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/genTx/service/AllChainAllVoteAdapter.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/genTx/service/AllChainAllVoteAdapter.kt @@ -134,7 +134,7 @@ class AllChainAllVoteAdapter( binding.apply { voteAllModel.basechain?.let { chain -> chainImg.setImageResource(chain.logo) - chainName.text = chain.name.uppercase() + chainName.text = chain.name voteCnt.text = voteAllModel.proposals.size.toString() if (voteAllModel.isBusy) { diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/genTx/service/AllChainClaimViewHolder.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/genTx/service/AllChainClaimViewHolder.kt index 23df10ad4..7123bf32e 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/genTx/service/AllChainClaimViewHolder.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/genTx/service/AllChainClaimViewHolder.kt @@ -28,7 +28,7 @@ class AllChainClaimViewHolder( valueAbleReward.apply { chainImg.setImageResource(baseChain.logo) - chainName.text = baseChain.name.uppercase() + chainName.text = baseChain.name chainRewardAddress.text = baseChain.cosmosFetcher()?.rewardAddress chainDiffer.goneOrVisible(baseChain.address.uppercase() == baseChain.cosmosFetcher()?.rewardAddress?.uppercase()) if (baseChain.address.uppercase() == baseChain.cosmosFetcher()?.rewardAddress?.uppercase()) { diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/genTx/service/AllChainCompoundingViewHolder.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/genTx/service/AllChainCompoundingViewHolder.kt index 15ed95aa7..6f58a2865 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/genTx/service/AllChainCompoundingViewHolder.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/genTx/service/AllChainCompoundingViewHolder.kt @@ -25,7 +25,7 @@ class AllChainCompoundingViewHolder( compoundAbleReward.apply { chainImg.setImageResource(baseChain.logo) - chainName.text = baseChain.name.uppercase() + chainName.text = baseChain.name if (!baseChain.isDefault) { chainBadge.visibility = View.VISIBLE diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/genTx/service/AllChainNotVoteAdapter.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/genTx/service/AllChainNotVoteAdapter.kt index 161689391..50895203f 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/genTx/service/AllChainNotVoteAdapter.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/genTx/service/AllChainNotVoteAdapter.kt @@ -139,7 +139,7 @@ class AllChainNotVoteAdapter( binding.apply { voteAllModel.basechain?.let { chain -> chainImg.setImageResource(chain.logo) - chainName.text = chain.name.uppercase() + chainName.text = chain.name voteCnt.text = voteAllModel.proposals.size.toString() if (voteAllModel.isBusy) { diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/option/address/AddressBookFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/option/address/AddressBookFragment.kt index ef3aceecd..8d3f457a7 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/option/address/AddressBookFragment.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/option/address/AddressBookFragment.kt @@ -220,7 +220,7 @@ class AddressBookFragment : BottomSheetDialogFragment() { } } - SendAssetType.ONLY_COSMOS_COIN, SendAssetType.ONLY_COSMOS_CW20 -> { + SendAssetType.ONLY_COSMOS_COIN, SendAssetType.ONLY_COSMOS_CW20, SendAssetType.ONLY_COSMOS_GRC20 -> { AppDatabase.getInstance().refAddressDao().selectAll() .filter { it.dpAddress?.startsWith(toChain.accountPrefix + 1) == true && it.dpAddress?.lowercase() != senderAddress.lowercase() } .forEach { refAddress -> @@ -346,7 +346,7 @@ class AddressBookFragment : BottomSheetDialogFragment() { ) } - SendAssetType.ONLY_COSMOS_COIN, SendAssetType.ONLY_COSMOS_CW20 -> { + SendAssetType.ONLY_COSMOS_COIN, SendAssetType.ONLY_COSMOS_CW20, SendAssetType.ONLY_COSMOS_GRC20 -> { if (refAddresses.isEmpty() && addressBooks.isEmpty()) { recycler.visibility = View.GONE emptyLayout.visibility = View.VISIBLE diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/option/address/TransferAddressFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/option/address/TransferAddressFragment.kt index a4e23c5b4..40beb0ce7 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/option/address/TransferAddressFragment.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/option/address/TransferAddressFragment.kt @@ -200,7 +200,7 @@ class TransferAddressFragment : BottomSheetDialogFragment() { return@setOnClickListener } - } else if (sendAssetType == SendAssetType.ONLY_COSMOS_COIN || sendAssetType == SendAssetType.ONLY_COSMOS_CW20) { + } else if (sendAssetType == SendAssetType.ONLY_COSMOS_COIN || sendAssetType == SendAssetType.ONLY_COSMOS_CW20 || sendAssetType == SendAssetType.ONLY_COSMOS_GRC20) { if (BaseUtils.isValidBechAddress( toChain, address ) diff --git a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/option/general/TransferAmountFragment.kt b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/option/general/TransferAmountFragment.kt index 782753800..759edf5ae 100644 --- a/app/src/main/java/wannabit/io/cosmostaion/ui/tx/option/general/TransferAmountFragment.kt +++ b/app/src/main/java/wannabit/io/cosmostaion/ui/tx/option/general/TransferAmountFragment.kt @@ -187,7 +187,7 @@ class TransferAmountFragment : BottomSheetDialogFragment() { } } - SendAssetType.ONLY_COSMOS_CW20, SendAssetType.ONLY_EVM_ERC20 -> { + SendAssetType.ONLY_COSMOS_CW20, SendAssetType.ONLY_EVM_ERC20, SendAssetType.ONLY_COSMOS_GRC20 -> { toSendToken?.let { token -> assetDecimal = token.decimals availableAmount.toBigDecimal().movePointLeft(assetDecimal) diff --git a/app/src/main/res/drawable-hdpi/chain_babylon_testnet.png b/app/src/main/res/drawable-hdpi/chain_babylon_testnet.png new file mode 100644 index 000000000..5e469f3be Binary files /dev/null and b/app/src/main/res/drawable-hdpi/chain_babylon_testnet.png differ diff --git a/app/src/main/res/drawable-hdpi/chain_bitcoin_signet.png b/app/src/main/res/drawable-hdpi/chain_bitcoin_signet.png new file mode 100644 index 000000000..a6e7df82f Binary files /dev/null and b/app/src/main/res/drawable-hdpi/chain_bitcoin_signet.png differ diff --git a/app/src/main/res/drawable-hdpi/chain_gno_testnet.png b/app/src/main/res/drawable-hdpi/chain_gno_testnet.png new file mode 100644 index 000000000..e0e435219 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/chain_gno_testnet.png differ diff --git a/app/src/main/res/drawable-hdpi/chain_secret.png b/app/src/main/res/drawable-hdpi/chain_secret.png index bbcea072d..992bcf238 100644 Binary files a/app/src/main/res/drawable-hdpi/chain_secret.png and b/app/src/main/res/drawable-hdpi/chain_secret.png differ diff --git a/app/src/main/res/drawable-mdpi/chain_babylon_testnet.png b/app/src/main/res/drawable-mdpi/chain_babylon_testnet.png new file mode 100644 index 000000000..8b0aaf1a4 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/chain_babylon_testnet.png differ diff --git a/app/src/main/res/drawable-mdpi/chain_bitcoin_signet.png b/app/src/main/res/drawable-mdpi/chain_bitcoin_signet.png new file mode 100644 index 000000000..3ac1fef7c Binary files /dev/null and b/app/src/main/res/drawable-mdpi/chain_bitcoin_signet.png differ diff --git a/app/src/main/res/drawable-mdpi/chain_gno_testnet.png b/app/src/main/res/drawable-mdpi/chain_gno_testnet.png new file mode 100644 index 000000000..79146a60a Binary files /dev/null and b/app/src/main/res/drawable-mdpi/chain_gno_testnet.png differ diff --git a/app/src/main/res/drawable-mdpi/chain_secret.png b/app/src/main/res/drawable-mdpi/chain_secret.png index de36b2f11..02f7096b1 100644 Binary files a/app/src/main/res/drawable-mdpi/chain_secret.png and b/app/src/main/res/drawable-mdpi/chain_secret.png differ diff --git a/app/src/main/res/drawable-xhdpi/chain_babylon_testnet.png b/app/src/main/res/drawable-xhdpi/chain_babylon_testnet.png new file mode 100644 index 000000000..5cc99f3f1 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/chain_babylon_testnet.png differ diff --git a/app/src/main/res/drawable-xhdpi/chain_bitcoin_signet.png b/app/src/main/res/drawable-xhdpi/chain_bitcoin_signet.png new file mode 100644 index 000000000..39f4acdbe Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/chain_bitcoin_signet.png differ diff --git a/app/src/main/res/drawable-xhdpi/chain_gno_testnet.png b/app/src/main/res/drawable-xhdpi/chain_gno_testnet.png new file mode 100644 index 000000000..5d52370b0 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/chain_gno_testnet.png differ diff --git a/app/src/main/res/drawable-xhdpi/chain_secret.png b/app/src/main/res/drawable-xhdpi/chain_secret.png index 4837aca81..cce61e280 100644 Binary files a/app/src/main/res/drawable-xhdpi/chain_secret.png and b/app/src/main/res/drawable-xhdpi/chain_secret.png differ diff --git a/app/src/main/res/drawable-xxhdpi/chain_babylon_testnet.png b/app/src/main/res/drawable-xxhdpi/chain_babylon_testnet.png new file mode 100644 index 000000000..1db17f411 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/chain_babylon_testnet.png differ diff --git a/app/src/main/res/drawable-xxhdpi/chain_bitcoin_signet.png b/app/src/main/res/drawable-xxhdpi/chain_bitcoin_signet.png new file mode 100644 index 000000000..de8b47594 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/chain_bitcoin_signet.png differ diff --git a/app/src/main/res/drawable-xxhdpi/chain_gno_testnet.png b/app/src/main/res/drawable-xxhdpi/chain_gno_testnet.png new file mode 100644 index 000000000..ca2a75d5a Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/chain_gno_testnet.png differ diff --git a/app/src/main/res/drawable-xxhdpi/chain_secret.png b/app/src/main/res/drawable-xxhdpi/chain_secret.png index 4551ecf61..719c7bf10 100644 Binary files a/app/src/main/res/drawable-xxhdpi/chain_secret.png and b/app/src/main/res/drawable-xxhdpi/chain_secret.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/chain_babylon_testnet.png b/app/src/main/res/drawable-xxxhdpi/chain_babylon_testnet.png new file mode 100644 index 000000000..9e99290c1 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/chain_babylon_testnet.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/chain_bitcoin_signet.png b/app/src/main/res/drawable-xxxhdpi/chain_bitcoin_signet.png new file mode 100644 index 000000000..a3e6abeb1 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/chain_bitcoin_signet.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/chain_gno_testnet.png b/app/src/main/res/drawable-xxxhdpi/chain_gno_testnet.png new file mode 100644 index 000000000..9f2ffb0ec Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/chain_gno_testnet.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/chain_secret.png b/app/src/main/res/drawable-xxxhdpi/chain_secret.png index 23be7cf92..9644a6386 100644 Binary files a/app/src/main/res/drawable-xxxhdpi/chain_secret.png and b/app/src/main/res/drawable-xxxhdpi/chain_secret.png differ diff --git a/app/src/main/res/layout/fragment_bit_sign.xml b/app/src/main/res/layout/fragment_bit_sign.xml new file mode 100644 index 000000000..acb928eef --- /dev/null +++ b/app/src/main/res/layout/fragment_bit_sign.xml @@ -0,0 +1,259 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +