edge-currency-accountbased 4.35.3 → 4.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/android/src/main/assets/edge-currency-accountbased/1700.chunk.js +4 -4
- package/android/src/main/assets/edge-currency-accountbased/2075.chunk.js +55 -0
- package/android/src/main/assets/edge-currency-accountbased/4089.chunk.js +1 -0
- package/android/src/main/assets/edge-currency-accountbased/4649.chunk.js +5 -5
- package/android/src/main/assets/edge-currency-accountbased/4937.chunk.js +1 -0
- package/android/src/main/assets/edge-currency-accountbased/5450.chunk.js +1 -1
- package/android/src/main/assets/edge-currency-accountbased/597.chunk.js +1 -1
- package/android/src/main/assets/edge-currency-accountbased/6845.chunk.js +8 -8
- package/android/src/main/assets/edge-currency-accountbased/6950.chunk.js +17 -15
- package/android/src/main/assets/edge-currency-accountbased/749.chunk.js +2 -2
- package/android/src/main/assets/edge-currency-accountbased/7798.chunk.js +2 -2
- package/android/src/main/assets/edge-currency-accountbased/8163.chunk.js +2 -2
- package/android/src/main/assets/edge-currency-accountbased/8330.chunk.js +1 -1
- package/android/src/main/assets/edge-currency-accountbased/9754.chunk.js +199 -0
- package/android/src/main/assets/edge-currency-accountbased/algorand.chunk.js +2 -2
- package/android/src/main/assets/edge-currency-accountbased/axelar.chunk.js +2 -2
- package/android/src/main/assets/edge-currency-accountbased/bnb.chunk.js +1 -1
- package/android/src/main/assets/edge-currency-accountbased/cardano.chunk.js +1 -1
- package/android/src/main/assets/edge-currency-accountbased/edge-currency-accountbased.js +8 -8
- package/android/src/main/assets/edge-currency-accountbased/eos.chunk.js +1 -1
- package/android/src/main/assets/edge-currency-accountbased/ethereum.chunk.js +9 -9
- package/android/src/main/assets/edge-currency-accountbased/filecoin.chunk.js +1 -1
- package/android/src/main/assets/edge-currency-accountbased/fio.chunk.js +1 -1
- package/android/src/main/assets/edge-currency-accountbased/polkadot.chunk.js +4 -4
- package/android/src/main/assets/edge-currency-accountbased/ripple.chunk.js +1 -1
- package/android/src/main/assets/edge-currency-accountbased/solana.chunk.js +1 -1
- package/android/src/main/assets/edge-currency-accountbased/sui.chunk.js +1 -1
- package/android/src/main/assets/edge-currency-accountbased/tron.chunk.js +1 -1
- package/lib/cosmos/engine/CosmosEngine.js +3 -1
- package/lib/ethereum/EthereumTools.js +30 -0
- package/lib/polkadot/PolkadotEngine.js +17 -4
- package/package.json +3 -3
- package/android/src/main/assets/edge-currency-accountbased/1715.chunk.js +0 -1
- package/android/src/main/assets/edge-currency-accountbased/4580.chunk.js +0 -150
- package/android/src/main/assets/edge-currency-accountbased/4842.chunk.js +0 -3
- package/android/src/main/assets/edge-currency-accountbased/7920.chunk.js +0 -55
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Ot=Object.defineProperty;var Lt=(oe,o,R)=>o in oe?Ot(oe,o,{enumerable:!0,configurable:!0,writable:!0,value:R}):oe[o]=R;var P=(oe,o,R)=>(Lt(oe,typeof o!="symbol"?o+"":o,R),R);(self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[1700],{73513:function(oe,o,R){"use strict";var C=R(48287).Buffer,c=R(9598),v=R(39615),B=R(22623);function y(h){var D=Object.create(null);return h&&Object.keys(h).forEach(function(X){if(X!=="default"){var le=Object.getOwnPropertyDescriptor(h,X);Object.defineProperty(D,X,le.get?le:{enumerable:!0,get:function(){return h[X]}})}}),D.default=h,Object.freeze(D)}var a=y(c);a.utils.hmacSha256Sync=(h,...D)=>v.hmac(B.sha256,h,a.utils.concatBytes(...D)),a.utils.sha256Sync=(...h)=>B.sha256(a.utils.concatBytes(...h));const d=a.utils._normalizePrivateKey,w=32,i=32,E=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=32;function T(h,D){for(let X=0;X<32;++X)if(h[X]!==D[X])return h[X]<D[X]?-1:1;return 0}function F(h){return!(!(h instanceof Uint8Array)||h.length!==i||T(h,E)>=0)}function V(h){return h instanceof Uint8Array&&h.length===64&&T(h.subarray(0,32),E)<0&&T(h.subarray(32,64),E)<0}function K(h){return h instanceof Uint8Array&&h.length===w}function H(h){return h===void 0||h instanceof Uint8Array&&h.length===g}function S(h){if(typeof h!="string")throw new TypeError("hexToNumber: expected string, got "+typeof h);return BigInt(`0x${h}`)}function A(h){return S(a.utils.bytesToHex(h))}function k(h){let D;if(typeof h=="bigint")D=h;else if(typeof h=="number"&&Number.isSafeInteger(h)&&h>=0)D=BigInt(h);else if(typeof h=="string"){if(h.length!==64)throw new Error("Expected 32 bytes of private scalar");D=S(h)}else if(h instanceof Uint8Array){if(h.length!==32)throw new Error("Expected 32 bytes of private scalar");D=A(h)}else throw new TypeError("Expected valid private scalar");if(D<0)throw new Error("Expected private scalar >= 0");return D}const U=(h,D)=>{const X=d(h),le=k(D),ge=a.utils._bigintTo32Bytes(a.utils.mod(X+le,a.CURVE.n));return a.utils.isValidPrivateKey(ge)?ge:null},Y=(h,D)=>{const X=d(h),le=k(D),ge=a.utils._bigintTo32Bytes(a.utils.mod(X-le,a.CURVE.n));return a.utils.isValidPrivateKey(ge)?ge:null},Z=h=>{const D=d(h),X=a.utils._bigintTo32Bytes(a.CURVE.n-D);return a.utils.isValidPrivateKey(X)?X:null},Q=(h,D,X)=>{const le=a.Point.fromHex(h),ge=k(D),me=a.Point.BASE.multiplyAndAddUnsafe(le,ge,1n);if(!me)throw new Error("Tweaked point at infinity");return me.toRawBytes(X)},be=(h,D,X)=>{const le=a.Point.fromHex(h),ge=typeof D=="string"?D:a.utils.bytesToHex(D),me=BigInt(`0x${ge}`);return le.multiply(me).toRawBytes(X)};function pe(h,D){return h===void 0?D!==void 0?f(D):!0:!!h}function ae(h){try{return h()}catch{return null}}function x(h,D){if(h.length===32!==D)return!1;try{return!!a.Point.fromHex(h)}catch{return!1}}function b(h){return x(h,!1)}function f(h){return x(h,!1)&&h.length===33}function I(h){return a.utils.isValidPrivateKey(h)}function z(h){return x(h,!0)}function M(h,D){if(!z(h))throw new Error("Expected Point");if(!F(D))throw new Error("Expected Tweak");return ae(()=>{const X=Q(h,D,!0);return{parity:X[0]%2===1?1:0,xOnlyPubkey:X.slice(1)}})}function G(h){if(!b(h))throw new Error("Expected Point");return h.slice(1,33)}function ne(h,D){if(!I(h))throw new Error("Expected Private");return ae(()=>a.getPublicKey(h,pe(D)))}function ie(h){if(!I(h))throw new Error("Expected Private");return G(ne(h))}function ce(h,D){if(!b(h))throw new Error("Expected Point");return a.Point.fromHex(h).toRawBytes(pe(D,h))}function W(h,D,X){if(!b(h))throw new Error("Expected Point");if(!F(D))throw new Error("Expected Tweak");return ae(()=>be(h,D,pe(X,h)))}function ue(h,D,X){if(!b(h)||!b(D))throw new Error("Expected Point");return ae(()=>{const le=a.Point.fromHex(h),ge=a.Point.fromHex(D);return le.equals(ge.negate())?null:le.add(ge).toRawBytes(pe(X,h))})}function O(h,D,X){if(!b(h))throw new Error("Expected Point");if(!F(D))throw new Error("Expected Tweak");return ae(()=>Q(h,D,pe(X,h)))}function ye(h,D){if(I(h)===!1)throw new Error("Expected Private");if(F(D)===!1)throw new Error("Expected Tweak");return ae(()=>U(h,D))}function ke(h,D){if(I(h)===!1)throw new Error("Expected Private");if(F(D)===!1)throw new Error("Expected Tweak");return ae(()=>Y(h,D))}function Ee(h){if(I(h)===!1)throw new Error("Expected Private");return Z(h)}function Pe(h,D,X){if(!I(D))throw new Error("Expected Private");if(!K(h))throw new Error("Expected Scalar");if(!H(X))throw new Error("Expected Extra Data (32 bytes)");return a.signSync(h,D,{der:!1,extraEntropy:X})}function Me(h,D,X=C.alloc(32,0)){if(!I(D))throw new Error("Expected Private");if(!K(h))throw new Error("Expected Scalar");if(!H(X))throw new Error("Expected Extra Data (32 bytes)");return a.schnorr.signSync(h,D,X)}function He(h,D,X,le){if(!b(D))throw new Error("Expected Point");if(!V(X))throw new Error("Expected Signature");if(!K(h))throw new Error("Expected Scalar");return a.verify(X,h,D,{strict:le})}function Ne(h,D,X){if(!z(D))throw new Error("Expected Point");if(!V(X))throw new Error("Expected Signature");if(!K(h))throw new Error("Expected Scalar");return a.schnorr.verifySync(X,h,D)}o.isPoint=b,o.isPointCompressed=f,o.isPrivate=I,o.isXOnlyPoint=z,o.pointAdd=ue,o.pointAddScalar=O,o.pointCompress=ce,o.pointFromScalar=ne,o.pointMultiply=W,o.privateAdd=ye,o.privateNegate=Ee,o.privateSub=ke,o.sign=Pe,o.signSchnorr=Me,o.verify=He,o.verifySchnorr=Ne,o.xOnlyPointAddTweak=M,o.xOnlyPointFromPoint=G,o.xOnlyPointFromScalar=ie},93238:function(oe,o,R){"use strict";Object.defineProperty(o,"__esModule",{value:!0}),o.ripemd160=o.RIPEMD160=void 0;const C=R(37202),c=R(99175),v=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),B=new Uint8Array(new Array(16).fill(0).map((H,S)=>S)),y=B.map(H=>(9*H+5)%16);let a=[B],d=[y];for(let H=0;H<4;H++)for(let S of[a,d])S.push(S[H].map(A=>v[A]));const w=[[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(H=>new Uint8Array(H)),i=a.map((H,S)=>H.map(A=>w[S][A])),E=d.map((H,S)=>H.map(A=>w[S][A])),g=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),T=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function F(H,S,A,k){return H===0?S^A^k:H===1?S&A|~S&k:H===2?(S|~A)^k:H===3?S&k|A&~k:S^(A|~k)}const V=new Uint32Array(16);class K extends C.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:S,h1:A,h2:k,h3:U,h4:Y}=this;return[S,A,k,U,Y]}set(S,A,k,U,Y){this.h0=S|0,this.h1=A|0,this.h2=k|0,this.h3=U|0,this.h4=Y|0}process(S,A){for(let f=0;f<16;f++,A+=4)V[f]=S.getUint32(A,!0);let k=this.h0|0,U=k,Y=this.h1|0,Z=Y,Q=this.h2|0,be=Q,pe=this.h3|0,ae=pe,x=this.h4|0,b=x;for(let f=0;f<5;f++){const I=4-f,z=g[f],M=T[f],G=a[f],ne=d[f],ie=i[f],ce=E[f];for(let W=0;W<16;W++){const ue=(0,c.rotl)(k+F(f,Y,Q,pe)+V[G[W]]+z,ie[W])+x|0;k=x,x=pe,pe=(0,c.rotl)(Q,10)|0,Q=Y,Y=ue}for(let W=0;W<16;W++){const ue=(0,c.rotl)(U+F(I,Z,be,ae)+V[ne[W]]+M,ce[W])+b|0;U=b,b=ae,ae=(0,c.rotl)(be,10)|0,be=Z,Z=ue}}this.set(this.h1+Q+ae|0,this.h2+pe+b|0,this.h3+x+U|0,this.h4+k+Z|0,this.h0+Y+be|0)}roundClean(){V.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}o.RIPEMD160=K,o.ripemd160=(0,c.wrapConstructor)(()=>new K)},9598:function(oe,o,R){"use strict";/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */Object.defineProperty(o,"__esModule",{value:!0}),o.utils=o.schnorr=o.verify=o.signSync=o.sign=o.getSharedSecret=o.recoverPublicKey=o.getPublicKey=o.Signature=o.Point=o.CURVE=void 0;const C=R(14923),c=BigInt(0),v=BigInt(1),B=BigInt(2),y=BigInt(3),a=BigInt(8),d=Object.freeze({a:c,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:v,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")});o.CURVE=d;const w=(n,e)=>(n+e/B)/e,i={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(n){const{n:e}=d,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),l=-v*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),m=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),N=r,j=BigInt("0x100000000000000000000000000000000"),$=w(N*n,e),J=w(-l*n,e);let q=O(n-$*r-J*m,e),_=O(-$*l-J*N,e);const te=q>j,re=_>j;if(te&&(q=e-q),re&&(_=e-_),q>j||_>j)throw new Error("splitScalarEndo: Endomorphism failed, k="+n);return{k1neg:te,k1:q,k2neg:re,k2:_}}},E=32,g=32,T=32,F=E+1,V=2*E+1;function K(n){const{a:e,b:r}=d,l=O(n*n),m=O(l*n);return O(m+e*n+r)}const H=d.a===c;class S extends Error{constructor(e){super(e)}}function A(n){if(!(n instanceof k))throw new TypeError("JacobianPoint expected")}class k{constructor(e,r,l){this.x=e,this.y=r,this.z=l}static fromAffine(e){if(!(e instanceof Z))throw new TypeError("JacobianPoint#fromAffine: expected Point");return e.equals(Z.ZERO)?k.ZERO:new k(e.x,e.y,v)}static toAffineBatch(e){const r=Pe(e.map(l=>l.z));return e.map((l,m)=>l.toAffine(r[m]))}static normalizeZ(e){return k.toAffineBatch(e).map(k.fromAffine)}equals(e){A(e);const{x:r,y:l,z:m}=this,{x:N,y:j,z:$}=e,J=O(m*m),q=O($*$),_=O(r*q),te=O(N*J),re=O(O(l*$)*q),de=O(O(j*m)*J);return _===te&&re===de}negate(){return new k(this.x,O(-this.y),this.z)}double(){const{x:e,y:r,z:l}=this,m=O(e*e),N=O(r*r),j=O(N*N),$=e+N,J=O(B*(O($*$)-m-j)),q=O(y*m),_=O(q*q),te=O(_-B*J),re=O(q*(J-te)-a*j),de=O(B*r*l);return new k(te,re,de)}add(e){A(e);const{x:r,y:l,z:m}=this,{x:N,y:j,z:$}=e;if(N===c||j===c)return this;if(r===c||l===c)return e;const J=O(m*m),q=O($*$),_=O(r*q),te=O(N*J),re=O(O(l*$)*q),de=O(O(j*m)*J),he=O(te-_),xe=O(de-re);if(he===c)return xe===c?this.double():k.ZERO;const Se=O(he*he),Le=O(he*Se),De=O(_*Se),$e=O(xe*xe-Le-B*De),Ve=O(xe*(De-$e)-re*Le),Fe=O(m*$*he);return new k($e,Ve,Fe)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){const r=k.ZERO;if(typeof e=="bigint"&&e===c)return r;let l=ue(e);if(l===v)return this;if(!H){let te=r,re=this;for(;l>c;)l&v&&(te=te.add(re)),re=re.double(),l>>=v;return te}let{k1neg:m,k1:N,k2neg:j,k2:$}=i.splitScalar(l),J=r,q=r,_=this;for(;N>c||$>c;)N&v&&(J=J.add(_)),$&v&&(q=q.add(_)),_=_.double(),N>>=v,$>>=v;return m&&(J=J.negate()),j&&(q=q.negate()),q=new k(O(q.x*i.beta),q.y,q.z),J.add(q)}precomputeWindow(e){const r=H?128/e+1:256/e+1,l=[];let m=this,N=m;for(let j=0;j<r;j++){N=m,l.push(N);for(let $=1;$<2**(e-1);$++)N=N.add(m),l.push(N);m=N.double()}return l}wNAF(e,r){!r&&this.equals(k.BASE)&&(r=Z.BASE);const l=r&&r._WINDOW_SIZE||1;if(256%l)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let m=r&&Y.get(r);m||(m=this.precomputeWindow(l),r&&l!==1&&(m=k.normalizeZ(m),Y.set(r,m)));let N=k.ZERO,j=k.BASE;const $=1+(H?128/l:256/l),J=2**(l-1),q=BigInt(2**l-1),_=2**l,te=BigInt(l);for(let re=0;re<$;re++){const de=re*J;let he=Number(e&q);e>>=te,he>J&&(he-=_,e+=v);const xe=de,Se=de+Math.abs(he)-1,Le=re%2!==0,De=he<0;he===0?j=j.add(U(Le,m[xe])):N=N.add(U(De,m[Se]))}return{p:N,f:j}}multiply(e,r){let l=ue(e),m,N;if(H){const{k1neg:j,k1:$,k2neg:J,k2:q}=i.splitScalar(l);let{p:_,f:te}=this.wNAF($,r),{p:re,f:de}=this.wNAF(q,r);_=U(j,_),re=U(J,re),re=new k(O(re.x*i.beta),re.y,re.z),m=_.add(re),N=te.add(de)}else{const{p:j,f:$}=this.wNAF(l,r);m=j,N=$}return k.normalizeZ([m,N])[0]}toAffine(e){const{x:r,y:l,z:m}=this,N=this.equals(k.ZERO);e==null&&(e=N?a:Ee(m));const j=e,$=O(j*j),J=O($*j),q=O(r*$),_=O(l*J),te=O(m*j);if(N)return Z.ZERO;if(te!==v)throw new Error("invZ was invalid");return new Z(q,_)}}k.BASE=new k(d.Gx,d.Gy,v),k.ZERO=new k(c,v,c);function U(n,e){const r=e.negate();return n?r:e}const Y=new WeakMap;class Z{constructor(e,r){this.x=e,this.y=r}_setWindowSize(e){this._WINDOW_SIZE=e,Y.delete(this)}hasEvenY(){return this.y%B===c}static fromCompressedHex(e){const r=e.length===32,l=ce(r?e:e.subarray(1));if(!le(l))throw new Error("Point is not on curve");const m=K(l);let N=ke(m);const j=(N&v)===v;r?j&&(N=O(-N)):(e[0]&1)===1!==j&&(N=O(-N));const $=new Z(l,N);return $.assertValidity(),$}static fromUncompressedHex(e){const r=ce(e.subarray(1,E+1)),l=ce(e.subarray(E+1,E*2+1)),m=new Z(r,l);return m.assertValidity(),m}static fromHex(e){const r=W(e),l=r.length,m=r[0];if(l===E)return this.fromCompressedHex(r);if(l===F&&(m===2||m===3))return this.fromCompressedHex(r);if(l===V&&m===4)return this.fromUncompressedHex(r);throw new Error(`Point.fromHex: received invalid point. Expected 32-${F} compressed bytes or ${V} uncompressed bytes, not ${l}`)}static fromPrivateKey(e){return Z.BASE.multiply(me(e))}static fromSignature(e,r,l){const{r:m,s:N}=Ke(r);if(![0,1,2,3].includes(l))throw new Error("Cannot recover: invalid recovery bit");const j=He(W(e)),{n:$}=d,J=l===2||l===3?m+$:m,q=Ee(J,$),_=O(-j*q,$),te=O(N*q,$),re=l&1?"03":"02",de=Z.fromHex(re+z(J)),he=Z.BASE.multiplyAndAddUnsafe(de,_,te);if(!he)throw new Error("Cannot recover signature: point at infinify");return he.assertValidity(),he}toRawBytes(e=!1){return ie(this.toHex(e))}toHex(e=!1){const r=z(this.x);return e?`${this.hasEvenY()?"02":"03"}${r}`:`04${r}${z(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:r,y:l}=this;if(!le(r)||!le(l))throw new Error(e);const m=O(l*l),N=K(r);if(O(m-N)!==c)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new Z(this.x,O(-this.y))}double(){return k.fromAffine(this).double().toAffine()}add(e){return k.fromAffine(this).add(k.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return k.fromAffine(this).multiply(e,this).toAffine()}multiplyAndAddUnsafe(e,r,l){const m=k.fromAffine(this),N=r===c||r===v||this!==Z.BASE?m.multiplyUnsafe(r):m.multiply(r),j=k.fromAffine(e).multiplyUnsafe(l),$=N.add(j);return $.equals(k.ZERO)?void 0:$.toAffine()}}o.Point=Z,Z.BASE=new Z(d.Gx,d.Gy),Z.ZERO=new Z(c,c);function Q(n){return Number.parseInt(n[0],16)>=8?"00"+n:n}function be(n){if(n.length<2||n[0]!==2)throw new Error(`Invalid signature integer tag: ${f(n)}`);const e=n[1],r=n.subarray(2,e+2);if(!e||r.length!==e)throw new Error("Invalid signature integer: wrong length");if(r[0]===0&&r[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:ce(r),left:n.subarray(e+2)}}function pe(n){if(n.length<2||n[0]!=48)throw new Error(`Invalid signature tag: ${f(n)}`);if(n[1]!==n.length-2)throw new Error("Invalid signature: incorrect length");const{data:e,left:r}=be(n.subarray(2)),{data:l,left:m}=be(r);if(m.length)throw new Error(`Invalid signature: left bytes after parsing: ${f(m)}`);return{r:e,s:l}}class ae{constructor(e,r){this.r=e,this.s=r,this.assertValidity()}static fromCompact(e){const r=e instanceof Uint8Array,l="Signature.fromCompact";if(typeof e!="string"&&!r)throw new TypeError(`${l}: Expected string or Uint8Array`);const m=r?f(e):e;if(m.length!==128)throw new Error(`${l}: Expected 64-byte hex`);return new ae(ne(m.slice(0,64)),ne(m.slice(64,128)))}static fromDER(e){const r=e instanceof Uint8Array;if(typeof e!="string"&&!r)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:l,s:m}=pe(r?e:ie(e));return new ae(l,m)}static fromHex(e){return this.fromDER(e)}assertValidity(){const{r:e,s:r}=this;if(!X(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!X(r))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const e=d.n>>v;return this.s>e}normalizeS(){return this.hasHighS()?new ae(this.r,O(-this.s,d.n)):this}toDERRawBytes(){return ie(this.toDERHex())}toDERHex(){const e=Q(G(this.s)),r=Q(G(this.r)),l=e.length/2,m=r.length/2,N=G(l),j=G(m);return`30${G(m+l+4)}02${j}${r}02${N}${e}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return ie(this.toCompactHex())}toCompactHex(){return z(this.r)+z(this.s)}}o.Signature=ae;function x(...n){if(!n.every(l=>l instanceof Uint8Array))throw new Error("Uint8Array list expected");if(n.length===1)return n[0];const e=n.reduce((l,m)=>l+m.length,0),r=new Uint8Array(e);for(let l=0,m=0;l<n.length;l++){const N=n[l];r.set(N,m),m+=N.length}return r}const b=Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));function f(n){if(!(n instanceof Uint8Array))throw new Error("Expected Uint8Array");let e="";for(let r=0;r<n.length;r++)e+=b[n[r]];return e}const I=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function z(n){if(typeof n!="bigint")throw new Error("Expected bigint");if(!(c<=n&&n<I))throw new Error("Expected number 0 <= n < 2^256");return n.toString(16).padStart(64,"0")}function M(n){const e=ie(z(n));if(e.length!==32)throw new Error("Error: expected 32 bytes");return e}function G(n){const e=n.toString(16);return e.length&1?`0${e}`:e}function ne(n){if(typeof n!="string")throw new TypeError("hexToNumber: expected string, got "+typeof n);return BigInt(`0x${n}`)}function ie(n){if(typeof n!="string")throw new TypeError("hexToBytes: expected string, got "+typeof n);if(n.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+n.length);const e=new Uint8Array(n.length/2);for(let r=0;r<e.length;r++){const l=r*2,m=n.slice(l,l+2),N=Number.parseInt(m,16);if(Number.isNaN(N)||N<0)throw new Error("Invalid byte sequence");e[r]=N}return e}function ce(n){return ne(f(n))}function W(n){return n instanceof Uint8Array?Uint8Array.from(n):ie(n)}function ue(n){if(typeof n=="number"&&Number.isSafeInteger(n)&&n>0)return BigInt(n);if(typeof n=="bigint"&&X(n))return n;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function O(n,e=d.P){const r=n%e;return r>=c?r:e+r}function ye(n,e){const{P:r}=d;let l=n;for(;e-- >c;)l*=l,l%=r;return l}function ke(n){const{P:e}=d,r=BigInt(6),l=BigInt(11),m=BigInt(22),N=BigInt(23),j=BigInt(44),$=BigInt(88),J=n*n*n%e,q=J*J*n%e,_=ye(q,y)*q%e,te=ye(_,y)*q%e,re=ye(te,B)*J%e,de=ye(re,l)*re%e,he=ye(de,m)*de%e,xe=ye(he,j)*he%e,Se=ye(xe,$)*xe%e,Le=ye(Se,j)*he%e,De=ye(Le,y)*q%e,$e=ye(De,N)*de%e,Ve=ye($e,r)*J%e,Fe=ye(Ve,B);if(Fe*Fe%e!==n)throw new Error("Cannot find square root");return Fe}function Ee(n,e=d.P){if(n===c||e<=c)throw new Error(`invert: expected positive integers, got n=${n} mod=${e}`);let r=O(n,e),l=e,m=c,N=v,j=v,$=c;for(;r!==c;){const q=l/r,_=l%r,te=m-j*q,re=N-$*q;l=r,r=_,m=j,N=$,j=te,$=re}if(l!==v)throw new Error("invert: does not exist");return O(m,e)}function Pe(n,e=d.P){const r=new Array(n.length),l=n.reduce((N,j,$)=>j===c?N:(r[$]=N,O(N*j,e)),v),m=Ee(l,e);return n.reduceRight((N,j,$)=>j===c?N:(r[$]=O(N*r[$],e),O(N*j,e)),m),r}function Me(n){const e=n.length*8-g*8,r=ce(n);return e>0?r>>BigInt(e):r}function He(n,e=!1){const r=Me(n);if(e)return r;const{n:l}=d;return r>=l?r-l:r}let Ne,h;class D{constructor(e,r){if(this.hashLen=e,this.qByteLen=r,typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof r!="number"||r<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 o.utils.hmacSha256(this.k,...e)}hmacSync(...e){return h(this.k,...e)}checkSync(){if(typeof h!="function")throw new S("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),e.length!==0&&(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),e.length!==0&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),e),this.v=this.hmacSync(this.v))}async generate(){this.incr();let e=0;const r=[];for(;e<this.qByteLen;){this.v=await this.hmac(this.v);const l=this.v.slice();r.push(l),e+=this.v.length}return x(...r)}generateSync(){this.checkSync(),this.incr();let e=0;const r=[];for(;e<this.qByteLen;){this.v=this.hmacSync(this.v);const l=this.v.slice();r.push(l),e+=this.v.length}return x(...r)}}function X(n){return c<n&&n<d.n}function le(n){return c<n&&n<d.P}function ge(n,e,r,l=!0){const{n:m}=d,N=He(n,!0);if(!X(N))return;const j=Ee(N,m),$=Z.BASE.multiply(N),J=O($.x,m);if(J===c)return;const q=O(j*O(e+r*J,m),m);if(q===c)return;let _=new ae(J,q),te=($.x===_.r?0:2)|Number($.y&v);return l&&_.hasHighS()&&(_=_.normalizeS(),te^=1),{sig:_,recovery:te}}function me(n){let e;if(typeof n=="bigint")e=n;else if(typeof n=="number"&&Number.isSafeInteger(n)&&n>0)e=BigInt(n);else if(typeof n=="string"){if(n.length!==2*g)throw new Error("Expected 32 bytes of private key");e=ne(n)}else if(n instanceof Uint8Array){if(n.length!==g)throw new Error("Expected 32 bytes of private key");e=ce(n)}else throw new TypeError("Expected valid private key");if(!X(e))throw new Error("Expected private key: 0 < key < n");return e}function Be(n){return n instanceof Z?(n.assertValidity(),n):Z.fromHex(n)}function Ke(n){if(n instanceof ae)return n.assertValidity(),n;try{return ae.fromDER(n)}catch{return ae.fromCompact(n)}}function Ce(n,e=!1){return Z.fromPrivateKey(n).toRawBytes(e)}o.getPublicKey=Ce;function ct(n,e,r,l=!1){return Z.fromSignature(n,e,r).toRawBytes(l)}o.recoverPublicKey=ct;function Qe(n){const e=n instanceof Uint8Array,r=typeof n=="string",l=(e||r)&&n.length;return e?l===F||l===V:r?l===F*2||l===V*2:n instanceof Z}function ft(n,e,r=!1){if(Qe(n))throw new TypeError("getSharedSecret: first arg must be private key");if(!Qe(e))throw new TypeError("getSharedSecret: second arg must be public key");const l=Be(e);return l.assertValidity(),l.multiply(me(n)).toRawBytes(r)}o.getSharedSecret=ft;function Je(n){const e=n.length>E?n.slice(0,E):n;return ce(e)}function ut(n){const e=Je(n),r=O(e,d.n);return _e(r<c?e:r)}function _e(n){return M(n)}function et(n,e,r){if(n==null)throw new Error(`sign: expected valid message hash, not "${n}"`);const l=W(n),m=me(e),N=[_e(m),ut(l)];if(r!=null){r===!0&&(r=o.utils.randomBytes(E));const J=W(r);if(J.length!==E)throw new Error(`sign: Expected ${E} bytes of extra data`);N.push(J)}const j=x(...N),$=Je(l);return{seed:j,m:$,d:m}}function tt(n,e){const{sig:r,recovery:l}=n,{der:m,recovered:N}=Object.assign({canonical:!0,der:!0},e),j=m?r.toDERRawBytes():r.toCompactRawBytes();return N?[j,l]:j}async function lt(n,e,r={}){const{seed:l,m,d:N}=et(n,e,r.extraEntropy),j=new D(T,g);await j.reseed(l);let $;for(;!($=ge(await j.generate(),m,N,r.canonical));)await j.reseed();return tt($,r)}o.sign=lt;function Ge(n,e,r={}){const{seed:l,m,d:N}=et(n,e,r.extraEntropy),j=new D(T,g);j.reseedSync(l);let $;for(;!($=ge(j.generateSync(),m,N,r.canonical));)j.reseedSync();return tt($,r)}o.signSync=Ge;const bt={strict:!0};function yt(n,e,r,l=bt){let m;try{m=Ke(n),e=W(e)}catch{return!1}const{r:N,s:j}=m;if(l.strict&&m.hasHighS())return!1;const $=He(e);let J;try{J=Be(r)}catch{return!1}const{n:q}=d,_=Ee(j,q),te=O($*_,q),re=O(N*_,q),de=Z.BASE.multiplyAndAddUnsafe(J,te,re);return de?O(de.x,q)===N:!1}o.verify=yt;function We(n){return O(ce(n),d.n)}class ze{constructor(e,r){this.r=e,this.s=r,this.assertValidity()}static fromHex(e){const r=W(e);if(r.length!==64)throw new TypeError(`SchnorrSignature.fromHex: expected 64 bytes, not ${r.length}`);const l=ce(r.subarray(0,32)),m=ce(r.subarray(32,64));return new ze(l,m)}assertValidity(){const{r:e,s:r}=this;if(!le(e)||!X(r))throw new Error("Invalid signature")}toHex(){return z(this.r)+z(this.s)}toRawBytes(){return ie(this.toHex())}}function ht(n){return Z.fromPrivateKey(n).toRawX()}class rt{constructor(e,r,l=o.utils.randomBytes()){if(e==null)throw new TypeError(`sign: Expected valid message, not "${e}"`);this.m=W(e);const{x:m,scalar:N}=this.getScalar(me(r));if(this.px=m,this.d=N,this.rand=W(l),this.rand.length!==32)throw new TypeError("sign: Expected 32 bytes of aux randomness")}getScalar(e){const r=Z.fromPrivateKey(e),l=r.hasEvenY()?e:d.n-e;return{point:r,scalar:l,x:r.toRawX()}}initNonce(e,r){return M(e^ce(r))}finalizeNonce(e){const r=O(ce(e),d.n);if(r===c)throw new Error("sign: Creation of signature failed. k is zero");const{point:l,x:m,scalar:N}=this.getScalar(r);return{R:l,rx:m,k:N}}finalizeSig(e,r,l,m){return new ze(e.x,O(r+l*m,d.n)).toRawBytes()}error(){throw new Error("sign: Invalid signature produced")}async calc(){const{m:e,d:r,px:l,rand:m}=this,N=o.utils.taggedHash,j=this.initNonce(r,await N(Re.aux,m)),{R:$,rx:J,k:q}=this.finalizeNonce(await N(Re.nonce,j,l,e)),_=We(await N(Re.challenge,J,l,e)),te=this.finalizeSig($,q,_,r);return await ot(te,e,l)||this.error(),te}calcSync(){const{m:e,d:r,px:l,rand:m}=this,N=o.utils.taggedHashSync,j=this.initNonce(r,N(Re.aux,m)),{R:$,rx:J,k:q}=this.finalizeNonce(N(Re.nonce,j,l,e)),_=We(N(Re.challenge,J,l,e)),te=this.finalizeSig($,q,_,r);return it(te,e,l)||this.error(),te}}async function dt(n,e,r){return new rt(n,e,r).calc()}function je(n,e,r){return new rt(n,e,r).calcSync()}function Oe(n,e,r){const l=n instanceof ze,m=l?n:ze.fromHex(n);return l&&m.assertValidity(),{...m,m:W(e),P:Be(r)}}function nt(n,e,r,l){const m=Z.BASE.multiplyAndAddUnsafe(e,me(r),O(-l,d.n));return!(!m||!m.hasEvenY()||m.x!==n)}async function ot(n,e,r){try{const{r:l,s:m,m:N,P:j}=Oe(n,e,r),$=We(await o.utils.taggedHash(Re.challenge,M(l),j.toRawX(),N));return nt(l,j,m,$)}catch{return!1}}function it(n,e,r){try{const{r:l,s:m,m:N,P:j}=Oe(n,e,r),$=We(o.utils.taggedHashSync(Re.challenge,M(l),j.toRawX(),N));return nt(l,j,m,$)}catch(l){if(l instanceof S)throw l;return!1}}o.schnorr={Signature:ze,getPublicKey:ht,sign:dt,verify:ot,signSync:je,verifySync:it},Z.BASE._setWindowSize(8);const ve={node:C,web:typeof self=="object"&&"crypto"in self?self.crypto:void 0},Re={challenge:"BIP0340/challenge",aux:"BIP0340/aux",nonce:"BIP0340/nonce"},Ze={};o.utils={bytesToHex:f,hexToBytes:ie,concatBytes:x,mod:O,invert:Ee,isValidPrivateKey(n){try{return me(n),!0}catch{return!1}},_bigintTo32Bytes:M,_normalizePrivateKey:me,hashToPrivateKey:n=>{n=W(n);const e=g+8;if(n.length<e||n.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");const r=O(ce(n),d.n-v)+v;return M(r)},randomBytes:(n=32)=>{if(ve.web)return ve.web.getRandomValues(new Uint8Array(n));if(ve.node){const{randomBytes:e}=ve.node;return Uint8Array.from(e(n))}else throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>o.utils.hashToPrivateKey(o.utils.randomBytes(g+8)),precompute(n=8,e=Z.BASE){const r=e===Z.BASE?e:new Z(e.x,e.y);return r._setWindowSize(n),r.multiply(y),r},sha256:async(...n)=>{if(ve.web){const e=await ve.web.subtle.digest("SHA-256",x(...n));return new Uint8Array(e)}else if(ve.node){const{createHash:e}=ve.node,r=e("sha256");return n.forEach(l=>r.update(l)),Uint8Array.from(r.digest())}else throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(n,...e)=>{if(ve.web){const r=await ve.web.subtle.importKey("raw",n,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),l=x(...e),m=await ve.web.subtle.sign("HMAC",r,l);return new Uint8Array(m)}else if(ve.node){const{createHmac:r}=ve.node,l=r("sha256",n);return e.forEach(m=>l.update(m)),Uint8Array.from(l.digest())}else throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(n,...e)=>{let r=Ze[n];if(r===void 0){const l=await o.utils.sha256(Uint8Array.from(n,m=>m.charCodeAt(0)));r=x(l,l),Ze[n]=r}return o.utils.sha256(r,...e)},taggedHashSync:(n,...e)=>{if(typeof Ne!="function")throw new S("sha256Sync is undefined, you need to set it");let r=Ze[n];if(r===void 0){const l=Ne(Uint8Array.from(n,m=>m.charCodeAt(0)));r=x(l,l),Ze[n]=r}return Ne(r,...e)},_JacobianPoint:k},Object.defineProperties(o.utils,{sha256Sync:{configurable:!1,get(){return Ne},set(n){Ne||(Ne=n)}},hmacSha256Sync:{configurable:!1,get(){return h},set(n){h||(h=n)}}})},63203:function(oe,o){"use strict";/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(o,"__esModule",{value:!0}),o.bytes=o.stringToBytes=o.str=o.bytesToString=o.hex=o.utf8=o.bech32m=o.bech32=o.base58check=o.createBase58check=o.base58xmr=o.base58xrp=o.base58flickr=o.base58=o.base64urlnopad=o.base64url=o.base64nopad=o.base64=o.base32crockford=o.base32hexnopad=o.base32hex=o.base32nopad=o.base32=o.base16=o.utils=o.assertNumber=void 0;function R(x){if(!Number.isSafeInteger(x))throw new Error(`Wrong integer: ${x}`)}o.assertNumber=R;function C(x){return x instanceof Uint8Array||x!=null&&typeof x=="object"&&x.constructor.name==="Uint8Array"}function c(...x){const b=M=>M,f=(M,G)=>ne=>M(G(ne)),I=x.map(M=>M.encode).reduceRight(f,b),z=x.map(M=>M.decode).reduce(f,b);return{encode:I,decode:z}}function v(x){return{encode:b=>{if(!Array.isArray(b)||b.length&&typeof b[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return b.map(f=>{if(R(f),f<0||f>=x.length)throw new Error(`Digit index outside alphabet: ${f} (alphabet: ${x.length})`);return x[f]})},decode:b=>{if(!Array.isArray(b)||b.length&&typeof b[0]!="string")throw new Error("alphabet.decode input should be array of strings");return b.map(f=>{if(typeof f!="string")throw new Error(`alphabet.decode: not string element=${f}`);const I=x.indexOf(f);if(I===-1)throw new Error(`Unknown letter: "${f}". Allowed: ${x}`);return I})}}}function B(x=""){if(typeof x!="string")throw new Error("join separator should be string");return{encode:b=>{if(!Array.isArray(b)||b.length&&typeof b[0]!="string")throw new Error("join.encode input should be array of strings");for(let f of b)if(typeof f!="string")throw new Error(`join.encode: non-string input=${f}`);return b.join(x)},decode:b=>{if(typeof b!="string")throw new Error("join.decode input should be string");return b.split(x)}}}function y(x,b="="){if(R(x),typeof b!="string")throw new Error("padding chr should be string");return{encode(f){if(!Array.isArray(f)||f.length&&typeof f[0]!="string")throw new Error("padding.encode input should be array of strings");for(let I of f)if(typeof I!="string")throw new Error(`padding.encode: non-string input=${I}`);for(;f.length*x%8;)f.push(b);return f},decode(f){if(!Array.isArray(f)||f.length&&typeof f[0]!="string")throw new Error("padding.encode input should be array of strings");for(let z of f)if(typeof z!="string")throw new Error(`padding.decode: non-string input=${z}`);let I=f.length;if(I*x%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;I>0&&f[I-1]===b;I--)if(!((I-1)*x%8))throw new Error("Invalid padding: string has too much padding");return f.slice(0,I)}}}function a(x){if(typeof x!="function")throw new Error("normalize fn should be function");return{encode:b=>b,decode:b=>x(b)}}function d(x,b,f){if(b<2)throw new Error(`convertRadix: wrong from=${b}, base cannot be less than 2`);if(f<2)throw new Error(`convertRadix: wrong to=${f}, base cannot be less than 2`);if(!Array.isArray(x))throw new Error("convertRadix: data should be array");if(!x.length)return[];let I=0;const z=[],M=Array.from(x);for(M.forEach(G=>{if(R(G),G<0||G>=b)throw new Error(`Wrong integer: ${G}`)});;){let G=0,ne=!0;for(let ie=I;ie<M.length;ie++){const ce=M[ie],W=b*G+ce;if(!Number.isSafeInteger(W)||b*G/b!==G||W-ce!==b*G)throw new Error("convertRadix: carry overflow");G=W%f;const ue=Math.floor(W/f);if(M[ie]=ue,!Number.isSafeInteger(ue)||ue*f+G!==W)throw new Error("convertRadix: carry overflow");if(ne)ue?ne=!1:I=ie;else continue}if(z.push(G),ne)break}for(let G=0;G<x.length-1&&x[G]===0;G++)z.push(0);return z.reverse()}const w=(x,b)=>b?w(b,x%b):x,i=(x,b)=>x+(b-w(x,b));function E(x,b,f,I){if(!Array.isArray(x))throw new Error("convertRadix2: data should be array");if(b<=0||b>32)throw new Error(`convertRadix2: wrong from=${b}`);if(f<=0||f>32)throw new Error(`convertRadix2: wrong to=${f}`);if(i(b,f)>32)throw new Error(`convertRadix2: carry overflow from=${b} to=${f} carryBits=${i(b,f)}`);let z=0,M=0;const G=2**f-1,ne=[];for(const ie of x){if(R(ie),ie>=2**b)throw new Error(`convertRadix2: invalid data word=${ie} from=${b}`);if(z=z<<b|ie,M+b>32)throw new Error(`convertRadix2: carry overflow pos=${M} from=${b}`);for(M+=b;M>=f;M-=f)ne.push((z>>M-f&G)>>>0);z&=2**M-1}if(z=z<<f-M&G,!I&&M>=b)throw new Error("Excess padding");if(!I&&z)throw new Error(`Non-zero padding: ${z}`);return I&&M>0&&ne.push(z>>>0),ne}function g(x){return R(x),{encode:b=>{if(!C(b))throw new Error("radix.encode input should be Uint8Array");return d(Array.from(b),2**8,x)},decode:b=>{if(!Array.isArray(b)||b.length&&typeof b[0]!="number")throw new Error("radix.decode input should be array of numbers");return Uint8Array.from(d(b,x,2**8))}}}function T(x,b=!1){if(R(x),x<=0||x>32)throw new Error("radix2: bits should be in (0..32]");if(i(8,x)>32||i(x,8)>32)throw new Error("radix2: carry overflow");return{encode:f=>{if(!C(f))throw new Error("radix2.encode input should be Uint8Array");return E(Array.from(f),8,x,!b)},decode:f=>{if(!Array.isArray(f)||f.length&&typeof f[0]!="number")throw new Error("radix2.decode input should be array of numbers");return Uint8Array.from(E(f,x,8,b))}}}function F(x){if(typeof x!="function")throw new Error("unsafeWrapper fn should be function");return function(...b){try{return x.apply(null,b)}catch{}}}function V(x,b){if(R(x),typeof b!="function")throw new Error("checksum fn should be function");return{encode(f){if(!C(f))throw new Error("checksum.encode: input should be Uint8Array");const I=b(f).slice(0,x),z=new Uint8Array(f.length+x);return z.set(f),z.set(I,f.length),z},decode(f){if(!C(f))throw new Error("checksum.decode: input should be Uint8Array");const I=f.slice(0,-x),z=b(I).slice(0,x),M=f.slice(-x);for(let G=0;G<x;G++)if(z[G]!==M[G])throw new Error("Invalid checksum");return I}}}o.utils={alphabet:v,chain:c,checksum:V,convertRadix:d,convertRadix2:E,radix:g,radix2:T,join:B,padding:y},o.base16=c(T(4),v("0123456789ABCDEF"),B("")),o.base32=c(T(5),v("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),y(5),B("")),o.base32nopad=c(T(5),v("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),B("")),o.base32hex=c(T(5),v("0123456789ABCDEFGHIJKLMNOPQRSTUV"),y(5),B("")),o.base32hexnopad=c(T(5),v("0123456789ABCDEFGHIJKLMNOPQRSTUV"),B("")),o.base32crockford=c(T(5),v("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),B(""),a(x=>x.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1"))),o.base64=c(T(6),v("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),y(6),B("")),o.base64nopad=c(T(6),v("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),B("")),o.base64url=c(T(6),v("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),y(6),B("")),o.base64urlnopad=c(T(6),v("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),B(""));const K=x=>c(g(58),v(x),B(""));o.base58=K("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),o.base58flickr=K("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),o.base58xrp=K("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const H=[0,2,3,5,6,7,9,10,11];o.base58xmr={encode(x){let b="";for(let f=0;f<x.length;f+=8){const I=x.subarray(f,f+8);b+=o.base58.encode(I).padStart(H[I.length],"1")}return b},decode(x){let b=[];for(let f=0;f<x.length;f+=11){const I=x.slice(f,f+11),z=H.indexOf(I.length),M=o.base58.decode(I);for(let G=0;G<M.length-z;G++)if(M[G]!==0)throw new Error("base58xmr: wrong padding");b=b.concat(Array.from(M.slice(M.length-z)))}return Uint8Array.from(b)}};const S=x=>c(V(4,b=>x(x(b))),o.base58);o.createBase58check=S,o.base58check=o.createBase58check;const A=c(v("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),B("")),k=[996825010,642813549,513874426,1027748829,705979059];function U(x){const b=x>>25;let f=(x&33554431)<<5;for(let I=0;I<k.length;I++)(b>>I&1)===1&&(f^=k[I]);return f}function Y(x,b,f=1){const I=x.length;let z=1;for(let M=0;M<I;M++){const G=x.charCodeAt(M);if(G<33||G>126)throw new Error(`Invalid prefix (${x})`);z=U(z)^G>>5}z=U(z);for(let M=0;M<I;M++)z=U(z)^x.charCodeAt(M)&31;for(let M of b)z=U(z)^M;for(let M=0;M<6;M++)z=U(z);return z^=f,A.encode(E([z%2**30],30,5,!1))}function Z(x){const b=x==="bech32"?1:734539939,f=T(5),I=f.decode,z=f.encode,M=F(I);function G(W,ue,O=90){if(typeof W!="string")throw new Error(`bech32.encode prefix should be string, not ${typeof W}`);if(!Array.isArray(ue)||ue.length&&typeof ue[0]!="number")throw new Error(`bech32.encode words should be array of numbers, not ${typeof ue}`);if(W.length===0)throw new TypeError(`Invalid prefix length ${W.length}`);const ye=W.length+7+ue.length;if(O!==!1&&ye>O)throw new TypeError(`Length ${ye} exceeds limit ${O}`);const ke=W.toLowerCase(),Ee=Y(ke,ue,b);return`${ke}1${A.encode(ue)}${Ee}`}function ne(W,ue=90){if(typeof W!="string")throw new Error(`bech32.decode input should be string, not ${typeof W}`);if(W.length<8||ue!==!1&&W.length>ue)throw new TypeError(`Wrong string length: ${W.length} (${W}). Expected (8..${ue})`);const O=W.toLowerCase();if(W!==O&&W!==W.toUpperCase())throw new Error("String must be lowercase or uppercase");const ye=O.lastIndexOf("1");if(ye===0||ye===-1)throw new Error('Letter "1" must be present between prefix and data only');const ke=O.slice(0,ye),Ee=O.slice(ye+1);if(Ee.length<6)throw new Error("Data must be at least 6 characters long");const Pe=A.decode(Ee).slice(0,-6),Me=Y(ke,Pe,b);if(!Ee.endsWith(Me))throw new Error(`Invalid checksum in ${W}: expected "${Me}"`);return{prefix:ke,words:Pe}}const ie=F(ne);function ce(W){const{prefix:ue,words:O}=ne(W,!1);return{prefix:ue,words:O,bytes:I(O)}}return{encode:G,decode:ne,decodeToBytes:ce,decodeUnsafe:ie,fromWords:I,fromWordsUnsafe:M,toWords:z}}o.bech32=Z("bech32"),o.bech32m=Z("bech32m"),o.utf8={encode:x=>new TextDecoder().decode(x),decode:x=>new TextEncoder().encode(x)},o.hex=c(T(4),v("0123456789abcdef"),B(""),a(x=>{if(typeof x!="string"||x.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof x} with length ${x.length}`);return x.toLowerCase()}));const Q={utf8:o.utf8,hex:o.hex,base16:o.base16,base32:o.base32,base64:o.base64,base64url:o.base64url,base58:o.base58,base58xmr:o.base58xmr},be="Invalid encoding type. Available types: utf8, hex, base16, base32, base64, base64url, base58, base58xmr",pe=(x,b)=>{if(typeof x!="string"||!Q.hasOwnProperty(x))throw new TypeError(be);if(!C(b))throw new TypeError("bytesToString() expects Uint8Array");return Q[x].encode(b)};o.bytesToString=pe,o.str=o.bytesToString;const ae=(x,b)=>{if(!Q.hasOwnProperty(x))throw new TypeError(be);if(typeof b!="string")throw new TypeError("stringToBytes() expects string");return Q[x].decode(b)};o.stringToBytes=ae,o.bytes=o.stringToBytes},11206:function(oe,o,R){"use strict";var C=R(48287).Buffer;Object.defineProperty(o,"__esModule",{value:!0}),o.BIP32Factory=void 0;const c=R(25311),v=R(87569),B=R(63203),y=R(22623),a=R(8676),d=R(57513),w=(0,B.base58check)(y.sha256),i={encode:g=>w.encode(Uint8Array.from(g)),decode:g=>C.from(w.decode(g))};function E(g){(0,v.testEcc)(g);const T=a.BufferN(32),F=a.compile({wif:a.UInt8,bip32:{public:a.UInt32,private:a.UInt32}}),V={messagePrefix:`Bitcoin Signed Message:
|
|
2
|
-
`,bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},K=2147483648,H=Math.pow(2,31)-1;function S(b){return a.String(b)&&b.match(/^(m\/)?(\d+'?\/)*\d+'?$/)!==null}function A(b){return a.UInt32(b)&&b<=H}function k(b){return b.length===32?b:b.slice(1,33)}class U{constructor(f,I){this.__D=f,this.__Q=I,this.lowR=!1}get publicKey(){return this.__Q===void 0&&(this.__Q=C.from(g.pointFromScalar(this.__D,!0))),this.__Q}get privateKey(){return this.__D}sign(f,I){if(!this.privateKey)throw new Error("Missing private key");if(I===void 0&&(I=this.lowR),I===!1)return C.from(g.sign(f,this.privateKey));{let z=C.from(g.sign(f,this.privateKey));const M=C.alloc(32,0);let G=0;for(;z[0]>127;)G++,M.writeUIntLE(G,0,6),z=C.from(g.sign(f,this.privateKey,M));return z}}signSchnorr(f){if(!this.privateKey)throw new Error("Missing private key");if(!g.signSchnorr)throw new Error("signSchnorr not supported by ecc library");return C.from(g.signSchnorr(f,this.privateKey))}verify(f,I){return g.verify(f,this.publicKey,I)}verifySchnorr(f,I){if(!g.verifySchnorr)throw new Error("verifySchnorr not supported by ecc library");return g.verifySchnorr(f,this.publicKey.subarray(1,33),I)}}class Y extends U{constructor(f,I,z,M,G=0,ne=0,ie=0){super(f,I),this.chainCode=z,this.network=M,this.__DEPTH=G,this.__INDEX=ne,this.__PARENT_FINGERPRINT=ie,a(F,M)}get depth(){return this.__DEPTH}get index(){return this.__INDEX}get parentFingerprint(){return this.__PARENT_FINGERPRINT}get identifier(){return c.hash160(this.publicKey)}get fingerprint(){return this.identifier.slice(0,4)}get compressed(){return!0}isNeutered(){return this.__D===void 0}neutered(){return ae(this.publicKey,this.chainCode,this.network,this.depth,this.index,this.parentFingerprint)}toBase58(){const f=this.network,I=this.isNeutered()?f.bip32.public:f.bip32.private,z=C.allocUnsafe(78);return z.writeUInt32BE(I,0),z.writeUInt8(this.depth,4),z.writeUInt32BE(this.parentFingerprint,5),z.writeUInt32BE(this.index,9),this.chainCode.copy(z,13),this.isNeutered()?this.publicKey.copy(z,45):(z.writeUInt8(0,45),this.privateKey.copy(z,46)),i.encode(z)}toWIF(){if(!this.privateKey)throw new TypeError("Missing private key");return d.encode(this.network.wif,this.privateKey,!0)}derive(f){a(a.UInt32,f);const I=f>=K,z=C.allocUnsafe(37);if(I){if(this.isNeutered())throw new TypeError("Missing private key for hardened child key");z[0]=0,this.privateKey.copy(z,1),z.writeUInt32BE(f,33)}else this.publicKey.copy(z,0),z.writeUInt32BE(f,33);const M=c.hmacSHA512(this.chainCode,z),G=M.slice(0,32),ne=M.slice(32);if(!g.isPrivate(G))return this.derive(f+1);let ie;if(this.isNeutered()){const ce=C.from(g.pointAddScalar(this.publicKey,G,!0));if(ce===null)return this.derive(f+1);ie=ae(ce,ne,this.network,this.depth+1,f,this.fingerprint.readUInt32BE(0))}else{const ce=C.from(g.privateAdd(this.privateKey,G));if(ce==null)return this.derive(f+1);ie=be(ce,ne,this.network,this.depth+1,f,this.fingerprint.readUInt32BE(0))}return ie}deriveHardened(f){return a(A,f),this.derive(f+K)}derivePath(f){a(S,f);let I=f.split("/");if(I[0]==="m"){if(this.parentFingerprint)throw new TypeError("Expected master, got child");I=I.slice(1)}return I.reduce((z,M)=>{let G;return M.slice(-1)==="'"?(G=parseInt(M.slice(0,-1),10),z.deriveHardened(G)):(G=parseInt(M,10),z.derive(G))},this)}tweak(f){return this.privateKey?this.tweakFromPrivateKey(f):this.tweakFromPublicKey(f)}tweakFromPublicKey(f){const I=k(this.publicKey);if(!g.xOnlyPointAddTweak)throw new Error("xOnlyPointAddTweak not supported by ecc library");const z=g.xOnlyPointAddTweak(I,f);if(!z||z.xOnlyPubkey===null)throw new Error("Cannot tweak public key!");const M=C.from([z.parity===0?2:3]),G=C.concat([M,z.xOnlyPubkey]);return new U(void 0,G)}tweakFromPrivateKey(f){const I=this.publicKey[0]===3||this.publicKey[0]===4&&(this.publicKey[64]&1)===1,z=(()=>{if(I){if(g.privateNegate)return g.privateNegate(this.privateKey);throw new Error("privateNegate not supported by ecc library")}else return this.privateKey})(),M=g.privateAdd(z,f);if(!M)throw new Error("Invalid tweaked private key!");return new U(C.from(M),void 0)}}function Z(b,f){const I=i.decode(b);if(I.length!==78)throw new TypeError("Invalid buffer length");f=f||V;const z=I.readUInt32BE(0);if(z!==f.bip32.private&&z!==f.bip32.public)throw new TypeError("Invalid network version");const M=I[4],G=I.readUInt32BE(5);if(M===0&&G!==0)throw new TypeError("Invalid parent fingerprint");const ne=I.readUInt32BE(9);if(M===0&&ne!==0)throw new TypeError("Invalid index");const ie=I.slice(13,45);let ce;if(z===f.bip32.private){if(I.readUInt8(45)!==0)throw new TypeError("Invalid private key");const W=I.slice(46,78);ce=be(W,ie,f,M,ne,G)}else{const W=I.slice(45,78);ce=ae(W,ie,f,M,ne,G)}return ce}function Q(b,f,I){return be(b,f,I)}function be(b,f,I,z,M,G){if(a({privateKey:T,chainCode:T},{privateKey:b,chainCode:f}),I=I||V,!g.isPrivate(b))throw new TypeError("Private key not in range [1, n)");return new Y(b,void 0,f,I,z,M,G)}function pe(b,f,I){return ae(b,f,I)}function ae(b,f,I,z,M,G){if(a({publicKey:a.BufferN(33),chainCode:T},{publicKey:b,chainCode:f}),I=I||V,!g.isPoint(b))throw new TypeError("Point is not on the curve");return new Y(void 0,b,f,I,z,M,G)}function x(b,f){if(a(a.Buffer,b),b.length<16)throw new TypeError("Seed should be at least 128 bits");if(b.length>64)throw new TypeError("Seed should be at most 512 bits");f=f||V;const I=c.hmacSHA512(C.from("Bitcoin seed","utf8"),b),z=I.slice(0,32),M=I.slice(32);return Q(z,M,f)}return{fromSeed:x,fromBase58:Z,fromPublicKey:pe,fromPrivateKey:Q}}o.BIP32Factory=E},25311:function(oe,o,R){"use strict";var C=R(48287).Buffer;Object.defineProperty(o,"__esModule",{value:!0}),o.hmacSHA512=o.hash160=void 0;const c=R(39615),v=R(93238),B=R(22623),y=R(30102);function a(w){const i=(0,B.sha256)(Uint8Array.from(w));return C.from((0,v.ripemd160)(i))}o.hash160=a;function d(w,i){return C.from((0,c.hmac)(y.sha512,w,i))}o.hmacSHA512=d},83328:function(oe,o,R){"use strict";var C;C={value:!0},o.Pr=C=void 0;var c=R(11206);C={enumerable:!0,get:function(){return c.BIP32Factory}},Object.defineProperty(o,"Pr",{enumerable:!0,get:function(){return c.BIP32Factory}})},87569:function(oe,o,R){"use strict";var C=R(48287).Buffer;Object.defineProperty(o,"__esModule",{value:!0}),o.testEcc=void 0;const c=y=>C.from(y,"hex");function v(y){if(B(y.isPoint(c("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),B(!y.isPoint(c("030000000000000000000000000000000000000000000000000000000000000005"))),B(y.isPrivate(c("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),B(y.isPrivate(c("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),B(!y.isPrivate(c("0000000000000000000000000000000000000000000000000000000000000000"))),B(!y.isPrivate(c("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"))),B(!y.isPrivate(c("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142"))),B(C.from(y.pointFromScalar(c("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(c("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99"))),y.xOnlyPointAddTweak){B(y.xOnlyPointAddTweak(c("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),c("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))===null);let a=y.xOnlyPointAddTweak(c("1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b"),c("a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac"));B(C.from(a.xOnlyPubkey).equals(c("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"))&&a.parity===1),a=y.xOnlyPointAddTweak(c("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"),c("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47"))}B(C.from(y.pointAddScalar(c("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),c("0000000000000000000000000000000000000000000000000000000000000003"))).equals(c("02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5"))),B(C.from(y.privateAdd(c("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"),c("0000000000000000000000000000000000000000000000000000000000000002"))).equals(c("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),y.privateNegate&&(B(C.from(y.privateNegate(c("0000000000000000000000000000000000000000000000000000000000000001"))).equals(c("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),B(C.from(y.privateNegate(c("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"))).equals(c("0000000000000000000000000000000000000000000000000000000000000003"))),B(C.from(y.privateNegate(c("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(c("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792")))),B(C.from(y.sign(c("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),c("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))).equals(c("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),B(y.verify(c("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),c("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),c("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),y.signSchnorr&&B(C.from(y.signSchnorr(c("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),c("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"),c("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906"))).equals(c("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7"))),y.verifySchnorr&&B(y.verifySchnorr(c("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),c("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"),c("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")))}o.testEcc=v;function B(y){if(!y)throw new Error("ecc library invalid")}},17009:function(oe,o,R){oe.exports=R(27655)(R(59393))},59393:function(oe,o,R){const C=R(86729).ec,c=new C("secp256k1"),v=c.curve,B=v.n.constructor;function y(i,E){let g=new B(E);if(g.cmp(v.p)>=0)return null;g=g.toRed(v.red);let T=g.redSqr().redIMul(g).redIAdd(v.b).redSqrt();return i===3!==T.isOdd()&&(T=T.redNeg()),c.keyPair({pub:{x:g,y:T}})}function a(i,E,g){let T=new B(E),F=new B(g);if(T.cmp(v.p)>=0||F.cmp(v.p)>=0||(T=T.toRed(v.red),F=F.toRed(v.red),(i===6||i===7)&&F.isOdd()!==(i===7)))return null;const V=T.redSqr().redIMul(T);return F.redSqr().redISub(V.redIAdd(v.b)).isZero()?c.keyPair({pub:{x:T,y:F}}):null}function d(i){const E=i[0];switch(E){case 2:case 3:return i.length!==33?null:y(E,i.subarray(1,33));case 4:case 6:case 7:return i.length!==65?null:a(E,i.subarray(1,33),i.subarray(33,65));default:return null}}function w(i,E){const g=E.encode(null,i.length===33);for(let T=0;T<i.length;++T)i[T]=g[T]}oe.exports={contextRandomize(){return 0},privateKeyVerify(i){const E=new B(i);return E.cmp(v.n)<0&&!E.isZero()?0:1},privateKeyNegate(i){const E=new B(i),g=v.n.sub(E).umod(v.n).toArrayLike(Uint8Array,"be",32);return i.set(g),0},privateKeyTweakAdd(i,E){const g=new B(E);if(g.cmp(v.n)>=0||(g.iadd(new B(i)),g.cmp(v.n)>=0&&g.isub(v.n),g.isZero()))return 1;const T=g.toArrayLike(Uint8Array,"be",32);return i.set(T),0},privateKeyTweakMul(i,E){let g=new B(E);if(g.cmp(v.n)>=0||g.isZero())return 1;g.imul(new B(i)),g.cmp(v.n)>=0&&(g=g.umod(v.n));const T=g.toArrayLike(Uint8Array,"be",32);return i.set(T),0},publicKeyVerify(i){return d(i)===null?1:0},publicKeyCreate(i,E){const g=new B(E);if(g.cmp(v.n)>=0||g.isZero())return 1;const T=c.keyFromPrivate(E).getPublic();return w(i,T),0},publicKeyConvert(i,E){const g=d(E);if(g===null)return 1;const T=g.getPublic();return w(i,T),0},publicKeyNegate(i,E){const g=d(E);if(g===null)return 1;const T=g.getPublic();return T.y=T.y.redNeg(),w(i,T),0},publicKeyCombine(i,E){const g=new Array(E.length);for(let F=0;F<E.length;++F)if(g[F]=d(E[F]),g[F]===null)return 1;let T=g[0].getPublic();for(let F=1;F<g.length;++F)T=T.add(g[F].pub);return T.isInfinity()?2:(w(i,T),0)},publicKeyTweakAdd(i,E,g){const T=d(E);if(T===null)return 1;if(g=new B(g),g.cmp(v.n)>=0)return 2;const F=T.getPublic().add(v.g.mul(g));return F.isInfinity()?2:(w(i,F),0)},publicKeyTweakMul(i,E,g){const T=d(E);if(T===null)return 1;if(g=new B(g),g.cmp(v.n)>=0||g.isZero())return 2;const F=T.getPublic().mul(g);return w(i,F),0},signatureNormalize(i){const E=new B(i.subarray(0,32)),g=new B(i.subarray(32,64));return E.cmp(v.n)>=0||g.cmp(v.n)>=0?1:(g.cmp(c.nh)===1&&i.set(v.n.sub(g).toArrayLike(Uint8Array,"be",32),32),0)},signatureExport(i,E){const g=E.subarray(0,32),T=E.subarray(32,64);if(new B(g).cmp(v.n)>=0||new B(T).cmp(v.n)>=0)return 1;const{output:F}=i;let V=F.subarray(4,4+33);V[0]=0,V.set(g,1);let K=33,H=0;for(;K>1&&V[H]===0&&!(V[H+1]&128);--K,++H);if(V=V.subarray(H),V[0]&128||K>1&&V[0]===0&&!(V[1]&128))return 1;let S=F.subarray(6+33,6+33+33);S[0]=0,S.set(T,1);let A=33,k=0;for(;A>1&&S[k]===0&&!(S[k+1]&128);--A,++k);return S=S.subarray(k),S[0]&128||A>1&&S[0]===0&&!(S[1]&128)?1:(i.outputlen=6+K+A,F[0]=48,F[1]=i.outputlen-2,F[2]=2,F[3]=V.length,F.set(V,4),F[4+K]=2,F[5+K]=S.length,F.set(S,6+K),0)},signatureImport(i,E){if(E.length<8||E.length>72||E[0]!==48||E[1]!==E.length-2||E[2]!==2)return 1;const g=E[3];if(g===0||5+g>=E.length||E[4+g]!==2)return 1;const T=E[5+g];if(T===0||6+g+T!==E.length||E[4]&128||g>1&&E[4]===0&&!(E[5]&128)||E[g+6]&128||T>1&&E[g+6]===0&&!(E[g+7]&128))return 1;let F=E.subarray(4,4+g);if(F.length===33&&F[0]===0&&(F=F.subarray(1)),F.length>32)return 1;let V=E.subarray(6+g);if(V.length===33&&V[0]===0&&(V=V.slice(1)),V.length>32)throw new Error("S length is too long");let K=new B(F);K.cmp(v.n)>=0&&(K=new B(0));let H=new B(E.subarray(6+g));return H.cmp(v.n)>=0&&(H=new B(0)),i.set(K.toArrayLike(Uint8Array,"be",32),0),i.set(H.toArrayLike(Uint8Array,"be",32),32),0},ecdsaSign(i,E,g,T,F){if(F){const H=F;F=S=>{const A=H(E,g,null,T,S);if(!(A instanceof Uint8Array&&A.length===32))throw new Error("This is the way");return new B(A)}}const V=new B(g);if(V.cmp(v.n)>=0||V.isZero())return 1;let K;try{K=c.sign(E,g,{canonical:!0,k:F,pers:T})}catch{return 1}return i.signature.set(K.r.toArrayLike(Uint8Array,"be",32),0),i.signature.set(K.s.toArrayLike(Uint8Array,"be",32),32),i.recid=K.recoveryParam,0},ecdsaVerify(i,E,g){const T={r:i.subarray(0,32),s:i.subarray(32,64)},F=new B(T.r),V=new B(T.s);if(F.cmp(v.n)>=0||V.cmp(v.n)>=0)return 1;if(V.cmp(c.nh)===1||F.isZero()||V.isZero())return 3;const K=d(g);if(K===null)return 2;const H=K.getPublic();return c.verify(E,T,H)?0:3},ecdsaRecover(i,E,g,T){const F={r:E.slice(0,32),s:E.slice(32,64)},V=new B(F.r),K=new B(F.s);if(V.cmp(v.n)>=0||K.cmp(v.n)>=0)return 1;if(V.isZero()||K.isZero())return 2;let H;try{H=c.recoverPubKey(T,F,g)}catch{return 2}return w(i,H),0},ecdh(i,E,g,T,F,V,K){const H=d(E);if(H===null)return 1;const S=new B(g);if(S.cmp(v.n)>=0||S.isZero())return 2;const A=H.getPublic().mul(S);if(F===void 0){const k=A.encode(null,!0),U=c.hash().update(k).digest();for(let Y=0;Y<32;++Y)i[Y]=U[Y]}else{V||(V=new Uint8Array(32));const k=A.getX().toArray("be",32);for(let Q=0;Q<32;++Q)V[Q]=k[Q];K||(K=new Uint8Array(32));const U=A.getY().toArray("be",32);for(let Q=0;Q<32;++Q)K[Q]=U[Q];const Y=F(V,K,T);if(!(Y instanceof Uint8Array&&Y.length===i.length))return 2;i.set(Y)}return 0}}},27655:function(oe){const o={IMPOSSIBLE_CASE:"Impossible case. Please create issue.",TWEAK_ADD:"The tweak was out of range or the resulted private key is invalid",TWEAK_MUL:"The tweak was out of range or equal to zero",CONTEXT_RANDOMIZE_UNKNOW:"Unknow error on context randomization",SECKEY_INVALID:"Private Key is invalid",PUBKEY_PARSE:"Public Key could not be parsed",PUBKEY_SERIALIZE:"Public Key serialization error",PUBKEY_COMBINE:"The sum of the public keys is not valid",SIG_PARSE:"Signature could not be parsed",SIGN:"The nonce generation function failed, or the private key was invalid",RECOVER:"Public key could not be recover",ECDH:"Scalar was invalid (zero or overflow)"};function R(y,a){if(!y)throw new Error(a)}function C(y,a,d){if(R(a instanceof Uint8Array,`Expected ${y} to be an Uint8Array`),d!==void 0)if(Array.isArray(d)){const w=d.join(", "),i=`Expected ${y} to be an Uint8Array with length [${w}]`;R(d.includes(a.length),i)}else{const w=`Expected ${y} to be an Uint8Array with length ${d}`;R(a.length===d,w)}}function c(y){R(B(y)==="Boolean","Expected compressed to be a Boolean")}function v(y=d=>new Uint8Array(d),a){return typeof y=="function"&&(y=y(a)),C("output",y,a),y}function B(y){return Object.prototype.toString.call(y).slice(8,-1)}oe.exports=y=>({contextRandomize(a){switch(R(a===null||a instanceof Uint8Array,"Expected seed to be an Uint8Array or null"),a!==null&&C("seed",a,32),y.contextRandomize(a)){case 1:throw new Error(o.CONTEXT_RANDOMIZE_UNKNOW)}},privateKeyVerify(a){return C("private key",a,32),y.privateKeyVerify(a)===0},privateKeyNegate(a){switch(C("private key",a,32),y.privateKeyNegate(a)){case 0:return a;case 1:throw new Error(o.IMPOSSIBLE_CASE)}},privateKeyTweakAdd(a,d){switch(C("private key",a,32),C("tweak",d,32),y.privateKeyTweakAdd(a,d)){case 0:return a;case 1:throw new Error(o.TWEAK_ADD)}},privateKeyTweakMul(a,d){switch(C("private key",a,32),C("tweak",d,32),y.privateKeyTweakMul(a,d)){case 0:return a;case 1:throw new Error(o.TWEAK_MUL)}},publicKeyVerify(a){return C("public key",a,[33,65]),y.publicKeyVerify(a)===0},publicKeyCreate(a,d=!0,w){switch(C("private key",a,32),c(d),w=v(w,d?33:65),y.publicKeyCreate(w,a)){case 0:return w;case 1:throw new Error(o.SECKEY_INVALID);case 2:throw new Error(o.PUBKEY_SERIALIZE)}},publicKeyConvert(a,d=!0,w){switch(C("public key",a,[33,65]),c(d),w=v(w,d?33:65),y.publicKeyConvert(w,a)){case 0:return w;case 1:throw new Error(o.PUBKEY_PARSE);case 2:throw new Error(o.PUBKEY_SERIALIZE)}},publicKeyNegate(a,d=!0,w){switch(C("public key",a,[33,65]),c(d),w=v(w,d?33:65),y.publicKeyNegate(w,a)){case 0:return w;case 1:throw new Error(o.PUBKEY_PARSE);case 2:throw new Error(o.IMPOSSIBLE_CASE);case 3:throw new Error(o.PUBKEY_SERIALIZE)}},publicKeyCombine(a,d=!0,w){R(Array.isArray(a),"Expected public keys to be an Array"),R(a.length>0,"Expected public keys array will have more than zero items");for(const i of a)C("public key",i,[33,65]);switch(c(d),w=v(w,d?33:65),y.publicKeyCombine(w,a)){case 0:return w;case 1:throw new Error(o.PUBKEY_PARSE);case 2:throw new Error(o.PUBKEY_COMBINE);case 3:throw new Error(o.PUBKEY_SERIALIZE)}},publicKeyTweakAdd(a,d,w=!0,i){switch(C("public key",a,[33,65]),C("tweak",d,32),c(w),i=v(i,w?33:65),y.publicKeyTweakAdd(i,a,d)){case 0:return i;case 1:throw new Error(o.PUBKEY_PARSE);case 2:throw new Error(o.TWEAK_ADD)}},publicKeyTweakMul(a,d,w=!0,i){switch(C("public key",a,[33,65]),C("tweak",d,32),c(w),i=v(i,w?33:65),y.publicKeyTweakMul(i,a,d)){case 0:return i;case 1:throw new Error(o.PUBKEY_PARSE);case 2:throw new Error(o.TWEAK_MUL)}},signatureNormalize(a){switch(C("signature",a,64),y.signatureNormalize(a)){case 0:return a;case 1:throw new Error(o.SIG_PARSE)}},signatureExport(a,d){C("signature",a,64),d=v(d,72);const w={output:d,outputlen:72};switch(y.signatureExport(w,a)){case 0:return d.slice(0,w.outputlen);case 1:throw new Error(o.SIG_PARSE);case 2:throw new Error(o.IMPOSSIBLE_CASE)}},signatureImport(a,d){switch(C("signature",a),d=v(d,64),y.signatureImport(d,a)){case 0:return d;case 1:throw new Error(o.SIG_PARSE);case 2:throw new Error(o.IMPOSSIBLE_CASE)}},ecdsaSign(a,d,w={},i){C("message",a,32),C("private key",d,32),R(B(w)==="Object","Expected options to be an Object"),w.data!==void 0&&C("options.data",w.data),w.noncefn!==void 0&&R(B(w.noncefn)==="Function","Expected options.noncefn to be a Function"),i=v(i,64);const E={signature:i,recid:null};switch(y.ecdsaSign(E,a,d,w.data,w.noncefn)){case 0:return E;case 1:throw new Error(o.SIGN);case 2:throw new Error(o.IMPOSSIBLE_CASE)}},ecdsaVerify(a,d,w){switch(C("signature",a,64),C("message",d,32),C("public key",w,[33,65]),y.ecdsaVerify(a,d,w)){case 0:return!0;case 3:return!1;case 1:throw new Error(o.SIG_PARSE);case 2:throw new Error(o.PUBKEY_PARSE)}},ecdsaRecover(a,d,w,i=!0,E){switch(C("signature",a,64),R(B(d)==="Number"&&d>=0&&d<=3,"Expected recovery id to be a Number within interval [0, 3]"),C("message",w,32),c(i),E=v(E,i?33:65),y.ecdsaRecover(E,a,d,w)){case 0:return E;case 1:throw new Error(o.SIG_PARSE);case 2:throw new Error(o.RECOVER);case 3:throw new Error(o.IMPOSSIBLE_CASE)}},ecdh(a,d,w={},i){switch(C("public key",a,[33,65]),C("private key",d,32),R(B(w)==="Object","Expected options to be an Object"),w.data!==void 0&&C("options.data",w.data),w.hashfn!==void 0?(R(B(w.hashfn)==="Function","Expected options.hashfn to be a Function"),w.xbuf!==void 0&&C("options.xbuf",w.xbuf,32),w.ybuf!==void 0&&C("options.ybuf",w.ybuf,32),C("output",i)):i=v(i,32),y.ecdh(i,a,d,w.data,w.hashfn,w.xbuf,w.ybuf)){case 0:return i;case 1:throw new Error(o.PUBKEY_PARSE);case 2:throw new Error(o.ECDH)}}})},14034:function(oe){var o="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",R="0123456789ABCDEFGHIJKLMNOPQRSTUV",C="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function c(v,B){var y=v.indexOf(B);if(y===-1)throw new Error("Invalid character found: "+B);return y}oe.exports=function(B,y){var a;switch(y){case"RFC3548":case"RFC4648":a=o,B=B.replace(/=+$/,"");break;case"RFC4648-HEX":a=R,B=B.replace(/=+$/,"");break;case"Crockford":a=C,B=B.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1");break;default:throw new Error("Unknown base32 variant: "+y)}for(var d=B.length,w=0,i=0,E=0,g=new Uint8Array(d*5/8|0),T=0;T<d;T++)i=i<<5|c(a,B[T]),w+=5,w>=8&&(g[E++]=i>>>w-8&255,w-=8);return g.buffer}},74156:function(oe,o,R){const C=R(20829);function c(A,k,U){const Y=A[k]+A[U];let Z=A[k+1]+A[U+1];Y>=4294967296&&Z++,A[k]=Y,A[k+1]=Z}function v(A,k,U,Y){let Z=A[k]+U;U<0&&(Z+=4294967296);let Q=A[k+1]+Y;Z>=4294967296&&Q++,A[k]=Z,A[k+1]=Q}function B(A,k){return A[k]^A[k+1]<<8^A[k+2]<<16^A[k+3]<<24}function y(A,k,U,Y,Z,Q){const be=E[Z],pe=E[Z+1],ae=E[Q],x=E[Q+1];c(i,A,k),v(i,A,be,pe);let b=i[Y]^i[A],f=i[Y+1]^i[A+1];i[Y]=f,i[Y+1]=b,c(i,U,Y),b=i[k]^i[U],f=i[k+1]^i[U+1],i[k]=b>>>24^f<<8,i[k+1]=f>>>24^b<<8,c(i,A,k),v(i,A,ae,x),b=i[Y]^i[A],f=i[Y+1]^i[A+1],i[Y]=b>>>16^f<<16,i[Y+1]=f>>>16^b<<16,c(i,U,Y),b=i[k]^i[U],f=i[k+1]^i[U+1],i[k]=f>>>31^b<<1,i[k+1]=b>>>31^f<<1}const a=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),d=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3],w=new Uint8Array(d.map(function(A){return A*2})),i=new Uint32Array(32),E=new Uint32Array(32);function g(A,k){let U=0;for(U=0;U<16;U++)i[U]=A.h[U],i[U+16]=a[U];for(i[24]=i[24]^A.t,i[25]=i[25]^A.t/4294967296,k&&(i[28]=~i[28],i[29]=~i[29]),U=0;U<32;U++)E[U]=B(A.b,4*U);for(U=0;U<12;U++)y(0,8,16,24,w[U*16+0],w[U*16+1]),y(2,10,18,26,w[U*16+2],w[U*16+3]),y(4,12,20,28,w[U*16+4],w[U*16+5]),y(6,14,22,30,w[U*16+6],w[U*16+7]),y(0,10,20,30,w[U*16+8],w[U*16+9]),y(2,12,22,24,w[U*16+10],w[U*16+11]),y(4,14,16,26,w[U*16+12],w[U*16+13]),y(6,8,18,28,w[U*16+14],w[U*16+15]);for(U=0;U<16;U++)A.h[U]=A.h[U]^i[U]^i[U+16]}const T=new Uint8Array([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]);function F(A,k,U,Y){if(A===0||A>64)throw new Error("Illegal output length, expected 0 < length <= 64");if(k&&k.length>64)throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");if(U&&U.length!==16)throw new Error("Illegal salt, expected Uint8Array with length is 16");if(Y&&Y.length!==16)throw new Error("Illegal personal, expected Uint8Array with length is 16");const Z={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:A};T.fill(0),T[0]=A,k&&(T[1]=k.length),T[2]=1,T[3]=1,U&&T.set(U,32),Y&&T.set(Y,48);for(let Q=0;Q<16;Q++)Z.h[Q]=a[Q]^B(T,Q*4);return k&&(V(Z,k),Z.c=128),Z}function V(A,k){for(let U=0;U<k.length;U++)A.c===128&&(A.t+=A.c,g(A,!1),A.c=0),A.b[A.c++]=k[U]}function K(A){for(A.t+=A.c;A.c<128;)A.b[A.c++]=0;g(A,!0);const k=new Uint8Array(A.outlen);for(let U=0;U<A.outlen;U++)k[U]=A.h[U>>2]>>8*(U&3);return k}function H(A,k,U,Y,Z){U=U||64,A=C.normalizeInput(A),Y&&(Y=C.normalizeInput(Y)),Z&&(Z=C.normalizeInput(Z));const Q=F(U,k,Y,Z);return V(Q,A),K(Q)}function S(A,k,U,Y,Z){const Q=H(A,k,U,Y,Z);return C.toHex(Q)}oe.exports={blake2b:H,blake2bHex:S,blake2bInit:F,blake2bUpdate:V,blake2bFinal:K}},51843:function(oe,o,R){const C=R(20829);function c(K,H){return K[H]^K[H+1]<<8^K[H+2]<<16^K[H+3]<<24}function v(K,H,S,A,k,U){d[K]=d[K]+d[H]+k,d[A]=B(d[A]^d[K],16),d[S]=d[S]+d[A],d[H]=B(d[H]^d[S],12),d[K]=d[K]+d[H]+U,d[A]=B(d[A]^d[K],8),d[S]=d[S]+d[A],d[H]=B(d[H]^d[S],7)}function B(K,H){return K>>>H^K<<32-H}const y=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0]),d=new Uint32Array(16),w=new Uint32Array(16);function i(K,H){let S=0;for(S=0;S<8;S++)d[S]=K.h[S],d[S+8]=y[S];for(d[12]^=K.t,d[13]^=K.t/4294967296,H&&(d[14]=~d[14]),S=0;S<16;S++)w[S]=c(K.b,4*S);for(S=0;S<10;S++)v(0,4,8,12,w[a[S*16+0]],w[a[S*16+1]]),v(1,5,9,13,w[a[S*16+2]],w[a[S*16+3]]),v(2,6,10,14,w[a[S*16+4]],w[a[S*16+5]]),v(3,7,11,15,w[a[S*16+6]],w[a[S*16+7]]),v(0,5,10,15,w[a[S*16+8]],w[a[S*16+9]]),v(1,6,11,12,w[a[S*16+10]],w[a[S*16+11]]),v(2,7,8,13,w[a[S*16+12]],w[a[S*16+13]]),v(3,4,9,14,w[a[S*16+14]],w[a[S*16+15]]);for(S=0;S<8;S++)K.h[S]^=d[S]^d[S+8]}function E(K,H){if(!(K>0&&K<=32))throw new Error("Incorrect output length, should be in [1, 32]");const S=H?H.length:0;if(H&&!(S>0&&S<=32))throw new Error("Incorrect key length, should be in [1, 32]");const A={h:new Uint32Array(y),b:new Uint8Array(64),c:0,t:0,outlen:K};return A.h[0]^=16842752^S<<8^K,S>0&&(g(A,H),A.c=64),A}function g(K,H){for(let S=0;S<H.length;S++)K.c===64&&(K.t+=K.c,i(K,!1),K.c=0),K.b[K.c++]=H[S]}function T(K){for(K.t+=K.c;K.c<64;)K.b[K.c++]=0;i(K,!0);const H=new Uint8Array(K.outlen);for(let S=0;S<K.outlen;S++)H[S]=K.h[S>>2]>>8*(S&3)&255;return H}function F(K,H,S){S=S||32,K=C.normalizeInput(K);const A=E(S,H);return g(A,K),T(A)}function V(K,H,S){const A=F(K,H,S);return C.toHex(A)}oe.exports={blake2s:F,blake2sHex:V,blake2sInit:E,blake2sUpdate:g,blake2sFinal:T}},92493:function(oe,o,R){const C=R(74156),c=R(51843);oe.exports={blake2b:C.blake2b,blake2bHex:C.blake2bHex,blake2bInit:C.blake2bInit,blake2bUpdate:C.blake2bUpdate,blake2bFinal:C.blake2bFinal,blake2s:c.blake2s,blake2sHex:c.blake2sHex,blake2sInit:c.blake2sInit,blake2sUpdate:c.blake2sUpdate,blake2sFinal:c.blake2sFinal}},20829:function(oe){const o="Input must be an string, Buffer or Uint8Array";function R(y){let a;if(y instanceof Uint8Array)a=y;else if(typeof y=="string")a=new TextEncoder().encode(y);else throw new Error(o);return a}function C(y){return Array.prototype.map.call(y,function(a){return(a<16?"0":"")+a.toString(16)}).join("")}function c(y){return(4294967296+y).toString(16).substring(1)}function v(y,a,d){let w=`
|
|
3
|
-
`+
|
|
4
|
-
`+new Array(y.length+4).join(" "):i<a.length-2&&(w+=" ")}console.log(w)}function B(y,a,d){let w=new Date().getTime();const i=new Uint8Array(a);for(let g=0;g<a;g++)i[g]=g%256;const E=new Date().getTime();console.log("Generated random input in "+(E-w)+"ms"),w=E;for(let g=0;g<d;g++){const T=y(i),F=new Date().getTime(),V=F-w;w=F,console.log("Hashed in "+V+"ms: "+T.substring(0,20)+"..."),console.log(Math.round(a/(1<<20)/(V/1e3)*100)/100+" MB PER SECOND")}}oe.exports={normalizeInput:R,toHex:C,debugPrint:v,testSpeed:B}},42394:function(oe,o,R){const C=R(92861).Buffer;oe.exports=class{constructor(v=C.from([])){this.buffer=v,this._bytesRead=0,this._bytesWrote=0}read(v){this._bytesRead+=v;const B=this.buffer.slice(0,v);return this.buffer=this.buffer.slice(v),B}write(v){v=C.from(v),this._bytesWrote+=v.length,this.buffer=C.concat([this.buffer,v])}get end(){return!this.buffer.length}get bytesRead(){return this._bytesRead}get bytesWrote(){return this._bytesWrote}}},68249:function(oe,o,R){o.unsigned=R(77698),R(7905)},7905:function(oe,o,R){const C=R(39404),c=R(42394);oe.exports={encode:a,decode:d,write:y,read:v,readBn:B};function v(w){return B(w).toString()}function B(w){const i=new C(0);let E=0,g;for(;g=w.read(1)[0],i.ior(new C(g&127).shln(E)),E+=7,g>>7!==0;);return g&64&&i.setn(E),i.fromTwos(E)}function y(w,i){let E=new C(w);const g=E.isNeg();for(g&&(E=E.toTwos(E.bitLength()+8));;){const F=E.maskn(7).toNumber();if(E.ishrn(7),T(E)&&(F&64)!==0||E.isZero()&&(F&64)===0){i.write([F]);break}else i.write([F|128])}function T(F){return g&&F.toString(2).indexOf("0")<0}}function a(w){const i=new c;return y(w,i),i.buffer}function d(w){const i=new c(w);return v(i)}},77698:function(oe,o,R){const C=R(39404),c=R(42394);oe.exports={encode:a,decode:d,read:v,readBn:B,write:y};function v(w){return B(w).toString()}function B(w){const i=new C(0);let E=0,g;for(;g=w.read(1)[0],i.ior(new C(g&127).shln(E)),g>>7!==0;)E+=7;return i}function y(w,i){const E=new C(w);for(;;){const g=E.maskn(7).toNumber();if(E.ishrn(7),E.isZero()){i.write([g]);break}else i.write([g|128])}}function a(w){const i=new c;return y(w,i),i.buffer}function d(w){const i=new c(w);return v(i)}},31700:function(oe,o,R){"use strict";R.d(o,{pV:function(){return D},lg:function(){return a},X$:function(){return d},yo:function(){return Ge},to:function(){return N},D7:function(){return S},ou:function(){return Ie},ZX:function(){return de},uW:function(){return m}});var C=R(72505),c=R(39404),v;(function(s){s.ETH="10"})(v||(v={}));const B=255;var y;(function(s){s[s.ID=0]="ID",s[s.SECP256K1=1]="SECP256K1",s[s.ACTOR=2]="ACTOR",s[s.BLS=3]="BLS",s[s.DELEGATED=4]="DELEGATED"})(y||(y={}));var a;(function(s){s.Mainnet="mainnet",s.Calibration="calibration",s.Butterfly="butterfly"})(a||(a={}));var d;(function(s){s.Mainnet="f",s.Testnet="t"})(d||(d={}));const w=20,i=54,E=48,g=20,T=20,F=9,V=new c(2).pow(new c(63)).sub(new c(1));var K;(function(s){s[s.Zero=0]="Zero"})(K||(K={}));var H;(function(s){s[s.Transfer=0]="Transfer",s[s.InvokeEVM=3844450837]="InvokeEVM"})(H||(H={}));var S;(function(s){s[s.SECP256K1=1]="SECP256K1",s[s.BLS=3]="BLS"})(S||(S={}));var A;(function(s){s[s.System=0]="System",s[s.Init=1]="Init",s[s.Reward=2]="Reward",s[s.Cron=3]="Cron",s[s.StoragePower=4]="StoragePower",s[s.StorageMarket=5]="StorageMarket",s[s.VerifiedRegistry=6]="VerifiedRegistry",s[s.DataCap=7]="DataCap",s[s.EAM=10]="EAM"})(A||(A={}));var k;(function(s){s[s.Exec=2]="Exec",s[s.Exec4=3]="Exec4"})(k||(k={}));var U;(function(s){s[s.UpdateChannelState=2]="UpdateChannelState",s[s.Settle=3]="Settle",s[s.Collect=4]="Collect"})(U||(U={}));var Y;(function(s){s.Account="bafk2bzacebor5mnjnsav34cmm5pcd3dy4wubbv4wtcrvba7depy3sct7ie4sy",s.Cron="bafk2bzacebetehhedh55alfn4rcx2mhjhvuiustxlhtxc3drkemnpttws5eqw",s.DataCap="bafk2bzaced6uhmrh5jjexhw4lco4ipesi2iutl7uupnyspgmnbydyo3amtu4i",s.EAM="bafk2bzacea6wzcnflfnaxqnwydoghh7ezg5au32ew3bnzljzpiw6fimhlpoiu",s.EthAccount="bafk2bzacedrbpvjvyzif2cjxosm4pliyq2m6wzndvrg7r6hzdhixplzvgubbw",s.EVM="bafk2bzaceabftmhejmvjvpzmbsv4cvaew6v5juj5sqtq7cfijugwsnahnsy5w",s.Init="bafk2bzaceduyjd35y7o2lhvevtysqf45rp5ot7x5f36q6iond6dyiz6773g5q",s.Multisig="bafk2bzacebcb72fmbpocetnzgni2wnbrduamlqx6fl3yelrlzu7id6bu5ib5g",s.PaymentChannel="bafk2bzaceazwhm63kyp47pste5i5acnuhosrgythyagf3kc5clogiqqx6vkzk",s.Placeholder="bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro",s.Reward="bafk2bzacecp7xo5ev46y64zr5osnn5fxo7itpoqw235tcfv6eo4rymzdemet2",s.StorageMarket="bafk2bzacedjt5mueomasx7dijooxnwxsbtzu2dj2ppp45rtle4kiinkmgzeei",s.StorageMiner="bafk2bzacebkjnjp5okqjhjxzft5qkuv36u4tz7inawseiwi2kw4j43xpxvhpm",s.StoragePower="bafk2bzaced2qsypqwore3jrdtaesh4itst2fyeepdsozvtffc2pianzmphdum",s.System="bafk2bzacedqvik2n3phnj3cni3h2k5mtvz43nyq7mdmv7k7euejysvajywdug",s.VerifiedRegistry="bafk2bzaceceoo5jlom2zweh7kpye2vkj33wgqnkjshlsw2neemqkfg5g2rmvg"})(Y||(Y={}));var Z;(function(s){s.Account="bafk2bzaceampw4romta75hyz5p4cqriypmpbgnkxncgxgqn6zptv5lsp2w2bo",s.Cron="bafk2bzacedcbtsifegiu432m5tysjzkxkmoczxscb6hqpmrr6img7xzdbbs2g",s.DataCap="bafk2bzacealj5uk7wixhvk7l5tnredtelralwnceafqq34nb2lbylhtuyo64u",s.EAM="bafk2bzacedrpm5gbleh4xkyo2jvs7p5g6f34soa6dpv7ashcdgy676snsum6g",s.EthAccount="bafk2bzaceaqoc5zakbhjxn3jljc4lxnthllzunhdor7sxhwgmskvc6drqc3fa",s.EVM="bafk2bzaceahmzdxhqsm7cu2mexusjp6frm7r4kdesvti3etv5evfqboos2j4g",s.Init="bafk2bzaced2f5rhir3hbpqbz5ght7ohv2kgj42g5ykxrypuo2opxsup3ykwl6",s.Multisig="bafk2bzaceduf3hayh63jnl4z2knxv7cnrdenoubni22fxersc4octlwpxpmy4",s.PaymentChannel="bafk2bzaceartlg4mrbwgzcwric6mtvyawpbgx2xclo2vj27nna57nxynf3pgc",s.Placeholder="bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro",s.Reward="bafk2bzacebnhtaejfjtzymyfmbdrfmo7vgj3zsof6zlucbmkhrvcuotw5dxpq",s.StorageMarket="bafk2bzaceclejwjtpu2dhw3qbx6ow7b4pmhwa7ocrbbiqwp36sq5yeg6jz2bc",s.StorageMiner="bafk2bzaced4h7noksockro7glnssz2jnmo2rpzd7dvnmfs4p24zx3h6gtx47s",s.StoragePower="bafk2bzacec4ay4crzo73ypmh7o3fjendhbqrxake46bprabw67fvwjz5q6ixq",s.System="bafk2bzacedakk5nofebyup4m7nvx6djksfwhnxzrfuq4oyemhpl4lllaikr64",s.VerifiedRegistry="bafk2bzacedfel6edzqpe5oujno7fog4i526go4dtcs6vwrdtbpy2xq6htvcg6"})(Z||(Z={}));var Q=R(14034),be=R(68249);const pe="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",ae="0123456789ABCDEFGHIJKLMNOPQRSTUV",x="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function b(s,t,u){u=u||{};let p,L;switch(t){case"RFC3548":case"RFC4648":p=pe,L=!0;break;case"RFC4648-HEX":p=ae,L=!0;break;case"Crockford":p=x,L=!1;break}if(!p)throw new Error(`Unknown base32 variant: ${t}`);const ee=u.padding!==void 0?u.padding:L,se=f(s);let fe=0,we=0,Ae="";for(let Ue=0;Ue<se.byteLength;Ue++)for(we=we<<8|se.getUint8(Ue),fe+=8;fe>=5;)Ae+=p[we>>>fe-5&31],fe-=5;if(fe>0&&(Ae+=p[we<<5-fe&31]),ee)for(;Ae.length%8!==0;)Ae+="=";return Ae}function f(s){if(s instanceof Int8Array||s instanceof Uint8Array||s instanceof Uint8ClampedArray)return new DataView(s.buffer,s.byteOffset,s.byteLength);if(s instanceof ArrayBuffer)return new DataView(s);throw new TypeError("Expected `data` to be an ArrayBuffer, Buffer, Int8Array, Uint8Array or Uint8ClampedArray")}class I extends Error{constructor(t){super(),this.message=`Invalid protocol indicator byte [${t}]`}}class z extends Error{constructor(t){super(),this.message="Unknown protocol indicator byte [${value}]"}}class M extends Error{constructor(t){super(),this.message=`Invalid payload length [${t}]`}}class G extends Error{constructor(t){super(),this.message=`Invalid namespace [${t}]`}}class ne extends Error{constructor(t){super(),this.message=`Invalid network [${t}]`}}class ie extends Error{constructor(){super(),this.message="Invalid subAddress."}}class ce extends Error{constructor(t){super(),this.message=`${t} protocol not supported.`}}class W extends Error{constructor(t,u){super(),this.message=`Invalid address (checksum not matching the payload). ${t} vs ${u}`}}class ue extends Error{constructor(){super(),this.message="Private key need to be an instance of Buffer or a base64 string."}}var O=R(92493),ye=R(48287).Buffer;function ke(s){const t=O.blake2bInit(4);return O.blake2bUpdate(t,s),ye.from(O.blake2bFinal(t))}function Ee(s){let t=0;for(;t<s.length;){const u=s[t];if(t++,u<128)break}return t==s.length?-1:t}const Pe=s=>Object.values(d).includes(s),Me=s=>Object.values(Network).includes(s),He=s=>s===a.Mainnet?d.Mainnet:d.Testnet,Ne=s=>s!==Network.Mainnet;var h=R(48287).Buffer;const st=class{constructor(t,u){P(this,"networkPrefix");P(this,"protocol");P(this,"getPayload",()=>this.payload);P(this,"getNetworkPrefix",()=>this.networkPrefix);P(this,"getProtocol",()=>this.protocol);P(this,"getChecksum",()=>ke(this.toBytes()));this.networkPrefix=t,this.protocol=u}};let D=st;P(D,"fromString",t=>{const u=parseInt(t[1]);switch(u){case y.ID:return le.fromString(t);case y.ACTOR:return me.fromString(t);case y.SECP256K1:return ge.fromString(t);case y.BLS:return X.fromString(t);case y.DELEGATED:{const p=Be.fromString(t);return st.isFilEthAddress(p)?new Ke(p.getNetworkPrefix(),p.getSubAddress()):p}default:throw new z(u)}}),P(D,"fromBytes",(t,u)=>{const p=u[0];switch(p){case y.ID:return le.fromBytes(t,u);case y.ACTOR:return me.fromBytes(t,u);case y.SECP256K1:return ge.fromBytes(t,u);case y.BLS:return X.fromBytes(t,u);case y.DELEGATED:{const L=Be.fromBytes(t,u);return st.isFilEthAddress(L)?new Ke(L.getNetworkPrefix(),L.getSubAddress()):L}default:throw new z(p)}}),P(D,"fromEthAddress",(t,u)=>{if(typeof u=="string"){const L=u.startsWith("0x")?u.substring(2):u;u=h.from(L,"hex")}const p=h.alloc(12);if(p[0]=B,p.compare(u,0,12)==0){let L=12;for(;u[L]==0;)L+=1;return new le(t,h.from(u.subarray(L)))}return new Ke(t,u)}),P(D,"isAddressId",t=>t.protocol==y.ID),P(D,"isAddressBls",t=>t.protocol==y.BLS),P(D,"isAddressSecp256k1",t=>t.protocol==y.SECP256K1),P(D,"isAddressDelegated",t=>t.protocol==y.DELEGATED),P(D,"isFilEthAddress",t=>t.protocol==y.DELEGATED&&"namespace"in t&&t.namespace==v.ETH),P(D,"isAddressActor",t=>t.protocol==y.ACTOR);class X extends D{constructor(u,p){super(u,y.BLS);P(this,"payload");P(this,"toBytes",()=>h.concat([h.from(`0${this.protocol}`,"hex"),this.payload]));P(this,"toString",()=>{const u=this.getChecksum();return this.networkPrefix+this.protocol.toString()+b(h.concat([this.payload,u]),"RFC4648",{padding:!1}).toLowerCase()});if(p.byteLength!==E)throw new M(p.byteLength);this.payload=p}static fromString(u){const p=u[0],L=u[1];if(!Pe(p))throw new ne(p);if(parseInt(L)!=y.BLS)throw new I(parseInt(L));const ee=h.from(Q(u.substring(2).toUpperCase(),"RFC4648")),se=h.from(ee.subarray(0,-4)),fe=h.from(ee.subarray(-4)),we=new X(p,se);if(we.getChecksum().toString("hex")!==fe.toString("hex"))throw new W(we.getChecksum().toString("hex"),fe.toString("hex"));return we}static fromBytes(u,p){if(p[0]!=y.BLS)throw new I(p[0]);const L=h.from(p.subarray(1));return new X(u,L)}}class le extends D{constructor(u,p){super(u,y.ID);P(this,"id");P(this,"payload");P(this,"toBytes",()=>h.concat([h.from(`0${this.protocol}`,"hex"),this.payload]));P(this,"toString",()=>this.networkPrefix+this.protocol.toString()+be.unsigned.decode(this.payload));P(this,"getId",()=>this.id);P(this,"toEthAddressHex",(u=!1)=>{const p=h.alloc(w);return p[0]=B,p.set(this.payload,w-this.payload.length),`${u?"0x":""}${p.toString("hex")}`});const L=typeof p=="string"?be.unsigned.encode(p):p;if(L.length>F)throw new M(L.length);this.payload=L,this.id=this.toString().substring(2)}static fromString(u){const p=u[0],L=u[1];if(!Pe(p))throw new ne(p);if(parseInt(L)!=y.ID)throw new I(parseInt(L));const ee=be.unsigned.encode(u.substring(2));return new le(p,ee)}static fromBytes(u,p){if(p[0]!=y.ID)throw new I(p[0]);const L=h.from(p.subarray(1));return new le(u,L)}}class ge extends D{constructor(u,p){super(u,y.SECP256K1);P(this,"payload");P(this,"toBytes",()=>h.concat([h.from(`0${this.protocol}`,"hex"),this.payload]));P(this,"toString",()=>{const u=this.getChecksum();return this.networkPrefix+this.protocol.toString()+b(h.concat([this.payload,u]),"RFC4648",{padding:!1}).toLowerCase()});if(p.byteLength!==T)throw new M(p.byteLength);this.payload=p}static fromString(u){const p=u[0],L=u[1];if(!Pe(p))throw new ne(p);if(parseInt(L)!=y.SECP256K1)throw new I(parseInt(L));const ee=h.from(Q(u.substring(2).toUpperCase(),"RFC4648")),se=h.from(ee.subarray(0,-4)),fe=h.from(ee.subarray(-4)),we=new ge(p,se);if(we.getChecksum().toString("hex")!==fe.toString("hex"))throw new W(we.getChecksum().toString("hex"),fe.toString("hex"));return we}static fromBytes(u,p){if(p[0]!=y.SECP256K1)throw new I(p[0]);const L=h.from(p.subarray(1));return new ge(u,L)}}class me extends D{constructor(u,p){super(u,y.ACTOR);P(this,"payload");P(this,"toBytes",()=>h.concat([h.from(`0${this.protocol}`,"hex"),this.payload]));P(this,"toString",()=>{const u=this.getChecksum();return this.networkPrefix+this.protocol.toString()+b(h.concat([this.payload,u]),"RFC4648",{padding:!1}).toLowerCase()});if(p.byteLength!==g)throw new M(p.byteLength);this.payload=p}static fromString(u){const p=u[0],L=u[1];if(!Pe(p))throw new ne(p);if(parseInt(L)!=y.ACTOR)throw new I(parseInt(L));const ee=h.from(Q(u.substring(2).toUpperCase(),"RFC4648")),se=h.from(ee.subarray(0,-4)),fe=h.from(ee.subarray(-4)),we=new me(p,se);if(we.getChecksum().toString("hex")!==fe.toString("hex"))throw new W(we.getChecksum().toString("hex"),fe.toString("hex"));return we}static fromBytes(u,p){if(p[0]!=y.ACTOR)throw new I(p[0]);const L=h.from(p.subarray(1));return new me(u,L)}}class Be extends D{constructor(u,p,L){super(u,y.DELEGATED);P(this,"payload");P(this,"namespace");P(this,"subAddress");P(this,"getNamespace",()=>this.namespace);P(this,"getSubAddress",()=>this.subAddress);P(this,"toBytes",()=>{const u=h.from(be.unsigned.encode(this.namespace)),p=h.from(be.unsigned.encode(this.protocol));return h.concat([p,u,this.subAddress])});P(this,"toString",()=>{const u=this.getChecksum();return this.networkPrefix+this.protocol.toString()+this.namespace+"f"+b(h.concat([this.subAddress,u]),"RFC4648",{padding:!1}).toLowerCase()});if(new c(p).gt(V))throw new G(p);if(L.length===0||L.length>i)throw new ie;this.namespace=p,this.subAddress=L,this.payload=h.from(this.toBytes().subarray(1))}static fromString(u){const p=u[0],L=u[1];if(!Pe(p))throw new ne(p);if(parseInt(L)!=y.DELEGATED)throw new I(parseInt(L));const ee=u.substring(2,u.indexOf("f",2)),se=u.substring(u.indexOf("f",2)+1),fe=h.from(Q(se.toUpperCase(),"RFC4648")),we=h.from(fe.subarray(0,-4)),Ae=h.from(fe.subarray(-4)),Ue=new Be(p,ee,we);if(Ue.getChecksum().toString("hex")!==Ae.toString("hex"))throw new W(Ue.getChecksum().toString("hex"),Ae.toString("hex"));return Ue}static fromBytes(u,p){if(p[0]!=y.DELEGATED)throw new I(p[0]);const L=Ee(h.from(p.subarray(1))),ee=be.unsigned.decode(h.from(p.subarray(1,1+L))),se=h.from(p.subarray(L+1));return new Be(u,ee,se)}}class Ke extends Be{constructor(u,p){super(u,v.ETH,p);P(this,"toEthAddressHex",(u=!1)=>`${u?"0x":""}${this.subAddress.toString("hex")}`);if(p.length!==w)throw new Error("invalid ethereum address: length should be 32 bytes")}static fromBytes(u,p){const L=Be.fromBytes(u,p);if(L.getNamespace()!==v.ETH)throw new Error("invalid filecoin address for ethereum space");return new Ke(L.getNetworkPrefix(),L.getSubAddress())}static fromString(u){const p=Be.fromString(u);if(p.getNamespace()!==v.ETH)throw new Error("invalid filecoin address for ethereum space");return new Ke(p.getNetworkPrefix(),p.getSubAddress())}}const Ce="2.0",ct="Filecoin.MpoolGetNonce",Qe="Filecoin.MpoolPush",ft="Filecoin.StateWaitMsg",Je="Filecoin.GasEstimateMessageGas",ut="Filecoin.StateReadState",_e="Filecoin.StateListMiners",et="Filecoin.StateMinerInfo",tt="Filecoin.ClientQueryAsk",lt="Filecoin.WalletBalance";class Ge{constructor(t,u){P(this,"fetcher");P(this,"network");P(this,"getNetwork",()=>this.network);P(this,"validateNetwork",(t,u="address")=>{const p=He(this.network);if(typeof t=="string"&&(t=D.fromString(t)),t.getNetworkPrefix()!==p)throw new Error(`${u} belongs to ${t.getNetworkPrefix()} network while rpc allows ${p}`);return t});this.fetcher=C.create({baseURL:u.url,timeout:u.timeout,headers:{Authorization:`Bearer ${u.token}`}}),this.network=t}async getNonce(t){t=this.validateNetwork(t);try{return(await this.fetcher.post("",{jsonrpc:Ce,method:ct,id:1,params:[t.toString()]})).data}catch(u){return this.handleError(u)}}async broadcastTransaction(t,u){this.validateNetwork(t.to,"receiver"),this.validateNetwork(t.from,"sender");try{return(await this.fetcher.post("",{jsonrpc:Ce,method:Qe,id:1,params:[{Message:t.toJSON(),Signature:u.toJSON()}]})).data}catch(p){return this.handleError(p)}}async getGasEstimation(t){this.validateNetwork(t.to,"receiver"),this.validateNetwork(t.from,"sender");try{return(await this.fetcher.post("",{jsonrpc:Ce,method:Je,id:1,params:[t.toJSON(),{MaxFee:"0"},null]})).data}catch(u){return this.handleError(u)}}async readState(t){t=this.validateNetwork(t);try{return(await this.fetcher.post("",{jsonrpc:Ce,method:ut,id:1,params:[t.toString(),null]})).data}catch(u){return this.handleError(u)}}async waitMsgState(t,u,p){try{return(await this.fetcher.post("",{jsonrpc:Ce,method:ft,id:1,params:[t,u,p,!1]})).data}catch(L){return this.handleError(L)}}async walletBalance(t){t=this.validateNetwork(t);try{return(await this.fetcher.post("",{jsonrpc:Ce,method:lt,id:1,params:[t.toString()]})).data}catch(u){return this.handleError(u)}}async listMiners(){try{return(await this.fetcher.post("",{jsonrpc:Ce,method:_e,id:1,params:[null]})).data}catch(t){return this.handleError(t)}}async getMinerInfo(t){t=this.validateNetwork(t);try{return(await this.fetcher.post("",{jsonrpc:Ce,method:et,id:1,params:[t.toString(),null]})).data}catch(u){return this.handleError(u)}}async askForStorage(t,u){t=this.validateNetwork(t);try{return(await this.fetcher.post("",{jsonrpc:Ce,method:tt,id:1,params:[u,t.toString()]})).data}catch(p){return this.handleError(p)}}handleError(t){if(C.isAxiosError(t)){if(t.response){if(t.response.data)return t.response.data;if(t.response.statusText)return{error:{message:`${t.response.status} - ${t.response.statusText}`}}}if(t.request)return{error:{message:"request made but no response received"}};if(t.message)return{error:{message:t.message}}}throw t}}class bt extends Ge{constructor(t){super(a.Mainnet,t)}}class yt extends Ge{constructor(t){super(a.Calibration,t)}}class We extends Ge{constructor(t){super(a.Butterfly,t)}}var ze=R(90749),ht=R(83328),rt=R(73513),dt=R.t(rt,2),je=R(17009),Oe=R(48287).Buffer;const nt=Oe.from([1,113,160,228,2,32]),ot=32,it=s=>{const t=s.split("/");return t[2].includes("'")?t[2].substring(0,t[2].length-1):t[2]};function ve(s){const t=O.blake2bInit(ot);O.blake2bUpdate(t,s);const u=Oe.from(O.blake2bFinal(t));return Oe.concat([nt,u])}function Re(s){const t=O.blake2bInit(32);return O.blake2bUpdate(t,ve(s)),Oe.from(O.blake2bFinal(t))}const Ze=s=>{if(typeof s=="string")if(s.substring(s.length-1)==="=")s=Oe.from(s,"base64");else throw new ue;if(s.length!==32)throw new ue;return s},n=s=>{const t=O.blake2bInit(20);return O.blake2bUpdate(t,s),Oe.from(O.blake2bFinal(t))},e=s=>S.BLS===s||S.SECP256K1===s;var r=R(48287).Buffer;const l=ht.Pr(dt),Ye=class{static recoverAccount(t,u,p,L){switch(u){case S.SECP256K1:{p=Ze(p);const{publicKey:ee,address:se}=Ye.getPublicSecp256k1FromPrivKey(t,p);return{type:u,privateKey:p,address:se,publicKey:ee,path:L}}default:throw new Error("not supported yet")}}};let m=Ye;P(m,"generateMnemonic",()=>ze.generateMnemonic(256)),P(m,"mnemonicToSeed",(t,u)=>ze.mnemonicToSeedSync(t,u)),P(m,"deriveAccount",(t,u,p,L,ee)=>{const se=Ye.mnemonicToSeed(t,L);return Ye.deriveAccountFromSeed(se,u,p,ee)}),P(m,"deriveAccountFromSeed",(t,u,p,L)=>{switch(typeof t=="string"&&(t=r.from(t,"hex")),u){case S.SECP256K1:{const ee=l.fromSeed(t),{privateKey:se}=ee.derivePath(p);if(!se)throw new Error("privateKey not generated");L||(L=it(p)==="1"?d.Testnet:d.Mainnet);const{publicKey:fe,address:we}=Ye.getPublicSecp256k1FromPrivKey(L,se);return{type:u,privateKey:se,publicKey:fe,address:we,path:p}}default:throw new Error("not supported yet")}}),P(m,"signTransaction",async(t,u)=>{const p=await u.serialize(),L=Re(p),{privateKey:ee,type:se}=t;switch(se){case S.SECP256K1:{const fe=je.ecdsaSign(L,ee);return new N(se,r.concat([r.from(fe.signature),r.from([fe.recid])]))}default:throw new Error("not supported yet")}}),P(m,"verifySignature",async(t,u)=>{const p=await u.serialize(),L=Re(p);switch(t.getType()){case S.SECP256K1:{const ee=t.getData(),se=je.ecdsaRecover(ee.subarray(0,-1),ee[64],L,!1),fe=n(se);return u.from.getPayload().toString("hex")!==fe.toString("hex")?!1:je.ecdsaVerify(ee.subarray(0,-1),L,se)}default:throw new Error("not supported yet")}}),P(m,"getPublicSecp256k1FromPrivKey",(t,u)=>{const p=je.publicKeyCreate(u),L=new Uint8Array(65);je.publicKeyConvert(p,!1,L);const ee=r.from(L),se=n(L);return{publicKey:ee,address:new ge(t,se)}});const wt=class{constructor(t,u){P(this,"type");P(this,"data");P(this,"toJSON",()=>({Type:this.type,Data:this.data.toString("base64")}));P(this,"getType",()=>this.type);P(this,"getData",()=>this.data);P(this,"isSecp256k1",()=>this.type===S.SECP256K1);P(this,"isBls",()=>this.type===S.BLS);this.type=t,this.data=u}};let N=wt;P(N,"fromJSON",t=>{if(typeof t!="object"||t===null)throw new Error("input should be an object");if(!("Type"in t)||typeof t.Type!="number")throw new Error("'Type' should be a number");if(!e(t.Type))throw new Error("invalid signature type");if(!("Data"in t)||typeof t.Data!="string")throw new Error("'Data' should be a base64 encoded string");return new wt(t.Type,r.from(t.Data,"base64"))});var j=R(48287).Buffer;const $=(s,t=10)=>{if(s.toString()==="0")return j.from("");const u=new c(s,t),p=u.toArrayLike(j,"be",u.byteLength()),L=j.from(u.isNeg()?"01":"00","hex");return j.concat([L,p])},J=(s,t=10)=>{if(s.length===0)return"0";if(s[0]!=0&&s[0]!=1)throw new Error("invalid bigint");const u=s[0]===1?"-":"",p=new c(s.subarray(1));return u+p.toString(t)},q=s=>new Promise(t=>setTimeout(t,s)),_=async s=>{let t=s();for(;!t;)await q(50),t=s();return t};var te=R(48287).Buffer;let re;R.e(1523).then(R.bind(R,71523)).then(s=>{re=s}).catch(s=>{throw s});const qe=class{constructor(t,u,p,L,ee,se,fe,we,Ae,Ue){P(this,"version");P(this,"to");P(this,"from");P(this,"nonce");P(this,"value");P(this,"gasLimit");P(this,"gasFeeCap");P(this,"gasPremium");P(this,"method");P(this,"params");P(this,"toJSON",()=>({To:this.to.toString(),From:this.from.toString(),Nonce:this.nonce,Value:this.value,Params:this.params,GasFeeCap:this.gasFeeCap,GasPremium:this.gasPremium,GasLimit:this.gasLimit,Method:this.method}));P(this,"serialize",async()=>{const t=await _(()=>re),u=[this.version,this.to.toBytes(),this.from.toBytes(),this.nonce,$(this.value,10),this.gasLimit,$(this.gasFeeCap,10),$(this.gasPremium,10),this.method,te.from(this.params,"base64")];return te.from(t.encode(u))});P(this,"prepareToSend",async t=>{const u=await t.getNonce(this.from);if("error"in u)throw new Error(u.error.message);this.nonce=u.result;const p=await t.getGasEstimation(this);if("error"in p)throw new Error(p.error.message);return this.gasFeeCap=p.result.GasFeeCap,this.gasLimit=p.result.GasLimit,this.gasPremium=p.result.GasPremium,this});if(this.version=t,this.to=u,this.from=p,this.nonce=L,this.value=ee,this.gasLimit=se,this.gasFeeCap=fe,this.gasPremium=we,this.method=Ae,this.params=Ue,ee===""||ee.includes("-"))throw new Error("value must not be empty or negative")}};let de=qe;P(de,"getNew",(t,u,p,L,ee=te.alloc(0))=>new qe(K.Zero,t,u,0,p.toAtto(),0,"0","0",L,ee.toString("base64"))),P(de,"fromCBOR",async(t,u)=>{typeof u=="string"&&(u=te.from(u,"hex"));const L=(await _(()=>re)).decode(u);if(!(L instanceof Array))throw new Error("Decoded raw tx should be an array");if(L.length<10)throw new Error("The cbor is missing some fields... please verify you have 9 fields.");const[ee,se,fe,we,Ae,Ue,Ct,Rt,Tt,Ut]=L;if(ee!==K.Zero)throw new Error("Unsupported version");if(Ae[0]===1)throw new Error("Value cant be negative");const Nt=new c(te.from(Ae).toString("hex"),16).toString(10),Kt=new c(te.from(Ct).toString("hex"),16).toString(10),zt=new c(te.from(Rt).toString("hex"),16).toString(10);return new qe(ee,D.fromBytes(t,se),D.fromBytes(t,fe),we,Nt,Ue,Kt,zt,Tt,Ut.toString("base64"))}),P(de,"fromJSON",t=>{if(typeof t!="object"||t==null)throw new Error("tx should be an json object");if(!("To"in t)||typeof t.To!="string")throw new Error("'To' is a required field and has to be a 'string'");if(!("From"in t)||typeof t.From!="string")throw new Error("'From' is a required field and has to be a 'string'");if(!("Nonce"in t)||typeof t.Nonce!="number")throw new Error("'Nonce' is a required field and has to be a 'number'");if(!("Value"in t)||typeof t.Value!="string"||t.Value===""||t.Value.includes("-"))throw new Error("'Value' is a required field and has to be a 'string' but not empty or negative");if(!("GasFeeCap"in t)||typeof t.GasFeeCap!="string")throw new Error("'GasFeeCap' is a required field and has to be a 'string'");if(!("GasPremium"in t)||typeof t.GasPremium!="string")throw new Error("'GasPremium' is a required field and has to be a 'string'");if(!("GasLimit"in t)||typeof t.GasLimit!="number")throw new Error("'GasLimit' is a required field and has to be a 'number'");if(!("Method"in t)||typeof t.Method!="number")throw new Error("'Method' is a required field and has to be a 'number'");if(!("Params"in t)||typeof t.Params!="string")throw new Error("'Params' is a required field and has to be a 'string'");return new qe(K.Zero,D.fromString(t.To),D.fromString(t.From),t.Nonce,t.Value,t.GasLimit,t.GasFeeCap,t.GasPremium,t.Method,t.Params)});const he=(s,t)=>{const u=s.isNeg()?"-":"",p=s.abs().toString(),L=p.length-t,ee=xe(L>0?`${p.substring(0,L)}.${p.substring(L)}`:`0.${"".padStart(-1*L,"0")}${p}`);return`${u}${ee}`},xe=s=>{for(let t=s.length-1;t>=0;t--){if(s[t]==".")return s.substring(0,t);if(s[t]!="0"||t===1)return s.substring(0,t+1)}throw new Error("invalid value")},Se=18,Le=15,De=12,$e=9,Ve=6,Fe=3,St=0,xt=new c(10).pow(new c(Fe)),At=new c(10).pow(new c(Ve)),Pt=new c(10).pow(new c($e)),Bt=new c(10).pow(new c(De)),It=new c(10).pow(new c(Le)),kt=new c(10).pow(new c(Se)),Te=class{constructor(t){P(this,"value");P(this,"add",t=>(this.value=this.value.add(t.value),this));P(this,"sub",t=>(this.value=this.value.sub(t.value),this));P(this,"gt",t=>this.value.gt(t.value));P(this,"gte",t=>this.value.gte(t.value));P(this,"lt",t=>this.value.lt(t.value));P(this,"lte",t=>this.value.lte(t.value));P(this,"isNegative",()=>this.value.isNeg());P(this,"isPositive",()=>!this.value.isNeg());P(this,"isZero",()=>this.value.isZero());P(this,"toWhole",()=>he(this.value,Se));P(this,"toMilli",()=>he(this.value,Se-Fe));P(this,"toMicro",()=>he(this.value,Se-Ve));P(this,"toNano",()=>he(this.value,Se-$e));P(this,"toPico",()=>he(this.value,Se-De));P(this,"toFemto",()=>he(this.value,Se-Le));P(this,"toAtto",()=>he(this.value,0));P(this,"serialize",()=>$(this.value.toString(10),10));this.value=t}};let Ie=Te;P(Ie,"zero",()=>new Te(new c("0"))),P(Ie,"deserialize",t=>new Te(new c(J(t,10),10))),P(Ie,"fromAtto",t=>new Te(new c(t))),P(Ie,"fromFemto",t=>new Te(new c(t).mul(xt))),P(Ie,"fromPico",t=>new Te(new c(t).mul(At))),P(Ie,"fromNano",t=>new Te(new c(t).mul(Pt))),P(Ie,"fromMicro",t=>new Te(new c(t).mul(Bt))),P(Ie,"fromMilli",t=>new Te(new c(t).mul(It))),P(Ie,"fromWhole",t=>new Te(new c(t).mul(kt)));class gt{}P(gt,"send",null),P(gt,"getBalance",null);var Dt=R(48287).Buffer;class pt{}P(pt,"newTx",null),P(pt,"newExecTx",null);let mt;R.e(1523).then(R.bind(R,71523)).then(s=>{mt=s}).catch(s=>{throw s});let Et;R.e(2131).then(R.bind(R,92131)).then(s=>{Et=s}).catch(s=>{throw s});class Ft{constructor(t,u){P(this,"targetActorCid");P(this,"targetConstructorParams");P(this,"serialize",async()=>{const t=await waitFor(()=>mt),u=await waitFor(()=>Et);return t.encode([u.CID.parse(this.targetActorCid),this.targetConstructorParams])});this.targetActorCid=t,this.targetConstructorParams=u}}let vt;R.e(1523).then(R.bind(R,71523)).then(s=>{vt=s}).catch(s=>{throw s});class Mt{constructor(t,u){P(this,"from");P(this,"to");P(this,"serialize",async()=>(await waitFor(()=>vt)).encode([this.from.toBytes(),this.to.toBytes()]));this.from=t,this.to=u}}const Ht=s=>{switch(s){case Network.Calibration:return ActorsCalibrationV11;case Network.Mainnet:return ActorsMainnetV10;case Network.Butterfly:throw new Error("not implemented yet")}},at=class{constructor(t,u,p){P(this,"channelAddress");P(this,"from");P(this,"to");P(this,"getAddress",()=>this.channelAddress);P(this,"getTo",()=>this.to);P(this,"getFrom",()=>this.from);P(this,"settle",(t,u)=>{const{address:p}=u,L=Transaction.getNew(this.channelAddress,p,Token.zero(),PayChActorMethods.Settle);return at.sendTx(t,u,L)});P(this,"collect",(t,u)=>{const{address:p}=u,L=Transaction.getNew(this.channelAddress,p,Token.zero(),PayChActorMethods.Collect);return at.sendTx(t,u,L)});this.channelAddress=t,this.from=u,this.to=p}};let Xe=at;P(Xe,"create",null),P(Xe,"loadFromCid",null),P(Xe,"sendTx",null)}}]);
|
|
1
|
+
var Ot=Object.defineProperty;var Lt=(ae,i,C)=>i in ae?Ot(ae,i,{enumerable:!0,configurable:!0,writable:!0,value:C}):ae[i]=C;var P=(ae,i,C)=>(Lt(ae,typeof i!="symbol"?i+"":i,C),C);(self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[1700],{73513:function(ae,i,C){"use strict";var k=C(48287).Buffer,h=C(9598),S=C(39615),I=C(22623);function b(f){var T=Object.create(null);return f&&Object.keys(f).forEach(function(Y){if(Y!=="default"){var ue=Object.getOwnPropertyDescriptor(f,Y);Object.defineProperty(T,Y,ue.get?ue:{enumerable:!0,get:function(){return f[Y]}})}}),T.default=f,Object.freeze(T)}var s=b(h);s.utils.hmacSha256Sync=(f,...T)=>S.hmac(I.sha256,f,s.utils.concatBytes(...T)),s.utils.sha256Sync=(...f)=>I.sha256(s.utils.concatBytes(...f));const d=s.utils._normalizePrivateKey,l=32,o=32,g=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]),w=32;function L(f,T){for(let Y=0;Y<32;++Y)if(f[Y]!==T[Y])return f[Y]<T[Y]?-1:1;return 0}function D(f){return!(!(f instanceof Uint8Array)||f.length!==o||L(f,g)>=0)}function Z(f){return f instanceof Uint8Array&&f.length===64&&L(f.subarray(0,32),g)<0&&L(f.subarray(32,64),g)<0}function N(f){return f instanceof Uint8Array&&f.length===l}function F(f){return f===void 0||f instanceof Uint8Array&&f.length===w}function v(f){if(typeof f!="string")throw new TypeError("hexToNumber: expected string, got "+typeof f);return BigInt(`0x${f}`)}function A(f){return v(s.utils.bytesToHex(f))}function x(f){let T;if(typeof f=="bigint")T=f;else if(typeof f=="number"&&Number.isSafeInteger(f)&&f>=0)T=BigInt(f);else if(typeof f=="string"){if(f.length!==64)throw new Error("Expected 32 bytes of private scalar");T=v(f)}else if(f instanceof Uint8Array){if(f.length!==32)throw new Error("Expected 32 bytes of private scalar");T=A(f)}else throw new TypeError("Expected valid private scalar");if(T<0)throw new Error("Expected private scalar >= 0");return T}const K=(f,T)=>{const Y=d(f),ue=x(T),ye=s.utils._bigintTo32Bytes(s.utils.mod(Y+ue,s.CURVE.n));return s.utils.isValidPrivateKey(ye)?ye:null},X=(f,T)=>{const Y=d(f),ue=x(T),ye=s.utils._bigintTo32Bytes(s.utils.mod(Y-ue,s.CURVE.n));return s.utils.isValidPrivateKey(ye)?ye:null},G=f=>{const T=d(f),Y=s.utils._bigintTo32Bytes(s.CURVE.n-T);return s.utils.isValidPrivateKey(Y)?Y:null},_=(f,T,Y)=>{const ue=s.Point.fromHex(f),ye=x(T),xe=s.Point.BASE.multiplyAndAddUnsafe(ue,ye,1n);if(!xe)throw new Error("Tweaked point at infinity");return xe.toRawBytes(Y)},Ee=(f,T,Y)=>{const ue=s.Point.fromHex(f),ye=typeof T=="string"?T:s.utils.bytesToHex(T),xe=BigInt(`0x${ye}`);return ue.multiply(xe).toRawBytes(Y)};function ve(f,T){return f===void 0?T!==void 0?z(T):!0:!!f}function fe(f){try{return f()}catch{return null}}function de(f,T){if(f.length===32!==T)return!1;try{return!!s.Point.fromHex(f)}catch{return!1}}function V(f){return de(f,!1)}function z(f){return de(f,!1)&&f.length===33}function j(f){return s.utils.isValidPrivateKey(f)}function W(f){return de(f,!0)}function te(f,T){if(!W(f))throw new Error("Expected Point");if(!D(T))throw new Error("Expected Tweak");return fe(()=>{const Y=_(f,T,!0);return{parity:Y[0]%2===1?1:0,xOnlyPubkey:Y.slice(1)}})}function se(f){if(!V(f))throw new Error("Expected Point");return f.slice(1,33)}function m(f,T){if(!j(f))throw new Error("Expected Private");return fe(()=>s.getPublicKey(f,ve(T)))}function B(f){if(!j(f))throw new Error("Expected Private");return se(m(f))}function R(f,T){if(!V(f))throw new Error("Expected Point");return s.Point.fromHex(f).toRawBytes(ve(T,f))}function $(f,T,Y){if(!V(f))throw new Error("Expected Point");if(!D(T))throw new Error("Expected Tweak");return fe(()=>Ee(f,T,ve(Y,f)))}function q(f,T,Y){if(!V(f)||!V(T))throw new Error("Expected Point");return fe(()=>{const ue=s.Point.fromHex(f),ye=s.Point.fromHex(T);return ue.equals(ye.negate())?null:ue.add(ye).toRawBytes(ve(Y,f))})}function p(f,T,Y){if(!V(f))throw new Error("Expected Point");if(!D(T))throw new Error("Expected Tweak");return fe(()=>_(f,T,ve(Y,f)))}function oe(f,T){if(j(f)===!1)throw new Error("Expected Private");if(D(T)===!1)throw new Error("Expected Tweak");return fe(()=>K(f,T))}function we(f,T){if(j(f)===!1)throw new Error("Expected Private");if(D(T)===!1)throw new Error("Expected Tweak");return fe(()=>X(f,T))}function Ae(f){if(j(f)===!1)throw new Error("Expected Private");return G(f)}function Se(f,T,Y){if(!j(T))throw new Error("Expected Private");if(!N(f))throw new Error("Expected Scalar");if(!F(Y))throw new Error("Expected Extra Data (32 bytes)");return s.signSync(f,T,{der:!1,extraEntropy:Y})}function Te(f,T,Y=k.alloc(32,0)){if(!j(T))throw new Error("Expected Private");if(!N(f))throw new Error("Expected Scalar");if(!F(Y))throw new Error("Expected Extra Data (32 bytes)");return s.schnorr.signSync(f,T,Y)}function be(f,T,Y,ue){if(!V(T))throw new Error("Expected Point");if(!Z(Y))throw new Error("Expected Signature");if(!N(f))throw new Error("Expected Scalar");return s.verify(Y,f,T,{strict:ue})}function le(f,T,Y){if(!W(T))throw new Error("Expected Point");if(!Z(Y))throw new Error("Expected Signature");if(!N(f))throw new Error("Expected Scalar");return s.schnorr.verifySync(Y,f,T)}i.isPoint=V,i.isPointCompressed=z,i.isPrivate=j,i.isXOnlyPoint=W,i.pointAdd=q,i.pointAddScalar=p,i.pointCompress=R,i.pointFromScalar=m,i.pointMultiply=$,i.privateAdd=oe,i.privateNegate=Ae,i.privateSub=we,i.sign=Se,i.signSchnorr=Te,i.verify=be,i.verifySchnorr=le,i.xOnlyPointAddTweak=te,i.xOnlyPointFromPoint=se,i.xOnlyPointFromScalar=B},93238:function(ae,i,C){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.ripemd160=i.RIPEMD160=void 0;const k=C(37202),h=C(99175),S=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),I=new Uint8Array(new Array(16).fill(0).map((F,v)=>v)),b=I.map(F=>(9*F+5)%16);let s=[I],d=[b];for(let F=0;F<4;F++)for(let v of[s,d])v.push(v[F].map(A=>S[A]));const l=[[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(F=>new Uint8Array(F)),o=s.map((F,v)=>F.map(A=>l[v][A])),g=d.map((F,v)=>F.map(A=>l[v][A])),w=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),L=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function D(F,v,A,x){return F===0?v^A^x:F===1?v&A|~v&x:F===2?(v|~A)^x:F===3?v&x|A&~x:v^(A|~x)}const Z=new Uint32Array(16);class N extends k.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:v,h1:A,h2:x,h3:K,h4:X}=this;return[v,A,x,K,X]}set(v,A,x,K,X){this.h0=v|0,this.h1=A|0,this.h2=x|0,this.h3=K|0,this.h4=X|0}process(v,A){for(let z=0;z<16;z++,A+=4)Z[z]=v.getUint32(A,!0);let x=this.h0|0,K=x,X=this.h1|0,G=X,_=this.h2|0,Ee=_,ve=this.h3|0,fe=ve,de=this.h4|0,V=de;for(let z=0;z<5;z++){const j=4-z,W=w[z],te=L[z],se=s[z],m=d[z],B=o[z],R=g[z];for(let $=0;$<16;$++){const q=(0,h.rotl)(x+D(z,X,_,ve)+Z[se[$]]+W,B[$])+de|0;x=de,de=ve,ve=(0,h.rotl)(_,10)|0,_=X,X=q}for(let $=0;$<16;$++){const q=(0,h.rotl)(K+D(j,G,Ee,fe)+Z[m[$]]+te,R[$])+V|0;K=V,V=fe,fe=(0,h.rotl)(Ee,10)|0,Ee=G,G=q}}this.set(this.h1+_+fe|0,this.h2+ve+V|0,this.h3+de+K|0,this.h4+x+G|0,this.h0+X+Ee|0)}roundClean(){Z.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}i.RIPEMD160=N,i.ripemd160=(0,h.wrapConstructor)(()=>new N)},9598:function(ae,i,C){"use strict";/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */Object.defineProperty(i,"__esModule",{value:!0}),i.utils=i.schnorr=i.verify=i.signSync=i.sign=i.getSharedSecret=i.recoverPublicKey=i.getPublicKey=i.Signature=i.Point=i.CURVE=void 0;const k=C(14923),h=BigInt(0),S=BigInt(1),I=BigInt(2),b=BigInt(3),s=BigInt(8),d=Object.freeze({a:h,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:S,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")});i.CURVE=d;const l=(n,e)=>(n+e/I)/e,o={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(n){const{n:e}=d,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),u=-S*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),E=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),U=r,M=BigInt("0x100000000000000000000000000000000"),H=l(U*n,e),J=l(-u*n,e);let Q=p(n-H*r-J*E,e),ee=p(-H*u-J*U,e);const ne=Q>M,ie=ee>M;if(ne&&(Q=e-Q),ie&&(ee=e-ee),Q>M||ee>M)throw new Error("splitScalarEndo: Endomorphism failed, k="+n);return{k1neg:ne,k1:Q,k2neg:ie,k2:ee}}},g=32,w=32,L=32,D=g+1,Z=2*g+1;function N(n){const{a:e,b:r}=d,u=p(n*n),E=p(u*n);return p(E+e*n+r)}const F=d.a===h;class v extends Error{constructor(e){super(e)}}function A(n){if(!(n instanceof x))throw new TypeError("JacobianPoint expected")}class x{constructor(e,r,u){this.x=e,this.y=r,this.z=u}static fromAffine(e){if(!(e instanceof G))throw new TypeError("JacobianPoint#fromAffine: expected Point");return e.equals(G.ZERO)?x.ZERO:new x(e.x,e.y,S)}static toAffineBatch(e){const r=Se(e.map(u=>u.z));return e.map((u,E)=>u.toAffine(r[E]))}static normalizeZ(e){return x.toAffineBatch(e).map(x.fromAffine)}equals(e){A(e);const{x:r,y:u,z:E}=this,{x:U,y:M,z:H}=e,J=p(E*E),Q=p(H*H),ee=p(r*Q),ne=p(U*J),ie=p(p(u*H)*Q),pe=p(p(M*E)*J);return ee===ne&&ie===pe}negate(){return new x(this.x,p(-this.y),this.z)}double(){const{x:e,y:r,z:u}=this,E=p(e*e),U=p(r*r),M=p(U*U),H=e+U,J=p(I*(p(H*H)-E-M)),Q=p(b*E),ee=p(Q*Q),ne=p(ee-I*J),ie=p(Q*(J-ne)-s*M),pe=p(I*r*u);return new x(ne,ie,pe)}add(e){A(e);const{x:r,y:u,z:E}=this,{x:U,y:M,z:H}=e;if(U===h||M===h)return this;if(r===h||u===h)return e;const J=p(E*E),Q=p(H*H),ee=p(r*Q),ne=p(U*J),ie=p(p(u*H)*Q),pe=p(p(M*E)*J),ge=p(ne-ee),ke=p(pe-ie);if(ge===h)return ke===h?this.double():x.ZERO;const Ie=p(ge*ge),Fe=p(ge*Ie),Me=p(ee*Ie),$e=p(ke*ke-Fe-I*Me),Ve=p(ke*(Me-$e)-ie*Fe),He=p(E*H*ge);return new x($e,Ve,He)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){const r=x.ZERO;if(typeof e=="bigint"&&e===h)return r;let u=q(e);if(u===S)return this;if(!F){let ne=r,ie=this;for(;u>h;)u&S&&(ne=ne.add(ie)),ie=ie.double(),u>>=S;return ne}let{k1neg:E,k1:U,k2neg:M,k2:H}=o.splitScalar(u),J=r,Q=r,ee=this;for(;U>h||H>h;)U&S&&(J=J.add(ee)),H&S&&(Q=Q.add(ee)),ee=ee.double(),U>>=S,H>>=S;return E&&(J=J.negate()),M&&(Q=Q.negate()),Q=new x(p(Q.x*o.beta),Q.y,Q.z),J.add(Q)}precomputeWindow(e){const r=F?128/e+1:256/e+1,u=[];let E=this,U=E;for(let M=0;M<r;M++){U=E,u.push(U);for(let H=1;H<2**(e-1);H++)U=U.add(E),u.push(U);E=U.double()}return u}wNAF(e,r){!r&&this.equals(x.BASE)&&(r=G.BASE);const u=r&&r._WINDOW_SIZE||1;if(256%u)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let E=r&&X.get(r);E||(E=this.precomputeWindow(u),r&&u!==1&&(E=x.normalizeZ(E),X.set(r,E)));let U=x.ZERO,M=x.BASE;const H=1+(F?128/u:256/u),J=2**(u-1),Q=BigInt(2**u-1),ee=2**u,ne=BigInt(u);for(let ie=0;ie<H;ie++){const pe=ie*J;let ge=Number(e&Q);e>>=ne,ge>J&&(ge-=ee,e+=S);const ke=pe,Ie=pe+Math.abs(ge)-1,Fe=ie%2!==0,Me=ge<0;ge===0?M=M.add(K(Fe,E[ke])):U=U.add(K(Me,E[Ie]))}return{p:U,f:M}}multiply(e,r){let u=q(e),E,U;if(F){const{k1neg:M,k1:H,k2neg:J,k2:Q}=o.splitScalar(u);let{p:ee,f:ne}=this.wNAF(H,r),{p:ie,f:pe}=this.wNAF(Q,r);ee=K(M,ee),ie=K(J,ie),ie=new x(p(ie.x*o.beta),ie.y,ie.z),E=ee.add(ie),U=ne.add(pe)}else{const{p:M,f:H}=this.wNAF(u,r);E=M,U=H}return x.normalizeZ([E,U])[0]}toAffine(e){const{x:r,y:u,z:E}=this,U=this.equals(x.ZERO);e==null&&(e=U?s:Ae(E));const M=e,H=p(M*M),J=p(H*M),Q=p(r*H),ee=p(u*J),ne=p(E*M);if(U)return G.ZERO;if(ne!==S)throw new Error("invZ was invalid");return new G(Q,ee)}}x.BASE=new x(d.Gx,d.Gy,S),x.ZERO=new x(h,S,h);function K(n,e){const r=e.negate();return n?r:e}const X=new WeakMap;class G{constructor(e,r){this.x=e,this.y=r}_setWindowSize(e){this._WINDOW_SIZE=e,X.delete(this)}hasEvenY(){return this.y%I===h}static fromCompressedHex(e){const r=e.length===32,u=R(r?e:e.subarray(1));if(!ue(u))throw new Error("Point is not on curve");const E=N(u);let U=we(E);const M=(U&S)===S;r?M&&(U=p(-U)):(e[0]&1)===1!==M&&(U=p(-U));const H=new G(u,U);return H.assertValidity(),H}static fromUncompressedHex(e){const r=R(e.subarray(1,g+1)),u=R(e.subarray(g+1,g*2+1)),E=new G(r,u);return E.assertValidity(),E}static fromHex(e){const r=$(e),u=r.length,E=r[0];if(u===g)return this.fromCompressedHex(r);if(u===D&&(E===2||E===3))return this.fromCompressedHex(r);if(u===Z&&E===4)return this.fromUncompressedHex(r);throw new Error(`Point.fromHex: received invalid point. Expected 32-${D} compressed bytes or ${Z} uncompressed bytes, not ${u}`)}static fromPrivateKey(e){return G.BASE.multiply(xe(e))}static fromSignature(e,r,u){const{r:E,s:U}=Oe(r);if(![0,1,2,3].includes(u))throw new Error("Cannot recover: invalid recovery bit");const M=be($(e)),{n:H}=d,J=u===2||u===3?E+H:E,Q=Ae(J,H),ee=p(-M*Q,H),ne=p(U*Q,H),ie=u&1?"03":"02",pe=G.fromHex(ie+W(J)),ge=G.BASE.multiplyAndAddUnsafe(pe,ee,ne);if(!ge)throw new Error("Cannot recover signature: point at infinify");return ge.assertValidity(),ge}toRawBytes(e=!1){return B(this.toHex(e))}toHex(e=!1){const r=W(this.x);return e?`${this.hasEvenY()?"02":"03"}${r}`:`04${r}${W(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:r,y:u}=this;if(!ue(r)||!ue(u))throw new Error(e);const E=p(u*u),U=N(r);if(p(E-U)!==h)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new G(this.x,p(-this.y))}double(){return x.fromAffine(this).double().toAffine()}add(e){return x.fromAffine(this).add(x.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return x.fromAffine(this).multiply(e,this).toAffine()}multiplyAndAddUnsafe(e,r,u){const E=x.fromAffine(this),U=r===h||r===S||this!==G.BASE?E.multiplyUnsafe(r):E.multiply(r),M=x.fromAffine(e).multiplyUnsafe(u),H=U.add(M);return H.equals(x.ZERO)?void 0:H.toAffine()}}i.Point=G,G.BASE=new G(d.Gx,d.Gy),G.ZERO=new G(h,h);function _(n){return Number.parseInt(n[0],16)>=8?"00"+n:n}function Ee(n){if(n.length<2||n[0]!==2)throw new Error(`Invalid signature integer tag: ${z(n)}`);const e=n[1],r=n.subarray(2,e+2);if(!e||r.length!==e)throw new Error("Invalid signature integer: wrong length");if(r[0]===0&&r[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:R(r),left:n.subarray(e+2)}}function ve(n){if(n.length<2||n[0]!=48)throw new Error(`Invalid signature tag: ${z(n)}`);if(n[1]!==n.length-2)throw new Error("Invalid signature: incorrect length");const{data:e,left:r}=Ee(n.subarray(2)),{data:u,left:E}=Ee(r);if(E.length)throw new Error(`Invalid signature: left bytes after parsing: ${z(E)}`);return{r:e,s:u}}class fe{constructor(e,r){this.r=e,this.s=r,this.assertValidity()}static fromCompact(e){const r=e instanceof Uint8Array,u="Signature.fromCompact";if(typeof e!="string"&&!r)throw new TypeError(`${u}: Expected string or Uint8Array`);const E=r?z(e):e;if(E.length!==128)throw new Error(`${u}: Expected 64-byte hex`);return new fe(m(E.slice(0,64)),m(E.slice(64,128)))}static fromDER(e){const r=e instanceof Uint8Array;if(typeof e!="string"&&!r)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:u,s:E}=ve(r?e:B(e));return new fe(u,E)}static fromHex(e){return this.fromDER(e)}assertValidity(){const{r:e,s:r}=this;if(!Y(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Y(r))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const e=d.n>>S;return this.s>e}normalizeS(){return this.hasHighS()?new fe(this.r,p(-this.s,d.n)):this}toDERRawBytes(){return B(this.toDERHex())}toDERHex(){const e=_(se(this.s)),r=_(se(this.r)),u=e.length/2,E=r.length/2,U=se(u),M=se(E);return`30${se(E+u+4)}02${M}${r}02${U}${e}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return B(this.toCompactHex())}toCompactHex(){return W(this.r)+W(this.s)}}i.Signature=fe;function de(...n){if(!n.every(u=>u instanceof Uint8Array))throw new Error("Uint8Array list expected");if(n.length===1)return n[0];const e=n.reduce((u,E)=>u+E.length,0),r=new Uint8Array(e);for(let u=0,E=0;u<n.length;u++){const U=n[u];r.set(U,E),E+=U.length}return r}const V=Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));function z(n){if(!(n instanceof Uint8Array))throw new Error("Expected Uint8Array");let e="";for(let r=0;r<n.length;r++)e+=V[n[r]];return e}const j=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function W(n){if(typeof n!="bigint")throw new Error("Expected bigint");if(!(h<=n&&n<j))throw new Error("Expected number 0 <= n < 2^256");return n.toString(16).padStart(64,"0")}function te(n){const e=B(W(n));if(e.length!==32)throw new Error("Error: expected 32 bytes");return e}function se(n){const e=n.toString(16);return e.length&1?`0${e}`:e}function m(n){if(typeof n!="string")throw new TypeError("hexToNumber: expected string, got "+typeof n);return BigInt(`0x${n}`)}function B(n){if(typeof n!="string")throw new TypeError("hexToBytes: expected string, got "+typeof n);if(n.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+n.length);const e=new Uint8Array(n.length/2);for(let r=0;r<e.length;r++){const u=r*2,E=n.slice(u,u+2),U=Number.parseInt(E,16);if(Number.isNaN(U)||U<0)throw new Error("Invalid byte sequence");e[r]=U}return e}function R(n){return m(z(n))}function $(n){return n instanceof Uint8Array?Uint8Array.from(n):B(n)}function q(n){if(typeof n=="number"&&Number.isSafeInteger(n)&&n>0)return BigInt(n);if(typeof n=="bigint"&&Y(n))return n;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function p(n,e=d.P){const r=n%e;return r>=h?r:e+r}function oe(n,e){const{P:r}=d;let u=n;for(;e-- >h;)u*=u,u%=r;return u}function we(n){const{P:e}=d,r=BigInt(6),u=BigInt(11),E=BigInt(22),U=BigInt(23),M=BigInt(44),H=BigInt(88),J=n*n*n%e,Q=J*J*n%e,ee=oe(Q,b)*Q%e,ne=oe(ee,b)*Q%e,ie=oe(ne,I)*J%e,pe=oe(ie,u)*ie%e,ge=oe(pe,E)*pe%e,ke=oe(ge,M)*ge%e,Ie=oe(ke,H)*ke%e,Fe=oe(Ie,M)*ge%e,Me=oe(Fe,b)*Q%e,$e=oe(Me,U)*pe%e,Ve=oe($e,r)*J%e,He=oe(Ve,I);if(He*He%e!==n)throw new Error("Cannot find square root");return He}function Ae(n,e=d.P){if(n===h||e<=h)throw new Error(`invert: expected positive integers, got n=${n} mod=${e}`);let r=p(n,e),u=e,E=h,U=S,M=S,H=h;for(;r!==h;){const Q=u/r,ee=u%r,ne=E-M*Q,ie=U-H*Q;u=r,r=ee,E=M,U=H,M=ne,H=ie}if(u!==S)throw new Error("invert: does not exist");return p(E,e)}function Se(n,e=d.P){const r=new Array(n.length),u=n.reduce((U,M,H)=>M===h?U:(r[H]=U,p(U*M,e)),S),E=Ae(u,e);return n.reduceRight((U,M,H)=>M===h?U:(r[H]=p(U*r[H],e),p(U*M,e)),E),r}function Te(n){const e=n.length*8-w*8,r=R(n);return e>0?r>>BigInt(e):r}function be(n,e=!1){const r=Te(n);if(e)return r;const{n:u}=d;return r>=u?r-u:r}let le,f;class T{constructor(e,r){if(this.hashLen=e,this.qByteLen=r,typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof r!="number"||r<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 i.utils.hmacSha256(this.k,...e)}hmacSync(...e){return f(this.k,...e)}checkSync(){if(typeof f!="function")throw new v("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),e.length!==0&&(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),e.length!==0&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),e),this.v=this.hmacSync(this.v))}async generate(){this.incr();let e=0;const r=[];for(;e<this.qByteLen;){this.v=await this.hmac(this.v);const u=this.v.slice();r.push(u),e+=this.v.length}return de(...r)}generateSync(){this.checkSync(),this.incr();let e=0;const r=[];for(;e<this.qByteLen;){this.v=this.hmacSync(this.v);const u=this.v.slice();r.push(u),e+=this.v.length}return de(...r)}}function Y(n){return h<n&&n<d.n}function ue(n){return h<n&&n<d.P}function ye(n,e,r,u=!0){const{n:E}=d,U=be(n,!0);if(!Y(U))return;const M=Ae(U,E),H=G.BASE.multiply(U),J=p(H.x,E);if(J===h)return;const Q=p(M*p(e+r*J,E),E);if(Q===h)return;let ee=new fe(J,Q),ne=(H.x===ee.r?0:2)|Number(H.y&S);return u&&ee.hasHighS()&&(ee=ee.normalizeS(),ne^=1),{sig:ee,recovery:ne}}function xe(n){let e;if(typeof n=="bigint")e=n;else if(typeof n=="number"&&Number.isSafeInteger(n)&&n>0)e=BigInt(n);else if(typeof n=="string"){if(n.length!==2*w)throw new Error("Expected 32 bytes of private key");e=m(n)}else if(n instanceof Uint8Array){if(n.length!==w)throw new Error("Expected 32 bytes of private key");e=R(n)}else throw new TypeError("Expected valid private key");if(!Y(e))throw new Error("Expected private key: 0 < key < n");return e}function Pe(n){return n instanceof G?(n.assertValidity(),n):G.fromHex(n)}function Oe(n){if(n instanceof fe)return n.assertValidity(),n;try{return fe.fromDER(n)}catch{return fe.fromCompact(n)}}function Ue(n,e=!1){return G.fromPrivateKey(n).toRawBytes(e)}i.getPublicKey=Ue;function ct(n,e,r,u=!1){return G.fromSignature(n,e,r).toRawBytes(u)}i.recoverPublicKey=ct;function Qe(n){const e=n instanceof Uint8Array,r=typeof n=="string",u=(e||r)&&n.length;return e?u===D||u===Z:r?u===D*2||u===Z*2:n instanceof G}function ft(n,e,r=!1){if(Qe(n))throw new TypeError("getSharedSecret: first arg must be private key");if(!Qe(e))throw new TypeError("getSharedSecret: second arg must be public key");const u=Pe(e);return u.assertValidity(),u.multiply(xe(n)).toRawBytes(r)}i.getSharedSecret=ft;function Je(n){const e=n.length>g?n.slice(0,g):n;return R(e)}function ut(n){const e=Je(n),r=p(e,d.n);return _e(r<h?e:r)}function _e(n){return te(n)}function et(n,e,r){if(n==null)throw new Error(`sign: expected valid message hash, not "${n}"`);const u=$(n),E=xe(e),U=[_e(E),ut(u)];if(r!=null){r===!0&&(r=i.utils.randomBytes(g));const J=$(r);if(J.length!==g)throw new Error(`sign: Expected ${g} bytes of extra data`);U.push(J)}const M=de(...U),H=Je(u);return{seed:M,m:H,d:E}}function tt(n,e){const{sig:r,recovery:u}=n,{der:E,recovered:U}=Object.assign({canonical:!0,der:!0},e),M=E?r.toDERRawBytes():r.toCompactRawBytes();return U?[M,u]:M}async function lt(n,e,r={}){const{seed:u,m:E,d:U}=et(n,e,r.extraEntropy),M=new T(L,w);await M.reseed(u);let H;for(;!(H=ye(await M.generate(),E,U,r.canonical));)await M.reseed();return tt(H,r)}i.sign=lt;function Ge(n,e,r={}){const{seed:u,m:E,d:U}=et(n,e,r.extraEntropy),M=new T(L,w);M.reseedSync(u);let H;for(;!(H=ye(M.generateSync(),E,U,r.canonical));)M.reseedSync();return tt(H,r)}i.signSync=Ge;const bt={strict:!0};function yt(n,e,r,u=bt){let E;try{E=Oe(n),e=$(e)}catch{return!1}const{r:U,s:M}=E;if(u.strict&&E.hasHighS())return!1;const H=be(e);let J;try{J=Pe(r)}catch{return!1}const{n:Q}=d,ee=Ae(M,Q),ne=p(H*ee,Q),ie=p(U*ee,Q),pe=G.BASE.multiplyAndAddUnsafe(J,ne,ie);return pe?p(pe.x,Q)===U:!1}i.verify=yt;function We(n){return p(R(n),d.n)}class Le{constructor(e,r){this.r=e,this.s=r,this.assertValidity()}static fromHex(e){const r=$(e);if(r.length!==64)throw new TypeError(`SchnorrSignature.fromHex: expected 64 bytes, not ${r.length}`);const u=R(r.subarray(0,32)),E=R(r.subarray(32,64));return new Le(u,E)}assertValidity(){const{r:e,s:r}=this;if(!ue(e)||!Y(r))throw new Error("Invalid signature")}toHex(){return W(this.r)+W(this.s)}toRawBytes(){return B(this.toHex())}}function ht(n){return G.fromPrivateKey(n).toRawX()}class rt{constructor(e,r,u=i.utils.randomBytes()){if(e==null)throw new TypeError(`sign: Expected valid message, not "${e}"`);this.m=$(e);const{x:E,scalar:U}=this.getScalar(xe(r));if(this.px=E,this.d=U,this.rand=$(u),this.rand.length!==32)throw new TypeError("sign: Expected 32 bytes of aux randomness")}getScalar(e){const r=G.fromPrivateKey(e),u=r.hasEvenY()?e:d.n-e;return{point:r,scalar:u,x:r.toRawX()}}initNonce(e,r){return te(e^R(r))}finalizeNonce(e){const r=p(R(e),d.n);if(r===h)throw new Error("sign: Creation of signature failed. k is zero");const{point:u,x:E,scalar:U}=this.getScalar(r);return{R:u,rx:E,k:U}}finalizeSig(e,r,u,E){return new Le(e.x,p(r+u*E,d.n)).toRawBytes()}error(){throw new Error("sign: Invalid signature produced")}async calc(){const{m:e,d:r,px:u,rand:E}=this,U=i.utils.taggedHash,M=this.initNonce(r,await U(Ne.aux,E)),{R:H,rx:J,k:Q}=this.finalizeNonce(await U(Ne.nonce,M,u,e)),ee=We(await U(Ne.challenge,J,u,e)),ne=this.finalizeSig(H,Q,ee,r);return await ot(ne,e,u)||this.error(),ne}calcSync(){const{m:e,d:r,px:u,rand:E}=this,U=i.utils.taggedHashSync,M=this.initNonce(r,U(Ne.aux,E)),{R:H,rx:J,k:Q}=this.finalizeNonce(U(Ne.nonce,M,u,e)),ee=We(U(Ne.challenge,J,u,e)),ne=this.finalizeSig(H,Q,ee,r);return it(ne,e,u)||this.error(),ne}}async function dt(n,e,r){return new rt(n,e,r).calc()}function je(n,e,r){return new rt(n,e,r).calcSync()}function De(n,e,r){const u=n instanceof Le,E=u?n:Le.fromHex(n);return u&&E.assertValidity(),{...E,m:$(e),P:Pe(r)}}function nt(n,e,r,u){const E=G.BASE.multiplyAndAddUnsafe(e,xe(r),p(-u,d.n));return!(!E||!E.hasEvenY()||E.x!==n)}async function ot(n,e,r){try{const{r:u,s:E,m:U,P:M}=De(n,e,r),H=We(await i.utils.taggedHash(Ne.challenge,te(u),M.toRawX(),U));return nt(u,M,E,H)}catch{return!1}}function it(n,e,r){try{const{r:u,s:E,m:U,P:M}=De(n,e,r),H=We(i.utils.taggedHashSync(Ne.challenge,te(u),M.toRawX(),U));return nt(u,M,E,H)}catch(u){if(u instanceof v)throw u;return!1}}i.schnorr={Signature:Le,getPublicKey:ht,sign:dt,verify:ot,signSync:je,verifySync:it},G.BASE._setWindowSize(8);const Be={node:k,web:typeof self=="object"&&"crypto"in self?self.crypto:void 0},Ne={challenge:"BIP0340/challenge",aux:"BIP0340/aux",nonce:"BIP0340/nonce"},Ze={};i.utils={bytesToHex:z,hexToBytes:B,concatBytes:de,mod:p,invert:Ae,isValidPrivateKey(n){try{return xe(n),!0}catch{return!1}},_bigintTo32Bytes:te,_normalizePrivateKey:xe,hashToPrivateKey:n=>{n=$(n);const e=w+8;if(n.length<e||n.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");const r=p(R(n),d.n-S)+S;return te(r)},randomBytes:(n=32)=>{if(Be.web)return Be.web.getRandomValues(new Uint8Array(n));if(Be.node){const{randomBytes:e}=Be.node;return Uint8Array.from(e(n))}else throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>i.utils.hashToPrivateKey(i.utils.randomBytes(w+8)),precompute(n=8,e=G.BASE){const r=e===G.BASE?e:new G(e.x,e.y);return r._setWindowSize(n),r.multiply(b),r},sha256:async(...n)=>{if(Be.web){const e=await Be.web.subtle.digest("SHA-256",de(...n));return new Uint8Array(e)}else if(Be.node){const{createHash:e}=Be.node,r=e("sha256");return n.forEach(u=>r.update(u)),Uint8Array.from(r.digest())}else throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(n,...e)=>{if(Be.web){const r=await Be.web.subtle.importKey("raw",n,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),u=de(...e),E=await Be.web.subtle.sign("HMAC",r,u);return new Uint8Array(E)}else if(Be.node){const{createHmac:r}=Be.node,u=r("sha256",n);return e.forEach(E=>u.update(E)),Uint8Array.from(u.digest())}else throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(n,...e)=>{let r=Ze[n];if(r===void 0){const u=await i.utils.sha256(Uint8Array.from(n,E=>E.charCodeAt(0)));r=de(u,u),Ze[n]=r}return i.utils.sha256(r,...e)},taggedHashSync:(n,...e)=>{if(typeof le!="function")throw new v("sha256Sync is undefined, you need to set it");let r=Ze[n];if(r===void 0){const u=le(Uint8Array.from(n,E=>E.charCodeAt(0)));r=de(u,u),Ze[n]=r}return le(r,...e)},_JacobianPoint:x},Object.defineProperties(i.utils,{sha256Sync:{configurable:!1,get(){return le},set(n){le||(le=n)}},hmacSha256Sync:{configurable:!1,get(){return f},set(n){f||(f=n)}}})},63203:function(ae,i){"use strict";/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(i,"__esModule",{value:!0}),i.bytes=i.stringToBytes=i.str=i.bytesToString=i.hex=i.utf8=i.bech32m=i.bech32=i.base58check=i.createBase58check=i.base58xmr=i.base58xrp=i.base58flickr=i.base58=i.base64urlnopad=i.base64url=i.base64nopad=i.base64=i.base32crockford=i.base32hexnopad=i.base32hex=i.base32nopad=i.base32=i.base16=i.utils=i.assertNumber=void 0;function C(m){return m instanceof Uint8Array||ArrayBuffer.isView(m)&&m.constructor.name==="Uint8Array"}function k(m,B){return Array.isArray(B)?B.length===0?!0:m?B.every(R=>typeof R=="string"):B.every(R=>Number.isSafeInteger(R)):!1}function h(m){if(typeof m!="function")throw new Error("function expected");return!0}function S(m,B){if(typeof B!="string")throw new Error(`${m}: string expected`);return!0}function I(m){if(!Number.isSafeInteger(m))throw new Error(`invalid integer: ${m}`)}i.assertNumber=I;function b(m){if(!Array.isArray(m))throw new Error("array expected")}function s(m,B){if(!k(!0,B))throw new Error(`${m}: array of strings expected`)}function d(m,B){if(!k(!1,B))throw new Error(`${m}: array of numbers expected`)}function l(...m){const B=p=>p,R=(p,oe)=>we=>p(oe(we)),$=m.map(p=>p.encode).reduceRight(R,B),q=m.map(p=>p.decode).reduce(R,B);return{encode:$,decode:q}}function o(m){const B=typeof m=="string"?m.split(""):m,R=B.length;s("alphabet",B);const $=new Map(B.map((q,p)=>[q,p]));return{encode:q=>(b(q),q.map(p=>{if(!Number.isSafeInteger(p)||p<0||p>=R)throw new Error(`alphabet.encode: digit index outside alphabet "${p}". Allowed: ${m}`);return B[p]})),decode:q=>(b(q),q.map(p=>{S("alphabet.decode",p);const oe=$.get(p);if(oe===void 0)throw new Error(`Unknown letter: "${p}". Allowed: ${m}`);return oe}))}}function g(m=""){return S("join",m),{encode:B=>(s("join.decode",B),B.join(m)),decode:B=>(S("join.decode",B),B.split(m))}}function w(m,B="="){return I(m),S("padding",B),{encode(R){for(s("padding.encode",R);R.length*m%8;)R.push(B);return R},decode(R){s("padding.decode",R);let $=R.length;if($*m%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;$>0&&R[$-1]===B;$--)if(($-1)*m%8===0)throw new Error("padding: invalid, string has too much padding");return R.slice(0,$)}}}function L(m){return h(m),{encode:B=>B,decode:B=>m(B)}}function D(m,B,R){if(B<2)throw new Error(`convertRadix: invalid from=${B}, base cannot be less than 2`);if(R<2)throw new Error(`convertRadix: invalid to=${R}, base cannot be less than 2`);if(b(m),!m.length)return[];let $=0;const q=[],p=Array.from(m,we=>{if(I(we),we<0||we>=B)throw new Error(`invalid integer: ${we}`);return we}),oe=p.length;for(;;){let we=0,Ae=!0;for(let Se=$;Se<oe;Se++){const Te=p[Se],be=B*we,le=be+Te;if(!Number.isSafeInteger(le)||be/B!==we||le-Te!==be)throw new Error("convertRadix: carry overflow");const f=le/R;we=le%R;const T=Math.floor(f);if(p[Se]=T,!Number.isSafeInteger(T)||T*R+we!==le)throw new Error("convertRadix: carry overflow");if(Ae)T?Ae=!1:$=Se;else continue}if(q.push(we),Ae)break}for(let we=0;we<m.length-1&&m[we]===0;we++)q.push(0);return q.reverse()}const Z=(m,B)=>B===0?m:Z(B,m%B),N=(m,B)=>m+(B-Z(m,B)),F=(()=>{let m=[];for(let B=0;B<40;B++)m.push(2**B);return m})();function v(m,B,R,$){if(b(m),B<=0||B>32)throw new Error(`convertRadix2: wrong from=${B}`);if(R<=0||R>32)throw new Error(`convertRadix2: wrong to=${R}`);if(N(B,R)>32)throw new Error(`convertRadix2: carry overflow from=${B} to=${R} carryBits=${N(B,R)}`);let q=0,p=0;const oe=F[B],we=F[R]-1,Ae=[];for(const Se of m){if(I(Se),Se>=oe)throw new Error(`convertRadix2: invalid data word=${Se} from=${B}`);if(q=q<<B|Se,p+B>32)throw new Error(`convertRadix2: carry overflow pos=${p} from=${B}`);for(p+=B;p>=R;p-=R)Ae.push((q>>p-R&we)>>>0);const Te=F[p];if(Te===void 0)throw new Error("invalid carry");q&=Te-1}if(q=q<<R-p&we,!$&&p>=B)throw new Error("Excess padding");if(!$&&q>0)throw new Error(`Non-zero padding: ${q}`);return $&&p>0&&Ae.push(q>>>0),Ae}function A(m){I(m);const B=2**8;return{encode:R=>{if(!C(R))throw new Error("radix.encode input should be Uint8Array");return D(Array.from(R),B,m)},decode:R=>(d("radix.decode",R),Uint8Array.from(D(R,m,B)))}}function x(m,B=!1){if(I(m),m<=0||m>32)throw new Error("radix2: bits should be in (0..32]");if(N(8,m)>32||N(m,8)>32)throw new Error("radix2: carry overflow");return{encode:R=>{if(!C(R))throw new Error("radix2.encode input should be Uint8Array");return v(Array.from(R),8,m,!B)},decode:R=>(d("radix2.decode",R),Uint8Array.from(v(R,m,8,B)))}}function K(m){return h(m),function(...B){try{return m.apply(null,B)}catch{}}}function X(m,B){return I(m),h(B),{encode(R){if(!C(R))throw new Error("checksum.encode: input should be Uint8Array");const $=B(R).slice(0,m),q=new Uint8Array(R.length+m);return q.set(R),q.set($,R.length),q},decode(R){if(!C(R))throw new Error("checksum.decode: input should be Uint8Array");const $=R.slice(0,-m),q=R.slice(-m),p=B($).slice(0,m);for(let oe=0;oe<m;oe++)if(p[oe]!==q[oe])throw new Error("Invalid checksum");return $}}}i.utils={alphabet:o,chain:l,checksum:X,convertRadix:D,convertRadix2:v,radix:A,radix2:x,join:g,padding:w},i.base16=l(x(4),o("0123456789ABCDEF"),g("")),i.base32=l(x(5),o("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),w(5),g("")),i.base32nopad=l(x(5),o("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),g("")),i.base32hex=l(x(5),o("0123456789ABCDEFGHIJKLMNOPQRSTUV"),w(5),g("")),i.base32hexnopad=l(x(5),o("0123456789ABCDEFGHIJKLMNOPQRSTUV"),g("")),i.base32crockford=l(x(5),o("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),g(""),L(m=>m.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1"))),i.base64=l(x(6),o("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),w(6),g("")),i.base64nopad=l(x(6),o("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),g("")),i.base64url=l(x(6),o("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),w(6),g("")),i.base64urlnopad=l(x(6),o("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),g(""));const G=m=>l(A(58),o(m),g(""));i.base58=G("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),i.base58flickr=G("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),i.base58xrp=G("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const _=[0,2,3,5,6,7,9,10,11];i.base58xmr={encode(m){let B="";for(let R=0;R<m.length;R+=8){const $=m.subarray(R,R+8);B+=i.base58.encode($).padStart(_[$.length],"1")}return B},decode(m){let B=[];for(let R=0;R<m.length;R+=11){const $=m.slice(R,R+11),q=_.indexOf($.length),p=i.base58.decode($);for(let oe=0;oe<p.length-q;oe++)if(p[oe]!==0)throw new Error("base58xmr: wrong padding");B=B.concat(Array.from(p.slice(p.length-q)))}return Uint8Array.from(B)}};const Ee=m=>l(X(4,B=>m(m(B))),i.base58);i.createBase58check=Ee,i.base58check=i.createBase58check;const ve=l(o("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),g("")),fe=[996825010,642813549,513874426,1027748829,705979059];function de(m){const B=m>>25;let R=(m&33554431)<<5;for(let $=0;$<fe.length;$++)(B>>$&1)===1&&(R^=fe[$]);return R}function V(m,B,R=1){const $=m.length;let q=1;for(let p=0;p<$;p++){const oe=m.charCodeAt(p);if(oe<33||oe>126)throw new Error(`Invalid prefix (${m})`);q=de(q)^oe>>5}q=de(q);for(let p=0;p<$;p++)q=de(q)^m.charCodeAt(p)&31;for(let p of B)q=de(q)^p;for(let p=0;p<6;p++)q=de(q);return q^=R,ve.encode(v([q%F[30]],30,5,!1))}function z(m){const B=m==="bech32"?1:734539939,R=x(5),$=R.decode,q=R.encode,p=K($);function oe(be,le,f=90){S("bech32.encode prefix",be),C(le)&&(le=Array.from(le)),d("bech32.encode",le);const T=be.length;if(T===0)throw new TypeError(`Invalid prefix length ${T}`);const Y=T+7+le.length;if(f!==!1&&Y>f)throw new TypeError(`Length ${Y} exceeds limit ${f}`);const ue=be.toLowerCase(),ye=V(ue,le,B);return`${ue}1${ve.encode(le)}${ye}`}function we(be,le=90){S("bech32.decode input",be);const f=be.length;if(f<8||le!==!1&&f>le)throw new TypeError(`invalid string length: ${f} (${be}). Expected (8..${le})`);const T=be.toLowerCase();if(be!==T&&be!==be.toUpperCase())throw new Error("String must be lowercase or uppercase");const Y=T.lastIndexOf("1");if(Y===0||Y===-1)throw new Error('Letter "1" must be present between prefix and data only');const ue=T.slice(0,Y),ye=T.slice(Y+1);if(ye.length<6)throw new Error("Data must be at least 6 characters long");const xe=ve.decode(ye).slice(0,-6),Pe=V(ue,xe,B);if(!ye.endsWith(Pe))throw new Error(`Invalid checksum in ${be}: expected "${Pe}"`);return{prefix:ue,words:xe}}const Ae=K(we);function Se(be){const{prefix:le,words:f}=we(be,!1);return{prefix:le,words:f,bytes:$(f)}}function Te(be,le){return oe(be,q(le))}return{encode:oe,decode:we,encodeFromBytes:Te,decodeToBytes:Se,decodeUnsafe:Ae,fromWords:$,fromWordsUnsafe:p,toWords:q}}i.bech32=z("bech32"),i.bech32m=z("bech32m"),i.utf8={encode:m=>new TextDecoder().decode(m),decode:m=>new TextEncoder().encode(m)},i.hex=l(x(4),o("0123456789abcdef"),g(""),L(m=>{if(typeof m!="string"||m.length%2!==0)throw new TypeError(`hex.decode: expected string, got ${typeof m} with length ${m.length}`);return m.toLowerCase()}));const j={utf8:i.utf8,hex:i.hex,base16:i.base16,base32:i.base32,base64:i.base64,base64url:i.base64url,base58:i.base58,base58xmr:i.base58xmr},W="Invalid encoding type. Available types: utf8, hex, base16, base32, base64, base64url, base58, base58xmr",te=(m,B)=>{if(typeof m!="string"||!j.hasOwnProperty(m))throw new TypeError(W);if(!C(B))throw new TypeError("bytesToString() expects Uint8Array");return j[m].encode(B)};i.bytesToString=te,i.str=i.bytesToString;const se=(m,B)=>{if(!j.hasOwnProperty(m))throw new TypeError(W);if(typeof B!="string")throw new TypeError("stringToBytes() expects string");return j[m].decode(B)};i.stringToBytes=se,i.bytes=i.stringToBytes},11206:function(ae,i,C){"use strict";var k=C(48287).Buffer;Object.defineProperty(i,"__esModule",{value:!0}),i.BIP32Factory=void 0;const h=C(25311),S=C(87569),I=C(63203),b=C(22623),s=C(8676),d=C(57513),l=(0,I.base58check)(b.sha256),o={encode:w=>l.encode(Uint8Array.from(w)),decode:w=>k.from(l.decode(w))};function g(w){(0,S.testEcc)(w);const L=s.BufferN(32),D=s.compile({wif:s.UInt8,bip32:{public:s.UInt32,private:s.UInt32}}),Z={messagePrefix:`Bitcoin Signed Message:
|
|
2
|
+
`,bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},N=2147483648,F=Math.pow(2,31)-1;function v(V){return s.String(V)&&V.match(/^(m\/)?(\d+'?\/)*\d+'?$/)!==null}function A(V){return s.UInt32(V)&&V<=F}function x(V){return V.length===32?V:V.slice(1,33)}class K{constructor(z,j){this.__D=z,this.__Q=j,this.lowR=!1}get publicKey(){return this.__Q===void 0&&(this.__Q=k.from(w.pointFromScalar(this.__D,!0))),this.__Q}get privateKey(){return this.__D}sign(z,j){if(!this.privateKey)throw new Error("Missing private key");if(j===void 0&&(j=this.lowR),j===!1)return k.from(w.sign(z,this.privateKey));{let W=k.from(w.sign(z,this.privateKey));const te=k.alloc(32,0);let se=0;for(;W[0]>127;)se++,te.writeUIntLE(se,0,6),W=k.from(w.sign(z,this.privateKey,te));return W}}signSchnorr(z){if(!this.privateKey)throw new Error("Missing private key");if(!w.signSchnorr)throw new Error("signSchnorr not supported by ecc library");return k.from(w.signSchnorr(z,this.privateKey))}verify(z,j){return w.verify(z,this.publicKey,j)}verifySchnorr(z,j){if(!w.verifySchnorr)throw new Error("verifySchnorr not supported by ecc library");return w.verifySchnorr(z,this.publicKey.subarray(1,33),j)}}class X extends K{constructor(z,j,W,te,se=0,m=0,B=0){super(z,j),this.chainCode=W,this.network=te,this.__DEPTH=se,this.__INDEX=m,this.__PARENT_FINGERPRINT=B,s(D,te)}get depth(){return this.__DEPTH}get index(){return this.__INDEX}get parentFingerprint(){return this.__PARENT_FINGERPRINT}get identifier(){return h.hash160(this.publicKey)}get fingerprint(){return this.identifier.slice(0,4)}get compressed(){return!0}isNeutered(){return this.__D===void 0}neutered(){return fe(this.publicKey,this.chainCode,this.network,this.depth,this.index,this.parentFingerprint)}toBase58(){const z=this.network,j=this.isNeutered()?z.bip32.public:z.bip32.private,W=k.allocUnsafe(78);return W.writeUInt32BE(j,0),W.writeUInt8(this.depth,4),W.writeUInt32BE(this.parentFingerprint,5),W.writeUInt32BE(this.index,9),this.chainCode.copy(W,13),this.isNeutered()?this.publicKey.copy(W,45):(W.writeUInt8(0,45),this.privateKey.copy(W,46)),o.encode(W)}toWIF(){if(!this.privateKey)throw new TypeError("Missing private key");return d.encode(this.network.wif,this.privateKey,!0)}derive(z){s(s.UInt32,z);const j=z>=N,W=k.allocUnsafe(37);if(j){if(this.isNeutered())throw new TypeError("Missing private key for hardened child key");W[0]=0,this.privateKey.copy(W,1),W.writeUInt32BE(z,33)}else this.publicKey.copy(W,0),W.writeUInt32BE(z,33);const te=h.hmacSHA512(this.chainCode,W),se=te.slice(0,32),m=te.slice(32);if(!w.isPrivate(se))return this.derive(z+1);let B;if(this.isNeutered()){const R=k.from(w.pointAddScalar(this.publicKey,se,!0));if(R===null)return this.derive(z+1);B=fe(R,m,this.network,this.depth+1,z,this.fingerprint.readUInt32BE(0))}else{const R=k.from(w.privateAdd(this.privateKey,se));if(R==null)return this.derive(z+1);B=Ee(R,m,this.network,this.depth+1,z,this.fingerprint.readUInt32BE(0))}return B}deriveHardened(z){return s(A,z),this.derive(z+N)}derivePath(z){s(v,z);let j=z.split("/");if(j[0]==="m"){if(this.parentFingerprint)throw new TypeError("Expected master, got child");j=j.slice(1)}return j.reduce((W,te)=>{let se;return te.slice(-1)==="'"?(se=parseInt(te.slice(0,-1),10),W.deriveHardened(se)):(se=parseInt(te,10),W.derive(se))},this)}tweak(z){return this.privateKey?this.tweakFromPrivateKey(z):this.tweakFromPublicKey(z)}tweakFromPublicKey(z){const j=x(this.publicKey);if(!w.xOnlyPointAddTweak)throw new Error("xOnlyPointAddTweak not supported by ecc library");const W=w.xOnlyPointAddTweak(j,z);if(!W||W.xOnlyPubkey===null)throw new Error("Cannot tweak public key!");const te=k.from([W.parity===0?2:3]),se=k.concat([te,W.xOnlyPubkey]);return new K(void 0,se)}tweakFromPrivateKey(z){const j=this.publicKey[0]===3||this.publicKey[0]===4&&(this.publicKey[64]&1)===1,W=(()=>{if(j){if(w.privateNegate)return w.privateNegate(this.privateKey);throw new Error("privateNegate not supported by ecc library")}else return this.privateKey})(),te=w.privateAdd(W,z);if(!te)throw new Error("Invalid tweaked private key!");return new K(k.from(te),void 0)}}function G(V,z){const j=o.decode(V);if(j.length!==78)throw new TypeError("Invalid buffer length");z=z||Z;const W=j.readUInt32BE(0);if(W!==z.bip32.private&&W!==z.bip32.public)throw new TypeError("Invalid network version");const te=j[4],se=j.readUInt32BE(5);if(te===0&&se!==0)throw new TypeError("Invalid parent fingerprint");const m=j.readUInt32BE(9);if(te===0&&m!==0)throw new TypeError("Invalid index");const B=j.slice(13,45);let R;if(W===z.bip32.private){if(j.readUInt8(45)!==0)throw new TypeError("Invalid private key");const $=j.slice(46,78);R=Ee($,B,z,te,m,se)}else{const $=j.slice(45,78);R=fe($,B,z,te,m,se)}return R}function _(V,z,j){return Ee(V,z,j)}function Ee(V,z,j,W,te,se){if(s({privateKey:L,chainCode:L},{privateKey:V,chainCode:z}),j=j||Z,!w.isPrivate(V))throw new TypeError("Private key not in range [1, n)");return new X(V,void 0,z,j,W,te,se)}function ve(V,z,j){return fe(V,z,j)}function fe(V,z,j,W,te,se){if(s({publicKey:s.BufferN(33),chainCode:L},{publicKey:V,chainCode:z}),j=j||Z,!w.isPoint(V))throw new TypeError("Point is not on the curve");return new X(void 0,V,z,j,W,te,se)}function de(V,z){if(s(s.Buffer,V),V.length<16)throw new TypeError("Seed should be at least 128 bits");if(V.length>64)throw new TypeError("Seed should be at most 512 bits");z=z||Z;const j=h.hmacSHA512(k.from("Bitcoin seed","utf8"),V),W=j.slice(0,32),te=j.slice(32);return _(W,te,z)}return{fromSeed:de,fromBase58:G,fromPublicKey:ve,fromPrivateKey:_}}i.BIP32Factory=g},25311:function(ae,i,C){"use strict";var k=C(48287).Buffer;Object.defineProperty(i,"__esModule",{value:!0}),i.hmacSHA512=i.hash160=void 0;const h=C(39615),S=C(93238),I=C(22623),b=C(30102);function s(l){const o=(0,I.sha256)(Uint8Array.from(l));return k.from((0,S.ripemd160)(o))}i.hash160=s;function d(l,o){return k.from((0,h.hmac)(b.sha512,l,o))}i.hmacSHA512=d},83328:function(ae,i,C){"use strict";var k;k={value:!0},i.Pr=k=void 0;var h=C(11206);k={enumerable:!0,get:function(){return h.BIP32Factory}},Object.defineProperty(i,"Pr",{enumerable:!0,get:function(){return h.BIP32Factory}})},87569:function(ae,i,C){"use strict";var k=C(48287).Buffer;Object.defineProperty(i,"__esModule",{value:!0}),i.testEcc=void 0;const h=b=>k.from(b,"hex");function S(b){if(I(b.isPoint(h("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),I(!b.isPoint(h("030000000000000000000000000000000000000000000000000000000000000005"))),I(b.isPrivate(h("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),I(b.isPrivate(h("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),I(!b.isPrivate(h("0000000000000000000000000000000000000000000000000000000000000000"))),I(!b.isPrivate(h("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"))),I(!b.isPrivate(h("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142"))),I(k.from(b.pointFromScalar(h("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(h("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99"))),b.xOnlyPointAddTweak){I(b.xOnlyPointAddTweak(h("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),h("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))===null);let s=b.xOnlyPointAddTweak(h("1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b"),h("a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac"));I(k.from(s.xOnlyPubkey).equals(h("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"))&&s.parity===1),s=b.xOnlyPointAddTweak(h("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"),h("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47"))}I(k.from(b.pointAddScalar(h("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),h("0000000000000000000000000000000000000000000000000000000000000003"))).equals(h("02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5"))),I(k.from(b.privateAdd(h("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"),h("0000000000000000000000000000000000000000000000000000000000000002"))).equals(h("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),b.privateNegate&&(I(k.from(b.privateNegate(h("0000000000000000000000000000000000000000000000000000000000000001"))).equals(h("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),I(k.from(b.privateNegate(h("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"))).equals(h("0000000000000000000000000000000000000000000000000000000000000003"))),I(k.from(b.privateNegate(h("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(h("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792")))),I(k.from(b.sign(h("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),h("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))).equals(h("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),I(b.verify(h("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),h("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),h("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),b.signSchnorr&&I(k.from(b.signSchnorr(h("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),h("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"),h("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906"))).equals(h("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7"))),b.verifySchnorr&&I(b.verifySchnorr(h("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),h("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"),h("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")))}i.testEcc=S;function I(b){if(!b)throw new Error("ecc library invalid")}},17009:function(ae,i,C){ae.exports=C(27655)(C(59393))},59393:function(ae,i,C){const k=C(86729).ec,h=new k("secp256k1"),S=h.curve,I=S.n.constructor;function b(o,g){let w=new I(g);if(w.cmp(S.p)>=0)return null;w=w.toRed(S.red);let L=w.redSqr().redIMul(w).redIAdd(S.b).redSqrt();return o===3!==L.isOdd()&&(L=L.redNeg()),h.keyPair({pub:{x:w,y:L}})}function s(o,g,w){let L=new I(g),D=new I(w);if(L.cmp(S.p)>=0||D.cmp(S.p)>=0||(L=L.toRed(S.red),D=D.toRed(S.red),(o===6||o===7)&&D.isOdd()!==(o===7)))return null;const Z=L.redSqr().redIMul(L);return D.redSqr().redISub(Z.redIAdd(S.b)).isZero()?h.keyPair({pub:{x:L,y:D}}):null}function d(o){const g=o[0];switch(g){case 2:case 3:return o.length!==33?null:b(g,o.subarray(1,33));case 4:case 6:case 7:return o.length!==65?null:s(g,o.subarray(1,33),o.subarray(33,65));default:return null}}function l(o,g){const w=g.encode(null,o.length===33);for(let L=0;L<o.length;++L)o[L]=w[L]}ae.exports={contextRandomize(){return 0},privateKeyVerify(o){const g=new I(o);return g.cmp(S.n)<0&&!g.isZero()?0:1},privateKeyNegate(o){const g=new I(o),w=S.n.sub(g).umod(S.n).toArrayLike(Uint8Array,"be",32);return o.set(w),0},privateKeyTweakAdd(o,g){const w=new I(g);if(w.cmp(S.n)>=0||(w.iadd(new I(o)),w.cmp(S.n)>=0&&w.isub(S.n),w.isZero()))return 1;const L=w.toArrayLike(Uint8Array,"be",32);return o.set(L),0},privateKeyTweakMul(o,g){let w=new I(g);if(w.cmp(S.n)>=0||w.isZero())return 1;w.imul(new I(o)),w.cmp(S.n)>=0&&(w=w.umod(S.n));const L=w.toArrayLike(Uint8Array,"be",32);return o.set(L),0},publicKeyVerify(o){return d(o)===null?1:0},publicKeyCreate(o,g){const w=new I(g);if(w.cmp(S.n)>=0||w.isZero())return 1;const L=h.keyFromPrivate(g).getPublic();return l(o,L),0},publicKeyConvert(o,g){const w=d(g);if(w===null)return 1;const L=w.getPublic();return l(o,L),0},publicKeyNegate(o,g){const w=d(g);if(w===null)return 1;const L=w.getPublic();return L.y=L.y.redNeg(),l(o,L),0},publicKeyCombine(o,g){const w=new Array(g.length);for(let D=0;D<g.length;++D)if(w[D]=d(g[D]),w[D]===null)return 1;let L=w[0].getPublic();for(let D=1;D<w.length;++D)L=L.add(w[D].pub);return L.isInfinity()?2:(l(o,L),0)},publicKeyTweakAdd(o,g,w){const L=d(g);if(L===null)return 1;if(w=new I(w),w.cmp(S.n)>=0)return 2;const D=L.getPublic().add(S.g.mul(w));return D.isInfinity()?2:(l(o,D),0)},publicKeyTweakMul(o,g,w){const L=d(g);if(L===null)return 1;if(w=new I(w),w.cmp(S.n)>=0||w.isZero())return 2;const D=L.getPublic().mul(w);return l(o,D),0},signatureNormalize(o){const g=new I(o.subarray(0,32)),w=new I(o.subarray(32,64));return g.cmp(S.n)>=0||w.cmp(S.n)>=0?1:(w.cmp(h.nh)===1&&o.set(S.n.sub(w).toArrayLike(Uint8Array,"be",32),32),0)},signatureExport(o,g){const w=g.subarray(0,32),L=g.subarray(32,64);if(new I(w).cmp(S.n)>=0||new I(L).cmp(S.n)>=0)return 1;const{output:D}=o;let Z=D.subarray(4,4+33);Z[0]=0,Z.set(w,1);let N=33,F=0;for(;N>1&&Z[F]===0&&!(Z[F+1]&128);--N,++F);if(Z=Z.subarray(F),Z[0]&128||N>1&&Z[0]===0&&!(Z[1]&128))return 1;let v=D.subarray(6+33,6+33+33);v[0]=0,v.set(L,1);let A=33,x=0;for(;A>1&&v[x]===0&&!(v[x+1]&128);--A,++x);return v=v.subarray(x),v[0]&128||A>1&&v[0]===0&&!(v[1]&128)?1:(o.outputlen=6+N+A,D[0]=48,D[1]=o.outputlen-2,D[2]=2,D[3]=Z.length,D.set(Z,4),D[4+N]=2,D[5+N]=v.length,D.set(v,6+N),0)},signatureImport(o,g){if(g.length<8||g.length>72||g[0]!==48||g[1]!==g.length-2||g[2]!==2)return 1;const w=g[3];if(w===0||5+w>=g.length||g[4+w]!==2)return 1;const L=g[5+w];if(L===0||6+w+L!==g.length||g[4]&128||w>1&&g[4]===0&&!(g[5]&128)||g[w+6]&128||L>1&&g[w+6]===0&&!(g[w+7]&128))return 1;let D=g.subarray(4,4+w);if(D.length===33&&D[0]===0&&(D=D.subarray(1)),D.length>32)return 1;let Z=g.subarray(6+w);if(Z.length===33&&Z[0]===0&&(Z=Z.slice(1)),Z.length>32)throw new Error("S length is too long");let N=new I(D);N.cmp(S.n)>=0&&(N=new I(0));let F=new I(g.subarray(6+w));return F.cmp(S.n)>=0&&(F=new I(0)),o.set(N.toArrayLike(Uint8Array,"be",32),0),o.set(F.toArrayLike(Uint8Array,"be",32),32),0},ecdsaSign(o,g,w,L,D){if(D){const F=D;D=v=>{const A=F(g,w,null,L,v);if(!(A instanceof Uint8Array&&A.length===32))throw new Error("This is the way");return new I(A)}}const Z=new I(w);if(Z.cmp(S.n)>=0||Z.isZero())return 1;let N;try{N=h.sign(g,w,{canonical:!0,k:D,pers:L})}catch{return 1}return o.signature.set(N.r.toArrayLike(Uint8Array,"be",32),0),o.signature.set(N.s.toArrayLike(Uint8Array,"be",32),32),o.recid=N.recoveryParam,0},ecdsaVerify(o,g,w){const L={r:o.subarray(0,32),s:o.subarray(32,64)},D=new I(L.r),Z=new I(L.s);if(D.cmp(S.n)>=0||Z.cmp(S.n)>=0)return 1;if(Z.cmp(h.nh)===1||D.isZero()||Z.isZero())return 3;const N=d(w);if(N===null)return 2;const F=N.getPublic();return h.verify(g,L,F)?0:3},ecdsaRecover(o,g,w,L){const D={r:g.slice(0,32),s:g.slice(32,64)},Z=new I(D.r),N=new I(D.s);if(Z.cmp(S.n)>=0||N.cmp(S.n)>=0)return 1;if(Z.isZero()||N.isZero())return 2;let F;try{F=h.recoverPubKey(L,D,w)}catch{return 2}return l(o,F),0},ecdh(o,g,w,L,D,Z,N){const F=d(g);if(F===null)return 1;const v=new I(w);if(v.cmp(S.n)>=0||v.isZero())return 2;const A=F.getPublic().mul(v);if(D===void 0){const x=A.encode(null,!0),K=h.hash().update(x).digest();for(let X=0;X<32;++X)o[X]=K[X]}else{Z||(Z=new Uint8Array(32));const x=A.getX().toArray("be",32);for(let _=0;_<32;++_)Z[_]=x[_];N||(N=new Uint8Array(32));const K=A.getY().toArray("be",32);for(let _=0;_<32;++_)N[_]=K[_];const X=D(Z,N,L);if(!(X instanceof Uint8Array&&X.length===o.length))return 2;o.set(X)}return 0}}},27655:function(ae){const i={IMPOSSIBLE_CASE:"Impossible case. Please create issue.",TWEAK_ADD:"The tweak was out of range or the resulted private key is invalid",TWEAK_MUL:"The tweak was out of range or equal to zero",CONTEXT_RANDOMIZE_UNKNOW:"Unknow error on context randomization",SECKEY_INVALID:"Private Key is invalid",PUBKEY_PARSE:"Public Key could not be parsed",PUBKEY_SERIALIZE:"Public Key serialization error",PUBKEY_COMBINE:"The sum of the public keys is not valid",SIG_PARSE:"Signature could not be parsed",SIGN:"The nonce generation function failed, or the private key was invalid",RECOVER:"Public key could not be recover",ECDH:"Scalar was invalid (zero or overflow)"};function C(b,s){if(!b)throw new Error(s)}function k(b,s,d){if(C(s instanceof Uint8Array,`Expected ${b} to be an Uint8Array`),d!==void 0)if(Array.isArray(d)){const l=d.join(", "),o=`Expected ${b} to be an Uint8Array with length [${l}]`;C(d.includes(s.length),o)}else{const l=`Expected ${b} to be an Uint8Array with length ${d}`;C(s.length===d,l)}}function h(b){C(I(b)==="Boolean","Expected compressed to be a Boolean")}function S(b=d=>new Uint8Array(d),s){return typeof b=="function"&&(b=b(s)),k("output",b,s),b}function I(b){return Object.prototype.toString.call(b).slice(8,-1)}ae.exports=b=>({contextRandomize(s){switch(C(s===null||s instanceof Uint8Array,"Expected seed to be an Uint8Array or null"),s!==null&&k("seed",s,32),b.contextRandomize(s)){case 1:throw new Error(i.CONTEXT_RANDOMIZE_UNKNOW)}},privateKeyVerify(s){return k("private key",s,32),b.privateKeyVerify(s)===0},privateKeyNegate(s){switch(k("private key",s,32),b.privateKeyNegate(s)){case 0:return s;case 1:throw new Error(i.IMPOSSIBLE_CASE)}},privateKeyTweakAdd(s,d){switch(k("private key",s,32),k("tweak",d,32),b.privateKeyTweakAdd(s,d)){case 0:return s;case 1:throw new Error(i.TWEAK_ADD)}},privateKeyTweakMul(s,d){switch(k("private key",s,32),k("tweak",d,32),b.privateKeyTweakMul(s,d)){case 0:return s;case 1:throw new Error(i.TWEAK_MUL)}},publicKeyVerify(s){return k("public key",s,[33,65]),b.publicKeyVerify(s)===0},publicKeyCreate(s,d=!0,l){switch(k("private key",s,32),h(d),l=S(l,d?33:65),b.publicKeyCreate(l,s)){case 0:return l;case 1:throw new Error(i.SECKEY_INVALID);case 2:throw new Error(i.PUBKEY_SERIALIZE)}},publicKeyConvert(s,d=!0,l){switch(k("public key",s,[33,65]),h(d),l=S(l,d?33:65),b.publicKeyConvert(l,s)){case 0:return l;case 1:throw new Error(i.PUBKEY_PARSE);case 2:throw new Error(i.PUBKEY_SERIALIZE)}},publicKeyNegate(s,d=!0,l){switch(k("public key",s,[33,65]),h(d),l=S(l,d?33:65),b.publicKeyNegate(l,s)){case 0:return l;case 1:throw new Error(i.PUBKEY_PARSE);case 2:throw new Error(i.IMPOSSIBLE_CASE);case 3:throw new Error(i.PUBKEY_SERIALIZE)}},publicKeyCombine(s,d=!0,l){C(Array.isArray(s),"Expected public keys to be an Array"),C(s.length>0,"Expected public keys array will have more than zero items");for(const o of s)k("public key",o,[33,65]);switch(h(d),l=S(l,d?33:65),b.publicKeyCombine(l,s)){case 0:return l;case 1:throw new Error(i.PUBKEY_PARSE);case 2:throw new Error(i.PUBKEY_COMBINE);case 3:throw new Error(i.PUBKEY_SERIALIZE)}},publicKeyTweakAdd(s,d,l=!0,o){switch(k("public key",s,[33,65]),k("tweak",d,32),h(l),o=S(o,l?33:65),b.publicKeyTweakAdd(o,s,d)){case 0:return o;case 1:throw new Error(i.PUBKEY_PARSE);case 2:throw new Error(i.TWEAK_ADD)}},publicKeyTweakMul(s,d,l=!0,o){switch(k("public key",s,[33,65]),k("tweak",d,32),h(l),o=S(o,l?33:65),b.publicKeyTweakMul(o,s,d)){case 0:return o;case 1:throw new Error(i.PUBKEY_PARSE);case 2:throw new Error(i.TWEAK_MUL)}},signatureNormalize(s){switch(k("signature",s,64),b.signatureNormalize(s)){case 0:return s;case 1:throw new Error(i.SIG_PARSE)}},signatureExport(s,d){k("signature",s,64),d=S(d,72);const l={output:d,outputlen:72};switch(b.signatureExport(l,s)){case 0:return d.slice(0,l.outputlen);case 1:throw new Error(i.SIG_PARSE);case 2:throw new Error(i.IMPOSSIBLE_CASE)}},signatureImport(s,d){switch(k("signature",s),d=S(d,64),b.signatureImport(d,s)){case 0:return d;case 1:throw new Error(i.SIG_PARSE);case 2:throw new Error(i.IMPOSSIBLE_CASE)}},ecdsaSign(s,d,l={},o){k("message",s,32),k("private key",d,32),C(I(l)==="Object","Expected options to be an Object"),l.data!==void 0&&k("options.data",l.data),l.noncefn!==void 0&&C(I(l.noncefn)==="Function","Expected options.noncefn to be a Function"),o=S(o,64);const g={signature:o,recid:null};switch(b.ecdsaSign(g,s,d,l.data,l.noncefn)){case 0:return g;case 1:throw new Error(i.SIGN);case 2:throw new Error(i.IMPOSSIBLE_CASE)}},ecdsaVerify(s,d,l){switch(k("signature",s,64),k("message",d,32),k("public key",l,[33,65]),b.ecdsaVerify(s,d,l)){case 0:return!0;case 3:return!1;case 1:throw new Error(i.SIG_PARSE);case 2:throw new Error(i.PUBKEY_PARSE)}},ecdsaRecover(s,d,l,o=!0,g){switch(k("signature",s,64),C(I(d)==="Number"&&d>=0&&d<=3,"Expected recovery id to be a Number within interval [0, 3]"),k("message",l,32),h(o),g=S(g,o?33:65),b.ecdsaRecover(g,s,d,l)){case 0:return g;case 1:throw new Error(i.SIG_PARSE);case 2:throw new Error(i.RECOVER);case 3:throw new Error(i.IMPOSSIBLE_CASE)}},ecdh(s,d,l={},o){switch(k("public key",s,[33,65]),k("private key",d,32),C(I(l)==="Object","Expected options to be an Object"),l.data!==void 0&&k("options.data",l.data),l.hashfn!==void 0?(C(I(l.hashfn)==="Function","Expected options.hashfn to be a Function"),l.xbuf!==void 0&&k("options.xbuf",l.xbuf,32),l.ybuf!==void 0&&k("options.ybuf",l.ybuf,32),k("output",o)):o=S(o,32),b.ecdh(o,s,d,l.data,l.hashfn,l.xbuf,l.ybuf)){case 0:return o;case 1:throw new Error(i.PUBKEY_PARSE);case 2:throw new Error(i.ECDH)}}})},14034:function(ae){var i="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",C="0123456789ABCDEFGHIJKLMNOPQRSTUV",k="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function h(S,I){var b=S.indexOf(I);if(b===-1)throw new Error("Invalid character found: "+I);return b}ae.exports=function(I,b){var s;switch(b){case"RFC3548":case"RFC4648":s=i,I=I.replace(/=+$/,"");break;case"RFC4648-HEX":s=C,I=I.replace(/=+$/,"");break;case"Crockford":s=k,I=I.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1");break;default:throw new Error("Unknown base32 variant: "+b)}for(var d=I.length,l=0,o=0,g=0,w=new Uint8Array(d*5/8|0),L=0;L<d;L++)o=o<<5|h(s,I[L]),l+=5,l>=8&&(w[g++]=o>>>l-8&255,l-=8);return w.buffer}},74156:function(ae,i,C){const k=C(20829);function h(A,x,K){const X=A[x]+A[K];let G=A[x+1]+A[K+1];X>=4294967296&&G++,A[x]=X,A[x+1]=G}function S(A,x,K,X){let G=A[x]+K;K<0&&(G+=4294967296);let _=A[x+1]+X;G>=4294967296&&_++,A[x]=G,A[x+1]=_}function I(A,x){return A[x]^A[x+1]<<8^A[x+2]<<16^A[x+3]<<24}function b(A,x,K,X,G,_){const Ee=g[G],ve=g[G+1],fe=g[_],de=g[_+1];h(o,A,x),S(o,A,Ee,ve);let V=o[X]^o[A],z=o[X+1]^o[A+1];o[X]=z,o[X+1]=V,h(o,K,X),V=o[x]^o[K],z=o[x+1]^o[K+1],o[x]=V>>>24^z<<8,o[x+1]=z>>>24^V<<8,h(o,A,x),S(o,A,fe,de),V=o[X]^o[A],z=o[X+1]^o[A+1],o[X]=V>>>16^z<<16,o[X+1]=z>>>16^V<<16,h(o,K,X),V=o[x]^o[K],z=o[x+1]^o[K+1],o[x]=z>>>31^V<<1,o[x+1]=V>>>31^z<<1}const s=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),d=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3],l=new Uint8Array(d.map(function(A){return A*2})),o=new Uint32Array(32),g=new Uint32Array(32);function w(A,x){let K=0;for(K=0;K<16;K++)o[K]=A.h[K],o[K+16]=s[K];for(o[24]=o[24]^A.t,o[25]=o[25]^A.t/4294967296,x&&(o[28]=~o[28],o[29]=~o[29]),K=0;K<32;K++)g[K]=I(A.b,4*K);for(K=0;K<12;K++)b(0,8,16,24,l[K*16+0],l[K*16+1]),b(2,10,18,26,l[K*16+2],l[K*16+3]),b(4,12,20,28,l[K*16+4],l[K*16+5]),b(6,14,22,30,l[K*16+6],l[K*16+7]),b(0,10,20,30,l[K*16+8],l[K*16+9]),b(2,12,22,24,l[K*16+10],l[K*16+11]),b(4,14,16,26,l[K*16+12],l[K*16+13]),b(6,8,18,28,l[K*16+14],l[K*16+15]);for(K=0;K<16;K++)A.h[K]=A.h[K]^o[K]^o[K+16]}const L=new Uint8Array([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]);function D(A,x,K,X){if(A===0||A>64)throw new Error("Illegal output length, expected 0 < length <= 64");if(x&&x.length>64)throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");if(K&&K.length!==16)throw new Error("Illegal salt, expected Uint8Array with length is 16");if(X&&X.length!==16)throw new Error("Illegal personal, expected Uint8Array with length is 16");const G={b:new Uint8Array(128),h:new Uint32Array(16),t:0,c:0,outlen:A};L.fill(0),L[0]=A,x&&(L[1]=x.length),L[2]=1,L[3]=1,K&&L.set(K,32),X&&L.set(X,48);for(let _=0;_<16;_++)G.h[_]=s[_]^I(L,_*4);return x&&(Z(G,x),G.c=128),G}function Z(A,x){for(let K=0;K<x.length;K++)A.c===128&&(A.t+=A.c,w(A,!1),A.c=0),A.b[A.c++]=x[K]}function N(A){for(A.t+=A.c;A.c<128;)A.b[A.c++]=0;w(A,!0);const x=new Uint8Array(A.outlen);for(let K=0;K<A.outlen;K++)x[K]=A.h[K>>2]>>8*(K&3);return x}function F(A,x,K,X,G){K=K||64,A=k.normalizeInput(A),X&&(X=k.normalizeInput(X)),G&&(G=k.normalizeInput(G));const _=D(K,x,X,G);return Z(_,A),N(_)}function v(A,x,K,X,G){const _=F(A,x,K,X,G);return k.toHex(_)}ae.exports={blake2b:F,blake2bHex:v,blake2bInit:D,blake2bUpdate:Z,blake2bFinal:N}},51843:function(ae,i,C){const k=C(20829);function h(N,F){return N[F]^N[F+1]<<8^N[F+2]<<16^N[F+3]<<24}function S(N,F,v,A,x,K){d[N]=d[N]+d[F]+x,d[A]=I(d[A]^d[N],16),d[v]=d[v]+d[A],d[F]=I(d[F]^d[v],12),d[N]=d[N]+d[F]+K,d[A]=I(d[A]^d[N],8),d[v]=d[v]+d[A],d[F]=I(d[F]^d[v],7)}function I(N,F){return N>>>F^N<<32-F}const b=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),s=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0]),d=new Uint32Array(16),l=new Uint32Array(16);function o(N,F){let v=0;for(v=0;v<8;v++)d[v]=N.h[v],d[v+8]=b[v];for(d[12]^=N.t,d[13]^=N.t/4294967296,F&&(d[14]=~d[14]),v=0;v<16;v++)l[v]=h(N.b,4*v);for(v=0;v<10;v++)S(0,4,8,12,l[s[v*16+0]],l[s[v*16+1]]),S(1,5,9,13,l[s[v*16+2]],l[s[v*16+3]]),S(2,6,10,14,l[s[v*16+4]],l[s[v*16+5]]),S(3,7,11,15,l[s[v*16+6]],l[s[v*16+7]]),S(0,5,10,15,l[s[v*16+8]],l[s[v*16+9]]),S(1,6,11,12,l[s[v*16+10]],l[s[v*16+11]]),S(2,7,8,13,l[s[v*16+12]],l[s[v*16+13]]),S(3,4,9,14,l[s[v*16+14]],l[s[v*16+15]]);for(v=0;v<8;v++)N.h[v]^=d[v]^d[v+8]}function g(N,F){if(!(N>0&&N<=32))throw new Error("Incorrect output length, should be in [1, 32]");const v=F?F.length:0;if(F&&!(v>0&&v<=32))throw new Error("Incorrect key length, should be in [1, 32]");const A={h:new Uint32Array(b),b:new Uint8Array(64),c:0,t:0,outlen:N};return A.h[0]^=16842752^v<<8^N,v>0&&(w(A,F),A.c=64),A}function w(N,F){for(let v=0;v<F.length;v++)N.c===64&&(N.t+=N.c,o(N,!1),N.c=0),N.b[N.c++]=F[v]}function L(N){for(N.t+=N.c;N.c<64;)N.b[N.c++]=0;o(N,!0);const F=new Uint8Array(N.outlen);for(let v=0;v<N.outlen;v++)F[v]=N.h[v>>2]>>8*(v&3)&255;return F}function D(N,F,v){v=v||32,N=k.normalizeInput(N);const A=g(v,F);return w(A,N),L(A)}function Z(N,F,v){const A=D(N,F,v);return k.toHex(A)}ae.exports={blake2s:D,blake2sHex:Z,blake2sInit:g,blake2sUpdate:w,blake2sFinal:L}},92493:function(ae,i,C){const k=C(74156),h=C(51843);ae.exports={blake2b:k.blake2b,blake2bHex:k.blake2bHex,blake2bInit:k.blake2bInit,blake2bUpdate:k.blake2bUpdate,blake2bFinal:k.blake2bFinal,blake2s:h.blake2s,blake2sHex:h.blake2sHex,blake2sInit:h.blake2sInit,blake2sUpdate:h.blake2sUpdate,blake2sFinal:h.blake2sFinal}},20829:function(ae){const i="Input must be an string, Buffer or Uint8Array";function C(b){let s;if(b instanceof Uint8Array)s=b;else if(typeof b=="string")s=new TextEncoder().encode(b);else throw new Error(i);return s}function k(b){return Array.prototype.map.call(b,function(s){return(s<16?"0":"")+s.toString(16)}).join("")}function h(b){return(4294967296+b).toString(16).substring(1)}function S(b,s,d){let l=`
|
|
3
|
+
`+b+" = ";for(let o=0;o<s.length;o+=2){if(d===32)l+=h(s[o]).toUpperCase(),l+=" ",l+=h(s[o+1]).toUpperCase();else if(d===64)l+=h(s[o+1]).toUpperCase(),l+=h(s[o]).toUpperCase();else throw new Error("Invalid size "+d);o%6===4?l+=`
|
|
4
|
+
`+new Array(b.length+4).join(" "):o<s.length-2&&(l+=" ")}console.log(l)}function I(b,s,d){let l=new Date().getTime();const o=new Uint8Array(s);for(let w=0;w<s;w++)o[w]=w%256;const g=new Date().getTime();console.log("Generated random input in "+(g-l)+"ms"),l=g;for(let w=0;w<d;w++){const L=b(o),D=new Date().getTime(),Z=D-l;l=D,console.log("Hashed in "+Z+"ms: "+L.substring(0,20)+"..."),console.log(Math.round(s/(1<<20)/(Z/1e3)*100)/100+" MB PER SECOND")}}ae.exports={normalizeInput:C,toHex:k,debugPrint:S,testSpeed:I}},42394:function(ae,i,C){const k=C(92861).Buffer;ae.exports=class{constructor(S=k.from([])){this.buffer=S,this._bytesRead=0,this._bytesWrote=0}read(S){this._bytesRead+=S;const I=this.buffer.slice(0,S);return this.buffer=this.buffer.slice(S),I}write(S){S=k.from(S),this._bytesWrote+=S.length,this.buffer=k.concat([this.buffer,S])}get end(){return!this.buffer.length}get bytesRead(){return this._bytesRead}get bytesWrote(){return this._bytesWrote}}},68249:function(ae,i,C){i.unsigned=C(77698),C(7905)},7905:function(ae,i,C){const k=C(39404),h=C(42394);ae.exports={encode:s,decode:d,write:b,read:S,readBn:I};function S(l){return I(l).toString()}function I(l){const o=new k(0);let g=0,w;for(;w=l.read(1)[0],o.ior(new k(w&127).shln(g)),g+=7,w>>7!==0;);return w&64&&o.setn(g),o.fromTwos(g)}function b(l,o){let g=new k(l);const w=g.isNeg();for(w&&(g=g.toTwos(g.bitLength()+8));;){const D=g.maskn(7).toNumber();if(g.ishrn(7),L(g)&&(D&64)!==0||g.isZero()&&(D&64)===0){o.write([D]);break}else o.write([D|128])}function L(D){return w&&D.toString(2).indexOf("0")<0}}function s(l){const o=new h;return b(l,o),o.buffer}function d(l){const o=new h(l);return S(o)}},77698:function(ae,i,C){const k=C(39404),h=C(42394);ae.exports={encode:s,decode:d,read:S,readBn:I,write:b};function S(l){return I(l).toString()}function I(l){const o=new k(0);let g=0,w;for(;w=l.read(1)[0],o.ior(new k(w&127).shln(g)),w>>7!==0;)g+=7;return o}function b(l,o){const g=new k(l);for(;;){const w=g.maskn(7).toNumber();if(g.ishrn(7),g.isZero()){o.write([w]);break}else o.write([w|128])}}function s(l){const o=new h;return b(l,o),o.buffer}function d(l){const o=new h(l);return S(o)}},31700:function(ae,i,C){"use strict";C.d(i,{pV:function(){return T},lg:function(){return s},X$:function(){return d},yo:function(){return Ge},to:function(){return U},D7:function(){return v},ou:function(){return Re},ZX:function(){return pe},uW:function(){return E}});var k=C(72505),h=C(39404),S;(function(a){a.ETH="10"})(S||(S={}));const I=255;var b;(function(a){a[a.ID=0]="ID",a[a.SECP256K1=1]="SECP256K1",a[a.ACTOR=2]="ACTOR",a[a.BLS=3]="BLS",a[a.DELEGATED=4]="DELEGATED"})(b||(b={}));var s;(function(a){a.Mainnet="mainnet",a.Calibration="calibration",a.Butterfly="butterfly"})(s||(s={}));var d;(function(a){a.Mainnet="f",a.Testnet="t"})(d||(d={}));const l=20,o=54,g=48,w=20,L=20,D=9,Z=new h(2).pow(new h(63)).sub(new h(1));var N;(function(a){a[a.Zero=0]="Zero"})(N||(N={}));var F;(function(a){a[a.Transfer=0]="Transfer",a[a.InvokeEVM=3844450837]="InvokeEVM"})(F||(F={}));var v;(function(a){a[a.SECP256K1=1]="SECP256K1",a[a.BLS=3]="BLS"})(v||(v={}));var A;(function(a){a[a.System=0]="System",a[a.Init=1]="Init",a[a.Reward=2]="Reward",a[a.Cron=3]="Cron",a[a.StoragePower=4]="StoragePower",a[a.StorageMarket=5]="StorageMarket",a[a.VerifiedRegistry=6]="VerifiedRegistry",a[a.DataCap=7]="DataCap",a[a.EAM=10]="EAM"})(A||(A={}));var x;(function(a){a[a.Exec=2]="Exec",a[a.Exec4=3]="Exec4"})(x||(x={}));var K;(function(a){a[a.UpdateChannelState=2]="UpdateChannelState",a[a.Settle=3]="Settle",a[a.Collect=4]="Collect"})(K||(K={}));var X;(function(a){a.Account="bafk2bzacebor5mnjnsav34cmm5pcd3dy4wubbv4wtcrvba7depy3sct7ie4sy",a.Cron="bafk2bzacebetehhedh55alfn4rcx2mhjhvuiustxlhtxc3drkemnpttws5eqw",a.DataCap="bafk2bzaced6uhmrh5jjexhw4lco4ipesi2iutl7uupnyspgmnbydyo3amtu4i",a.EAM="bafk2bzacea6wzcnflfnaxqnwydoghh7ezg5au32ew3bnzljzpiw6fimhlpoiu",a.EthAccount="bafk2bzacedrbpvjvyzif2cjxosm4pliyq2m6wzndvrg7r6hzdhixplzvgubbw",a.EVM="bafk2bzaceabftmhejmvjvpzmbsv4cvaew6v5juj5sqtq7cfijugwsnahnsy5w",a.Init="bafk2bzaceduyjd35y7o2lhvevtysqf45rp5ot7x5f36q6iond6dyiz6773g5q",a.Multisig="bafk2bzacebcb72fmbpocetnzgni2wnbrduamlqx6fl3yelrlzu7id6bu5ib5g",a.PaymentChannel="bafk2bzaceazwhm63kyp47pste5i5acnuhosrgythyagf3kc5clogiqqx6vkzk",a.Placeholder="bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro",a.Reward="bafk2bzacecp7xo5ev46y64zr5osnn5fxo7itpoqw235tcfv6eo4rymzdemet2",a.StorageMarket="bafk2bzacedjt5mueomasx7dijooxnwxsbtzu2dj2ppp45rtle4kiinkmgzeei",a.StorageMiner="bafk2bzacebkjnjp5okqjhjxzft5qkuv36u4tz7inawseiwi2kw4j43xpxvhpm",a.StoragePower="bafk2bzaced2qsypqwore3jrdtaesh4itst2fyeepdsozvtffc2pianzmphdum",a.System="bafk2bzacedqvik2n3phnj3cni3h2k5mtvz43nyq7mdmv7k7euejysvajywdug",a.VerifiedRegistry="bafk2bzaceceoo5jlom2zweh7kpye2vkj33wgqnkjshlsw2neemqkfg5g2rmvg"})(X||(X={}));var G;(function(a){a.Account="bafk2bzaceampw4romta75hyz5p4cqriypmpbgnkxncgxgqn6zptv5lsp2w2bo",a.Cron="bafk2bzacedcbtsifegiu432m5tysjzkxkmoczxscb6hqpmrr6img7xzdbbs2g",a.DataCap="bafk2bzacealj5uk7wixhvk7l5tnredtelralwnceafqq34nb2lbylhtuyo64u",a.EAM="bafk2bzacedrpm5gbleh4xkyo2jvs7p5g6f34soa6dpv7ashcdgy676snsum6g",a.EthAccount="bafk2bzaceaqoc5zakbhjxn3jljc4lxnthllzunhdor7sxhwgmskvc6drqc3fa",a.EVM="bafk2bzaceahmzdxhqsm7cu2mexusjp6frm7r4kdesvti3etv5evfqboos2j4g",a.Init="bafk2bzaced2f5rhir3hbpqbz5ght7ohv2kgj42g5ykxrypuo2opxsup3ykwl6",a.Multisig="bafk2bzaceduf3hayh63jnl4z2knxv7cnrdenoubni22fxersc4octlwpxpmy4",a.PaymentChannel="bafk2bzaceartlg4mrbwgzcwric6mtvyawpbgx2xclo2vj27nna57nxynf3pgc",a.Placeholder="bafk2bzacedfvut2myeleyq67fljcrw4kkmn5pb5dpyozovj7jpoez5irnc3ro",a.Reward="bafk2bzacebnhtaejfjtzymyfmbdrfmo7vgj3zsof6zlucbmkhrvcuotw5dxpq",a.StorageMarket="bafk2bzaceclejwjtpu2dhw3qbx6ow7b4pmhwa7ocrbbiqwp36sq5yeg6jz2bc",a.StorageMiner="bafk2bzaced4h7noksockro7glnssz2jnmo2rpzd7dvnmfs4p24zx3h6gtx47s",a.StoragePower="bafk2bzacec4ay4crzo73ypmh7o3fjendhbqrxake46bprabw67fvwjz5q6ixq",a.System="bafk2bzacedakk5nofebyup4m7nvx6djksfwhnxzrfuq4oyemhpl4lllaikr64",a.VerifiedRegistry="bafk2bzacedfel6edzqpe5oujno7fog4i526go4dtcs6vwrdtbpy2xq6htvcg6"})(G||(G={}));var _=C(14034),Ee=C(68249);const ve="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",fe="0123456789ABCDEFGHIJKLMNOPQRSTUV",de="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function V(a,t,c){c=c||{};let y,O;switch(t){case"RFC3548":case"RFC4648":y=ve,O=!0;break;case"RFC4648-HEX":y=fe,O=!0;break;case"Crockford":y=de,O=!1;break}if(!y)throw new Error(`Unknown base32 variant: ${t}`);const re=c.padding!==void 0?c.padding:O,ce=z(a);let he=0,me=0,Ce="";for(let ze=0;ze<ce.byteLength;ze++)for(me=me<<8|ce.getUint8(ze),he+=8;he>=5;)Ce+=y[me>>>he-5&31],he-=5;if(he>0&&(Ce+=y[me<<5-he&31]),re)for(;Ce.length%8!==0;)Ce+="=";return Ce}function z(a){if(a instanceof Int8Array||a instanceof Uint8Array||a instanceof Uint8ClampedArray)return new DataView(a.buffer,a.byteOffset,a.byteLength);if(a instanceof ArrayBuffer)return new DataView(a);throw new TypeError("Expected `data` to be an ArrayBuffer, Buffer, Int8Array, Uint8Array or Uint8ClampedArray")}class j extends Error{constructor(t){super(),this.message=`Invalid protocol indicator byte [${t}]`}}class W extends Error{constructor(t){super(),this.message="Unknown protocol indicator byte [${value}]"}}class te extends Error{constructor(t){super(),this.message=`Invalid payload length [${t}]`}}class se extends Error{constructor(t){super(),this.message=`Invalid namespace [${t}]`}}class m extends Error{constructor(t){super(),this.message=`Invalid network [${t}]`}}class B extends Error{constructor(){super(),this.message="Invalid subAddress."}}class R extends Error{constructor(t){super(),this.message=`${t} protocol not supported.`}}class $ extends Error{constructor(t,c){super(),this.message=`Invalid address (checksum not matching the payload). ${t} vs ${c}`}}class q extends Error{constructor(){super(),this.message="Private key need to be an instance of Buffer or a base64 string."}}var p=C(92493),oe=C(48287).Buffer;function we(a){const t=p.blake2bInit(4);return p.blake2bUpdate(t,a),oe.from(p.blake2bFinal(t))}function Ae(a){let t=0;for(;t<a.length;){const c=a[t];if(t++,c<128)break}return t==a.length?-1:t}const Se=a=>Object.values(d).includes(a),Te=a=>Object.values(Network).includes(a),be=a=>a===s.Mainnet?d.Mainnet:d.Testnet,le=a=>a!==Network.Mainnet;var f=C(48287).Buffer;const st=class{constructor(t,c){P(this,"networkPrefix");P(this,"protocol");P(this,"getPayload",()=>this.payload);P(this,"getNetworkPrefix",()=>this.networkPrefix);P(this,"getProtocol",()=>this.protocol);P(this,"getChecksum",()=>we(this.toBytes()));this.networkPrefix=t,this.protocol=c}};let T=st;P(T,"fromString",t=>{const c=parseInt(t[1]);switch(c){case b.ID:return ue.fromString(t);case b.ACTOR:return xe.fromString(t);case b.SECP256K1:return ye.fromString(t);case b.BLS:return Y.fromString(t);case b.DELEGATED:{const y=Pe.fromString(t);return st.isFilEthAddress(y)?new Oe(y.getNetworkPrefix(),y.getSubAddress()):y}default:throw new W(c)}}),P(T,"fromBytes",(t,c)=>{const y=c[0];switch(y){case b.ID:return ue.fromBytes(t,c);case b.ACTOR:return xe.fromBytes(t,c);case b.SECP256K1:return ye.fromBytes(t,c);case b.BLS:return Y.fromBytes(t,c);case b.DELEGATED:{const O=Pe.fromBytes(t,c);return st.isFilEthAddress(O)?new Oe(O.getNetworkPrefix(),O.getSubAddress()):O}default:throw new W(y)}}),P(T,"fromEthAddress",(t,c)=>{if(typeof c=="string"){const O=c.startsWith("0x")?c.substring(2):c;c=f.from(O,"hex")}const y=f.alloc(12);if(y[0]=I,y.compare(c,0,12)==0){let O=12;for(;c[O]==0;)O+=1;return new ue(t,f.from(c.subarray(O)))}return new Oe(t,c)}),P(T,"isAddressId",t=>t.protocol==b.ID),P(T,"isAddressBls",t=>t.protocol==b.BLS),P(T,"isAddressSecp256k1",t=>t.protocol==b.SECP256K1),P(T,"isAddressDelegated",t=>t.protocol==b.DELEGATED),P(T,"isFilEthAddress",t=>t.protocol==b.DELEGATED&&"namespace"in t&&t.namespace==S.ETH),P(T,"isAddressActor",t=>t.protocol==b.ACTOR);class Y extends T{constructor(c,y){super(c,b.BLS);P(this,"payload");P(this,"toBytes",()=>f.concat([f.from(`0${this.protocol}`,"hex"),this.payload]));P(this,"toString",()=>{const c=this.getChecksum();return this.networkPrefix+this.protocol.toString()+V(f.concat([this.payload,c]),"RFC4648",{padding:!1}).toLowerCase()});if(y.byteLength!==g)throw new te(y.byteLength);this.payload=y}static fromString(c){const y=c[0],O=c[1];if(!Se(y))throw new m(y);if(parseInt(O)!=b.BLS)throw new j(parseInt(O));const re=f.from(_(c.substring(2).toUpperCase(),"RFC4648")),ce=f.from(re.subarray(0,-4)),he=f.from(re.subarray(-4)),me=new Y(y,ce);if(me.getChecksum().toString("hex")!==he.toString("hex"))throw new $(me.getChecksum().toString("hex"),he.toString("hex"));return me}static fromBytes(c,y){if(y[0]!=b.BLS)throw new j(y[0]);const O=f.from(y.subarray(1));return new Y(c,O)}}class ue extends T{constructor(c,y){super(c,b.ID);P(this,"id");P(this,"payload");P(this,"toBytes",()=>f.concat([f.from(`0${this.protocol}`,"hex"),this.payload]));P(this,"toString",()=>this.networkPrefix+this.protocol.toString()+Ee.unsigned.decode(this.payload));P(this,"getId",()=>this.id);P(this,"toEthAddressHex",(c=!1)=>{const y=f.alloc(l);return y[0]=I,y.set(this.payload,l-this.payload.length),`${c?"0x":""}${y.toString("hex")}`});const O=typeof y=="string"?Ee.unsigned.encode(y):y;if(O.length>D)throw new te(O.length);this.payload=O,this.id=this.toString().substring(2)}static fromString(c){const y=c[0],O=c[1];if(!Se(y))throw new m(y);if(parseInt(O)!=b.ID)throw new j(parseInt(O));const re=Ee.unsigned.encode(c.substring(2));return new ue(y,re)}static fromBytes(c,y){if(y[0]!=b.ID)throw new j(y[0]);const O=f.from(y.subarray(1));return new ue(c,O)}}class ye extends T{constructor(c,y){super(c,b.SECP256K1);P(this,"payload");P(this,"toBytes",()=>f.concat([f.from(`0${this.protocol}`,"hex"),this.payload]));P(this,"toString",()=>{const c=this.getChecksum();return this.networkPrefix+this.protocol.toString()+V(f.concat([this.payload,c]),"RFC4648",{padding:!1}).toLowerCase()});if(y.byteLength!==L)throw new te(y.byteLength);this.payload=y}static fromString(c){const y=c[0],O=c[1];if(!Se(y))throw new m(y);if(parseInt(O)!=b.SECP256K1)throw new j(parseInt(O));const re=f.from(_(c.substring(2).toUpperCase(),"RFC4648")),ce=f.from(re.subarray(0,-4)),he=f.from(re.subarray(-4)),me=new ye(y,ce);if(me.getChecksum().toString("hex")!==he.toString("hex"))throw new $(me.getChecksum().toString("hex"),he.toString("hex"));return me}static fromBytes(c,y){if(y[0]!=b.SECP256K1)throw new j(y[0]);const O=f.from(y.subarray(1));return new ye(c,O)}}class xe extends T{constructor(c,y){super(c,b.ACTOR);P(this,"payload");P(this,"toBytes",()=>f.concat([f.from(`0${this.protocol}`,"hex"),this.payload]));P(this,"toString",()=>{const c=this.getChecksum();return this.networkPrefix+this.protocol.toString()+V(f.concat([this.payload,c]),"RFC4648",{padding:!1}).toLowerCase()});if(y.byteLength!==w)throw new te(y.byteLength);this.payload=y}static fromString(c){const y=c[0],O=c[1];if(!Se(y))throw new m(y);if(parseInt(O)!=b.ACTOR)throw new j(parseInt(O));const re=f.from(_(c.substring(2).toUpperCase(),"RFC4648")),ce=f.from(re.subarray(0,-4)),he=f.from(re.subarray(-4)),me=new xe(y,ce);if(me.getChecksum().toString("hex")!==he.toString("hex"))throw new $(me.getChecksum().toString("hex"),he.toString("hex"));return me}static fromBytes(c,y){if(y[0]!=b.ACTOR)throw new j(y[0]);const O=f.from(y.subarray(1));return new xe(c,O)}}class Pe extends T{constructor(c,y,O){super(c,b.DELEGATED);P(this,"payload");P(this,"namespace");P(this,"subAddress");P(this,"getNamespace",()=>this.namespace);P(this,"getSubAddress",()=>this.subAddress);P(this,"toBytes",()=>{const c=f.from(Ee.unsigned.encode(this.namespace)),y=f.from(Ee.unsigned.encode(this.protocol));return f.concat([y,c,this.subAddress])});P(this,"toString",()=>{const c=this.getChecksum();return this.networkPrefix+this.protocol.toString()+this.namespace+"f"+V(f.concat([this.subAddress,c]),"RFC4648",{padding:!1}).toLowerCase()});if(new h(y).gt(Z))throw new se(y);if(O.length===0||O.length>o)throw new B;this.namespace=y,this.subAddress=O,this.payload=f.from(this.toBytes().subarray(1))}static fromString(c){const y=c[0],O=c[1];if(!Se(y))throw new m(y);if(parseInt(O)!=b.DELEGATED)throw new j(parseInt(O));const re=c.substring(2,c.indexOf("f",2)),ce=c.substring(c.indexOf("f",2)+1),he=f.from(_(ce.toUpperCase(),"RFC4648")),me=f.from(he.subarray(0,-4)),Ce=f.from(he.subarray(-4)),ze=new Pe(y,re,me);if(ze.getChecksum().toString("hex")!==Ce.toString("hex"))throw new $(ze.getChecksum().toString("hex"),Ce.toString("hex"));return ze}static fromBytes(c,y){if(y[0]!=b.DELEGATED)throw new j(y[0]);const O=Ae(f.from(y.subarray(1))),re=Ee.unsigned.decode(f.from(y.subarray(1,1+O))),ce=f.from(y.subarray(O+1));return new Pe(c,re,ce)}}class Oe extends Pe{constructor(c,y){super(c,S.ETH,y);P(this,"toEthAddressHex",(c=!1)=>`${c?"0x":""}${this.subAddress.toString("hex")}`);if(y.length!==l)throw new Error("invalid ethereum address: length should be 32 bytes")}static fromBytes(c,y){const O=Pe.fromBytes(c,y);if(O.getNamespace()!==S.ETH)throw new Error("invalid filecoin address for ethereum space");return new Oe(O.getNetworkPrefix(),O.getSubAddress())}static fromString(c){const y=Pe.fromString(c);if(y.getNamespace()!==S.ETH)throw new Error("invalid filecoin address for ethereum space");return new Oe(y.getNetworkPrefix(),y.getSubAddress())}}const Ue="2.0",ct="Filecoin.MpoolGetNonce",Qe="Filecoin.MpoolPush",ft="Filecoin.StateWaitMsg",Je="Filecoin.GasEstimateMessageGas",ut="Filecoin.StateReadState",_e="Filecoin.StateListMiners",et="Filecoin.StateMinerInfo",tt="Filecoin.ClientQueryAsk",lt="Filecoin.WalletBalance";class Ge{constructor(t,c){P(this,"fetcher");P(this,"network");P(this,"getNetwork",()=>this.network);P(this,"validateNetwork",(t,c="address")=>{const y=be(this.network);if(typeof t=="string"&&(t=T.fromString(t)),t.getNetworkPrefix()!==y)throw new Error(`${c} belongs to ${t.getNetworkPrefix()} network while rpc allows ${y}`);return t});this.fetcher=k.create({baseURL:c.url,timeout:c.timeout,headers:{Authorization:`Bearer ${c.token}`}}),this.network=t}async getNonce(t){t=this.validateNetwork(t);try{return(await this.fetcher.post("",{jsonrpc:Ue,method:ct,id:1,params:[t.toString()]})).data}catch(c){return this.handleError(c)}}async broadcastTransaction(t,c){this.validateNetwork(t.to,"receiver"),this.validateNetwork(t.from,"sender");try{return(await this.fetcher.post("",{jsonrpc:Ue,method:Qe,id:1,params:[{Message:t.toJSON(),Signature:c.toJSON()}]})).data}catch(y){return this.handleError(y)}}async getGasEstimation(t){this.validateNetwork(t.to,"receiver"),this.validateNetwork(t.from,"sender");try{return(await this.fetcher.post("",{jsonrpc:Ue,method:Je,id:1,params:[t.toJSON(),{MaxFee:"0"},null]})).data}catch(c){return this.handleError(c)}}async readState(t){t=this.validateNetwork(t);try{return(await this.fetcher.post("",{jsonrpc:Ue,method:ut,id:1,params:[t.toString(),null]})).data}catch(c){return this.handleError(c)}}async waitMsgState(t,c,y){try{return(await this.fetcher.post("",{jsonrpc:Ue,method:ft,id:1,params:[t,c,y,!1]})).data}catch(O){return this.handleError(O)}}async walletBalance(t){t=this.validateNetwork(t);try{return(await this.fetcher.post("",{jsonrpc:Ue,method:lt,id:1,params:[t.toString()]})).data}catch(c){return this.handleError(c)}}async listMiners(){try{return(await this.fetcher.post("",{jsonrpc:Ue,method:_e,id:1,params:[null]})).data}catch(t){return this.handleError(t)}}async getMinerInfo(t){t=this.validateNetwork(t);try{return(await this.fetcher.post("",{jsonrpc:Ue,method:et,id:1,params:[t.toString(),null]})).data}catch(c){return this.handleError(c)}}async askForStorage(t,c){t=this.validateNetwork(t);try{return(await this.fetcher.post("",{jsonrpc:Ue,method:tt,id:1,params:[c,t.toString()]})).data}catch(y){return this.handleError(y)}}handleError(t){if(k.isAxiosError(t)){if(t.response){if(t.response.data)return t.response.data;if(t.response.statusText)return{error:{message:`${t.response.status} - ${t.response.statusText}`}}}if(t.request)return{error:{message:"request made but no response received"}};if(t.message)return{error:{message:t.message}}}throw t}}class bt extends Ge{constructor(t){super(s.Mainnet,t)}}class yt extends Ge{constructor(t){super(s.Calibration,t)}}class We extends Ge{constructor(t){super(s.Butterfly,t)}}var Le=C(90749),ht=C(83328),rt=C(73513),dt=C.t(rt,2),je=C(17009),De=C(48287).Buffer;const nt=De.from([1,113,160,228,2,32]),ot=32,it=a=>{const t=a.split("/");return t[2].includes("'")?t[2].substring(0,t[2].length-1):t[2]};function Be(a){const t=p.blake2bInit(ot);p.blake2bUpdate(t,a);const c=De.from(p.blake2bFinal(t));return De.concat([nt,c])}function Ne(a){const t=p.blake2bInit(32);return p.blake2bUpdate(t,Be(a)),De.from(p.blake2bFinal(t))}const Ze=a=>{if(typeof a=="string")if(a.substring(a.length-1)==="=")a=De.from(a,"base64");else throw new q;if(a.length!==32)throw new q;return a},n=a=>{const t=p.blake2bInit(20);return p.blake2bUpdate(t,a),De.from(p.blake2bFinal(t))},e=a=>v.BLS===a||v.SECP256K1===a;var r=C(48287).Buffer;const u=ht.Pr(dt),Ye=class{static recoverAccount(t,c,y,O){switch(c){case v.SECP256K1:{y=Ze(y);const{publicKey:re,address:ce}=Ye.getPublicSecp256k1FromPrivKey(t,y);return{type:c,privateKey:y,address:ce,publicKey:re,path:O}}default:throw new Error("not supported yet")}}};let E=Ye;P(E,"generateMnemonic",()=>Le.generateMnemonic(256)),P(E,"mnemonicToSeed",(t,c)=>Le.mnemonicToSeedSync(t,c)),P(E,"deriveAccount",(t,c,y,O,re)=>{const ce=Ye.mnemonicToSeed(t,O);return Ye.deriveAccountFromSeed(ce,c,y,re)}),P(E,"deriveAccountFromSeed",(t,c,y,O)=>{switch(typeof t=="string"&&(t=r.from(t,"hex")),c){case v.SECP256K1:{const re=u.fromSeed(t),{privateKey:ce}=re.derivePath(y);if(!ce)throw new Error("privateKey not generated");O||(O=it(y)==="1"?d.Testnet:d.Mainnet);const{publicKey:he,address:me}=Ye.getPublicSecp256k1FromPrivKey(O,ce);return{type:c,privateKey:ce,publicKey:he,address:me,path:y}}default:throw new Error("not supported yet")}}),P(E,"signTransaction",async(t,c)=>{const y=await c.serialize(),O=Ne(y),{privateKey:re,type:ce}=t;switch(ce){case v.SECP256K1:{const he=je.ecdsaSign(O,re);return new U(ce,r.concat([r.from(he.signature),r.from([he.recid])]))}default:throw new Error("not supported yet")}}),P(E,"verifySignature",async(t,c)=>{const y=await c.serialize(),O=Ne(y);switch(t.getType()){case v.SECP256K1:{const re=t.getData(),ce=je.ecdsaRecover(re.subarray(0,-1),re[64],O,!1),he=n(ce);return c.from.getPayload().toString("hex")!==he.toString("hex")?!1:je.ecdsaVerify(re.subarray(0,-1),O,ce)}default:throw new Error("not supported yet")}}),P(E,"getPublicSecp256k1FromPrivKey",(t,c)=>{const y=je.publicKeyCreate(c),O=new Uint8Array(65);je.publicKeyConvert(y,!1,O);const re=r.from(O),ce=n(O);return{publicKey:re,address:new ye(t,ce)}});const wt=class{constructor(t,c){P(this,"type");P(this,"data");P(this,"toJSON",()=>({Type:this.type,Data:this.data.toString("base64")}));P(this,"getType",()=>this.type);P(this,"getData",()=>this.data);P(this,"isSecp256k1",()=>this.type===v.SECP256K1);P(this,"isBls",()=>this.type===v.BLS);this.type=t,this.data=c}};let U=wt;P(U,"fromJSON",t=>{if(typeof t!="object"||t===null)throw new Error("input should be an object");if(!("Type"in t)||typeof t.Type!="number")throw new Error("'Type' should be a number");if(!e(t.Type))throw new Error("invalid signature type");if(!("Data"in t)||typeof t.Data!="string")throw new Error("'Data' should be a base64 encoded string");return new wt(t.Type,r.from(t.Data,"base64"))});var M=C(48287).Buffer;const H=(a,t=10)=>{if(a.toString()==="0")return M.from("");const c=new h(a,t),y=c.toArrayLike(M,"be",c.byteLength()),O=M.from(c.isNeg()?"01":"00","hex");return M.concat([O,y])},J=(a,t=10)=>{if(a.length===0)return"0";if(a[0]!=0&&a[0]!=1)throw new Error("invalid bigint");const c=a[0]===1?"-":"",y=new h(a.subarray(1));return c+y.toString(t)},Q=a=>new Promise(t=>setTimeout(t,a)),ee=async a=>{let t=a();for(;!t;)await Q(50),t=a();return t};var ne=C(48287).Buffer;let ie;C.e(1523).then(C.bind(C,71523)).then(a=>{ie=a}).catch(a=>{throw a});const qe=class{constructor(t,c,y,O,re,ce,he,me,Ce,ze){P(this,"version");P(this,"to");P(this,"from");P(this,"nonce");P(this,"value");P(this,"gasLimit");P(this,"gasFeeCap");P(this,"gasPremium");P(this,"method");P(this,"params");P(this,"toJSON",()=>({To:this.to.toString(),From:this.from.toString(),Nonce:this.nonce,Value:this.value,Params:this.params,GasFeeCap:this.gasFeeCap,GasPremium:this.gasPremium,GasLimit:this.gasLimit,Method:this.method}));P(this,"serialize",async()=>{const t=await ee(()=>ie),c=[this.version,this.to.toBytes(),this.from.toBytes(),this.nonce,H(this.value,10),this.gasLimit,H(this.gasFeeCap,10),H(this.gasPremium,10),this.method,ne.from(this.params,"base64")];return ne.from(t.encode(c))});P(this,"prepareToSend",async t=>{const c=await t.getNonce(this.from);if("error"in c)throw new Error(c.error.message);this.nonce=c.result;const y=await t.getGasEstimation(this);if("error"in y)throw new Error(y.error.message);return this.gasFeeCap=y.result.GasFeeCap,this.gasLimit=y.result.GasLimit,this.gasPremium=y.result.GasPremium,this});if(this.version=t,this.to=c,this.from=y,this.nonce=O,this.value=re,this.gasLimit=ce,this.gasFeeCap=he,this.gasPremium=me,this.method=Ce,this.params=ze,re===""||re.includes("-"))throw new Error("value must not be empty or negative")}};let pe=qe;P(pe,"getNew",(t,c,y,O,re=ne.alloc(0))=>new qe(N.Zero,t,c,0,y.toAtto(),0,"0","0",O,re.toString("base64"))),P(pe,"fromCBOR",async(t,c)=>{typeof c=="string"&&(c=ne.from(c,"hex"));const O=(await ee(()=>ie)).decode(c);if(!(O instanceof Array))throw new Error("Decoded raw tx should be an array");if(O.length<10)throw new Error("The cbor is missing some fields... please verify you have 9 fields.");const[re,ce,he,me,Ce,ze,Ct,Tt,Rt,Ut]=O;if(re!==N.Zero)throw new Error("Unsupported version");if(Ce[0]===1)throw new Error("Value cant be negative");const Nt=new h(ne.from(Ce).toString("hex"),16).toString(10),Kt=new h(ne.from(Ct).toString("hex"),16).toString(10),zt=new h(ne.from(Tt).toString("hex"),16).toString(10);return new qe(re,T.fromBytes(t,ce),T.fromBytes(t,he),me,Nt,ze,Kt,zt,Rt,Ut.toString("base64"))}),P(pe,"fromJSON",t=>{if(typeof t!="object"||t==null)throw new Error("tx should be an json object");if(!("To"in t)||typeof t.To!="string")throw new Error("'To' is a required field and has to be a 'string'");if(!("From"in t)||typeof t.From!="string")throw new Error("'From' is a required field and has to be a 'string'");if(!("Nonce"in t)||typeof t.Nonce!="number")throw new Error("'Nonce' is a required field and has to be a 'number'");if(!("Value"in t)||typeof t.Value!="string"||t.Value===""||t.Value.includes("-"))throw new Error("'Value' is a required field and has to be a 'string' but not empty or negative");if(!("GasFeeCap"in t)||typeof t.GasFeeCap!="string")throw new Error("'GasFeeCap' is a required field and has to be a 'string'");if(!("GasPremium"in t)||typeof t.GasPremium!="string")throw new Error("'GasPremium' is a required field and has to be a 'string'");if(!("GasLimit"in t)||typeof t.GasLimit!="number")throw new Error("'GasLimit' is a required field and has to be a 'number'");if(!("Method"in t)||typeof t.Method!="number")throw new Error("'Method' is a required field and has to be a 'number'");if(!("Params"in t)||typeof t.Params!="string")throw new Error("'Params' is a required field and has to be a 'string'");return new qe(N.Zero,T.fromString(t.To),T.fromString(t.From),t.Nonce,t.Value,t.GasLimit,t.GasFeeCap,t.GasPremium,t.Method,t.Params)});const ge=(a,t)=>{const c=a.isNeg()?"-":"",y=a.abs().toString(),O=y.length-t,re=ke(O>0?`${y.substring(0,O)}.${y.substring(O)}`:`0.${"".padStart(-1*O,"0")}${y}`);return`${c}${re}`},ke=a=>{for(let t=a.length-1;t>=0;t--){if(a[t]==".")return a.substring(0,t);if(a[t]!="0"||t===1)return a.substring(0,t+1)}throw new Error("invalid value")},Ie=18,Fe=15,Me=12,$e=9,Ve=6,He=3,St=0,xt=new h(10).pow(new h(He)),At=new h(10).pow(new h(Ve)),Pt=new h(10).pow(new h($e)),Bt=new h(10).pow(new h(Me)),It=new h(10).pow(new h(Fe)),kt=new h(10).pow(new h(Ie)),Ke=class{constructor(t){P(this,"value");P(this,"add",t=>(this.value=this.value.add(t.value),this));P(this,"sub",t=>(this.value=this.value.sub(t.value),this));P(this,"gt",t=>this.value.gt(t.value));P(this,"gte",t=>this.value.gte(t.value));P(this,"lt",t=>this.value.lt(t.value));P(this,"lte",t=>this.value.lte(t.value));P(this,"isNegative",()=>this.value.isNeg());P(this,"isPositive",()=>!this.value.isNeg());P(this,"isZero",()=>this.value.isZero());P(this,"toWhole",()=>ge(this.value,Ie));P(this,"toMilli",()=>ge(this.value,Ie-He));P(this,"toMicro",()=>ge(this.value,Ie-Ve));P(this,"toNano",()=>ge(this.value,Ie-$e));P(this,"toPico",()=>ge(this.value,Ie-Me));P(this,"toFemto",()=>ge(this.value,Ie-Fe));P(this,"toAtto",()=>ge(this.value,0));P(this,"serialize",()=>H(this.value.toString(10),10));this.value=t}};let Re=Ke;P(Re,"zero",()=>new Ke(new h("0"))),P(Re,"deserialize",t=>new Ke(new h(J(t,10),10))),P(Re,"fromAtto",t=>new Ke(new h(t))),P(Re,"fromFemto",t=>new Ke(new h(t).mul(xt))),P(Re,"fromPico",t=>new Ke(new h(t).mul(At))),P(Re,"fromNano",t=>new Ke(new h(t).mul(Pt))),P(Re,"fromMicro",t=>new Ke(new h(t).mul(Bt))),P(Re,"fromMilli",t=>new Ke(new h(t).mul(It))),P(Re,"fromWhole",t=>new Ke(new h(t).mul(kt)));class gt{}P(gt,"send",null),P(gt,"getBalance",null);var Dt=C(48287).Buffer;class pt{}P(pt,"newTx",null),P(pt,"newExecTx",null);let mt;C.e(1523).then(C.bind(C,71523)).then(a=>{mt=a}).catch(a=>{throw a});let Et;C.e(2131).then(C.bind(C,92131)).then(a=>{Et=a}).catch(a=>{throw a});class Ft{constructor(t,c){P(this,"targetActorCid");P(this,"targetConstructorParams");P(this,"serialize",async()=>{const t=await waitFor(()=>mt),c=await waitFor(()=>Et);return t.encode([c.CID.parse(this.targetActorCid),this.targetConstructorParams])});this.targetActorCid=t,this.targetConstructorParams=c}}let vt;C.e(1523).then(C.bind(C,71523)).then(a=>{vt=a}).catch(a=>{throw a});class Mt{constructor(t,c){P(this,"from");P(this,"to");P(this,"serialize",async()=>(await waitFor(()=>vt)).encode([this.from.toBytes(),this.to.toBytes()]));this.from=t,this.to=c}}const Ht=a=>{switch(a){case Network.Calibration:return ActorsCalibrationV11;case Network.Mainnet:return ActorsMainnetV10;case Network.Butterfly:throw new Error("not implemented yet")}},at=class{constructor(t,c,y){P(this,"channelAddress");P(this,"from");P(this,"to");P(this,"getAddress",()=>this.channelAddress);P(this,"getTo",()=>this.to);P(this,"getFrom",()=>this.from);P(this,"settle",(t,c)=>{const{address:y}=c,O=Transaction.getNew(this.channelAddress,y,Token.zero(),PayChActorMethods.Settle);return at.sendTx(t,c,O)});P(this,"collect",(t,c)=>{const{address:y}=c,O=Transaction.getNew(this.channelAddress,y,Token.zero(),PayChActorMethods.Collect);return at.sendTx(t,c,O)});this.channelAddress=t,this.from=c,this.to=y}};let Xe=at;P(Xe,"create",null),P(Xe,"loadFromCid",null),P(Xe,"sendTx",null)}}]);
|