@teleportdao/bitcoin 1.5.7 → 1.5.8
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/.tmp/check.ts +1 -1
- package/dist/bundle.js +1 -1
- package/dist/transaction-builder/transaction-builder.d.ts.map +1 -1
- package/dist/transaction-builder/transaction-builder.js +11 -2
- package/dist/transaction-builder/transaction-builder.js.map +1 -1
- package/package.json +2 -2
- package/src/transaction-builder/transaction-builder.ts +14 -2
package/dist/bundle.js
CHANGED
|
@@ -14,4 +14,4 @@ t.read=function(e,t,r,n,i){var o,a,s=8*i-n-1,u=(1<<s)-1,c=u>>1,f=-7,l=r?i-1:0,d=
|
|
|
14
14
|
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
15
15
|
function n(e){if(!Number.isSafeInteger(e))throw new Error("Wrong integer: "+e)}function i(...e){const t=(e,t)=>r=>e(t(r));return{encode:Array.from(e).reverse().reduce((e,r)=>e?t(e,r.encode):r.encode,void 0),decode:e.reduce((e,r)=>e?t(e,r.decode):r.decode,void 0)}}function o(e){return{encode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("alphabet.encode input should be an array of numbers");return t.map(t=>{if(n(t),t<0||t>=e.length)throw new Error(`Digit index outside alphabet: ${t} (alphabet: ${e.length})`);return e[t]})},decode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("alphabet.decode input should be array of strings");return t.map(t=>{if("string"!=typeof t)throw new Error("alphabet.decode: not string element="+t);const r=e.indexOf(t);if(-1===r)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return r})}}}function a(e=""){if("string"!=typeof e)throw new Error("join separator should be string");return{encode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("join.encode input should be array of strings");for(let e of t)if("string"!=typeof e)throw new Error("join.encode: non-string input="+e);return t.join(e)},decode:t=>{if("string"!=typeof t)throw new Error("join.decode input should be string");return t.split(e)}}}function s(e,t="="){if(n(e),"string"!=typeof t)throw new Error("padding chr should be string");return{encode(r){if(!Array.isArray(r)||r.length&&"string"!=typeof r[0])throw new Error("padding.encode input should be array of strings");for(let e of r)if("string"!=typeof e)throw new Error("padding.encode: non-string input="+e);for(;r.length*e%8;)r.push(t);return r},decode(r){if(!Array.isArray(r)||r.length&&"string"!=typeof r[0])throw new Error("padding.encode input should be array of strings");for(let e of r)if("string"!=typeof e)throw new Error("padding.decode: non-string input="+e);let n=r.length;if(n*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;n>0&&r[n-1]===t;n--)if(!((n-1)*e%8))throw new Error("Invalid padding: string has too much padding");return r.slice(0,n)}}}function u(e){if("function"!=typeof e)throw new Error("normalize fn should be function");return{encode:e=>e,decode:t=>e(t)}}function c(e,t,r){if(t<2)throw new Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: wrong to=${r}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let i=0;const o=[],a=Array.from(e);for(a.forEach(e=>{if(n(e),e<0||e>=t)throw new Error("Wrong integer: "+e)});;){let e=0,n=!0;for(let o=i;o<a.length;o++){const s=a[o],u=t*e+s;if(!Number.isSafeInteger(u)||t*e/t!==e||u-s!=t*e)throw new Error("convertRadix: carry overflow");e=u%r;const c=Math.floor(u/r);if(a[o]=c,!Number.isSafeInteger(c)||c*r+e!==u)throw new Error("convertRadix: carry overflow");n&&(c?n=!1:i=o)}if(o.push(e),n)break}for(let t=0;t<e.length-1&&0===e[t];t++)o.push(0);return o.reverse()}r.r(t),r.d(t,"assertNumber",(function(){return n})),r.d(t,"utils",(function(){return g})),r.d(t,"base16",(function(){return y})),r.d(t,"base32",(function(){return v})),r.d(t,"base32hex",(function(){return w})),r.d(t,"base32crockford",(function(){return _})),r.d(t,"base64",(function(){return E})),r.d(t,"base64url",(function(){return k})),r.d(t,"base64urlnopad",(function(){return S})),r.d(t,"base58",(function(){return T})),r.d(t,"base58flickr",(function(){return A})),r.d(t,"base58xrp",(function(){return P})),r.d(t,"base58xmr",(function(){return I})),r.d(t,"base58check",(function(){return B})),r.d(t,"bech32",(function(){return C})),r.d(t,"bech32m",(function(){return H})),r.d(t,"utf8",(function(){return z})),r.d(t,"hex",(function(){return L})),r.d(t,"bytesToString",(function(){return q})),r.d(t,"str",(function(){return K})),r.d(t,"stringToBytes",(function(){return W})),r.d(t,"bytes",(function(){return V}));const f=(e,t)=>t?f(t,e%t):e,l=(e,t)=>e+(t-f(e,t));function d(e,t,r,i){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(t<=0||t>32)throw new Error("convertRadix2: wrong from="+t);if(r<=0||r>32)throw new Error("convertRadix2: wrong to="+r);if(l(t,r)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${r} carryBits=${l(t,r)}`);let o=0,a=0;const s=2**r-1,u=[];for(const i of e){if(n(i),i>=2**t)throw new Error(`convertRadix2: invalid data word=${i} from=${t}`);if(o=o<<t|i,a+t>32)throw new Error(`convertRadix2: carry overflow pos=${a} from=${t}`);for(a+=t;a>=r;a-=r)u.push((o>>a-r&s)>>>0);o&=2**a-1}if(o=o<<r-a&s,!i&&a>=t)throw new Error("Excess padding");if(!i&&o)throw new Error("Non-zero padding: "+o);return i&&a>0&&u.push(o>>>0),u}function h(e){return n(e),{encode:t=>{if(!(t instanceof Uint8Array))throw new Error("radix.encode input should be Uint8Array");return c(Array.from(t),256,e)},decode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("radix.decode input should be array of strings");return Uint8Array.from(c(t,e,256))}}}function p(e,t=!1){if(n(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(l(8,e)>32||l(e,8)>32)throw new Error("radix2: carry overflow");return{encode:r=>{if(!(r instanceof Uint8Array))throw new Error("radix2.encode input should be Uint8Array");return d(Array.from(r),8,e,!t)},decode:r=>{if(!Array.isArray(r)||r.length&&"number"!=typeof r[0])throw new Error("radix2.decode input should be array of strings");return Uint8Array.from(d(r,e,8,t))}}}function b(e){if("function"!=typeof e)throw new Error("unsafeWrapper fn should be function");return function(...t){try{return e.apply(null,t)}catch(e){}}}function m(e,t){if(n(e),"function"!=typeof t)throw new Error("checksum fn should be function");return{encode(r){if(!(r instanceof Uint8Array))throw new Error("checksum.encode: input should be Uint8Array");const n=t(r).slice(0,e),i=new Uint8Array(r.length+e);return i.set(r),i.set(n,r.length),i},decode(r){if(!(r instanceof Uint8Array))throw new Error("checksum.decode: input should be Uint8Array");const n=r.slice(0,-e),i=t(n).slice(0,e),o=r.slice(-e);for(let t=0;t<e;t++)if(i[t]!==o[t])throw new Error("Invalid checksum");return n}}}const g={alphabet:o,chain:i,checksum:m,radix:h,radix2:p,join:a,padding:s},y=i(p(4),o("0123456789ABCDEF"),a("")),v=i(p(5),o("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),s(5),a("")),w=i(p(5),o("0123456789ABCDEFGHIJKLMNOPQRSTUV"),s(5),a("")),_=i(p(5),o("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),a(""),u(e=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1"))),E=i(p(6),o("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),s(6),a("")),k=i(p(6),o("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),s(6),a("")),S=i(p(6),o("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),a("")),x=e=>i(h(58),o(e),a("")),T=x("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),A=x("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),P=x("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"),O=[0,2,3,5,6,7,9,10,11],I={encode(e){let t="";for(let r=0;r<e.length;r+=8){const n=e.subarray(r,r+8);t+=T.encode(n).padStart(O[n.length],"1")}return t},decode(e){let t=[];for(let r=0;r<e.length;r+=11){const n=e.slice(r,r+11),i=O.indexOf(n.length),o=T.decode(n);for(let e=0;e<o.length-i;e++)if(0!==o[e])throw new Error("base58xmr: wrong padding");t=t.concat(Array.from(o.slice(o.length-i)))}return Uint8Array.from(t)}},B=e=>i(m(4,t=>e(e(t))),T),M=i(o("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),a("")),R=[996825010,642813549,513874426,1027748829,705979059];function N(e){const t=e>>25;let r=(33554431&e)<<5;for(let e=0;e<R.length;e++)1==(t>>e&1)&&(r^=R[e]);return r}function j(e,t,r=1){const n=e.length;let i=1;for(let t=0;t<n;t++){const r=e.charCodeAt(t);if(r<33||r>126)throw new Error(`Invalid prefix (${e})`);i=N(i)^r>>5}i=N(i);for(let t=0;t<n;t++)i=N(i)^31&e.charCodeAt(t);for(let e of t)i=N(i)^e;for(let e=0;e<6;e++)i=N(i);return i^=r,M.encode(d([i%2**30],30,5,!1))}function U(e){const t="bech32"===e?1:734539939,r=p(5),n=r.decode,i=r.encode,o=b(n);function a(e,r=90){if("string"!=typeof e)throw new Error("bech32.decode input should be string, not "+typeof e);if(e.length<8||!1!==r&&e.length>r)throw new TypeError(`Wrong string length: ${e.length} (${e}). Expected (8..${r})`);const n=e.toLowerCase();if(e!==n&&e!==e.toUpperCase())throw new Error("String must be lowercase or uppercase");const i=(e=n).lastIndexOf("1");if(0===i||-1===i)throw new Error('Letter "1" must be present between prefix and data only');const o=e.slice(0,i),a=e.slice(i+1);if(a.length<6)throw new Error("Data must be at least 6 characters long");const s=M.decode(a).slice(0,-6),u=j(o,s,t);if(!a.endsWith(u))throw new Error(`Invalid checksum in ${e}: expected "${u}"`);return{prefix:o,words:s}}return{encode:function(e,r,n=90){if("string"!=typeof e)throw new Error("bech32.encode prefix should be string, not "+typeof e);if(!Array.isArray(r)||r.length&&"number"!=typeof r[0])throw new Error("bech32.encode words should be array of numbers, not "+typeof r);const i=e.length+7+r.length;if(!1!==n&&i>n)throw new TypeError(`Length ${i} exceeds limit ${n}`);const o=e.toLowerCase(),a=j(o,r,t);return`${o}1${M.encode(r)}${a}`},decode:a,decodeToBytes:function(e){const{prefix:t,words:r}=a(e,!1);return{prefix:t,words:r,bytes:n(r)}},decodeUnsafe:b(a),fromWords:n,fromWordsUnsafe:o,toWords:i}}const C=U("bech32"),H=U("bech32m"),z={encode:e=>(new TextDecoder).decode(e),decode:e=>(new TextEncoder).encode(e)},L=i(p(4),o("0123456789abcdef"),a(""),u(e=>{if("string"!=typeof e||e.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()})),D={utf8:z,hex:L,base16:y,base32:v,base64:E,base64url:k,base58:T,base58xmr:I},F="Invalid encoding type. Available types: utf8, hex, base16, base32, base64, base64url, base58, base58xmr",q=(e,t)=>{if("string"!=typeof e||!D.hasOwnProperty(e))throw new TypeError(F);if(!(t instanceof Uint8Array))throw new TypeError("bytesToString() expects Uint8Array");return D[e].encode(t)},K=q,W=(e,t)=>{if(!D.hasOwnProperty(e))throw new TypeError(F);if("string"!=typeof t)throw new TypeError("stringToBytes() expects string");return D[e].decode(t)},V=W},function(e,t,r){(t=e.exports=r(102)).Stream=t,t.Readable=t,t.Writable=r(106),t.Duplex=r(29),t.Transform=r(108),t.PassThrough=r(222),t.finished=r(71),t.pipeline=r(223)},function(e,t){},function(e,t,r){"use strict";function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function i(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function o(e,t,r){return(t=s(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,s(n.key),n)}}function s(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}var u=r(0).Buffer,c=r(219).inspect,f=c&&c.custom||"inspect";e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}var t,r,n;return t=e,(r=[{key:"push",value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r}},{key:"concat",value:function(e){if(0===this.length)return u.alloc(0);for(var t,r,n,i=u.allocUnsafe(e>>>0),o=this.head,a=0;o;)t=o.data,r=i,n=a,u.prototype.copy.call(t,r,n),a+=o.data.length,o=o.next;return i}},{key:"consume",value:function(e,t){var r;return e<this.head.data.length?(r=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):r=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),r}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(e){var t=this.head,r=1,n=t.data;for(e-=n.length;t=t.next;){var i=t.data,o=e>i.length?i.length:e;if(o===i.length?n+=i:n+=i.slice(0,e),0==(e-=o)){o===i.length?(++r,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(e){var t=u.allocUnsafe(e),r=this.head,n=1;for(r.data.copy(t),e-=r.data.length;r=r.next;){var i=r.data,o=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,o),0==(e-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,t}},{key:f,value:function(e,t){return c(this,i(i({},t),{},{depth:0,customInspect:!1}))}}])&&a(t.prototype,r),n&&a(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}()},function(e,t){},function(e,t,r){"use strict";(function(t){var n;function i(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var o=r(71),a=Symbol("lastResolve"),s=Symbol("lastReject"),u=Symbol("error"),c=Symbol("ended"),f=Symbol("lastPromise"),l=Symbol("handlePromise"),d=Symbol("stream");function h(e,t){return{value:e,done:t}}function p(e){var t=e[a];if(null!==t){var r=e[d].read();null!==r&&(e[f]=null,e[a]=null,e[s]=null,t(h(r,!1)))}}function b(e){t.nextTick(p,e)}var m=Object.getPrototypeOf((function(){})),g=Object.setPrototypeOf((i(n={get stream(){return this[d]},next:function(){var e=this,r=this[u];if(null!==r)return Promise.reject(r);if(this[c])return Promise.resolve(h(void 0,!0));if(this[d].destroyed)return new Promise((function(r,n){t.nextTick((function(){e[u]?n(e[u]):r(h(void 0,!0))}))}));var n,i=this[f];if(i)n=new Promise(function(e,t){return function(r,n){e.then((function(){t[c]?r(h(void 0,!0)):t[l](r,n)}),n)}}(i,this));else{var o=this[d].read();if(null!==o)return Promise.resolve(h(o,!1));n=new Promise(this[l])}return this[f]=n,n}},Symbol.asyncIterator,(function(){return this})),i(n,"return",(function(){var e=this;return new Promise((function(t,r){e[d].destroy(null,(function(e){e?r(e):t(h(void 0,!0))}))}))})),n),m);e.exports=function(e){var t,r=Object.create(g,(i(t={},d,{value:e,writable:!0}),i(t,a,{value:null,writable:!0}),i(t,s,{value:null,writable:!0}),i(t,u,{value:null,writable:!0}),i(t,c,{value:e._readableState.endEmitted,writable:!0}),i(t,l,{value:function(e,t){var n=r[d].read();n?(r[f]=null,r[a]=null,r[s]=null,e(h(n,!1))):(r[a]=e,r[s]=t)},writable:!0}),t));return r[f]=null,o(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=r[s];return null!==t&&(r[f]=null,r[a]=null,r[s]=null,t(e)),void(r[u]=e)}var n=r[a];null!==n&&(r[f]=null,r[a]=null,r[s]=null,n(h(void 0,!0))),r[c]=!0})),e.on("readable",b.bind(null,r)),r}}).call(this,r(10))},function(e,t){e.exports=function(){throw new Error("Readable.from is not available in the browser")}},function(e,t,r){"use strict";e.exports=i;var n=r(108);function i(e){if(!(this instanceof i))return new i(e);n.call(this,e)}r(2)(i,n),i.prototype._transform=function(e,t,r){r(null,e)}},function(e,t,r){"use strict";var n;var i=r(28).codes,o=i.ERR_MISSING_ARGS,a=i.ERR_STREAM_DESTROYED;function s(e){if(e)throw e}function u(e,t,i,o){o=function(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}(o);var s=!1;e.on("close",(function(){s=!0})),void 0===n&&(n=r(71)),n(e,{readable:t,writable:i},(function(e){if(e)return o(e);s=!0,o()}));var u=!1;return function(t){if(!s&&!u)return u=!0,function(e){return e.setHeader&&"function"==typeof e.abort}(e)?e.abort():"function"==typeof e.destroy?e.destroy():void o(t||new a("pipe"))}}function c(e){e()}function f(e,t){return e.pipe(t)}function l(e){return e.length?"function"!=typeof e[e.length-1]?s:e.pop():s}e.exports=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n,i=l(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new o("streams");var a=t.map((function(e,r){var o=r<t.length-1;return u(e,o,r>0,(function(e){n||(n=e),e&&a.forEach(c),o||(a.forEach(c),i(n))}))}));return t.reduce(f)}},function(e,t,r){var n=r(2),i=r(30),o=r(4).Buffer,a=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(e){return e<<30|e>>>2}function f(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,l=0;l<16;++l)r[l]=e.readInt32BE(4*l);for(;l<80;++l)r[l]=r[l-3]^r[l-8]^r[l-14]^r[l-16];for(var d=0;d<80;++d){var h=~~(d/20),p=0|((t=n)<<5|t>>>27)+f(h,i,o,s)+u+r[d]+a[h];u=s,s=o,o=c(i),i=n,n=p}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var e=o.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},e.exports=u},function(e,t,r){var n=r(2),i=r(30),o=r(4).Buffer,a=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(e){return e<<5|e>>>27}function f(e){return e<<30|e>>>2}function l(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,s=0|this._d,u=0|this._e,d=0;d<16;++d)r[d]=e.readInt32BE(4*d);for(;d<80;++d)r[d]=(t=r[d-3]^r[d-8]^r[d-14]^r[d-16])<<1|t>>>31;for(var h=0;h<80;++h){var p=~~(h/20),b=c(n)+l(p,i,o,s)+u+r[h]+a[p]|0;u=s,s=o,o=f(i),i=n,n=b}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var e=o.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},e.exports=u},function(e,t,r){var n=r(2),i=r(111),o=r(30),a=r(4).Buffer,s=new Array(64);function u(){this.init(),this._w=s,o.call(this,64,56)}n(u,i),u.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},u.prototype._hash=function(){var e=a.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e},e.exports=u},function(e,t,r){var n=r(2),i=r(112),o=r(30),a=r(4).Buffer,s=new Array(160);function u(){this.init(),this._w=s,o.call(this,128,112)}n(u,i),u.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},u.prototype._hash=function(){var e=a.allocUnsafe(48);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e},e.exports=u},function(e,t,r){e.exports=i;var n=r(40).EventEmitter;function i(){n.call(this)}r(31)(i,n),i.Readable=r(73),i.Writable=r(235),i.Duplex=r(236),i.Transform=r(237),i.PassThrough=r(238),i.Stream=i,i.prototype.pipe=function(e,t){var r=this;function i(t){e.writable&&!1===e.write(t)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),e.on("drain",o),e._isStdio||t&&!1===t.end||(r.on("end",s),r.on("close",u));var a=!1;function s(){a||(a=!0,e.end())}function u(){a||(a=!0,"function"==typeof e.destroy&&e.destroy())}function c(e){if(f(),0===n.listenerCount(this,"error"))throw e}function f(){r.removeListener("data",i),e.removeListener("drain",o),r.removeListener("end",s),r.removeListener("close",u),r.removeListener("error",c),e.removeListener("error",c),r.removeListener("end",f),r.removeListener("close",f),e.removeListener("close",f)}return r.on("error",c),e.on("error",c),r.on("end",f),r.on("close",f),e.on("close",f),e.emit("pipe",r),e}},function(e,t){},function(e,t,r){"use strict";var n=r(47).Buffer,i=r(231);e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},e.prototype.concat=function(e){if(0===this.length)return n.alloc(0);for(var t,r,i,o=n.allocUnsafe(e>>>0),a=this.head,s=0;a;)t=a.data,r=o,i=s,t.copy(r,i),s+=a.data.length,a=a.next;return o},e}(),i&&i.inspect&&i.inspect.custom&&(e.exports.prototype[i.inspect.custom]=function(){var e=i.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,r){(function(e){var n=void 0!==e&&e||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;function o(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new o(i.call(setTimeout,n,arguments),clearTimeout)},t.setInterval=function(){return new o(i.call(setInterval,n,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(n,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},r(233),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,r(17))},function(e,t,r){(function(e,t){!function(e,r){"use strict";if(!e.setImmediate){var n,i,o,a,s,u=1,c={},f=!1,l=e.document,d=Object.getPrototypeOf&&Object.getPrototypeOf(e);d=d&&d.setTimeout?d:e,"[object process]"==={}.toString.call(e.process)?n=function(e){t.nextTick((function(){p(e)}))}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,r=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=r,t}}()?e.MessageChannel?((o=new MessageChannel).port1.onmessage=function(e){p(e.data)},n=function(e){o.port2.postMessage(e)}):l&&"onreadystatechange"in l.createElement("script")?(i=l.documentElement,n=function(e){var t=l.createElement("script");t.onreadystatechange=function(){p(e),t.onreadystatechange=null,i.removeChild(t),t=null},i.appendChild(t)}):n=function(e){setTimeout(p,0,e)}:(a="setImmediate$"+Math.random()+"$",s=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(a)&&p(+t.data.slice(a.length))},e.addEventListener?e.addEventListener("message",s,!1):e.attachEvent("onmessage",s),n=function(t){e.postMessage(a+t,"*")}),d.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r<t.length;r++)t[r]=arguments[r+1];var i={callback:e,args:t};return c[u]=i,n(u),u++},d.clearImmediate=h}function h(e){delete c[e]}function p(e){if(f)setTimeout(p,0,e);else{var t=c[e];if(t){f=!0;try{!function(e){var t=e.callback,r=e.args;switch(r.length){case 0:t();break;case 1:t(r[0]);break;case 2:t(r[0],r[1]);break;case 3:t(r[0],r[1],r[2]);break;default:t.apply(void 0,r)}}(t)}finally{h(e),f=!1}}}}}("undefined"==typeof self?void 0===e?this:e:self)}).call(this,r(17),r(10))},function(e,t,r){"use strict";e.exports=o;var n=r(116),i=Object.create(r(42));function o(e){if(!(this instanceof o))return new o(e);n.call(this,e)}i.inherits=r(31),i.inherits(o,n),o.prototype._transform=function(e,t,r){r(null,e)}},function(e,t,r){e.exports=r(74)},function(e,t,r){e.exports=r(23)},function(e,t,r){e.exports=r(73).Transform},function(e,t,r){e.exports=r(73).PassThrough},function(e,t,r){"use strict";var n=r(240),i=r(4).Buffer;e.exports=function(e){function t(t){var r=t.slice(0,-4),n=t.slice(-4),i=e(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(t){var r=e(t);return n.encode(i.concat([t,r],t.length+4))},decode:function(e){var r=t(n.decode(e));if(!r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(e){var r=n.decodeUnsafe(e);if(r)return t(r)}}}},function(e,t,r){var n=r(241);e.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},function(e,t,r){"use strict";var n=r(4).Buffer;e.exports=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var i=0;i<e.length;i++){var o=e.charAt(i),a=o.charCodeAt(0);if(255!==t[a])throw new TypeError(o+" is ambiguous");t[a]=i}var s=e.length,u=e.charAt(0),c=Math.log(s)/Math.log(256),f=Math.log(256)/Math.log(s);function l(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return n.alloc(0);for(var r=0,i=0,o=0;e[r]===u;)i++,r++;for(var a=(e.length-r)*c+1>>>0,f=new Uint8Array(a);e[r];){var l=t[e.charCodeAt(r)];if(255===l)return;for(var d=0,h=a-1;(0!==l||d<o)&&-1!==h;h--,d++)l+=s*f[h]>>>0,f[h]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=d,r++}for(var p=a-o;p!==a&&0===f[p];)p++;var b=n.allocUnsafe(i+(a-p));b.fill(0,0,i);for(var m=i;p!==a;)b[m++]=f[p++];return b}return{encode:function(t){if((Array.isArray(t)||t instanceof Uint8Array)&&(t=n.from(t)),!n.isBuffer(t))throw new TypeError("Expected Buffer");if(0===t.length)return"";for(var r=0,i=0,o=0,a=t.length;o!==a&&0===t[o];)o++,r++;for(var c=(a-o)*f+1>>>0,l=new Uint8Array(c);o!==a;){for(var d=t[o],h=0,p=c-1;(0!==d||h<i)&&-1!==p;p--,h++)d+=256*l[p]>>>0,l[p]=d%s>>>0,d=d/s>>>0;if(0!==d)throw new Error("Non-zero carry");i=h,o++}for(var b=c-i;b!==c&&0===l[b];)b++;for(var m=u.repeat(r);b<c;++b)m+=e.charAt(l[b]);return m},decodeUnsafe:l,decode:function(e){var t=l(e);if(t)return t;throw new Error("Non-base"+s+" character")}}}},function(e,t,r){"use strict";r.r(t),r.d(t,"CURVE",(function(){return c})),r.d(t,"Point",(function(){return v})),r.d(t,"Signature",(function(){return E})),r.d(t,"getPublicKey",(function(){return X})),r.d(t,"recoverPublicKey",(function(){return Y})),r.d(t,"getSharedSecret",(function(){return J})),r.d(t,"sign",(function(){return ne})),r.d(t,"signSync",(function(){return ie})),r.d(t,"verify",(function(){return ae})),r.d(t,"schnorr",(function(){return pe})),r.d(t,"utils",(function(){return ye}));var n=r(153);
|
|
16
16
|
/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */
|
|
17
|
-
const i=BigInt(0),o=BigInt(1),a=BigInt(2),s=BigInt(3),u=BigInt(8),c=Object.freeze({a:i,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:o,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")}),f=(e,t)=>(e+t/a)/t,l={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(e){const{n:t}=c,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-o*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),a=r,s=BigInt("0x100000000000000000000000000000000"),u=f(a*e,t),l=f(-n*e,t);let d=j(e-u*r-l*i,t),h=j(-u*n-l*a,t);const p=d>s,b=h>s;if(p&&(d=t-d),b&&(h=t-h),d>s||h>s)throw new Error("splitScalarEndo: Endomorphism failed, k="+e);return{k1neg:p,k1:d,k2neg:b,k2:h}}};function d(e){const{a:t,b:r}=c,n=j(e*e),i=j(n*e);return j(i+t*e+r)}const h=c.a===i;class p extends Error{constructor(e){super(e)}}function b(e){if(!(e instanceof m))throw new TypeError("JacobianPoint expected")}class m{constructor(e,t,r){this.x=e,this.y=t,this.z=r}static fromAffine(e){if(!(e instanceof v))throw new TypeError("JacobianPoint#fromAffine: expected Point");return e.equals(v.ZERO)?m.ZERO:new m(e.x,e.y,o)}static toAffineBatch(e){const t=function(e,t=c.P){const r=new Array(e.length),n=C(e.reduce((e,n,o)=>n===i?e:(r[o]=e,j(e*n,t)),o),t);return e.reduceRight((e,n,o)=>n===i?e:(r[o]=j(e*r[o],t),j(e*n,t)),n),r}(e.map(e=>e.z));return e.map((e,r)=>e.toAffine(t[r]))}static normalizeZ(e){return m.toAffineBatch(e).map(m.fromAffine)}equals(e){b(e);const{x:t,y:r,z:n}=this,{x:i,y:o,z:a}=e,s=j(n*n),u=j(a*a),c=j(t*u),f=j(i*s),l=j(j(r*a)*u),d=j(j(o*n)*s);return c===f&&l===d}negate(){return new m(this.x,j(-this.y),this.z)}double(){const{x:e,y:t,z:r}=this,n=j(e*e),i=j(t*t),o=j(i*i),c=e+i,f=j(a*(j(c*c)-n-o)),l=j(s*n),d=j(l*l),h=j(d-a*f),p=j(l*(f-h)-u*o),b=j(a*t*r);return new m(h,p,b)}add(e){b(e);const{x:t,y:r,z:n}=this,{x:o,y:s,z:u}=e;if(o===i||s===i)return this;if(t===i||r===i)return e;const c=j(n*n),f=j(u*u),l=j(t*f),d=j(o*c),h=j(j(r*u)*f),p=j(j(s*n)*c),g=j(d-l),y=j(p-h);if(g===i)return y===i?this.double():m.ZERO;const v=j(g*g),w=j(g*v),_=j(l*v),E=j(y*y-w-a*_),k=j(y*(_-E)-h*w),S=j(n*u*g);return new m(E,k,S)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){const t=m.ZERO;if("bigint"==typeof e&&e===i)return t;let r=N(e);if(r===o)return this;if(!h){let e=t,n=this;for(;r>i;)r&o&&(e=e.add(n)),n=n.double(),r>>=o;return e}let{k1neg:n,k1:a,k2neg:s,k2:u}=l.splitScalar(r),c=t,f=t,d=this;for(;a>i||u>i;)a&o&&(c=c.add(d)),u&o&&(f=f.add(d)),d=d.double(),a>>=o,u>>=o;return n&&(c=c.negate()),s&&(f=f.negate()),f=new m(j(f.x*l.beta),f.y,f.z),c.add(f)}precomputeWindow(e){const t=h?128/e+1:256/e+1,r=[];let n=this,i=n;for(let o=0;o<t;o++){i=n,r.push(i);for(let t=1;t<2**(e-1);t++)i=i.add(n),r.push(i);n=i.double()}return r}wNAF(e,t){!t&&this.equals(m.BASE)&&(t=v.BASE);const r=t&&t._WINDOW_SIZE||1;if(256%r)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let n=t&&y.get(t);n||(n=this.precomputeWindow(r),t&&1!==r&&(n=m.normalizeZ(n),y.set(t,n)));let i=m.ZERO,a=m.BASE;const s=1+(h?128/r:256/r),u=2**(r-1),c=BigInt(2**r-1),f=2**r,l=BigInt(r);for(let t=0;t<s;t++){const r=t*u;let s=Number(e&c);e>>=l,s>u&&(s-=f,e+=o);const d=r,h=r+Math.abs(s)-1,p=t%2!=0,b=s<0;0===s?a=a.add(g(p,n[d])):i=i.add(g(b,n[h]))}return{p:i,f:a}}multiply(e,t){let r,n,i=N(e);if(h){const{k1neg:e,k1:o,k2neg:a,k2:s}=l.splitScalar(i);let{p:u,f:c}=this.wNAF(o,t),{p:f,f:d}=this.wNAF(s,t);u=g(e,u),f=g(a,f),f=new m(j(f.x*l.beta),f.y,f.z),r=u.add(f),n=c.add(d)}else{const{p:e,f:o}=this.wNAF(i,t);r=e,n=o}return m.normalizeZ([r,n])[0]}toAffine(e){const{x:t,y:r,z:n}=this,i=this.equals(m.ZERO);null==e&&(e=i?u:C(n));const a=e,s=j(a*a),c=j(s*a),f=j(t*s),l=j(r*c),d=j(n*a);if(i)return v.ZERO;if(d!==o)throw new Error("invZ was invalid");return new v(f,l)}}function g(e,t){const r=t.negate();return e?r:t}m.BASE=new m(c.Gx,c.Gy,o),m.ZERO=new m(i,o,i);const y=new WeakMap;class v{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,y.delete(this)}hasEvenY(){return this.y%a===i}static fromCompressedHex(e){const t=32===e.length,r=M(t?e:e.subarray(1));if(!q(r))throw new Error("Point is not on curve");let n=function(e){const{P:t}=c,r=BigInt(6),n=BigInt(11),i=BigInt(22),o=BigInt(23),u=BigInt(44),f=BigInt(88),l=e*e*e%t,d=l*l*e%t,h=U(d,s)*d%t,p=U(h,s)*d%t,b=U(p,a)*l%t,m=U(b,n)*b%t,g=U(m,i)*m%t,y=U(g,u)*g%t,v=U(y,f)*y%t,w=U(v,u)*g%t,_=U(w,s)*d%t,E=U(_,o)*m%t,k=U(E,r)*l%t,S=U(k,a);if(S*S%t!==e)throw new Error("Cannot find square root");return S}(d(r));const i=(n&o)===o;if(t)i&&(n=j(-n));else{1==(1&e[0])!==i&&(n=j(-n))}const u=new v(r,n);return u.assertValidity(),u}static fromUncompressedHex(e){const t=M(e.subarray(1,33)),r=M(e.subarray(33,65)),n=new v(t,r);return n.assertValidity(),n}static fromHex(e){const t=R(e),r=t.length,n=t[0];if(32===r)return this.fromCompressedHex(t);if(33===r&&(2===n||3===n))return this.fromCompressedHex(t);if(65===r&&4===n)return this.fromUncompressedHex(t);throw new Error("Point.fromHex: received invalid point. Expected 32-33 compressed bytes or 65 uncompressed bytes, not "+r)}static fromPrivateKey(e){return v.BASE.multiply(W(e))}static fromSignature(e,t,r){const{r:n,s:i}=G(t);if(![0,1,2,3].includes(r))throw new Error("Cannot recover: invalid recovery bit");const o=H(R(e)),{n:a}=c,s=2===r||3===r?n+a:n,u=C(s,a),f=j(-o*u,a),l=j(i*u,a),d=1&r?"03":"02",h=v.fromHex(d+A(s)),p=v.BASE.multiplyAndAddUnsafe(h,f,l);if(!p)throw new Error("Cannot recover signature: point at infinify");return p.assertValidity(),p}toRawBytes(e=!1){return B(this.toHex(e))}toHex(e=!1){const t=A(this.x);if(e){return`${this.hasEvenY()?"02":"03"}${t}`}return`04${t}${A(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const e="Point is not on elliptic curve",{x:t,y:r}=this;if(!q(t)||!q(r))throw new Error(e);const n=j(r*r);if(j(n-d(t))!==i)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new v(this.x,j(-this.y))}double(){return m.fromAffine(this).double().toAffine()}add(e){return m.fromAffine(this).add(m.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return m.fromAffine(this).multiply(e,this).toAffine()}multiplyAndAddUnsafe(e,t,r){const n=m.fromAffine(this),a=t===i||t===o||this!==v.BASE?n.multiplyUnsafe(t):n.multiply(t),s=m.fromAffine(e).multiplyUnsafe(r),u=a.add(s);return u.equals(m.ZERO)?void 0:u.toAffine()}}function w(e){return Number.parseInt(e[0],16)>=8?"00"+e:e}function _(e){if(e.length<2||2!==e[0])throw new Error("Invalid signature integer tag: "+x(e));const t=e[1],r=e.subarray(2,t+2);if(!t||r.length!==t)throw new Error("Invalid signature integer: wrong length");if(0===r[0]&&r[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:M(r),left:e.subarray(t+2)}}v.BASE=new v(c.Gx,c.Gy),v.ZERO=new v(i,i);class E{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromCompact(e){const t=e instanceof Uint8Array,r="Signature.fromCompact";if("string"!=typeof e&&!t)throw new TypeError(r+": Expected string or Uint8Array");const n=t?x(e):e;if(128!==n.length)throw new Error(r+": Expected 64-byte hex");return new E(I(n.slice(0,64)),I(n.slice(64,128)))}static fromDER(e){const t=e instanceof Uint8Array;if("string"!=typeof e&&!t)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:r,s:n}=function(e){if(e.length<2||48!=e[0])throw new Error("Invalid signature tag: "+x(e));if(e[1]!==e.length-2)throw new Error("Invalid signature: incorrect length");const{data:t,left:r}=_(e.subarray(2)),{data:n,left:i}=_(r);if(i.length)throw new Error("Invalid signature: left bytes after parsing: "+x(i));return{r:t,s:n}}(t?e:B(e));return new E(r,n)}static fromHex(e){return this.fromDER(e)}assertValidity(){const{r:e,s:t}=this;if(!F(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!F(t))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const e=c.n>>o;return this.s>e}normalizeS(){return this.hasHighS()?new E(this.r,j(-this.s,c.n)):this}toDERRawBytes(){return B(this.toDERHex())}toDERHex(){const e=w(O(this.s)),t=w(O(this.r)),r=e.length/2,n=t.length/2,i=O(r),o=O(n);return`30${O(n+r+4)}02${o}${t}02${i}${e}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return B(this.toCompactHex())}toCompactHex(){return A(this.r)+A(this.s)}}function k(...e){if(!e.every(e=>e instanceof Uint8Array))throw new Error("Uint8Array list expected");if(1===e.length)return e[0];const t=e.reduce((e,t)=>e+t.length,0),r=new Uint8Array(t);for(let t=0,n=0;t<e.length;t++){const i=e[t];r.set(i,n),n+=i.length}return r}const S=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function x(e){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");let t="";for(let r=0;r<e.length;r++)t+=S[e[r]];return t}const T=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function A(e){if("bigint"!=typeof e)throw new Error("Expected bigint");if(!(i<=e&&e<T))throw new Error("Expected number 0 <= n < 2^256");return e.toString(16).padStart(64,"0")}function P(e){const t=B(A(e));if(32!==t.length)throw new Error("Error: expected 32 bytes");return t}function O(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function I(e){if("string"!=typeof e)throw new TypeError("hexToNumber: expected string, got "+typeof e);return BigInt("0x"+e)}function B(e){if("string"!=typeof e)throw new TypeError("hexToBytes: expected string, got "+typeof e);if(e.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+e.length);const t=new Uint8Array(e.length/2);for(let r=0;r<t.length;r++){const n=2*r,i=e.slice(n,n+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");t[r]=o}return t}function M(e){return I(x(e))}function R(e){return e instanceof Uint8Array?Uint8Array.from(e):B(e)}function N(e){if("number"==typeof e&&Number.isSafeInteger(e)&&e>0)return BigInt(e);if("bigint"==typeof e&&F(e))return e;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function j(e,t=c.P){const r=e%t;return r>=i?r:t+r}function U(e,t){const{P:r}=c;let n=e;for(;t-- >i;)n*=n,n%=r;return n}function C(e,t=c.P){if(e===i||t<=i)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let r=j(e,t),n=t,a=i,s=o,u=o,f=i;for(;r!==i;){const e=n/r,t=n%r,i=a-u*e,o=s-f*e;n=r,r=t,a=u,s=f,u=i,f=o}if(n!==o)throw new Error("invert: does not exist");return j(a,t)}function H(e,t=!1){const r=function(e){const t=8*e.length-256,r=M(e);return t>0?r>>BigInt(t):r}(e);if(t)return r;const{n:n}=c;return r>=n?r-n:r}let z,L;class D{constructor(e,t){if(this.hashLen=e,this.qByteLen=t,"number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");this.v=new Uint8Array(e).fill(1),this.k=new Uint8Array(e).fill(0),this.counter=0}hmac(...e){return ye.hmacSha256(this.k,...e)}hmacSync(...e){return L(this.k,...e)}checkSync(){if("function"!=typeof L)throw new p("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}async reseed(e=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),e),this.v=await this.hmac(this.v),0!==e.length&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),e),this.v=await this.hmac(this.v))}reseedSync(e=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),e),this.v=this.hmacSync(this.v),0!==e.length&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),e),this.v=this.hmacSync(this.v))}async generate(){this.incr();let e=0;const t=[];for(;e<this.qByteLen;){this.v=await this.hmac(this.v);const r=this.v.slice();t.push(r),e+=this.v.length}return k(...t)}generateSync(){this.checkSync(),this.incr();let e=0;const t=[];for(;e<this.qByteLen;){this.v=this.hmacSync(this.v);const r=this.v.slice();t.push(r),e+=this.v.length}return k(...t)}}function F(e){return i<e&&e<c.n}function q(e){return i<e&&e<c.P}function K(e,t,r,n=!0){const{n:a}=c,s=H(e,!0);if(!F(s))return;const u=C(s,a),f=v.BASE.multiply(s),l=j(f.x,a);if(l===i)return;const d=j(u*j(t+r*l,a),a);if(d===i)return;let h=new E(l,d),p=(f.x===h.r?0:2)|Number(f.y&o);return n&&h.hasHighS()&&(h=h.normalizeS(),p^=1),{sig:h,recovery:p}}function W(e){let t;if("bigint"==typeof e)t=e;else if("number"==typeof e&&Number.isSafeInteger(e)&&e>0)t=BigInt(e);else if("string"==typeof e){if(64!==e.length)throw new Error("Expected 32 bytes of private key");t=I(e)}else{if(!(e instanceof Uint8Array))throw new TypeError("Expected valid private key");if(32!==e.length)throw new Error("Expected 32 bytes of private key");t=M(e)}if(!F(t))throw new Error("Expected private key: 0 < key < n");return t}function V(e){return e instanceof v?(e.assertValidity(),e):v.fromHex(e)}function G(e){if(e instanceof E)return e.assertValidity(),e;try{return E.fromDER(e)}catch(t){return E.fromCompact(e)}}function X(e,t=!1){return v.fromPrivateKey(e).toRawBytes(t)}function Y(e,t,r,n=!1){return v.fromSignature(e,t,r).toRawBytes(n)}function $(e){const t=e instanceof Uint8Array,r="string"==typeof e,n=(t||r)&&e.length;return t?33===n||65===n:r?66===n||130===n:e instanceof v}function J(e,t,r=!1){if($(e))throw new TypeError("getSharedSecret: first arg must be private key");if(!$(t))throw new TypeError("getSharedSecret: second arg must be public key");const n=V(t);return n.assertValidity(),n.multiply(W(e)).toRawBytes(r)}function Q(e){return M(e.length>32?e.slice(0,32):e)}function Z(e){const t=Q(e),r=j(t,c.n);return ee(r<i?t:r)}function ee(e){return P(e)}function te(e,t,r){if(null==e)throw new Error(`sign: expected valid message hash, not "${e}"`);const n=R(e),i=W(t),o=[ee(i),Z(n)];if(null!=r){!0===r&&(r=ye.randomBytes(32));const e=R(r);if(32!==e.length)throw new Error("sign: Expected 32 bytes of extra data");o.push(e)}return{seed:k(...o),m:Q(n),d:i}}function re(e,t){const{sig:r,recovery:n}=e,{der:i,recovered:o}=Object.assign({canonical:!0,der:!0},t),a=i?r.toDERRawBytes():r.toCompactRawBytes();return o?[a,n]:a}async function ne(e,t,r={}){const{seed:n,m:i,d:o}=te(e,t,r.extraEntropy),a=new D(32,32);let s;for(await a.reseed(n);!(s=K(await a.generate(),i,o,r.canonical));)await a.reseed();return re(s,r)}function ie(e,t,r={}){const{seed:n,m:i,d:o}=te(e,t,r.extraEntropy),a=new D(32,32);let s;for(a.reseedSync(n);!(s=K(a.generateSync(),i,o,r.canonical));)a.reseedSync();return re(s,r)}const oe={strict:!0};function ae(e,t,r,n=oe){let i;try{i=G(e),t=R(t)}catch(e){return!1}const{r:o,s:a}=i;if(n.strict&&i.hasHighS())return!1;const s=H(t);let u;try{u=V(r)}catch(e){return!1}const{n:f}=c,l=C(a,f),d=j(s*l,f),h=j(o*l,f),p=v.BASE.multiplyAndAddUnsafe(u,d,h);if(!p)return!1;return j(p.x,f)===o}function se(e){return j(M(e),c.n)}class ue{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromHex(e){const t=R(e);if(64!==t.length)throw new TypeError("SchnorrSignature.fromHex: expected 64 bytes, not "+t.length);const r=M(t.subarray(0,32)),n=M(t.subarray(32,64));return new ue(r,n)}assertValidity(){const{r:e,s:t}=this;if(!q(e)||!F(t))throw new Error("Invalid signature")}toHex(){return A(this.r)+A(this.s)}toRawBytes(){return B(this.toHex())}}class ce{constructor(e,t,r=ye.randomBytes()){if(null==e)throw new TypeError(`sign: Expected valid message, not "${e}"`);this.m=R(e);const{x:n,scalar:i}=this.getScalar(W(t));if(this.px=n,this.d=i,this.rand=R(r),32!==this.rand.length)throw new TypeError("sign: Expected 32 bytes of aux randomness")}getScalar(e){const t=v.fromPrivateKey(e),r=t.hasEvenY()?e:c.n-e;return{point:t,scalar:r,x:t.toRawX()}}initNonce(e,t){return P(e^M(t))}finalizeNonce(e){const t=j(M(e),c.n);if(t===i)throw new Error("sign: Creation of signature failed. k is zero");const{point:r,x:n,scalar:o}=this.getScalar(t);return{R:r,rx:n,k:o}}finalizeSig(e,t,r,n){return new ue(e.x,j(t+r*n,c.n)).toRawBytes()}error(){throw new Error("sign: Invalid signature produced")}async calc(){const{m:e,d:t,px:r,rand:n}=this,i=ye.taggedHash,o=this.initNonce(t,await i(me.aux,n)),{R:a,rx:s,k:u}=this.finalizeNonce(await i(me.nonce,o,r,e)),c=se(await i(me.challenge,s,r,e)),f=this.finalizeSig(a,u,c,t);return await de(f,e,r)||this.error(),f}calcSync(){const{m:e,d:t,px:r,rand:n}=this,i=ye.taggedHashSync,o=this.initNonce(t,i(me.aux,n)),{R:a,rx:s,k:u}=this.finalizeNonce(i(me.nonce,o,r,e)),c=se(i(me.challenge,s,r,e)),f=this.finalizeSig(a,u,c,t);return he(f,e,r)||this.error(),f}}function fe(e,t,r){const n=e instanceof ue,i=n?e:ue.fromHex(e);return n&&i.assertValidity(),{...i,m:R(t),P:V(r)}}function le(e,t,r,n){const i=v.BASE.multiplyAndAddUnsafe(t,W(r),j(-n,c.n));return!(!i||!i.hasEvenY()||i.x!==e)}async function de(e,t,r){try{const{r:n,s:i,m:o,P:a}=fe(e,t,r),s=se(await ye.taggedHash(me.challenge,P(n),a.toRawX(),o));return le(n,a,i,s)}catch(e){return!1}}function he(e,t,r){try{const{r:n,s:i,m:o,P:a}=fe(e,t,r),s=se(ye.taggedHashSync(me.challenge,P(n),a.toRawX(),o));return le(n,a,i,s)}catch(e){if(e instanceof p)throw e;return!1}}const pe={Signature:ue,getPublicKey:function(e){return v.fromPrivateKey(e).toRawX()},sign:async function(e,t,r){return new ce(e,t,r).calc()},verify:de,signSync:function(e,t,r){return new ce(e,t,r).calcSync()},verifySync:he};v.BASE._setWindowSize(8);const be={node:n,web:"object"==typeof self&&"crypto"in self?self.crypto:void 0},me={challenge:"BIP0340/challenge",aux:"BIP0340/aux",nonce:"BIP0340/nonce"},ge={},ye={bytesToHex:x,hexToBytes:B,concatBytes:k,mod:j,invert:C,isValidPrivateKey(e){try{return W(e),!0}catch(e){return!1}},_bigintTo32Bytes:P,_normalizePrivateKey:W,hashToPrivateKey:e=>{if((e=R(e)).length<40||e.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");return P(j(M(e),c.n-o)+o)},randomBytes:(e=32)=>{if(be.web)return be.web.getRandomValues(new Uint8Array(e));if(be.node){const{randomBytes:t}=be.node;return Uint8Array.from(t(e))}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>ye.hashToPrivateKey(ye.randomBytes(40)),precompute(e=8,t=v.BASE){const r=t===v.BASE?t:new v(t.x,t.y);return r._setWindowSize(e),r.multiply(s),r},sha256:async(...e)=>{if(be.web){const t=await be.web.subtle.digest("SHA-256",k(...e));return new Uint8Array(t)}if(be.node){const{createHash:t}=be.node,r=t("sha256");return e.forEach(e=>r.update(e)),Uint8Array.from(r.digest())}throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(e,...t)=>{if(be.web){const r=await be.web.subtle.importKey("raw",e,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),n=k(...t),i=await be.web.subtle.sign("HMAC",r,n);return new Uint8Array(i)}if(be.node){const{createHmac:r}=be.node,n=r("sha256",e);return t.forEach(e=>n.update(e)),Uint8Array.from(n.digest())}throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(e,...t)=>{let r=ge[e];if(void 0===r){const t=await ye.sha256(Uint8Array.from(e,e=>e.charCodeAt(0)));r=k(t,t),ge[e]=r}return ye.sha256(r,...t)},taggedHashSync:(e,...t)=>{if("function"!=typeof z)throw new p("sha256Sync is undefined, you need to set it");let r=ge[e];if(void 0===r){const t=z(Uint8Array.from(e,e=>e.charCodeAt(0)));r=k(t,t),ge[e]=r}return z(r,...t)},_JacobianPoint:m};Object.defineProperties(ye,{sha256Sync:{configurable:!1,get:()=>z,set(e){z||(z=e)}},hmacSha256Sync:{configurable:!1,get:()=>L,set(e){L||(L=e)}}})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(244);t.fromSeed=n.fromSeed,t.fromBase58=n.fromBase58,t.fromPublicKey=n.fromPublicKey,t.fromPrivateKey=n.fromPrivateKey},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(245),i=r(39),o=r(248),a=r(3),s=r(69),u=a.BufferN(32),c=a.compile({wif:a.UInt8,bip32:{public:a.UInt32,private:a.UInt32}}),f={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},l=Math.pow(2,31)-1;function d(e){return a.String(e)&&null!==e.match(/^(m\/)?(\d+'?\/)*\d+'?$/)}function h(e){return a.UInt32(e)&&e<=l}class p{constructor(e,t,r,n,i=0,o=0,s=0){this.__D=e,this.__Q=t,this.chainCode=r,this.network=n,this.__DEPTH=i,this.__INDEX=o,this.__PARENT_FINGERPRINT=s,a(c,n),this.lowR=!1}get depth(){return this.__DEPTH}get index(){return this.__INDEX}get parentFingerprint(){return this.__PARENT_FINGERPRINT}get publicKey(){return void 0===this.__Q&&(this.__Q=o.pointFromScalar(this.__D,!0)),this.__Q}get privateKey(){return this.__D}get identifier(){return n.hash160(this.publicKey)}get fingerprint(){return this.identifier.slice(0,4)}get compressed(){return!0}isNeutered(){return void 0===this.__D}neutered(){return g(this.publicKey,this.chainCode,this.network,this.depth,this.index,this.parentFingerprint)}toBase58(){const t=this.network,r=this.isNeutered()?t.bip32.public:t.bip32.private,n=e.allocUnsafe(78);return n.writeUInt32BE(r,0),n.writeUInt8(this.depth,4),n.writeUInt32BE(this.parentFingerprint,5),n.writeUInt32BE(this.index,9),this.chainCode.copy(n,13),this.isNeutered()?this.publicKey.copy(n,45):(n.writeUInt8(0,45),this.privateKey.copy(n,46)),i.encode(n)}toWIF(){if(!this.privateKey)throw new TypeError("Missing private key");return s.encode(this.network.wif,this.privateKey,!0)}derive(t){a(a.UInt32,t);const r=t>=2147483648,i=e.allocUnsafe(37);if(r){if(this.isNeutered())throw new TypeError("Missing private key for hardened child key");i[0]=0,this.privateKey.copy(i,1),i.writeUInt32BE(t,33)}else this.publicKey.copy(i,0),i.writeUInt32BE(t,33);const s=n.hmacSHA512(this.chainCode,i),u=s.slice(0,32),c=s.slice(32);if(!o.isPrivate(u))return this.derive(t+1);let f;if(this.isNeutered()){const e=o.pointAddScalar(this.publicKey,u,!0);if(null===e)return this.derive(t+1);f=g(e,c,this.network,this.depth+1,t,this.fingerprint.readUInt32BE(0))}else{const e=o.privateAdd(this.privateKey,u);if(null==e)return this.derive(t+1);f=m(e,c,this.network,this.depth+1,t,this.fingerprint.readUInt32BE(0))}return f}deriveHardened(e){return a(h,e),this.derive(e+2147483648)}derivePath(e){a(d,e);let t=e.split("/");if("m"===t[0]){if(this.parentFingerprint)throw new TypeError("Expected master, got child");t=t.slice(1)}return t.reduce((e,t)=>{let r;return"'"===t.slice(-1)?(r=parseInt(t.slice(0,-1),10),e.deriveHardened(r)):(r=parseInt(t,10),e.derive(r))},this)}sign(t,r){if(!this.privateKey)throw new Error("Missing private key");if(void 0===r&&(r=this.lowR),!1===r)return o.sign(t,this.privateKey);{let r=o.sign(t,this.privateKey);const n=e.alloc(32,0);let i=0;for(;r[0]>127;)i++,n.writeUIntLE(i,0,6),r=o.signWithEntropy(t,this.privateKey,n);return r}}verify(e,t){return o.verify(e,this.publicKey,t)}}function b(e,t,r){return m(e,t,r)}function m(e,t,r,n,i,s){if(a({privateKey:u,chainCode:u},{privateKey:e,chainCode:t}),r=r||f,!o.isPrivate(e))throw new TypeError("Private key not in range [1, n)");return new p(e,void 0,t,r,n,i,s)}function g(e,t,r,n,i,s){if(a({publicKey:a.BufferN(33),chainCode:u},{publicKey:e,chainCode:t}),r=r||f,!o.isPoint(e))throw new TypeError("Point is not on the curve");return new p(void 0,e,t,r,n,i,s)}t.fromBase58=function(e,t){const r=i.decode(e);if(78!==r.length)throw new TypeError("Invalid buffer length");t=t||f;const n=r.readUInt32BE(0);if(n!==t.bip32.private&&n!==t.bip32.public)throw new TypeError("Invalid network version");const o=r[4],a=r.readUInt32BE(5);if(0===o&&0!==a)throw new TypeError("Invalid parent fingerprint");const s=r.readUInt32BE(9);if(0===o&&0!==s)throw new TypeError("Invalid index");const u=r.slice(13,45);let c;if(n===t.bip32.private){if(0!==r.readUInt8(45))throw new TypeError("Invalid private key");c=m(r.slice(46,78),u,t,o,s,a)}else{c=g(r.slice(45,78),u,t,o,s,a)}return c},t.fromPrivateKey=b,t.fromPublicKey=function(e,t,r){return g(e,t,r)},t.fromSeed=function(t,r){if(a(a.Buffer,t),t.length<16)throw new TypeError("Seed should be at least 128 bits");if(t.length>64)throw new TypeError("Seed should be at most 512 bits");r=r||f;const i=n.hmacSHA512(e.from("Bitcoin seed","utf8"),t);return b(i.slice(0,32),i.slice(32),r)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(70),i=r(76);t.hash160=function(e){const t=n("sha256").update(e).digest();try{return n("rmd160").update(t).digest()}catch(e){return n("ripemd160").update(t).digest()}},t.hmacSHA512=function(e,t){return i("sha512",e).update(t).digest()}},function(e,t,r){"use strict";var n=r(2),i=r(4).Buffer,o=r(72),a=i.alloc(128);function s(e,t){o.call(this,"digest"),"string"==typeof t&&(t=i.from(t)),this._alg=e,this._key=t,t.length>64?t=e(t):t.length<64&&(t=i.concat([t,a],64));for(var r=this._ipad=i.allocUnsafe(64),n=this._opad=i.allocUnsafe(64),s=0;s<64;s++)r[s]=54^t[s],n[s]=92^t[s];this._hash=[r]}n(s,o),s.prototype._update=function(e){this._hash.push(e)},s.prototype._final=function(){var e=this._alg(i.concat(this._hash));return this._alg(i.concat([this._opad,e]))},e.exports=s},function(e,t,r){var n=r(100);e.exports=function(e){return(new n).update(e).digest()}},function(e,t,r){(function(t){const n=r(14),i=new(0,r(118).ec)("secp256k1"),o=r(270),a=t.alloc(32,0),s=t.from("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141","hex"),u=t.from("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f","hex"),c=i.curve.n,f=c.shrn(1),l=i.curve.g;function d(e){return t.isBuffer(e)&&32===e.length}function h(e){return!!d(e)&&e.compare(s)<0}function p(e){if(!t.isBuffer(e))return!1;if(e.length<33)return!1;const r=e[0],n=e.slice(1,33);if(0===n.compare(a))return!1;if(n.compare(u)>=0)return!1;if((2===r||3===r)&&33===e.length){try{w(e)}catch(e){return!1}return!0}const i=e.slice(33);return 0!==i.compare(a)&&(!(i.compare(u)>=0)&&(4===r&&65===e.length))}function b(e){return 4!==e[0]}function m(e){return!!d(e)&&(e.compare(a)>0&&e.compare(s)<0)}function g(e,t){return void 0===e&&void 0!==t?b(t):void 0===e||e}function y(e){return new n(e)}function v(e){return e.toArrayLike(t,"be",32)}function w(e){return i.curve.decodePoint(e)}function _(e,r){return t.from(e._encode(r))}function E(e,r,n){if(!d(e))throw new TypeError("Expected Hash");if(!m(r))throw new TypeError("Expected Private");if(void 0!==n&&!d(n))throw new TypeError("Expected Extra Data (32 bytes)");const i=y(r),a=y(e);let s,u;o(e,r,(function(e){const t=y(e),r=l.mul(t);return!r.isInfinity()&&(s=r.x.umod(c),0!==s.isZero()&&(u=t.invm(c).mul(a.add(i.mul(s))).umod(c),0!==u.isZero()))}),m,n),u.cmp(f)>0&&(u=c.sub(u));const h=t.allocUnsafe(64);return v(s).copy(h,0),v(u).copy(h,32),h}e.exports={isPoint:p,isPointCompressed:function(e){return!!p(e)&&b(e)},isPrivate:m,pointAdd:function(e,t,r){if(!p(e))throw new TypeError("Expected Point");if(!p(t))throw new TypeError("Expected Point");const n=w(e),i=w(t),o=n.add(i);return o.isInfinity()?null:_(o,g(r,e))},pointAddScalar:function(e,t,r){if(!p(e))throw new TypeError("Expected Point");if(!h(t))throw new TypeError("Expected Tweak");const n=g(r,e),i=w(e);if(0===t.compare(a))return _(i,n);const o=y(t),s=l.mul(o),u=i.add(s);return u.isInfinity()?null:_(u,n)},pointCompress:function(e,t){if(!p(e))throw new TypeError("Expected Point");const r=w(e);if(r.isInfinity())throw new TypeError("Expected Point");return _(r,g(t,e))},pointFromScalar:function(e,t){if(!m(e))throw new TypeError("Expected Private");const r=y(e),n=l.mul(r);return n.isInfinity()?null:_(n,g(t))},pointMultiply:function(e,t,r){if(!p(e))throw new TypeError("Expected Point");if(!h(t))throw new TypeError("Expected Tweak");const n=g(r,e),i=w(e),o=y(t),a=i.mul(o);return a.isInfinity()?null:_(a,n)},privateAdd:function(e,t){if(!m(e))throw new TypeError("Expected Private");if(!h(t))throw new TypeError("Expected Tweak");const r=y(e),n=y(t),i=v(r.add(n).umod(c));return m(i)?i:null},privateSub:function(e,t){if(!m(e))throw new TypeError("Expected Private");if(!h(t))throw new TypeError("Expected Tweak");const r=y(e),n=y(t),i=v(r.sub(n).umod(c));return m(i)?i:null},sign:function(e,t){return E(e,t)},signWithEntropy:function(e,t,r){return E(e,t,r)},verify:function(e,r,n,i){if(!d(e))throw new TypeError("Expected Hash");if(!p(r))throw new TypeError("Expected Point");if(!function(e){const r=e.slice(0,32),n=e.slice(32,64);return t.isBuffer(e)&&64===e.length&&r.compare(s)<0&&n.compare(s)<0}(n))throw new TypeError("Expected Signature");const o=w(r),a=y(n.slice(0,32)),u=y(n.slice(32,64));if(i&&u.cmp(f)>0)return!1;if(a.gtn(0)<=0)return!1;if(u.gtn(0)<=0)return!1;const h=y(e),b=u.invm(c),m=h.mul(b).umod(c),g=a.mul(b).umod(c),v=l.mulAdd(m,o,g);return!v.isInfinity()&&v.x.umod(c).eq(a)}}}).call(this,r(0).Buffer)},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t){},function(e){e.exports=JSON.parse('{"name":"elliptic","version":"6.5.4","description":"EC cryptography","main":"lib/elliptic.js","files":["lib"],"scripts":{"lint":"eslint lib test","lint:fix":"npm run lint -- --fix","unit":"istanbul test _mocha --reporter=spec test/index.js","test":"npm run lint && npm run unit","version":"grunt dist && git add dist/"},"repository":{"type":"git","url":"git@github.com:indutny/elliptic"},"keywords":["EC","Elliptic","curve","Cryptography"],"author":"Fedor Indutny <fedor@indutny.com>","license":"MIT","bugs":{"url":"https://github.com/indutny/elliptic/issues"},"homepage":"https://github.com/indutny/elliptic","devDependencies":{"brfs":"^2.0.2","coveralls":"^3.1.0","eslint":"^7.6.0","grunt":"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1","istanbul":"^0.4.5","mocha":"^8.0.1"},"dependencies":{"bn.js":"^4.11.9","brorand":"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1","inherits":"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"}}')},function(e,t){},function(e,t,r){"use strict";var n=r(11),i=r(14),o=r(2),a=r(49),s=n.assert;function u(e){a.call(this,"short",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function c(e,t,r,n){a.BasePoint.call(this,e,"affine"),null===t&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new i(t,16),this.y=new i(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function f(e,t,r,n){a.BasePoint.call(this,e,"jacobian"),null===t&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new i(0)):(this.x=new i(t,16),this.y=new i(r,16),this.z=new i(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}o(u,a),e.exports=u,u.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,r;if(e.beta)t=new i(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=(t=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(e.lambda)r=new i(e.lambda,16);else{var o=this._getEndoRoots(this.n);0===this.g.mul(o[0]).x.cmp(this.g.x.redMul(t))?r=o[0]:(r=o[1],s(0===this.g.mul(r).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:r,basis:e.basis?e.basis.map((function(e){return{a:new i(e.a,16),b:new i(e.b,16)}})):this._getEndoBasis(r)}}},u.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:i.mont(e),r=new i(2).toRed(t).redInvm(),n=r.redNeg(),o=new i(3).toRed(t).redNeg().redSqrt().redMul(r);return[n.redAdd(o).fromRed(),n.redSub(o).fromRed()]},u.prototype._getEndoBasis=function(e){for(var t,r,n,o,a,s,u,c,f,l=this.n.ushrn(Math.floor(this.n.bitLength()/2)),d=e,h=this.n.clone(),p=new i(1),b=new i(0),m=new i(0),g=new i(1),y=0;0!==d.cmpn(0);){var v=h.div(d);c=h.sub(v.mul(d)),f=m.sub(v.mul(p));var w=g.sub(v.mul(b));if(!n&&c.cmp(l)<0)t=u.neg(),r=p,n=c.neg(),o=f;else if(n&&2==++y)break;u=c,h=d,d=c,m=p,p=f,g=b,b=w}a=c.neg(),s=f;var _=n.sqr().add(o.sqr());return a.sqr().add(s.sqr()).cmp(_)>=0&&(a=t,s=r),n.negative&&(n=n.neg(),o=o.neg()),a.negative&&(a=a.neg(),s=s.neg()),[{a:n,b:o},{a:a,b:s}]},u.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),a=i.mul(r.a),s=o.mul(n.a),u=i.mul(r.b),c=o.mul(n.b);return{k1:e.sub(a).sub(s),k2:u.add(c).neg()}},u.prototype.pointFromX=function(e,t){(e=new i(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var o=n.fromRed().isOdd();return(t&&!o||!t&&o)&&(n=n.redNeg()),this.point(e,n)},u.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},u.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o<e.length;o++){var a=this._endoSplit(t[o]),s=e[o],u=s._getBeta();a.k1.negative&&(a.k1.ineg(),s=s.neg(!0)),a.k2.negative&&(a.k2.ineg(),u=u.neg(!0)),n[2*o]=s,n[2*o+1]=u,i[2*o]=a.k1,i[2*o+1]=a.k2}for(var c=this._wnafMulAdd(1,n,i,2*o,r),f=0;f<2*o;f++)n[f]=null,i[f]=null;return c},o(c,a.BasePoint),u.prototype.point=function(e,t,r){return new c(this,e,t,r)},u.prototype.pointFromJSON=function(e,t){return c.fromJSON(this,e,t)},c.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var t=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var r=this.curve,n=function(e){return r.point(e.x.redMul(r.endo.beta),e.y)};e.beta=t,t.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(n)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(n)}}}return t}},c.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},c.fromJSON=function(e,t,r){"string"==typeof t&&(t=JSON.parse(t));var n=e.point(t[0],t[1],r);if(!t[2])return n;function i(t){return e.point(t[0],t[1],r)}var o=t[2];return n.precomputed={beta:null,doubles:o.doubles&&{step:o.doubles.step,points:[n].concat(o.doubles.points.map(i))},naf:o.naf&&{wnd:o.naf.wnd,points:[n].concat(o.naf.points.map(i))}},n},c.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},c.prototype.isInfinity=function(){return this.inf},c.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},c.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),a=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},c.prototype.getX=function(){return this.x.fromRed()},c.prototype.getY=function(){return this.y.fromRed()},c.prototype.mul=function(e){return e=new i(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},c.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},c.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},c.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},c.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},c.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},o(f,a.BasePoint),u.prototype.jpoint=function(e,t,r){return new f(this,e,t,r)},f.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},f.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},f.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(r.redMul(this.z)),s=n.redSub(i),u=o.redSub(a);if(0===s.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=s.redSqr(),f=c.redMul(s),l=n.redMul(c),d=u.redSqr().redIAdd(f).redISub(l).redISub(l),h=u.redMul(l.redISub(d)).redISub(o.redMul(f)),p=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(d,h,p)},f.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),a=r.redSub(n),s=i.redSub(o);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),c=u.redMul(a),f=r.redMul(u),l=s.redSqr().redIAdd(c).redISub(f).redISub(f),d=s.redMul(f.redISub(l)).redISub(i.redMul(c)),h=this.z.redMul(a);return this.curve.jpoint(l,d,h)},f.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var r=this;for(t=0;t<e;t++)r=r.dbl();return r}var n=this.curve.a,i=this.curve.tinv,o=this.x,a=this.y,s=this.z,u=s.redSqr().redSqr(),c=a.redAdd(a);for(t=0;t<e;t++){var f=o.redSqr(),l=c.redSqr(),d=l.redSqr(),h=f.redAdd(f).redIAdd(f).redIAdd(n.redMul(u)),p=o.redMul(l),b=h.redSqr().redISub(p.redAdd(p)),m=p.redISub(b),g=h.redMul(m);g=g.redIAdd(g).redISub(d);var y=c.redMul(s);t+1<e&&(u=u.redMul(d)),o=b,s=y,c=g}return this.curve.jpoint(o,c.redMul(i),s)},f.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},f.prototype._zeroDbl=function(){var e,t,r;if(this.zOne){var n=this.x.redSqr(),i=this.y.redSqr(),o=i.redSqr(),a=this.x.redAdd(i).redSqr().redISub(n).redISub(o);a=a.redIAdd(a);var s=n.redAdd(n).redIAdd(n),u=s.redSqr().redISub(a).redISub(a),c=o.redIAdd(o);c=(c=c.redIAdd(c)).redIAdd(c),e=u,t=s.redMul(a.redISub(u)).redISub(c),r=this.y.redAdd(this.y)}else{var f=this.x.redSqr(),l=this.y.redSqr(),d=l.redSqr(),h=this.x.redAdd(l).redSqr().redISub(f).redISub(d);h=h.redIAdd(h);var p=f.redAdd(f).redIAdd(f),b=p.redSqr(),m=d.redIAdd(d);m=(m=m.redIAdd(m)).redIAdd(m),e=b.redISub(h).redISub(h),t=p.redMul(h.redISub(e)).redISub(m),r=(r=this.y.redMul(this.z)).redIAdd(r)}return this.curve.jpoint(e,t,r)},f.prototype._threeDbl=function(){var e,t,r;if(this.zOne){var n=this.x.redSqr(),i=this.y.redSqr(),o=i.redSqr(),a=this.x.redAdd(i).redSqr().redISub(n).redISub(o);a=a.redIAdd(a);var s=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),u=s.redSqr().redISub(a).redISub(a);e=u;var c=o.redIAdd(o);c=(c=c.redIAdd(c)).redIAdd(c),t=s.redMul(a.redISub(u)).redISub(c),r=this.y.redAdd(this.y)}else{var f=this.z.redSqr(),l=this.y.redSqr(),d=this.x.redMul(l),h=this.x.redSub(f).redMul(this.x.redAdd(f));h=h.redAdd(h).redIAdd(h);var p=d.redIAdd(d),b=(p=p.redIAdd(p)).redAdd(p);e=h.redSqr().redISub(b),r=this.y.redAdd(this.z).redSqr().redISub(l).redISub(f);var m=l.redSqr();m=(m=(m=m.redIAdd(m)).redIAdd(m)).redIAdd(m),t=h.redMul(p.redISub(e)).redISub(m)}return this.curve.jpoint(e,t,r)},f.prototype._dbl=function(){var e=this.curve.a,t=this.x,r=this.y,n=this.z,i=n.redSqr().redSqr(),o=t.redSqr(),a=r.redSqr(),s=o.redAdd(o).redIAdd(o).redIAdd(e.redMul(i)),u=t.redAdd(t),c=(u=u.redIAdd(u)).redMul(a),f=s.redSqr().redISub(c.redAdd(c)),l=c.redISub(f),d=a.redSqr();d=(d=(d=d.redIAdd(d)).redIAdd(d)).redIAdd(d);var h=s.redMul(l).redISub(d),p=r.redAdd(r).redMul(n);return this.curve.jpoint(f,h,p)},f.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr(),n=t.redSqr(),i=e.redAdd(e).redIAdd(e),o=i.redSqr(),a=this.x.redAdd(t).redSqr().redISub(e).redISub(n),s=(a=(a=(a=a.redIAdd(a)).redAdd(a).redIAdd(a)).redISub(o)).redSqr(),u=n.redIAdd(n);u=(u=(u=u.redIAdd(u)).redIAdd(u)).redIAdd(u);var c=i.redIAdd(a).redSqr().redISub(o).redISub(s).redISub(u),f=t.redMul(c);f=(f=f.redIAdd(f)).redIAdd(f);var l=this.x.redMul(s).redISub(f);l=(l=l.redIAdd(l)).redIAdd(l);var d=this.y.redMul(c.redMul(u.redISub(c)).redISub(a.redMul(s)));d=(d=(d=d.redIAdd(d)).redIAdd(d)).redIAdd(d);var h=this.z.redAdd(a).redSqr().redISub(r).redISub(s);return this.curve.jpoint(l,d,h)},f.prototype.mul=function(e,t){return e=new i(e,t),this.curve._wnafMul(this,e)},f.prototype.eq=function(e){if("affine"===e.type)return this.eq(e.toJ());if(this===e)return!0;var t=this.z.redSqr(),r=e.z.redSqr();if(0!==this.x.redMul(r).redISub(e.x.redMul(t)).cmpn(0))return!1;var n=t.redMul(this.z),i=r.redMul(e.z);return 0===this.y.redMul(i).redISub(e.y.redMul(n)).cmpn(0)},f.prototype.eqXToP=function(e){var t=this.z.redSqr(),r=e.toRed(this.curve.red).redMul(t);if(0===this.x.cmp(r))return!0;for(var n=e.clone(),i=this.curve.redN.redMul(t);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},f.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},f.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},function(e,t,r){"use strict";var n=r(14),i=r(2),o=r(49),a=r(11);function s(e){o.call(this,"mont",e),this.a=new n(e.a,16).toRed(this.red),this.b=new n(e.b,16).toRed(this.red),this.i4=new n(4).toRed(this.red).redInvm(),this.two=new n(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function u(e,t,r){o.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new n(t,16),this.z=new n(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}i(s,o),e.exports=s,s.prototype.validate=function(e){var t=e.normalize().x,r=t.redSqr(),n=r.redMul(t).redAdd(r.redMul(this.a)).redAdd(t);return 0===n.redSqrt().redSqr().cmp(n)},i(u,o.BasePoint),s.prototype.decodePoint=function(e,t){return this.point(a.toArray(e,t),1)},s.prototype.point=function(e,t){return new u(this,e,t)},s.prototype.pointFromJSON=function(e){return u.fromJSON(this,e)},u.prototype.precompute=function(){},u.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},u.fromJSON=function(e,t){return new u(e,t[0],t[1]||e.one)},u.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},u.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},u.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),r=e.redSub(t),n=e.redMul(t),i=r.redMul(t.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},u.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},u.prototype.diffAdd=function(e,t){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=e.x.redAdd(e.z),o=e.x.redSub(e.z).redMul(r),a=i.redMul(n),s=t.z.redMul(o.redAdd(a).redSqr()),u=t.x.redMul(o.redISub(a).redSqr());return this.curve.point(s,u)},u.prototype.mul=function(e){for(var t=e.clone(),r=this,n=this.curve.point(null,null),i=[];0!==t.cmpn(0);t.iushrn(1))i.push(t.andln(1));for(var o=i.length-1;o>=0;o--)0===i[o]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},u.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},u.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},u.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},u.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},u.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},function(e,t,r){"use strict";var n=r(11),i=r(14),o=r(2),a=r(49),s=n.assert;function u(e){this.twisted=1!=(0|e.a),this.mOneA=this.twisted&&-1==(0|e.a),this.extended=this.mOneA,a.call(this,"edwards",e),this.a=new i(e.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new i(e.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new i(e.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),s(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|e.c)}function c(e,t,r,n,o){a.BasePoint.call(this,e,"projective"),null===t&&null===r&&null===n?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new i(t,16),this.y=new i(r,16),this.z=n?new i(n,16):this.curve.one,this.t=o&&new i(o,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}o(u,a),e.exports=u,u.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},u.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},u.prototype.jpoint=function(e,t,r,n){return this.point(e,t,r,n)},u.prototype.pointFromX=function(e,t){(e=new i(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr(),n=this.c2.redSub(this.a.redMul(r)),o=this.one.redSub(this.c2.redMul(this.d).redMul(r)),a=n.redMul(o.redInvm()),s=a.redSqrt();if(0!==s.redSqr().redSub(a).cmp(this.zero))throw new Error("invalid point");var u=s.fromRed().isOdd();return(t&&!u||!t&&u)&&(s=s.redNeg()),this.point(e,s)},u.prototype.pointFromY=function(e,t){(e=new i(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr(),n=r.redSub(this.c2),o=r.redMul(this.d).redMul(this.c2).redSub(this.a),a=n.redMul(o.redInvm());if(0===a.cmp(this.zero)){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var s=a.redSqrt();if(0!==s.redSqr().redSub(a).cmp(this.zero))throw new Error("invalid point");return s.fromRed().isOdd()!==t&&(s=s.redNeg()),this.point(s,e)},u.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),r=e.y.redSqr(),n=t.redMul(this.a).redAdd(r),i=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(r)));return 0===n.cmp(i)},o(c,a.BasePoint),u.prototype.pointFromJSON=function(e){return c.fromJSON(this,e)},u.prototype.point=function(e,t,r,n){return new c(this,e,t,r,n)},c.fromJSON=function(e,t){return new c(e,t[0],t[1],t[2])},c.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},c.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},c.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(e),i=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),a=o.redSub(r),s=n.redSub(t),u=i.redMul(a),c=o.redMul(s),f=i.redMul(s),l=a.redMul(o);return this.curve.point(u,c,l,f)},c.prototype._projDbl=function(){var e,t,r,n,i,o,a=this.x.redAdd(this.y).redSqr(),s=this.x.redSqr(),u=this.y.redSqr();if(this.curve.twisted){var c=(n=this.curve._mulA(s)).redAdd(u);this.zOne?(e=a.redSub(s).redSub(u).redMul(c.redSub(this.curve.two)),t=c.redMul(n.redSub(u)),r=c.redSqr().redSub(c).redSub(c)):(i=this.z.redSqr(),o=c.redSub(i).redISub(i),e=a.redSub(s).redISub(u).redMul(o),t=c.redMul(n.redSub(u)),r=c.redMul(o))}else n=s.redAdd(u),i=this.curve._mulC(this.z).redSqr(),o=n.redSub(i).redSub(i),e=this.curve._mulC(a.redISub(n)).redMul(o),t=this.curve._mulC(n).redMul(s.redISub(u)),r=n.redMul(o);return this.curve.point(e,t,r)},c.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},c.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),r=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),i=this.z.redMul(e.z.redAdd(e.z)),o=r.redSub(t),a=i.redSub(n),s=i.redAdd(n),u=r.redAdd(t),c=o.redMul(a),f=s.redMul(u),l=o.redMul(u),d=a.redMul(s);return this.curve.point(c,f,d,l)},c.prototype._projAdd=function(e){var t,r,n=this.z.redMul(e.z),i=n.redSqr(),o=this.x.redMul(e.x),a=this.y.redMul(e.y),s=this.curve.d.redMul(o).redMul(a),u=i.redSub(s),c=i.redAdd(s),f=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(o).redISub(a),l=n.redMul(u).redMul(f);return this.curve.twisted?(t=n.redMul(c).redMul(a.redSub(this.curve._mulA(o))),r=u.redMul(c)):(t=n.redMul(c).redMul(a.redSub(o)),r=this.curve._mulC(u).redMul(c)),this.curve.point(l,t,r)},c.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},c.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},c.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!1)},c.prototype.jmulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!0)},c.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},c.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},c.prototype.getX=function(){return this.normalize(),this.x.fromRed()},c.prototype.getY=function(){return this.normalize(),this.y.fromRed()},c.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},c.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var r=e.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),0===this.x.cmp(t))return!0}},c.prototype.toP=c.prototype.normalize,c.prototype.mixedAdd=c.prototype.add},function(e,t,r){"use strict";t.sha1=r(257),t.sha224=r(258),t.sha256=r(123),t.sha384=r(259),t.sha512=r(124)},function(e,t,r){"use strict";var n=r(15),i=r(43),o=r(122),a=n.rotl32,s=n.sum32,u=n.sum32_5,c=o.ft_1,f=i.BlockHash,l=[1518500249,1859775393,2400959708,3395469782];function d(){if(!(this instanceof d))return new d;f.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}n.inherits(d,f),e.exports=d,d.blockSize=512,d.outSize=160,d.hmacStrength=80,d.padLength=64,d.prototype._update=function(e,t){for(var r=this.W,n=0;n<16;n++)r[n]=e[t+n];for(;n<r.length;n++)r[n]=a(r[n-3]^r[n-8]^r[n-14]^r[n-16],1);var i=this.h[0],o=this.h[1],f=this.h[2],d=this.h[3],h=this.h[4];for(n=0;n<r.length;n++){var p=~~(n/20),b=u(a(i,5),c(p,o,f,d),h,r[n],l[p]);h=d,d=f,f=a(o,30),o=i,i=b}this.h[0]=s(this.h[0],i),this.h[1]=s(this.h[1],o),this.h[2]=s(this.h[2],f),this.h[3]=s(this.h[3],d),this.h[4]=s(this.h[4],h)},d.prototype._digest=function(e){return"hex"===e?n.toHex32(this.h,"big"):n.split32(this.h,"big")}},function(e,t,r){"use strict";var n=r(15),i=r(123);function o(){if(!(this instanceof o))return new o;i.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}n.inherits(o,i),e.exports=o,o.blockSize=512,o.outSize=224,o.hmacStrength=192,o.padLength=64,o.prototype._digest=function(e){return"hex"===e?n.toHex32(this.h.slice(0,7),"big"):n.split32(this.h.slice(0,7),"big")}},function(e,t,r){"use strict";var n=r(15),i=r(124);function o(){if(!(this instanceof o))return new o;i.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}n.inherits(o,i),e.exports=o,o.blockSize=1024,o.outSize=384,o.hmacStrength=192,o.padLength=128,o.prototype._digest=function(e){return"hex"===e?n.toHex32(this.h.slice(0,12),"big"):n.split32(this.h.slice(0,12),"big")}},function(e,t,r){"use strict";var n=r(15),i=r(43),o=n.rotl32,a=n.sum32,s=n.sum32_3,u=n.sum32_4,c=i.BlockHash;function f(){if(!(this instanceof f))return new f;c.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}function l(e,t,r,n){return e<=15?t^r^n:e<=31?t&r|~t&n:e<=47?(t|~r)^n:e<=63?t&n|r&~n:t^(r|~n)}function d(e){return e<=15?0:e<=31?1518500249:e<=47?1859775393:e<=63?2400959708:2840853838}function h(e){return e<=15?1352829926:e<=31?1548603684:e<=47?1836072691:e<=63?2053994217:0}n.inherits(f,c),t.ripemd160=f,f.blockSize=512,f.outSize=160,f.hmacStrength=192,f.padLength=64,f.prototype._update=function(e,t){for(var r=this.h[0],n=this.h[1],i=this.h[2],c=this.h[3],f=this.h[4],y=r,v=n,w=i,_=c,E=f,k=0;k<80;k++){var S=a(o(u(r,l(k,n,i,c),e[p[k]+t],d(k)),m[k]),f);r=f,f=c,c=o(i,10),i=n,n=S,S=a(o(u(y,l(79-k,v,w,_),e[b[k]+t],h(k)),g[k]),E),y=E,E=_,_=o(w,10),w=v,v=S}S=s(this.h[1],i,_),this.h[1]=s(this.h[2],c,E),this.h[2]=s(this.h[3],f,y),this.h[3]=s(this.h[4],r,v),this.h[4]=s(this.h[0],n,w),this.h[0]=S},f.prototype._digest=function(e){return"hex"===e?n.toHex32(this.h,"little"):n.split32(this.h,"little")};var p=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],b=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],m=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],g=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]},function(e,t,r){"use strict";var n=r(15),i=r(24);function o(e,t,r){if(!(this instanceof o))return new o(e,t,r);this.Hash=e,this.blockSize=e.blockSize/8,this.outSize=e.outSize/8,this.inner=null,this.outer=null,this._init(n.toArray(t,r))}e.exports=o,o.prototype._init=function(e){e.length>this.blockSize&&(e=(new this.Hash).update(e).digest()),i(e.length<=this.blockSize);for(var t=e.length;t<this.blockSize;t++)e.push(0);for(t=0;t<e.length;t++)e[t]^=54;for(this.inner=(new this.Hash).update(e),t=0;t<e.length;t++)e[t]^=106;this.outer=(new this.Hash).update(e)},o.prototype.update=function(e,t){return this.inner.update(e,t),this},o.prototype.digest=function(e){return this.outer.update(this.inner.digest()),this.outer.digest(e)}},function(e,t){e.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}},function(e,t,r){"use strict";var n=r(14),i=r(264),o=r(11),a=r(77),s=r(120),u=o.assert,c=r(265),f=r(266);function l(e){if(!(this instanceof l))return new l(e);"string"==typeof e&&(u(Object.prototype.hasOwnProperty.call(a,e),"Unknown curve "+e),e=a[e]),e instanceof a.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}e.exports=l,l.prototype.keyPair=function(e){return new c(this,e)},l.prototype.keyFromPrivate=function(e,t){return c.fromPrivate(this,e,t)},l.prototype.keyFromPublic=function(e,t){return c.fromPublic(this,e,t)},l.prototype.genKeyPair=function(e){e||(e={});for(var t=new i({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||s(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),o=this.n.sub(new n(2));;){var a=new n(t.generate(r));if(!(a.cmp(o)>0))return a.iaddn(1),this.keyFromPrivate(a)}},l.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},l.prototype.sign=function(e,t,r,o){"object"==typeof r&&(o=r,r=null),o||(o={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new n(e,16));for(var a=this.n.byteLength(),s=t.getPrivate().toArray("be",a),u=e.toArray("be",a),c=new i({hash:this.hash,entropy:s,nonce:u,pers:o.pers,persEnc:o.persEnc||"utf8"}),l=this.n.sub(new n(1)),d=0;;d++){var h=o.k?o.k(d):new n(c.generate(this.n.byteLength()));if(!((h=this._truncateToN(h,!0)).cmpn(1)<=0||h.cmp(l)>=0)){var p=this.g.mul(h);if(!p.isInfinity()){var b=p.getX(),m=b.umod(this.n);if(0!==m.cmpn(0)){var g=h.invm(this.n).mul(m.mul(t.getPrivate()).iadd(e));if(0!==(g=g.umod(this.n)).cmpn(0)){var y=(p.getY().isOdd()?1:0)|(0!==b.cmp(m)?2:0);return o.canonical&&g.cmp(this.nh)>0&&(g=this.n.sub(g),y^=1),new f({r:m,s:g,recoveryParam:y})}}}}}},l.prototype.verify=function(e,t,r,i){e=this._truncateToN(new n(e,16)),r=this.keyFromPublic(r,i);var o=(t=new f(t,"hex")).r,a=t.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var s,u=a.invm(this.n),c=u.mul(e).umod(this.n),l=u.mul(o).umod(this.n);return this.curve._maxwellTrick?!(s=this.g.jmulAdd(c,r.getPublic(),l)).isInfinity()&&s.eqXToP(o):!(s=this.g.mulAdd(c,r.getPublic(),l)).isInfinity()&&0===s.getX().umod(this.n).cmp(o)},l.prototype.recoverPubKey=function(e,t,r,i){u((3&r)===r,"The recovery param is more than two bits"),t=new f(t,i);var o=this.n,a=new n(e),s=t.r,c=t.s,l=1&r,d=r>>1;if(s.cmp(this.curve.p.umod(this.curve.n))>=0&&d)throw new Error("Unable to find sencond key candinate");s=d?this.curve.pointFromX(s.add(this.curve.n),l):this.curve.pointFromX(s,l);var h=t.r.invm(o),p=o.sub(a).mul(h).umod(o),b=c.mul(h).umod(o);return this.g.mulAdd(p,s,b)},l.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new f(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},function(e,t,r){"use strict";var n=r(78),i=r(119),o=r(24);function a(e){if(!(this instanceof a))return new a(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=i.toArray(e.entropy,e.entropyEnc||"hex"),r=i.toArray(e.nonce,e.nonceEnc||"hex"),n=i.toArray(e.pers,e.persEnc||"hex");o(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}e.exports=a,a.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i<this.V.length;i++)this.K[i]=0,this.V[i]=1;this._update(n),this._reseed=1,this.reseedInterval=281474976710656},a.prototype._hmac=function(){return new n.hmac(this.hash,this.K)},a.prototype._update=function(e){var t=this._hmac().update(this.V).update([0]);e&&(t=t.update(e)),this.K=t.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())},a.prototype.reseed=function(e,t,r,n){"string"!=typeof t&&(n=r,r=t,t=null),e=i.toArray(e,t),r=i.toArray(r,n),o(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},a.prototype.generate=function(e,t,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var o=[];o.length<e;)this.V=this._hmac().update(this.V).digest(),o=o.concat(this.V);var a=o.slice(0,e);return this._update(r),this._reseed++,i.encode(a,t)}},function(e,t,r){"use strict";var n=r(14),i=r(11).assert;function o(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}e.exports=o,o.fromPublic=function(e,t,r){return t instanceof o?t:new o(e,{pub:t,pubEnc:r})},o.fromPrivate=function(e,t,r){return t instanceof o?t:new o(e,{priv:t,privEnc:r})},o.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},o.prototype.getPublic=function(e,t){return"string"==typeof e&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},o.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},o.prototype._importPrivate=function(e,t){this.priv=new n(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},o.prototype._importPublic=function(e,t){if(e.x||e.y)return"mont"===this.ec.curve.type?i(e.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||i(e.x&&e.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(e.x,e.y));this.pub=this.ec.curve.decodePoint(e,t)},o.prototype.derive=function(e){return e.validate()||i(e.validate(),"public point not validated"),e.mul(this.priv).getX()},o.prototype.sign=function(e,t,r){return this.ec.sign(e,this,t,r)},o.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},o.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"}},function(e,t,r){"use strict";var n=r(14),i=r(11),o=i.assert;function a(e,t){if(e instanceof a)return e;this._importDER(e,t)||(o(e.r&&e.s,"Signature without r or s"),this.r=new n(e.r,16),this.s=new n(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function s(){this.place=0}function u(e,t){var r=e[t.place++];if(!(128&r))return r;var n=15&r;if(0===n||n>4)return!1;for(var i=0,o=0,a=t.place;o<n;o++,a++)i<<=8,i|=e[a],i>>>=0;return!(i<=127)&&(t.place=a,i)}function c(e){for(var t=0,r=e.length-1;!e[t]&&!(128&e[t+1])&&t<r;)t++;return 0===t?e:e.slice(t)}function f(e,t){if(t<128)e.push(t);else{var r=1+(Math.log(t)/Math.LN2>>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}e.exports=a,a.prototype._importDER=function(e,t){e=i.toArray(e,t);var r=new s;if(48!==e[r.place++])return!1;var o=u(e,r);if(!1===o)return!1;if(o+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var a=u(e,r);if(!1===a)return!1;var c=e.slice(r.place,a+r.place);if(r.place+=a,2!==e[r.place++])return!1;var f=u(e,r);if(!1===f)return!1;if(e.length!==f+r.place)return!1;var l=e.slice(r.place,f+r.place);if(0===c[0]){if(!(128&c[1]))return!1;c=c.slice(1)}if(0===l[0]){if(!(128&l[1]))return!1;l=l.slice(1)}return this.r=new n(c),this.s=new n(l),this.recoveryParam=null,!0},a.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=c(t),r=c(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];f(n,t.length),(n=n.concat(t)).push(2),f(n,r.length);var o=n.concat(r),a=[48];return f(a,o.length),a=a.concat(o),i.encode(a,e)}},function(e,t,r){"use strict";var n=r(78),i=r(77),o=r(11),a=o.assert,s=o.parseBytes,u=r(268),c=r(269);function f(e){if(a("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof f))return new f(e);e=i[e].curve,this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=n.sha512}e.exports=f,f.prototype.sign=function(e,t){e=s(e);var r=this.keyFromSecret(t),n=this.hashInt(r.messagePrefix(),e),i=this.g.mul(n),o=this.encodePoint(i),a=this.hashInt(o,r.pubBytes(),e).mul(r.priv()),u=n.add(a).umod(this.curve.n);return this.makeSignature({R:i,S:u,Rencoded:o})},f.prototype.verify=function(e,t,r){e=s(e),t=this.makeSignature(t);var n=this.keyFromPublic(r),i=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S());return t.R().add(n.pub().mul(i)).eq(o)},f.prototype.hashInt=function(){for(var e=this.hash(),t=0;t<arguments.length;t++)e.update(arguments[t]);return o.intFromLE(e.digest()).umod(this.curve.n)},f.prototype.keyFromPublic=function(e){return u.fromPublic(this,e)},f.prototype.keyFromSecret=function(e){return u.fromSecret(this,e)},f.prototype.makeSignature=function(e){return e instanceof c?e:new c(this,e)},f.prototype.encodePoint=function(e){var t=e.getY().toArray("le",this.encodingLength);return t[this.encodingLength-1]|=e.getX().isOdd()?128:0,t},f.prototype.decodePoint=function(e){var t=(e=o.parseBytes(e)).length-1,r=e.slice(0,t).concat(-129&e[t]),n=0!=(128&e[t]),i=o.intFromLE(r);return this.curve.pointFromY(i,n)},f.prototype.encodeInt=function(e){return e.toArray("le",this.encodingLength)},f.prototype.decodeInt=function(e){return o.intFromLE(e)},f.prototype.isPoint=function(e){return e instanceof this.pointClass}},function(e,t,r){"use strict";var n=r(11),i=n.assert,o=n.parseBytes,a=n.cachedProperty;function s(e,t){this.eddsa=e,this._secret=o(t.secret),e.isPoint(t.pub)?this._pub=t.pub:this._pubBytes=o(t.pub)}s.fromPublic=function(e,t){return t instanceof s?t:new s(e,{pub:t})},s.fromSecret=function(e,t){return t instanceof s?t:new s(e,{secret:t})},s.prototype.secret=function(){return this._secret},a(s,"pubBytes",(function(){return this.eddsa.encodePoint(this.pub())})),a(s,"pub",(function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())})),a(s,"privBytes",(function(){var e=this.eddsa,t=this.hash(),r=e.encodingLength-1,n=t.slice(0,e.encodingLength);return n[0]&=248,n[r]&=127,n[r]|=64,n})),a(s,"priv",(function(){return this.eddsa.decodeInt(this.privBytes())})),a(s,"hash",(function(){return this.eddsa.hash().update(this.secret()).digest()})),a(s,"messagePrefix",(function(){return this.hash().slice(this.eddsa.encodingLength)})),s.prototype.sign=function(e){return i(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)},s.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)},s.prototype.getSecret=function(e){return i(this._secret,"KeyPair is public only"),n.encode(this.secret(),e)},s.prototype.getPublic=function(e){return n.encode(this.pubBytes(),e)},e.exports=s},function(e,t,r){"use strict";var n=r(14),i=r(11),o=i.assert,a=i.cachedProperty,s=i.parseBytes;function u(e,t){this.eddsa=e,"object"!=typeof t&&(t=s(t)),Array.isArray(t)&&(t={R:t.slice(0,e.encodingLength),S:t.slice(e.encodingLength)}),o(t.R&&t.S,"Signature without R or S"),e.isPoint(t.R)&&(this._R=t.R),t.S instanceof n&&(this._S=t.S),this._Rencoded=Array.isArray(t.R)?t.R:t.Rencoded,this._Sencoded=Array.isArray(t.S)?t.S:t.Sencoded}a(u,"S",(function(){return this.eddsa.decodeInt(this.Sencoded())})),a(u,"R",(function(){return this.eddsa.decodePoint(this.Rencoded())})),a(u,"Rencoded",(function(){return this.eddsa.encodePoint(this.R())})),a(u,"Sencoded",(function(){return this.eddsa.encodeInt(this.S())})),u.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},u.prototype.toHex=function(){return i.encode(this.toBytes(),"hex").toUpperCase()},e.exports=u},function(e,t,r){(function(t){const n=r(76),i=t.alloc(1,1),o=t.alloc(1,0);e.exports=function(e,r,a,s,u){let c=t.alloc(32,0),f=t.alloc(32,1);c=n("sha256",c).update(f).update(o).update(r).update(e).update(u||"").digest(),f=n("sha256",c).update(f).digest(),c=n("sha256",c).update(f).update(i).update(r).update(e).update(u||"").digest(),f=n("sha256",c).update(f).digest(),f=n("sha256",c).update(f).digest();let l=f;for(;!s(l)||!a(l);)c=n("sha256",c).update(f).update(o).digest(),f=n("sha256",c).update(f).digest(),f=n("sha256",c).update(f).digest(),l=f;return l}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(12),i=r(1),o=r(26),a=r(3),s=i.OPS;t.p2data=function(e,t){if(!e.data&&!e.output)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),a({network:a.maybe(a.Object),output:a.maybe(a.Buffer),data:a.maybe(a.arrayOf(a.Buffer))},e);const r={name:"embed",network:e.network||n.bitcoin};if(o.prop(r,"output",()=>{if(e.data)return i.compile([s.OP_RETURN].concat(e.data))}),o.prop(r,"data",()=>{if(e.output)return i.decompile(e.output).slice(1)}),t.validate&&e.output){const t=i.decompile(e.output);if(t[0]!==s.OP_RETURN)throw new TypeError("Output is invalid");if(!t.slice(1).every(a.Buffer))throw new TypeError("Output is invalid");if(e.data&&!function(e,t){return e.length===t.length&&e.every((e,r)=>e.equals(t[r]))}(e.data,r.data))throw new TypeError("Data mismatch")}return Object.assign(r,e)}},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.decode=function(e,t,r){t=t||4,r=void 0===r||r;const n=e.length;if(0===n)return 0;if(n>t)throw new TypeError("Script number overflow");if(r&&0==(127&e[n-1])&&(n<=1||0==(128&e[n-2])))throw new Error("Non-minimally encoded script number");if(5===n){const t=e.readUInt32LE(0),r=e.readUInt8(4);return 128&r?-(4294967296*(-129&r)+t):4294967296*r+t}let i=0;for(let t=0;t<n;++t)i|=e[t]<<8*t;return 128&e[n-1]?-(i&~(128<<8*(n-1))):i},t.encode=function(t){let r=Math.abs(t);const n=(i=r)>2147483647?5:i>8388607?4:i>32767?3:i>127?2:i>0?1:0;var i;const o=e.allocUnsafe(n),a=t<0;for(let e=0;e<n;++e)o.writeUInt8(255&r,e),r>>=8;return 128&o[n-1]?o.writeUInt8(a?128:0,n-1):a&&(o[n-1]|=128),o}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(16),i=r(125),o=r(3),a=e.alloc(1,0);function s(t){let r=0;for(;0===t[r];)++r;return r===t.length?a:128&(t=t.slice(r))[0]?e.concat([a,t],1+t.length):t}function u(t){0===t[0]&&(t=t.slice(1));const r=e.alloc(32,0),n=Math.max(0,32-t.length);return t.copy(r,n),r}t.decode=function(t){const r=t.readUInt8(t.length-1),n=-129&r;if(n<=0||n>=4)throw new Error("Invalid hashType "+r);const o=i.decode(t.slice(0,-1)),a=u(o.r),s=u(o.s);return{signature:e.concat([a,s],64),hashType:r}},t.encode=function(t,r){o({signature:n.BufferN(64),hashType:n.UInt8},{signature:t,hashType:r});const a=-129&r;if(a<=0||a>=4)throw new Error("Invalid hashType "+r);const u=e.allocUnsafe(1);u.writeUInt8(r,0);const c=s(t.slice(0,32)),f=s(t.slice(32,64));return e.concat([i.encode(c,f),u])}}).call(this,r(0).Buffer)},function(e,t,r){(function(t){const n=r(76),i=t.alloc(1,1),o=t.alloc(1,0);e.exports=function(e,r,a,s,u){let c=t.alloc(32,0),f=t.alloc(32,1);c=n("sha256",c).update(f).update(o).update(r).update(e).update(u||"").digest(),f=n("sha256",c).update(f).digest(),c=n("sha256",c).update(f).update(i).update(r).update(e).update(u||"").digest(),f=n("sha256",c).update(f).digest(),f=n("sha256",c).update(f).digest();let l=f;for(;!s(l)||!a(l);)c=n("sha256",c).update(f).update(o).digest(),f=n("sha256",c).update(f).digest(),f=n("sha256",c).update(f).digest(),l=f;return l}}).call(this,r(0).Buffer)},function(e,t,r){var n=r(80);function i(e){return e<n.OP_PUSHDATA1?1:e<=255?2:e<=65535?3:5}e.exports={encodingLength:i,encode:function(e,t,r){var o=i(t);return 1===o?e.writeUInt8(t,r):2===o?(e.writeUInt8(n.OP_PUSHDATA1,r),e.writeUInt8(t,r+1)):3===o?(e.writeUInt8(n.OP_PUSHDATA2,r),e.writeUInt16LE(t,r+1)):(e.writeUInt8(n.OP_PUSHDATA4,r),e.writeUInt32LE(t,r+1)),o},decode:function(e,t){var r,i,o=e.readUInt8(t);if(o<n.OP_PUSHDATA1)r=o,i=1;else if(o===n.OP_PUSHDATA1){if(t+2>e.length)return null;r=e.readUInt8(t+1),i=2}else if(o===n.OP_PUSHDATA2){if(t+3>e.length)return null;r=e.readUInt16LE(t+1),i=3}else{if(t+5>e.length)return null;if(o!==n.OP_PUSHDATA4)throw new Error("Unexpected opcode");r=e.readUInt32LE(t+1),i=5}return{opcode:o,number:r,size:i}}}},function(e,t,r){var n=r(80),i={};for(var o in n){i[n[o]]=o}e.exports=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(12),i=r(1),o=r(26),a=i.OPS,s=r(3),u=r(25),c=a.OP_RESERVED;function f(e,t){return e.length===t.length&&e.every((e,r)=>e.equals(t[r]))}t.p2ms=function(e,t){if(!(e.input||e.output||e.pubkeys&&void 0!==e.m||e.signatures))throw new TypeError("Not enough data");function r(e){return i.isCanonicalScriptSignature(e)||void 0!==(t.allowIncomplete&&e===a.OP_0)}t=Object.assign({validate:!0},t||{}),s({network:s.maybe(s.Object),m:s.maybe(s.Number),n:s.maybe(s.Number),output:s.maybe(s.Buffer),pubkeys:s.maybe(s.arrayOf(u.isPoint)),signatures:s.maybe(s.arrayOf(r)),input:s.maybe(s.Buffer)},e);const l={network:e.network||n.bitcoin};let d=[],h=!1;function p(e){h||(h=!0,d=i.decompile(e),l.m=d[0]-c,l.n=d[d.length-2]-c,l.pubkeys=d.slice(1,-2))}if(o.prop(l,"output",()=>{if(e.m&&l.n&&e.pubkeys)return i.compile([].concat(c+e.m,e.pubkeys,c+l.n,a.OP_CHECKMULTISIG))}),o.prop(l,"m",()=>{if(l.output)return p(l.output),l.m}),o.prop(l,"n",()=>{if(l.pubkeys)return l.pubkeys.length}),o.prop(l,"pubkeys",()=>{if(e.output)return p(e.output),l.pubkeys}),o.prop(l,"signatures",()=>{if(e.input)return i.decompile(e.input).slice(1)}),o.prop(l,"input",()=>{if(e.signatures)return i.compile([a.OP_0].concat(e.signatures))}),o.prop(l,"witness",()=>{if(l.input)return[]}),o.prop(l,"name",()=>{if(l.m&&l.n)return`p2ms(${l.m} of ${l.n})`}),t.validate){if(e.output){if(p(e.output),!s.Number(d[0]))throw new TypeError("Output is invalid");if(!s.Number(d[d.length-2]))throw new TypeError("Output is invalid");if(d[d.length-1]!==a.OP_CHECKMULTISIG)throw new TypeError("Output is invalid");if(l.m<=0||l.n>16||l.m>l.n||l.n!==d.length-3)throw new TypeError("Output is invalid");if(!l.pubkeys.every(e=>u.isPoint(e)))throw new TypeError("Output is invalid");if(void 0!==e.m&&e.m!==l.m)throw new TypeError("m mismatch");if(void 0!==e.n&&e.n!==l.n)throw new TypeError("n mismatch");if(e.pubkeys&&!f(e.pubkeys,l.pubkeys))throw new TypeError("Pubkeys mismatch")}if(e.pubkeys){if(void 0!==e.n&&e.n!==e.pubkeys.length)throw new TypeError("Pubkey count mismatch");if(l.n=e.pubkeys.length,l.n<l.m)throw new TypeError("Pubkey count cannot be less than m")}if(e.signatures){if(e.signatures.length<l.m)throw new TypeError("Not enough signatures provided");if(e.signatures.length>l.m)throw new TypeError("Too many signatures provided")}if(e.input){if(e.input[0]!==a.OP_0)throw new TypeError("Input is invalid");if(0===l.signatures.length||!l.signatures.every(r))throw new TypeError("Input has invalid signature(s)");if(e.signatures&&!f(e.signatures,l.signatures))throw new TypeError("Signature mismatch");if(void 0!==e.m&&e.m!==e.signatures.length)throw new TypeError("Signature count mismatch")}}return Object.assign(l,e)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(12),i=r(1),o=r(26),a=r(3),s=i.OPS,u=r(25);t.p2pk=function(e,t){if(!(e.input||e.output||e.pubkey||e.input||e.signature))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),a({network:a.maybe(a.Object),output:a.maybe(a.Buffer),pubkey:a.maybe(u.isPoint),signature:a.maybe(i.isCanonicalScriptSignature),input:a.maybe(a.Buffer)},e);const r=o.value(()=>i.decompile(e.input)),c={name:"p2pk",network:e.network||n.bitcoin};if(o.prop(c,"output",()=>{if(e.pubkey)return i.compile([e.pubkey,s.OP_CHECKSIG])}),o.prop(c,"pubkey",()=>{if(e.output)return e.output.slice(1,-1)}),o.prop(c,"signature",()=>{if(e.input)return r()[0]}),o.prop(c,"input",()=>{if(e.signature)return i.compile([e.signature])}),o.prop(c,"witness",()=>{if(c.input)return[]}),t.validate){if(e.output){if(e.output[e.output.length-1]!==s.OP_CHECKSIG)throw new TypeError("Output is invalid");if(!u.isPoint(c.pubkey))throw new TypeError("Output pubkey is invalid");if(e.pubkey&&!e.pubkey.equals(c.pubkey))throw new TypeError("Pubkey mismatch")}if(e.signature&&e.input&&!e.input.equals(c.input))throw new TypeError("Signature mismatch");if(e.input){if(1!==r().length)throw new TypeError("Input is invalid");if(!i.isCanonicalScriptSignature(c.signature))throw new TypeError("Input has invalid signature")}}return Object.assign(c,e)}},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(19),i=r(12),o=r(1),a=r(26),s=r(3),u=o.OPS,c=r(25),f=r(39);t.p2pkh=function(t,r){if(!(t.address||t.hash||t.output||t.pubkey||t.input))throw new TypeError("Not enough data");r=Object.assign({validate:!0},r||{}),s({network:s.maybe(s.Object),address:s.maybe(s.String),hash:s.maybe(s.BufferN(20)),output:s.maybe(s.BufferN(25)),pubkey:s.maybe(c.isPoint),signature:s.maybe(o.isCanonicalScriptSignature),input:s.maybe(s.Buffer)},t);const l=a.value(()=>{const e=f.decode(t.address);return{version:e.readUInt8(0),hash:e.slice(1)}}),d=a.value(()=>o.decompile(t.input)),h=t.network||i.bitcoin,p={name:"p2pkh",network:h};if(a.prop(p,"address",()=>{if(!p.hash)return;const t=e.allocUnsafe(21);return t.writeUInt8(h.pubKeyHash,0),p.hash.copy(t,1),f.encode(t)}),a.prop(p,"hash",()=>t.output?t.output.slice(3,23):t.address?l().hash:t.pubkey||p.pubkey?n.hash160(t.pubkey||p.pubkey):void 0),a.prop(p,"output",()=>{if(p.hash)return o.compile([u.OP_DUP,u.OP_HASH160,p.hash,u.OP_EQUALVERIFY,u.OP_CHECKSIG])}),a.prop(p,"pubkey",()=>{if(t.input)return d()[1]}),a.prop(p,"signature",()=>{if(t.input)return d()[0]}),a.prop(p,"input",()=>{if(t.pubkey&&t.signature)return o.compile([t.signature,t.pubkey])}),a.prop(p,"witness",()=>{if(p.input)return[]}),r.validate){let r=e.from([]);if(t.address){if(l().version!==h.pubKeyHash)throw new TypeError("Invalid version or Network mismatch");if(20!==l().hash.length)throw new TypeError("Invalid address");r=l().hash}if(t.hash){if(r.length>0&&!r.equals(t.hash))throw new TypeError("Hash mismatch");r=t.hash}if(t.output){if(25!==t.output.length||t.output[0]!==u.OP_DUP||t.output[1]!==u.OP_HASH160||20!==t.output[2]||t.output[23]!==u.OP_EQUALVERIFY||t.output[24]!==u.OP_CHECKSIG)throw new TypeError("Output is invalid");const e=t.output.slice(3,23);if(r.length>0&&!r.equals(e))throw new TypeError("Hash mismatch");r=e}if(t.pubkey){const e=n.hash160(t.pubkey);if(r.length>0&&!r.equals(e))throw new TypeError("Hash mismatch");r=e}if(t.input){const e=d();if(2!==e.length)throw new TypeError("Input is invalid");if(!o.isCanonicalScriptSignature(e[0]))throw new TypeError("Input has invalid signature");if(!c.isPoint(e[1]))throw new TypeError("Input has invalid pubkey");if(t.signature&&!t.signature.equals(e[0]))throw new TypeError("Signature mismatch");if(t.pubkey&&!t.pubkey.equals(e[1]))throw new TypeError("Pubkey mismatch");const i=n.hash160(e[1]);if(r.length>0&&!r.equals(i))throw new TypeError("Hash mismatch")}}return Object.assign(p,t)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(19),i=r(12),o=r(1),a=r(26),s=r(3),u=o.OPS,c=r(39);t.p2sh=function(t,r){if(!(t.address||t.hash||t.output||t.redeem||t.input))throw new TypeError("Not enough data");r=Object.assign({validate:!0},r||{}),s({network:s.maybe(s.Object),address:s.maybe(s.String),hash:s.maybe(s.BufferN(20)),output:s.maybe(s.BufferN(23)),redeem:s.maybe({network:s.maybe(s.Object),output:s.maybe(s.Buffer),input:s.maybe(s.Buffer),witness:s.maybe(s.arrayOf(s.Buffer))}),input:s.maybe(s.Buffer),witness:s.maybe(s.arrayOf(s.Buffer))},t);let f=t.network;f||(f=t.redeem&&t.redeem.network||i.bitcoin);const l={network:f},d=a.value(()=>{const e=c.decode(t.address);return{version:e.readUInt8(0),hash:e.slice(1)}}),h=a.value(()=>o.decompile(t.input)),p=a.value(()=>{const e=h();return{network:f,output:e[e.length-1],input:o.compile(e.slice(0,-1)),witness:t.witness||[]}});if(a.prop(l,"address",()=>{if(!l.hash)return;const t=e.allocUnsafe(21);return t.writeUInt8(l.network.scriptHash,0),l.hash.copy(t,1),c.encode(t)}),a.prop(l,"hash",()=>t.output?t.output.slice(2,22):t.address?d().hash:l.redeem&&l.redeem.output?n.hash160(l.redeem.output):void 0),a.prop(l,"output",()=>{if(l.hash)return o.compile([u.OP_HASH160,l.hash,u.OP_EQUAL])}),a.prop(l,"redeem",()=>{if(t.input)return p()}),a.prop(l,"input",()=>{if(t.redeem&&t.redeem.input&&t.redeem.output)return o.compile([].concat(o.decompile(t.redeem.input),t.redeem.output))}),a.prop(l,"witness",()=>l.redeem&&l.redeem.witness?l.redeem.witness:l.input?[]:void 0),a.prop(l,"name",()=>{const e=["p2sh"];return void 0!==l.redeem&&e.push(l.redeem.name),e.join("-")}),r.validate){let r=e.from([]);if(t.address){if(d().version!==f.scriptHash)throw new TypeError("Invalid version or Network mismatch");if(20!==d().hash.length)throw new TypeError("Invalid address");r=d().hash}if(t.hash){if(r.length>0&&!r.equals(t.hash))throw new TypeError("Hash mismatch");r=t.hash}if(t.output){if(23!==t.output.length||t.output[0]!==u.OP_HASH160||20!==t.output[1]||t.output[22]!==u.OP_EQUAL)throw new TypeError("Output is invalid");const e=t.output.slice(2,22);if(r.length>0&&!r.equals(e))throw new TypeError("Hash mismatch");r=e}const i=e=>{if(e.output){const t=o.decompile(e.output);if(!t||t.length<1)throw new TypeError("Redeem.output too short");const i=n.hash160(e.output);if(r.length>0&&!r.equals(i))throw new TypeError("Hash mismatch");r=i}if(e.input){const t=e.input.length>0,r=e.witness&&e.witness.length>0;if(!t&&!r)throw new TypeError("Empty input");if(t&&r)throw new TypeError("Input and witness provided");if(t){const t=o.decompile(e.input);if(!o.isPushOnly(t))throw new TypeError("Non push-only scriptSig")}}};if(t.input){const t=h();if(!t||t.length<1)throw new TypeError("Input too short");if(!e.isBuffer(p().output))throw new TypeError("Input is invalid");i(p())}if(t.redeem){if(t.redeem.network&&t.redeem.network!==f)throw new TypeError("Network mismatch");if(t.input){const e=p();if(t.redeem.output&&!t.redeem.output.equals(e.output))throw new TypeError("Redeem.output mismatch");if(t.redeem.input&&!t.redeem.input.equals(e.input))throw new TypeError("Redeem.input mismatch")}i(t.redeem)}if(t.witness&&t.redeem&&t.redeem.witness&&!function(e,t){return e.length===t.length&&e.every((e,r)=>e.equals(t[r]))}(t.redeem.witness,t.witness))throw new TypeError("Witness and redeem.witness mismatch")}return Object.assign(l,t)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(19),i=r(12),o=r(1),a=r(26),s=r(3),u=o.OPS,c=r(25),f=r(81),l=e.alloc(0);t.p2wpkh=function(t,r){if(!(t.address||t.hash||t.output||t.pubkey||t.witness))throw new TypeError("Not enough data");r=Object.assign({validate:!0},r||{}),s({address:s.maybe(s.String),hash:s.maybe(s.BufferN(20)),input:s.maybe(s.BufferN(0)),network:s.maybe(s.Object),output:s.maybe(s.BufferN(22)),pubkey:s.maybe(c.isPoint),signature:s.maybe(o.isCanonicalScriptSignature),witness:s.maybe(s.arrayOf(s.Buffer))},t);const d=a.value(()=>{const r=f.decode(t.address),n=r.words.shift(),i=f.fromWords(r.words);return{version:n,prefix:r.prefix,data:e.from(i)}}),h=t.network||i.bitcoin,p={name:"p2wpkh",network:h};if(a.prop(p,"address",()=>{if(!p.hash)return;const e=f.toWords(p.hash);return e.unshift(0),f.encode(h.bech32,e)}),a.prop(p,"hash",()=>t.output?t.output.slice(2,22):t.address?d().data:t.pubkey||p.pubkey?n.hash160(t.pubkey||p.pubkey):void 0),a.prop(p,"output",()=>{if(p.hash)return o.compile([u.OP_0,p.hash])}),a.prop(p,"pubkey",()=>t.pubkey?t.pubkey:t.witness?t.witness[1]:void 0),a.prop(p,"signature",()=>{if(t.witness)return t.witness[0]}),a.prop(p,"input",()=>{if(p.witness)return l}),a.prop(p,"witness",()=>{if(t.pubkey&&t.signature)return[t.signature,t.pubkey]}),r.validate){let r=e.from([]);if(t.address){if(h&&h.bech32!==d().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(0!==d().version)throw new TypeError("Invalid address version");if(20!==d().data.length)throw new TypeError("Invalid address data");r=d().data}if(t.hash){if(r.length>0&&!r.equals(t.hash))throw new TypeError("Hash mismatch");r=t.hash}if(t.output){if(22!==t.output.length||t.output[0]!==u.OP_0||20!==t.output[1])throw new TypeError("Output is invalid");if(r.length>0&&!r.equals(t.output.slice(2)))throw new TypeError("Hash mismatch");r=t.output.slice(2)}if(t.pubkey){const e=n.hash160(t.pubkey);if(r.length>0&&!r.equals(e))throw new TypeError("Hash mismatch");if(r=e,!c.isPoint(t.pubkey)||33!==t.pubkey.length)throw new TypeError("Invalid pubkey for p2wpkh")}if(t.witness){if(2!==t.witness.length)throw new TypeError("Witness is invalid");if(!o.isCanonicalScriptSignature(t.witness[0]))throw new TypeError("Witness has invalid signature");if(!c.isPoint(t.witness[1])||33!==t.witness[1].length)throw new TypeError("Witness has invalid pubkey");if(t.signature&&!t.signature.equals(t.witness[0]))throw new TypeError("Signature mismatch");if(t.pubkey&&!t.pubkey.equals(t.witness[1]))throw new TypeError("Pubkey mismatch");const e=n.hash160(t.witness[1]);if(r.length>0&&!r.equals(e))throw new TypeError("Hash mismatch")}}return Object.assign(p,t)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(19),i=r(12),o=r(1),a=r(26),s=r(3),u=o.OPS,c=r(25),f=r(81),l=e.alloc(0);function d(t){return!(!e.isBuffer(t)||65!==t.length||4!==t[0]||!c.isPoint(t))}t.p2wsh=function(t,r){if(!(t.address||t.hash||t.output||t.redeem||t.witness))throw new TypeError("Not enough data");r=Object.assign({validate:!0},r||{}),s({network:s.maybe(s.Object),address:s.maybe(s.String),hash:s.maybe(s.BufferN(32)),output:s.maybe(s.BufferN(34)),redeem:s.maybe({input:s.maybe(s.Buffer),network:s.maybe(s.Object),output:s.maybe(s.Buffer),witness:s.maybe(s.arrayOf(s.Buffer))}),input:s.maybe(s.BufferN(0)),witness:s.maybe(s.arrayOf(s.Buffer))},t);const c=a.value(()=>{const r=f.decode(t.address),n=r.words.shift(),i=f.fromWords(r.words);return{version:n,prefix:r.prefix,data:e.from(i)}}),h=a.value(()=>o.decompile(t.redeem.input));let p=t.network;p||(p=t.redeem&&t.redeem.network||i.bitcoin);const b={network:p};if(a.prop(b,"address",()=>{if(!b.hash)return;const e=f.toWords(b.hash);return e.unshift(0),f.encode(p.bech32,e)}),a.prop(b,"hash",()=>t.output?t.output.slice(2):t.address?c().data:b.redeem&&b.redeem.output?n.sha256(b.redeem.output):void 0),a.prop(b,"output",()=>{if(b.hash)return o.compile([u.OP_0,b.hash])}),a.prop(b,"redeem",()=>{if(t.witness)return{output:t.witness[t.witness.length-1],input:l,witness:t.witness.slice(0,-1)}}),a.prop(b,"input",()=>{if(b.witness)return l}),a.prop(b,"witness",()=>{if(t.redeem&&t.redeem.input&&t.redeem.input.length>0&&t.redeem.output&&t.redeem.output.length>0){const e=o.toStack(h());return b.redeem=Object.assign({witness:e},t.redeem),b.redeem.input=l,[].concat(e,t.redeem.output)}if(t.redeem&&t.redeem.output&&t.redeem.witness)return[].concat(t.redeem.witness,t.redeem.output)}),a.prop(b,"name",()=>{const e=["p2wsh"];return void 0!==b.redeem&&e.push(b.redeem.name),e.join("-")}),r.validate){let r=e.from([]);if(t.address){if(c().prefix!==p.bech32)throw new TypeError("Invalid prefix or Network mismatch");if(0!==c().version)throw new TypeError("Invalid address version");if(32!==c().data.length)throw new TypeError("Invalid address data");r=c().data}if(t.hash){if(r.length>0&&!r.equals(t.hash))throw new TypeError("Hash mismatch");r=t.hash}if(t.output){if(34!==t.output.length||t.output[0]!==u.OP_0||32!==t.output[1])throw new TypeError("Output is invalid");const e=t.output.slice(2);if(r.length>0&&!r.equals(e))throw new TypeError("Hash mismatch");r=e}if(t.redeem){if(t.redeem.network&&t.redeem.network!==p)throw new TypeError("Network mismatch");if(t.redeem.input&&t.redeem.input.length>0&&t.redeem.witness&&t.redeem.witness.length>0)throw new TypeError("Ambiguous witness source");if(t.redeem.output){if(0===o.decompile(t.redeem.output).length)throw new TypeError("Redeem.output is invalid");const e=n.sha256(t.redeem.output);if(r.length>0&&!r.equals(e))throw new TypeError("Hash mismatch");r=e}if(t.redeem.input&&!o.isPushOnly(h()))throw new TypeError("Non push-only scriptSig");if(t.witness&&t.redeem.witness&&!function(e,t){return e.length===t.length&&e.every((e,r)=>e.equals(t[r]))}(t.witness,t.redeem.witness))throw new TypeError("Witness and redeem.witness mismatch");if(t.redeem.input&&h().some(d)||t.redeem.output&&(o.decompile(t.redeem.output)||[]).some(d))throw new TypeError("redeem.input or redeem.output contains uncompressed pubkey")}if(t.witness&&t.witness.length>0){const e=t.witness[t.witness.length-1];if(t.redeem&&t.redeem.output&&!t.redeem.output.equals(e))throw new TypeError("Witness and redeem.output mismatch");if(t.witness.some(d)||(o.decompile(e)||[]).some(d))throw new TypeError("Witness contains uncompressed pubkey")}}return Object.assign(b,t)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t,n){var i=r(4).Buffer,o=t.crypto||t.msCrypto;o&&o.getRandomValues?e.exports=function(e,t){if(e>4294967295)throw new RangeError("requested too many random bytes");var r=i.allocUnsafe(e);if(e>0)if(e>65536)for(var a=0;a<e;a+=65536)o.getRandomValues(r.slice(a,a+65536));else o.getRandomValues(r);if("function"==typeof t)return n.nextTick((function(){t(null,r)}));return r}:e.exports=function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}}).call(this,r(17),r(10))},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(51),i=r(19),o=r(52),a=r(16),s=r(126),u=r(3),c=r(37),f=new TypeError("Cannot compute merkle root for zero transactions"),l=new TypeError("Cannot compute witness commit for non-segwit block");class d{constructor(){this.version=1,this.prevHash=void 0,this.merkleRoot=void 0,this.timestamp=0,this.witnessCommit=void 0,this.bits=0,this.nonce=0,this.transactions=void 0}static fromBuffer(e){if(e.length<80)throw new Error("Buffer too small (< 80 bytes)");const t=new n.BufferReader(e),r=new d;if(r.version=t.readInt32(),r.prevHash=t.readSlice(32),r.merkleRoot=t.readSlice(32),r.timestamp=t.readUInt32(),r.bits=t.readUInt32(),r.nonce=t.readUInt32(),80===e.length)return r;const i=()=>{const e=o.Transaction.fromBuffer(t.buffer.slice(t.offset),!0);return t.offset+=e.byteLength(),e},a=t.readVarInt();r.transactions=[];for(let e=0;e<a;++e){const e=i();r.transactions.push(e)}const s=r.getWitnessCommit();return s&&(r.witnessCommit=s),r}static fromHex(t){return d.fromBuffer(e.from(t,"hex"))}static calculateTarget(t){const r=((4278190080&t)>>24)-3,n=8388607&t,i=e.alloc(32,0);return i.writeUIntBE(n,29-r,3),i}static calculateMerkleRoot(t,r){if(u([{getHash:a.Function}],t),0===t.length)throw f;if(r&&!h(t))throw l;const n=t.map(e=>e.getHash(r)),o=s(n,i.hash256);return r?i.hash256(e.concat([o,t[0].ins[0].witness[0]])):o}getWitnessCommit(){if(!h(this.transactions))return null;const t=this.transactions[0].outs.filter(t=>t.script.slice(0,6).equals(e.from("6a24aa21a9ed","hex"))).map(e=>e.script.slice(6,38));if(0===t.length)return null;const r=t[t.length-1];return r instanceof e&&32===r.length?r:null}hasWitnessCommit(){return this.witnessCommit instanceof e&&32===this.witnessCommit.length||null!==this.getWitnessCommit()}hasWitness(){return(e=this.transactions)instanceof Array&&e.some(e=>"object"==typeof e&&e.ins instanceof Array&&e.ins.some(e=>"object"==typeof e&&e.witness instanceof Array&&e.witness.length>0));var e}weight(){return 3*this.byteLength(!1,!1)+this.byteLength(!1,!0)}byteLength(e,t=!0){return e||!this.transactions?80:80+c.encodingLength(this.transactions.length)+this.transactions.reduce((e,r)=>e+r.byteLength(t),0)}getHash(){return i.hash256(this.toBuffer(!0))}getId(){return n.reverseBuffer(this.getHash()).toString("hex")}getUTCDate(){const e=new Date(0);return e.setUTCSeconds(this.timestamp),e}toBuffer(t){const r=e.allocUnsafe(this.byteLength(t)),i=new n.BufferWriter(r);return i.writeInt32(this.version),i.writeSlice(this.prevHash),i.writeSlice(this.merkleRoot),i.writeUInt32(this.timestamp),i.writeUInt32(this.bits),i.writeUInt32(this.nonce),t||!this.transactions||(c.encode(this.transactions.length,r,i.offset),i.offset+=c.encode.bytes,this.transactions.forEach(e=>{const t=e.byteLength();e.toBuffer(r,i.offset),i.offset+=t})),r}toHex(e){return this.toBuffer(e).toString("hex")}checkTxRoots(){const e=this.hasWitnessCommit();return!(!e&&this.hasWitness())&&(this.__checkMerkleRoot()&&(!e||this.__checkWitnessCommit()))}checkProofOfWork(){const e=n.reverseBuffer(this.getHash()),t=d.calculateTarget(this.bits);return e.compare(t)<=0}__checkMerkleRoot(){if(!this.transactions)throw f;const e=d.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(e)}__checkWitnessCommit(){if(!this.transactions)throw f;if(!this.hasWitnessCommit())throw l;const e=d.calculateMerkleRoot(this.transactions,!0);return 0===this.witnessCommit.compare(e)}}function h(e){return e instanceof Array&&e[0]&&e[0].ins&&e[0].ins instanceof Array&&e[0].ins[0]&&e[0].ins[0].witness&&e[0].ins[0].witness instanceof Array&&e[0].ins[0].witness.length>0}t.Block=d}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(93),i=r(22),o=r(66),a=r(79),s=r(51),u=r(19),c=r(82),f=r(12),l=r(50),d=r(1),h=r(52),p={network:f.bitcoin,maximumFeeRate:5e3};class b{constructor(e={},t=new n.Psbt(new g)){this.data=t,this.opts=Object.assign({},p,e),this.__CACHE={__NON_WITNESS_UTXO_TX_CACHE:[],__NON_WITNESS_UTXO_BUF_CACHE:[],__TX_IN_CACHE:{},__TX:this.data.globalMap.unsignedTx.tx,__UNSAFE_SIGN_NONSEGWIT:!1},0===this.data.inputs.length&&this.setVersion(2);const r=(e,t,r,n)=>Object.defineProperty(e,t,{enumerable:r,writable:n});r(this,"__CACHE",!1,!0),r(this,"opts",!1,!0)}static fromBase64(t,r={}){const n=e.from(t,"base64");return this.fromBuffer(n,r)}static fromHex(t,r={}){const n=e.from(t,"hex");return this.fromBuffer(n,r)}static fromBuffer(e,t={}){const r=n.Psbt.fromBuffer(e,m),i=new b(t,r);var o,a;return o=i.__CACHE.__TX,a=i.__CACHE,o.ins.forEach(e=>{M(a,e)}),i}get inputCount(){return this.data.inputs.length}get version(){return this.__CACHE.__TX.version}set version(e){this.setVersion(e)}get locktime(){return this.__CACHE.__TX.locktime}set locktime(e){this.setLocktime(e)}get txInputs(){return this.__CACHE.__TX.ins.map(e=>({hash:s.cloneBuffer(e.hash),index:e.index,sequence:e.sequence}))}get txOutputs(){return this.__CACHE.__TX.outs.map(e=>{let t;try{t=a.fromOutputScript(e.script,this.opts.network)}catch(e){}return{script:s.cloneBuffer(e.script),value:e.value,address:t}})}combine(...e){return this.data.combine(...e.map(e=>e.data)),this}clone(){const e=b.fromBuffer(this.data.toBuffer());return e.opts=JSON.parse(JSON.stringify(this.opts)),e}setMaximumFeeRate(e){O(e),this.opts.maximumFeeRate=e}setVersion(e){O(e),I(this.data.inputs,"setVersion");const t=this.__CACHE;return t.__TX.version=e,t.__EXTRACTED_TX=void 0,this}setLocktime(e){O(e),I(this.data.inputs,"setLocktime");const t=this.__CACHE;return t.__TX.locktime=e,t.__EXTRACTED_TX=void 0,this}setInputSequence(e,t){O(t),I(this.data.inputs,"setInputSequence");const r=this.__CACHE;if(r.__TX.ins.length<=e)throw new Error("Input index too high");return r.__TX.ins[e].sequence=t,r.__EXTRACTED_TX=void 0,this}addInputs(e){return e.forEach(e=>this.addInput(e)),this}addInput(e){if(arguments.length>1||!e||void 0===e.hash||void 0===e.index)throw new Error("Invalid arguments for Psbt.addInput. Requires single object with at least [hash] and [index]");I(this.data.inputs,"addInput"),e.witnessScript&&Y(e.witnessScript);const t=this.__CACHE;this.data.addInput(e);M(t,t.__TX.ins[t.__TX.ins.length-1]);const r=this.data.inputs.length-1,n=this.data.inputs[r];return n.nonWitnessUtxo&&q(this.__CACHE,n,r),t.__FEE=void 0,t.__FEE_RATE=void 0,t.__EXTRACTED_TX=void 0,this}addOutputs(e){return e.forEach(e=>this.addOutput(e)),this}addOutput(e){if(arguments.length>1||!e||void 0===e.value||void 0===e.address&&void 0===e.script)throw new Error("Invalid arguments for Psbt.addOutput. Requires single object with at least [script or address] and [value]");I(this.data.inputs,"addOutput");const{address:t}=e;if("string"==typeof t){const{network:r}=this.opts,n=a.toOutputScript(t,r);e=Object.assign(e,{script:n})}const r=this.__CACHE;return this.data.addOutput(e),r.__FEE=void 0,r.__FEE_RATE=void 0,r.__EXTRACTED_TX=void 0,this}extractTransaction(e){if(!this.data.inputs.every(w))throw new Error("Not finalized");const t=this.__CACHE;if(e||function(e,t,r){const n=t.__FEE_RATE||e.getFeeRate(),i=t.__EXTRACTED_TX.virtualSize(),o=n*i;if(n>=r.maximumFeeRate)throw new Error(`Warning: You are paying around ${(o/1e8).toFixed(8)} in fees, which is ${n} satoshi per byte for a transaction with a VSize of ${i} bytes (segwit counted as 0.25 byte per byte). Use setMaximumFeeRate method to raise your threshold, or pass true to the first arg of extractTransaction.`)}(this,t,this.opts),t.__EXTRACTED_TX)return t.__EXTRACTED_TX;const r=t.__TX.clone();return K(this.data.inputs,r,t,!0),r}getFeeRate(){return U("__FEE_RATE","fee rate",this.data.inputs,this.__CACHE)}getFee(){return U("__FEE","fee",this.data.inputs,this.__CACHE)}finalizeAllInputs(){return o.checkForInput(this.data.inputs,0),Q(this.data.inputs.length).forEach(e=>this.finalizeInput(e)),this}finalizeInput(e,t=C){const r=o.checkForInput(this.data.inputs,e),{script:n,isP2SH:i,isP2WSH:a,isSegwit:s}=function(e,t,r){const n=r.__TX,i={script:null,isSegwit:!1,isP2SH:!1,isP2WSH:!1};if(i.isP2SH=!!t.redeemScript,i.isP2WSH=!!t.witnessScript,t.witnessScript)i.script=t.witnessScript;else if(t.redeemScript)i.script=t.redeemScript;else if(t.nonWitnessUtxo){const o=W(r,t,e),a=n.ins[e].index;i.script=o.outs[a].script}else t.witnessUtxo&&(i.script=t.witnessUtxo.script);(t.witnessScript||x(i.script))&&(i.isSegwit=!0);return i}(e,r,this.__CACHE);if(!n)throw new Error("No script found for input #"+e);!function(e){if(!e.sighashType||!e.partialSig)return;const{partialSig:t,sighashType:r}=e;t.forEach(e=>{const{hashType:t}=d.signature.decode(e.signature);if(r!==t)throw new Error("Signature sighash does not match input sighash type")})}(r);const{finalScriptSig:u,finalScriptWitness:c}=t(e,r,n,s,i,a);if(u&&this.data.updateInput(e,{finalScriptSig:u}),c&&this.data.updateInput(e,{finalScriptWitness:c}),!u&&!c)throw new Error("Unknown error finalizing input #"+e);return this.data.clearFinalizedInput(e),this}getInputType(t){const r=o.checkForInput(this.data.inputs,t),n=X(V(t,r,this.__CACHE),t,"input",r.redeemScript||function(t){if(!t)return;const r=d.decompile(t);if(!r)return;const n=r[r.length-1];if(!e.isBuffer(n)||G(n)||(i=n,d.isCanonicalScriptSignature(i)))return;var i;if(!d.decompile(n))return;return n}(r.finalScriptSig),r.witnessScript||function(e){if(!e)return;const t=D(e),r=t[t.length-1];if(G(r))return;if(!d.decompile(r))return;return r}(r.finalScriptWitness));return("raw"===n.type?"":n.type+"-")+J(n.meaningfulScript)}inputHasPubkey(e,t){return function(e,t,r,n){const i=V(r,t,n),{meaningfulScript:o}=X(i,r,"input",t.redeemScript,t.witnessScript);return $(e,o)}(t,o.checkForInput(this.data.inputs,e),e,this.__CACHE)}inputHasHDKey(e,t){const r=o.checkForInput(this.data.inputs,e),n=P(t);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}outputHasPubkey(e,t){return function(e,t,r,n){const i=n.__TX.outs[r].script,{meaningfulScript:o}=X(i,r,"output",t.redeemScript,t.witnessScript);return $(e,o)}(t,o.checkForOutput(this.data.outputs,e),e,this.__CACHE)}outputHasHDKey(e,t){const r=o.checkForOutput(this.data.outputs,e),n=P(t);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}validateSignaturesOfAllInputs(){o.checkForInput(this.data.inputs,0);return Q(this.data.inputs.length).map(e=>this.validateSignaturesOfInput(e)).reduce((e,t)=>!0===t&&e,!0)}validateSignaturesOfInput(e,t){const r=this.data.inputs[e],n=(r||{}).partialSig;if(!r||!n||n.length<1)throw new Error("No signatures to validate");const i=t?n.filter(e=>e.pubkey.equals(t)):n;if(i.length<1)throw new Error("No signatures for this pubkey");const o=[];let a,s,u;for(const t of i){const n=d.signature.decode(t.signature),{hash:i,script:f}=u!==n.hashType?z(e,Object.assign({},r,{sighashType:n.hashType}),this.__CACHE,!0):{hash:a,script:s};u=n.hashType,a=i,s=f,B(t.pubkey,f,"verify");const l=c.fromPublicKey(t.pubkey);o.push(l.verify(i,n.signature))}return o.every(e=>!0===e)}signAllInputsHD(e,t=[h.Transaction.SIGHASH_ALL]){if(!e||!e.publicKey||!e.fingerprint)throw new Error("Need HDSigner to sign input");const r=[];for(const n of Q(this.data.inputs.length))try{this.signInputHD(n,e,t),r.push(!0)}catch(e){r.push(!1)}if(r.every(e=>!1===e))throw new Error("No inputs were signed");return this}signAllInputsHDAsync(e,t=[h.Transaction.SIGHASH_ALL]){return new Promise((r,n)=>{if(!e||!e.publicKey||!e.fingerprint)return n(new Error("Need HDSigner to sign input"));const i=[],o=[];for(const r of Q(this.data.inputs.length))o.push(this.signInputHDAsync(r,e,t).then(()=>{i.push(!0)},()=>{i.push(!1)}));return Promise.all(o).then(()=>{if(i.every(e=>!1===e))return n(new Error("No inputs were signed"));r()})})}signInputHD(e,t,r=[h.Transaction.SIGHASH_ALL]){if(!t||!t.publicKey||!t.fingerprint)throw new Error("Need HDSigner to sign input");return L(e,this.data.inputs,t).forEach(t=>this.signInput(e,t,r)),this}signInputHDAsync(e,t,r=[h.Transaction.SIGHASH_ALL]){return new Promise((n,i)=>{if(!t||!t.publicKey||!t.fingerprint)return i(new Error("Need HDSigner to sign input"));const o=L(e,this.data.inputs,t).map(t=>this.signInputAsync(e,t,r));return Promise.all(o).then(()=>{n()}).catch(i)})}signAllInputs(e,t=[h.Transaction.SIGHASH_ALL]){if(!e||!e.publicKey)throw new Error("Need Signer to sign input");const r=[];for(const n of Q(this.data.inputs.length))try{this.signInput(n,e,t),r.push(!0)}catch(e){r.push(!1)}if(r.every(e=>!1===e))throw new Error("No inputs were signed");return this}signAllInputsAsync(e,t=[h.Transaction.SIGHASH_ALL]){return new Promise((r,n)=>{if(!e||!e.publicKey)return n(new Error("Need Signer to sign input"));const i=[],o=[];for(const[r]of this.data.inputs.entries())o.push(this.signInputAsync(r,e,t).then(()=>{i.push(!0)},()=>{i.push(!1)}));return Promise.all(o).then(()=>{if(i.every(e=>!1===e))return n(new Error("No inputs were signed"));r()})})}signInput(e,t,r=[h.Transaction.SIGHASH_ALL]){if(!t||!t.publicKey)throw new Error("Need Signer to sign input");const{hash:n,sighashType:i}=H(this.data.inputs,e,t.publicKey,this.__CACHE,r),o=[{pubkey:t.publicKey,signature:d.signature.encode(t.sign(n),i)}];return this.data.updateInput(e,{partialSig:o}),this}signInputAsync(e,t,r=[h.Transaction.SIGHASH_ALL]){return Promise.resolve().then(()=>{if(!t||!t.publicKey)throw new Error("Need Signer to sign input");const{hash:n,sighashType:i}=H(this.data.inputs,e,t.publicKey,this.__CACHE,r);return Promise.resolve(t.sign(n)).then(r=>{const n=[{pubkey:t.publicKey,signature:d.signature.encode(r,i)}];this.data.updateInput(e,{partialSig:n})})})}toBuffer(){return y(this.__CACHE),this.data.toBuffer()}toHex(){return y(this.__CACHE),this.data.toHex()}toBase64(){return y(this.__CACHE),this.data.toBase64()}updateGlobal(e){return this.data.updateGlobal(e),this}updateInput(e,t){return t.witnessScript&&Y(t.witnessScript),this.data.updateInput(e,t),t.nonWitnessUtxo&&q(this.__CACHE,this.data.inputs[e],e),this}updateOutput(e,t){return this.data.updateOutput(e,t),this}addUnknownKeyValToGlobal(e){return this.data.addUnknownKeyValToGlobal(e),this}addUnknownKeyValToInput(e,t){return this.data.addUnknownKeyValToInput(e,t),this}addUnknownKeyValToOutput(e,t){return this.data.addUnknownKeyValToOutput(e,t),this}clearFinalizedInput(e){return this.data.clearFinalizedInput(e),this}}t.Psbt=b;const m=e=>new g(e);class g{constructor(t=e.from([2,0,0,0,0,0,0,0,0,0])){this.tx=h.Transaction.fromBuffer(t),function(e){if(!e.ins.every(e=>e.script&&0===e.script.length&&e.witness&&0===e.witness.length))throw new Error("Format Error: Transaction ScriptSigs are not empty")}(this.tx),Object.defineProperty(this,"tx",{enumerable:!1,writable:!0})}getInputOutputCounts(){return{inputCount:this.tx.ins.length,outputCount:this.tx.outs.length}}addInput(t){if(void 0===t.hash||void 0===t.index||!e.isBuffer(t.hash)&&"string"!=typeof t.hash||"number"!=typeof t.index)throw new Error("Error adding input.");const r="string"==typeof t.hash?s.reverseBuffer(e.from(t.hash,"hex")):t.hash;this.tx.addInput(r,t.index,t.sequence)}addOutput(t){if(void 0===t.script||void 0===t.value||!e.isBuffer(t.script)||"number"!=typeof t.value)throw new Error("Error adding output.");this.tx.addOutput(t.script,t.value)}toBuffer(){return this.tx.toBuffer()}}function y(e){if(!1!==e.__UNSAFE_SIGN_NONSEGWIT)throw new Error("Not BIP174 compliant, can not export")}function v(e,t,r){if(!t)return!1;let n;if(n=r?r.map(e=>{const r=c.fromPublicKey(e,{compressed:!0}).publicKey;return t.find(e=>e.pubkey.equals(r))}).filter(e=>!!e):t,n.length>e)throw new Error("Too many signatures");return n.length===e}function w(e){return!!e.finalScriptSig||!!e.finalScriptWitness}function _(e){return t=>{try{return e({output:t}),!0}catch(e){return!1}}}const E=_(l.p2ms),k=_(l.p2pk),S=_(l.p2pkh),x=_(l.p2wpkh),T=_(l.p2wsh),A=_(l.p2sh);function P(e){return t=>!!t.masterFingerprint.equals(e.fingerprint)&&!!e.derivePath(t.path).publicKey.equals(t.pubkey)}function O(e){if("number"!=typeof e||e!==Math.floor(e)||e>4294967295||e<0)throw new Error("Invalid 32 bit integer")}function I(t,r){t.forEach(t=>{let n=!1,i=[];if(0===(t.partialSig||[]).length){if(!t.finalScriptSig&&!t.finalScriptWitness)return;i=function(t){const r=t.finalScriptSig&&d.decompile(t.finalScriptSig)||[],n=t.finalScriptWitness&&d.decompile(t.finalScriptWitness)||[];return r.concat(n).filter(t=>e.isBuffer(t)&&d.isCanonicalScriptSignature(t)).map(e=>({signature:e}))}(t)}else i=t.partialSig;if(i.forEach(e=>{const{hashType:t}=d.signature.decode(e.signature),i=[];t&h.Transaction.SIGHASH_ANYONECANPAY&&i.push("addInput");switch(31&t){case h.Transaction.SIGHASH_ALL:break;case h.Transaction.SIGHASH_SINGLE:case h.Transaction.SIGHASH_NONE:i.push("addOutput"),i.push("setInputSequence")}-1===i.indexOf(r)&&(n=!0)}),n)throw new Error("Can not modify transaction, signatures exist.")})}function B(e,t,r){if(!$(e,t))throw new Error(`Can not ${r} for this input with the key ${e.toString("hex")}`)}function M(t,r){const n=s.reverseBuffer(e.from(r.hash)).toString("hex")+":"+r.index;if(t.__TX_IN_CACHE[n])throw new Error("Duplicate input detected.");t.__TX_IN_CACHE[n]=1}function R(e,t){return(r,n,i,o)=>{const a=e({redeem:{output:i}}).output;if(!n.equals(a))throw new Error(`${t} for ${o} #${r} doesn't match the scriptPubKey in the prevout`)}}const N=R(l.p2sh,"Redeem script"),j=R(l.p2wsh,"Witness script");function U(e,t,r,n){if(!r.every(w))throw new Error("PSBT must be finalized to calculate "+t);if("__FEE_RATE"===e&&n.__FEE_RATE)return n.__FEE_RATE;if("__FEE"===e&&n.__FEE)return n.__FEE;let i,o=!0;return n.__EXTRACTED_TX?(i=n.__EXTRACTED_TX,o=!1):i=n.__TX.clone(),K(r,i,n,o),"__FEE_RATE"===e?n.__FEE_RATE:"__FEE"===e?n.__FEE:void 0}function C(e,t,r,n,i,o){const a=J(r);if(!function(e,t,r){switch(r){case"pubkey":case"pubkeyhash":case"witnesspubkeyhash":return v(1,e.partialSig);case"multisig":const r=l.p2ms({output:t});return v(r.m,e.partialSig,r.pubkeys);default:return!1}}(t,r,a))throw new Error("Can not finalize input #"+e);return function(e,t,r,n,i,o){let a,s;const u=function(e,t,r){let n;switch(t){case"multisig":const t=function(e,t){return l.p2ms({output:e}).pubkeys.map(e=>(t.filter(t=>t.pubkey.equals(e))[0]||{}).signature).filter(e=>!!e)}(e,r);n=l.p2ms({output:e,signatures:t});break;case"pubkey":n=l.p2pk({output:e,signature:r[0].signature});break;case"pubkeyhash":n=l.p2pkh({output:e,pubkey:r[0].pubkey,signature:r[0].signature});break;case"witnesspubkeyhash":n=l.p2wpkh({output:e,pubkey:r[0].pubkey,signature:r[0].signature})}return n}(e,t,r),c=o?l.p2wsh({redeem:u}):null,f=i?l.p2sh({redeem:c||u}):null;n?(s=F(c?c.witness:u.witness),f&&(a=f.input)):a=f?f.input:u.input;return{finalScriptSig:a,finalScriptWitness:s}}(r,a,t.partialSig,n,i,o)}function H(e,t,r,n,i){const a=o.checkForInput(e,t),{hash:s,sighashType:u,script:c}=z(t,a,n,!1,i);return B(r,c,"sign"),{hash:s,sighashType:u}}function z(e,t,r,n,i){const o=r.__TX,a=t.sighashType||h.Transaction.SIGHASH_ALL;if(i&&i.indexOf(a)<0){const e=function(e){let t=e&h.Transaction.SIGHASH_ANYONECANPAY?"SIGHASH_ANYONECANPAY | ":"";switch(31&e){case h.Transaction.SIGHASH_ALL:t+="SIGHASH_ALL";break;case h.Transaction.SIGHASH_SINGLE:t+="SIGHASH_SINGLE";break;case h.Transaction.SIGHASH_NONE:t+="SIGHASH_NONE"}return t}(a);throw new Error("Sighash type is not allowed. Retry the sign method passing the sighashTypes array of whitelisted types. Sighash type: "+e)}let s,u;if(t.nonWitnessUtxo){const n=W(r,t,e),i=o.ins[e].hash,a=n.getHash();if(!i.equals(a))throw new Error(`Non-witness UTXO hash for input #${e} doesn't match the hash specified in the prevout`);const s=o.ins[e].index;u=n.outs[s]}else{if(!t.witnessUtxo)throw new Error("Need a Utxo input item for signing");u=t.witnessUtxo}const{meaningfulScript:c,type:f}=X(u.script,e,"input",t.redeemScript,t.witnessScript);if(["p2sh-p2wsh","p2wsh"].indexOf(f)>=0)s=o.hashForWitnessV0(e,c,u.value,a);else if(x(c)){const t=l.p2pkh({hash:c.slice(2)}).output;s=o.hashForWitnessV0(e,t,u.value,a)}else{if(void 0===t.nonWitnessUtxo&&!1===r.__UNSAFE_SIGN_NONSEGWIT)throw new Error(`Input #${e} has witnessUtxo but non-segwit script: `+c.toString("hex"));n||!1===r.__UNSAFE_SIGN_NONSEGWIT||console.warn("Warning: Signing non-segwit inputs without the full parent transaction means there is a chance that a miner could feed you incorrect information to trick you into paying large fees. This behavior is the same as the old TransactionBuilder class when signing non-segwit scripts. You are not able to export this Psbt with toBuffer|toBase64|toHex since it is not BIP174 compliant.\n*********************\nPROCEED WITH CAUTION!\n*********************"),s=o.hashForSignature(e,c,a)}return{script:c,sighashType:a,hash:s}}function L(e,t,r){const n=o.checkForInput(t,e);if(!n.bip32Derivation||0===n.bip32Derivation.length)throw new Error("Need bip32Derivation to sign with HD");const i=n.bip32Derivation.map(e=>e.masterFingerprint.equals(r.fingerprint)?e:void 0).filter(e=>!!e);if(0===i.length)throw new Error("Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint");return i.map(e=>{const t=r.derivePath(e.path);if(!e.pubkey.equals(t.publicKey))throw new Error("pubkey did not match bip32Derivation");return t})}function D(e){let t=0;function r(){const r=i.decode(e,t);return t+=i.decode.bytes,r}function n(){return n=r(),t+=n,e.slice(t-n,t);var n}return function(){const e=r(),t=[];for(let r=0;r<e;r++)t.push(n());return t}()}function F(t){let r=e.allocUnsafe(0);function n(t){const n=r.length,o=i.encodingLength(t);r=e.concat([r,e.allocUnsafe(o)]),i.encode(t,r,n)}function o(t){n(t.length),function(t){r=e.concat([r,e.from(t)])}(t)}var a;return n((a=t).length),a.forEach(o),r}function q(e,t,r){e.__NON_WITNESS_UTXO_BUF_CACHE[r]=t.nonWitnessUtxo;const n=h.Transaction.fromBuffer(t.nonWitnessUtxo);e.__NON_WITNESS_UTXO_TX_CACHE[r]=n;const i=e,o=r;delete t.nonWitnessUtxo,Object.defineProperty(t,"nonWitnessUtxo",{enumerable:!0,get(){const e=i.__NON_WITNESS_UTXO_BUF_CACHE[o],t=i.__NON_WITNESS_UTXO_TX_CACHE[o];if(void 0!==e)return e;{const e=t.toBuffer();return i.__NON_WITNESS_UTXO_BUF_CACHE[o]=e,e}},set(e){i.__NON_WITNESS_UTXO_BUF_CACHE[o]=e}})}function K(e,t,r,n){let i=0;e.forEach((e,o)=>{if(n&&e.finalScriptSig&&(t.ins[o].script=e.finalScriptSig),n&&e.finalScriptWitness&&(t.ins[o].witness=D(e.finalScriptWitness)),e.witnessUtxo)i+=e.witnessUtxo.value;else if(e.nonWitnessUtxo){const n=W(r,e,o),a=t.ins[o].index,s=n.outs[a];i+=s.value}});const o=t.outs.reduce((e,t)=>e+t.value,0),a=i-o;if(a<0)throw new Error("Outputs are spending more than Inputs");const s=t.virtualSize();r.__FEE=a,r.__EXTRACTED_TX=t,r.__FEE_RATE=Math.floor(a/s)}function W(e,t,r){const n=e.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||q(e,t,r),n[r]}function V(e,t,r){if(void 0!==t.witnessUtxo)return t.witnessUtxo.script;if(void 0!==t.nonWitnessUtxo){return W(r,t,e).outs[r.__TX.ins[e].index].script}throw new Error("Can't find pubkey in input without Utxo data")}function G(e){return 33===e.length&&d.isCanonicalPubKey(e)}function X(e,t,r,n,i){const o=A(e),a=o&&n&&T(n),s=T(e);if(o&&void 0===n)throw new Error("scriptPubkey is P2SH but redeemScript missing");if((s||a)&&void 0===i)throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");let u;return a?(u=i,N(t,e,n,r),j(t,n,i,r),Y(u)):s?(u=i,j(t,e,i,r),Y(u)):o?(u=n,N(t,e,n,r)):u=e,{meaningfulScript:u,type:a?"p2sh-p2wsh":o?"p2sh":s?"p2wsh":"raw"}}function Y(e){if(x(e)||A(e))throw new Error("P2WPKH or P2SH can not be contained within P2WSH")}function $(e,t){const r=u.hash160(e),n=d.decompile(t);if(null===n)throw new Error("Unknown script error");return n.some(t=>"number"!=typeof t&&(t.equals(e)||t.equals(r)))}function J(e){return x(e)?"witnesspubkeyhash":S(e)?"pubkeyhash":E(e)?"multisig":k(e)?"pubkey":"nonstandard"}function Q(e){return[...Array(e).keys()]}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(79),i=r(51),o=r(287),a=r(19),s=r(82),u=r(12),c=r(50),f=r(1),l=r(1),d=r(52),h=r(16),p=r(3),b=o.types,m=new Set(["p2pkh","p2pk","p2wpkh","p2ms","p2sh-p2pkh","p2sh-p2pk","p2sh-p2wpkh","p2sh-p2ms","p2wsh-p2pkh","p2wsh-p2pk","p2wsh-p2ms","p2sh-p2wsh-p2pkh","p2sh-p2wsh-p2pk","p2sh-p2wsh-p2ms"]);function g(e,t,r){try{p(e,t)}catch(e){throw new Error(r)}}class y{constructor(e=u.bitcoin,t=2500){this.network=e,this.maximumFeeRate=t,this.__PREV_TX_SET={},this.__INPUTS=[],this.__TX=new d.Transaction,this.__TX.version=2,this.__USE_LOW_R=!1,console.warn("Deprecation Warning: TransactionBuilder will be removed in the future. (v6.x.x or later) Please use the Psbt class instead. Examples of usage are available in the transactions-psbt.js integration test file on our Github. A high level explanation is available in the psbt.ts and psbt.js files as well.")}static fromTransaction(e,t){const r=new y(t);return r.setVersion(e.version),r.setLockTime(e.locktime),e.outs.forEach(e=>{r.addOutput(e.script,e.value)}),e.ins.forEach(e=>{r.__addInputUnsafe(e.hash,e.index,{sequence:e.sequence,script:e.script,witness:e.witness})}),r.__INPUTS.forEach((t,r)=>{!function(e,t,r){if(e.redeemScriptType!==b.P2MS||!e.redeemScript)return;if(e.pubkeys.length===e.signatures.length)return;const n=e.signatures.concat();e.signatures=e.pubkeys.map(i=>{const o=s.fromPublicKey(i);let a;return n.some((i,s)=>{if(!i)return!1;const u=f.signature.decode(i),c=t.hashForSignature(r,e.redeemScript,u.hashType);return!!o.verify(c,u.signature)&&(n[s]=void 0,a=i,!0)}),a})}(t,e,r)}),r}setLowR(e){return p(p.maybe(p.Boolean),e),void 0===e&&(e=!0),this.__USE_LOW_R=e,e}setLockTime(e){if(p(h.UInt32,e),this.__INPUTS.some(e=>!!e.signatures&&e.signatures.some(e=>void 0!==e)))throw new Error("No, this would invalidate signatures");this.__TX.locktime=e}setVersion(e){p(h.UInt32,e),this.__TX.version=e}addInput(t,r,n,o){if(!this.__canModifyInputs())throw new Error("No, this would invalidate signatures");let a;if("string"==typeof(s=t)||s instanceof String)t=i.reverseBuffer(e.from(t,"hex"));else if(function(e){return e instanceof d.Transaction}(t)){const e=t.outs[r];o=e.script,a=e.value,t=t.getHash(!1)}var s;return this.__addInputUnsafe(t,r,{sequence:n,prevOutScript:o,value:a})}addOutput(e,t){if(!this.__canModifyOutputs())throw new Error("No, this would invalidate signatures");return"string"==typeof e&&(e=n.toOutputScript(e,this.network)),this.__TX.addOutput(e,t)}build(){return this.__build(!1)}buildIncomplete(){return this.__build(!0)}sign(e,t,r,n,i,o){!function({input:e,ourPubKey:t,keyPair:r,signatureHash:n,hashType:i,useLowR:o}){let a=!1;for(const[s,u]of e.pubkeys.entries()){if(!t.equals(u))continue;if(e.signatures[s])throw new Error("Signature already exists");if(33!==t.length&&e.hasWitness)throw new Error("BIP143 rejects uncompressed public keys in P2WPKH or P2WSH");const c=r.sign(n,o);e.signatures[s]=f.signature.encode(c,i),a=!0}if(!a)throw new Error("Key pair cannot sign for this input")}(function(e,t,r,n,i,o,a,s,u,l,y){let _;if("number"==typeof i)console.warn("DEPRECATED: TransactionBuilder sign method arguments will change in v6, please use the TxbSignArg interface"),_=i;else{if("object"!=typeof i)throw new TypeError("TransactionBuilder sign first arg must be TxbSignArg or number");!function(e,t){if(!m.has(t.prevOutScriptType))throw new TypeError(`Unknown prevOutScriptType "${t.prevOutScriptType}"`);g(p.Number,t.vin,"sign must include vin parameter as Number (input index)"),g(h.Signer,t.keyPair,"sign must include keyPair parameter as Signer interface"),g(p.maybe(p.Number),t.hashType,"sign hashType parameter must be a number");const r=(e[t.vin]||[]).prevOutType,n=t.prevOutScriptType;switch(n){case"p2pkh":if(r&&"pubkeyhash"!==r)throw new TypeError(`input #${t.vin} is not of type p2pkh: ${r}`);g(p.value(void 0),t.witnessScript,n+" requires NO witnessScript"),g(p.value(void 0),t.redeemScript,n+" requires NO redeemScript"),g(p.value(void 0),t.witnessValue,n+" requires NO witnessValue");break;case"p2pk":if(r&&"pubkey"!==r)throw new TypeError(`input #${t.vin} is not of type p2pk: ${r}`);g(p.value(void 0),t.witnessScript,n+" requires NO witnessScript"),g(p.value(void 0),t.redeemScript,n+" requires NO redeemScript"),g(p.value(void 0),t.witnessValue,n+" requires NO witnessValue");break;case"p2wpkh":if(r&&"witnesspubkeyhash"!==r)throw new TypeError(`input #${t.vin} is not of type p2wpkh: ${r}`);g(p.value(void 0),t.witnessScript,n+" requires NO witnessScript"),g(p.value(void 0),t.redeemScript,n+" requires NO redeemScript"),g(h.Satoshi,t.witnessValue,n+" requires witnessValue");break;case"p2ms":if(r&&"multisig"!==r)throw new TypeError(`input #${t.vin} is not of type p2ms: ${r}`);g(p.value(void 0),t.witnessScript,n+" requires NO witnessScript"),g(p.value(void 0),t.redeemScript,n+" requires NO redeemScript"),g(p.value(void 0),t.witnessValue,n+" requires NO witnessValue");break;case"p2sh-p2wpkh":if(r&&"scripthash"!==r)throw new TypeError(`input #${t.vin} is not of type p2sh-p2wpkh: ${r}`);g(p.value(void 0),t.witnessScript,n+" requires NO witnessScript"),g(p.Buffer,t.redeemScript,n+" requires redeemScript"),g(h.Satoshi,t.witnessValue,n+" requires witnessValue");break;case"p2sh-p2ms":case"p2sh-p2pk":case"p2sh-p2pkh":if(r&&"scripthash"!==r)throw new TypeError(`input #${t.vin} is not of type ${n}: ${r}`);g(p.value(void 0),t.witnessScript,n+" requires NO witnessScript"),g(p.Buffer,t.redeemScript,n+" requires redeemScript"),g(p.value(void 0),t.witnessValue,n+" requires NO witnessValue");break;case"p2wsh-p2ms":case"p2wsh-p2pk":case"p2wsh-p2pkh":if(r&&"witnessscripthash"!==r)throw new TypeError(`input #${t.vin} is not of type ${n}: ${r}`);g(p.Buffer,t.witnessScript,n+" requires witnessScript"),g(p.value(void 0),t.redeemScript,n+" requires NO redeemScript"),g(h.Satoshi,t.witnessValue,n+" requires witnessValue");break;case"p2sh-p2wsh-p2ms":case"p2sh-p2wsh-p2pk":case"p2sh-p2wsh-p2pkh":if(r&&"scripthash"!==r)throw new TypeError(`input #${t.vin} is not of type ${n}: ${r}`);g(p.Buffer,t.witnessScript,n+" requires witnessScript"),g(p.Buffer,t.redeemScript,n+" requires witnessScript"),g(h.Satoshi,t.witnessValue,n+" requires witnessScript")}}(t,i),({vin:_,keyPair:o,redeemScript:a,hashType:s,witnessValue:u,witnessScript:l}=i)}if(void 0===o)throw new Error("sign requires keypair");if(o.network&&o.network!==e)throw new TypeError("Inconsistent network");if(!t[_])throw new Error("No input at index: "+_);if(s=s||d.Transaction.SIGHASH_ALL,r(s))throw new Error("Transaction needs outputs");const E=t[_];if(void 0!==E.redeemScript&&a&&!E.redeemScript.equals(a))throw new Error("Inconsistent redeemScript");const k=o.publicKey||o.getPublicKey&&o.getPublicKey();if(!w(E)){if(void 0!==u){if(void 0!==E.value&&E.value!==u)throw new Error("Input did not match witnessValue");p(h.Satoshi,u),E.value=u}if(!w(E)){const e=function(e,t,r,n){if(r&&n){const i=c.p2wsh({redeem:{output:n}}),o=c.p2wsh({output:r}),a=c.p2sh({redeem:{output:r}}),s=c.p2sh({redeem:i});if(!i.hash.equals(o.hash))throw new Error("Witness script inconsistent with prevOutScript");if(!a.hash.equals(s.hash))throw new Error("Redeem script inconsistent with prevOutScript");const u=v(i.redeem.output,t);if(!u.pubkeys)throw new Error(u.type+" not supported as witnessScript ("+f.toASM(n)+")");e.signatures&&e.signatures.some(e=>void 0!==e)&&(u.signatures=e.signatures);const l=n;if(u.type===b.P2WPKH)throw new Error("P2SH(P2WSH(P2WPKH)) is a consensus failure");return{redeemScript:r,redeemScriptType:b.P2WSH,witnessScript:n,witnessScriptType:u.type,prevOutType:b.P2SH,prevOutScript:a.output,hasWitness:!0,signScript:l,signType:u.type,pubkeys:u.pubkeys,signatures:u.signatures,maxSignatures:u.maxSignatures}}if(r){const n=c.p2sh({redeem:{output:r}});if(e.prevOutScript){let t;try{t=c.p2sh({output:e.prevOutScript})}catch(e){throw new Error("PrevOutScript must be P2SH")}if(!n.hash.equals(t.hash))throw new Error("Redeem script inconsistent with prevOutScript")}const i=v(n.redeem.output,t);if(!i.pubkeys)throw new Error(i.type+" not supported as redeemScript ("+f.toASM(r)+")");e.signatures&&e.signatures.some(e=>void 0!==e)&&(i.signatures=e.signatures);let o=r;return i.type===b.P2WPKH&&(o=c.p2pkh({pubkey:i.pubkeys[0]}).output),{redeemScript:r,redeemScriptType:i.type,prevOutType:b.P2SH,prevOutScript:n.output,hasWitness:i.type===b.P2WPKH,signScript:o,signType:i.type,pubkeys:i.pubkeys,signatures:i.signatures,maxSignatures:i.maxSignatures}}if(n){const r=c.p2wsh({redeem:{output:n}});if(e.prevOutScript){const t=c.p2wsh({output:e.prevOutScript});if(!r.hash.equals(t.hash))throw new Error("Witness script inconsistent with prevOutScript")}const i=v(r.redeem.output,t);if(!i.pubkeys)throw new Error(i.type+" not supported as witnessScript ("+f.toASM(n)+")");e.signatures&&e.signatures.some(e=>void 0!==e)&&(i.signatures=e.signatures);const o=n;if(i.type===b.P2WPKH)throw new Error("P2WSH(P2WPKH) is a consensus failure");return{witnessScript:n,witnessScriptType:i.type,prevOutType:b.P2WSH,prevOutScript:r.output,hasWitness:!0,signScript:o,signType:i.type,pubkeys:i.pubkeys,signatures:i.signatures,maxSignatures:i.maxSignatures}}if(e.prevOutType&&e.prevOutScript){if(e.prevOutType===b.P2SH)throw new Error("PrevOutScript is "+e.prevOutType+", requires redeemScript");if(e.prevOutType===b.P2WSH)throw new Error("PrevOutScript is "+e.prevOutType+", requires witnessScript");if(!e.prevOutScript)throw new Error("PrevOutScript is missing");const r=v(e.prevOutScript,t);if(!r.pubkeys)throw new Error(r.type+" not supported ("+f.toASM(e.prevOutScript)+")");e.signatures&&e.signatures.some(e=>void 0!==e)&&(r.signatures=e.signatures);let n=e.prevOutScript;return r.type===b.P2WPKH&&(n=c.p2pkh({pubkey:r.pubkeys[0]}).output),{prevOutType:r.type,prevOutScript:e.prevOutScript,hasWitness:r.type===b.P2WPKH,signScript:n,signType:r.type,pubkeys:r.pubkeys,signatures:r.signatures,maxSignatures:r.maxSignatures}}const i=c.p2pkh({pubkey:t}).output;return{prevOutType:b.P2PKH,prevOutScript:i,hasWitness:!1,signScript:i,signType:b.P2PKH,pubkeys:[t],signatures:[void 0]}}(E,k,a,l);Object.assign(E,e)}if(!w(E))throw Error(E.prevOutType+" not supported")}let S;S=E.hasWitness?n.hashForWitnessV0(_,E.signScript,E.value,s):n.hashForSignature(_,E.signScript,s);return{input:E,ourPubKey:k,keyPair:o,signatureHash:S,hashType:s,useLowR:!!y}}(this.network,this.__INPUTS,this.__needsOutputs.bind(this),this.__TX,e,t,r,n,i,o,this.__USE_LOW_R))}__addInputUnsafe(e,t,r){if(d.Transaction.isCoinbaseHash(e))throw new Error("coinbase inputs not supported");const n=e.toString("hex")+":"+t;if(void 0!==this.__PREV_TX_SET[n])throw new Error("Duplicate TxOut: "+n);let i={};if(void 0!==r.script&&(i=function e(t,r,n,i){if(0===t.length&&0===r.length)return{};if(!n){let e=o.input(t,!0),i=o.witness(r,!0);e===b.NONSTANDARD&&(e=void 0),i===b.NONSTANDARD&&(i=void 0),n=e||i}switch(n){case b.P2WPKH:{const{output:e,pubkey:t,signature:n}=c.p2wpkh({witness:r});return{prevOutScript:e,prevOutType:b.P2WPKH,pubkeys:[t],signatures:[n]}}case b.P2PKH:{const{output:e,pubkey:r,signature:n}=c.p2pkh({input:t});return{prevOutScript:e,prevOutType:b.P2PKH,pubkeys:[r],signatures:[n]}}case b.P2PK:{const{signature:e}=c.p2pk({input:t});return{prevOutType:b.P2PK,pubkeys:[void 0],signatures:[e]}}case b.P2MS:{const{m:e,pubkeys:r,signatures:n}=c.p2ms({input:t,output:i},{allowIncomplete:!0});return{prevOutType:b.P2MS,pubkeys:r,signatures:n,maxSignatures:e}}}if(n===b.P2SH){const{output:n,redeem:i}=c.p2sh({input:t,witness:r}),a=o.output(i.output),s=e(i.input,i.witness,a,i.output);return s.prevOutType?{prevOutScript:n,prevOutType:b.P2SH,redeemScript:i.output,redeemScriptType:s.prevOutType,witnessScript:s.witnessScript,witnessScriptType:s.witnessScriptType,pubkeys:s.pubkeys,signatures:s.signatures}:{}}if(n===b.P2WSH){const{output:n,redeem:i}=c.p2wsh({input:t,witness:r}),a=o.output(i.output);let s;return s=a===b.P2WPKH?e(i.input,i.witness,a):e(f.compile(i.witness),[],a,i.output),s.prevOutType?{prevOutScript:n,prevOutType:b.P2WSH,witnessScript:i.output,witnessScriptType:s.prevOutType,pubkeys:s.pubkeys,signatures:s.signatures}:{}}return{prevOutType:b.NONSTANDARD,prevOutScript:t}}(r.script,r.witness||[])),void 0!==r.value&&(i.value=r.value),!i.prevOutScript&&r.prevOutScript){let e;if(!i.pubkeys&&!i.signatures){const t=v(r.prevOutScript);t.pubkeys&&(i.pubkeys=t.pubkeys,i.signatures=t.signatures),e=t.type}i.prevOutScript=r.prevOutScript,i.prevOutType=e||o.output(r.prevOutScript)}const a=this.__TX.addInput(e,t,r.sequence,r.scriptSig);return this.__INPUTS[a]=i,this.__PREV_TX_SET[n]=!0,a}__build(e){if(!e){if(!this.__TX.ins.length)throw new Error("Transaction has no inputs");if(!this.__TX.outs.length)throw new Error("Transaction has no outputs")}const t=this.__TX.clone();if(this.__INPUTS.forEach((r,n)=>{if(!r.prevOutType&&!e)throw new Error("Transaction is not complete");const i=function e(t,r,n){const i=r.pubkeys||[];let o=r.signatures||[];switch(t){case b.P2PKH:if(0===i.length)break;if(0===o.length)break;return c.p2pkh({pubkey:i[0],signature:o[0]});case b.P2WPKH:if(0===i.length)break;if(0===o.length)break;return c.p2wpkh({pubkey:i[0],signature:o[0]});case b.P2PK:if(0===i.length)break;if(0===o.length)break;return c.p2pk({signature:o[0]});case b.P2MS:{const e=r.maxSignatures;o=n?o.map(e=>e||l.OPS.OP_0):o.filter(e=>e);const t=!n||e===o.length;return c.p2ms({m:e,pubkeys:i,signatures:o},{allowIncomplete:n,validate:t})}case b.P2SH:{const t=e(r.redeemScriptType,r,n);if(!t)return;return c.p2sh({redeem:{output:t.output||r.redeemScript,input:t.input,witness:t.witness}})}case b.P2WSH:{const t=e(r.witnessScriptType,r,n);if(!t)return;return c.p2wsh({redeem:{output:r.witnessScript,input:t.input,witness:t.witness}})}}}(r.prevOutType,r,e);if(i)t.setInputScript(n,i.input),t.setWitness(n,i.witness);else{if(!e&&r.prevOutType===b.NONSTANDARD)throw new Error("Unknown input type");if(!e)throw new Error("Not enough information")}}),!e&&this.__overMaximumFees(t.virtualSize()))throw new Error("Transaction has absurd fees");return t}__canModifyInputs(){return this.__INPUTS.every(e=>!e.signatures||e.signatures.every(e=>{if(!e)return!0;return 0!=(_(e)&d.Transaction.SIGHASH_ANYONECANPAY)}))}__needsOutputs(e){return e===d.Transaction.SIGHASH_ALL?0===this.__TX.outs.length:0===this.__TX.outs.length&&this.__INPUTS.some(e=>!!e.signatures&&e.signatures.some(e=>{if(!e)return!1;return!(_(e)&d.Transaction.SIGHASH_NONE)}))}__canModifyOutputs(){const e=this.__TX.ins.length,t=this.__TX.outs.length;return this.__INPUTS.every(r=>void 0===r.signatures||r.signatures.every(r=>{if(!r)return!0;const n=31&_(r);return n===d.Transaction.SIGHASH_NONE||n===d.Transaction.SIGHASH_SINGLE&&e<=t}))}__overMaximumFees(e){return(this.__INPUTS.reduce((e,t)=>e+(t.value>>>0),0)-this.__TX.outs.reduce((e,t)=>e+t.value,0))/e>this.maximumFeeRate}}function v(e,t){p(h.Buffer,e);const r=o.output(e);switch(r){case b.P2PKH:{if(!t)return{type:r};const n=c.p2pkh({output:e}).hash,i=a.hash160(t);return n.equals(i)?{type:r,pubkeys:[t],signatures:[void 0]}:{type:r}}case b.P2WPKH:{if(!t)return{type:r};const n=c.p2wpkh({output:e}).hash,i=a.hash160(t);return n.equals(i)?{type:r,pubkeys:[t],signatures:[void 0]}:{type:r}}case b.P2PK:return{type:r,pubkeys:[c.p2pk({output:e}).pubkey],signatures:[void 0]};case b.P2MS:{const t=c.p2ms({output:e});return{type:r,pubkeys:t.pubkeys,signatures:t.pubkeys.map(()=>{}),maxSignatures:t.m}}}return{type:r}}function w(e){return void 0!==e.signScript&&void 0!==e.signType&&void 0!==e.pubkeys&&void 0!==e.signatures&&e.signatures.length===e.pubkeys.length&&e.pubkeys.length>0&&(!1===e.hasWitness||void 0!==e.value)}function _(e){return e.readUInt8(e.length-1)}t.TransactionBuilder=y}).call(this,r(0).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(83),o=r(290),a=r(84),s=r(85),u=r(295),c=r(298),f=r(300),l=r(302),d={P2MS:"multisig",NONSTANDARD:"nonstandard",NULLDATA:"nulldata",P2PK:"pubkey",P2PKH:"pubkeyhash",P2SH:"scripthash",P2WPKH:"witnesspubkeyhash",P2WSH:"witnessscripthash",WITNESS_COMMITMENT:"witnesscommitment"};t.types=d,t.output=function(e){if(f.output.check(e))return d.P2WPKH;if(l.output.check(e))return d.P2WSH;if(s.output.check(e))return d.P2PKH;if(u.output.check(e))return d.P2SH;const t=n.decompile(e);if(!t)throw new TypeError("Invalid script");return i.output.check(t)?d.P2MS:a.output.check(t)?d.P2PK:c.output.check(t)?d.WITNESS_COMMITMENT:o.output.check(t)?d.NULLDATA:d.NONSTANDARD},t.input=function(e,t){const r=n.decompile(e);if(!r)throw new TypeError("Invalid script");return s.input.check(r)?d.P2PKH:u.input.check(r,t)?d.P2SH:i.input.check(r,t)?d.P2MS:a.input.check(r)?d.P2PK:d.NONSTANDARD},t.witness=function(e,t){const r=n.decompile(e);if(!r)throw new TypeError("Invalid script");return f.input.check(r)?d.P2WPKH:l.input.check(r,t)?d.P2WSH:d.NONSTANDARD}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(1);function o(e){return e===i.OPS.OP_0||n.isCanonicalScriptSignature(e)}function a(e,t){const r=n.decompile(e);return!(r.length<2)&&(r[0]===i.OPS.OP_0&&(t?r.slice(1).every(o):r.slice(1).every(n.isCanonicalScriptSignature)))}t.check=a,a.toJSON=()=>"multisig input"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(1),o=r(16),a=i.OPS.OP_RESERVED;function s(e,t){const r=n.decompile(e);if(r.length<4)return!1;if(r[r.length-1]!==i.OPS.OP_CHECKMULTISIG)return!1;if(!o.Number(r[0]))return!1;if(!o.Number(r[r.length-2]))return!1;const s=r[0]-a,u=r[r.length-2]-a;if(s<=0)return!1;if(u>16)return!1;if(s>u)return!1;if(u!==r.length-3)return!1;if(t)return!0;return r.slice(1,-2).every(n.isCanonicalPubKey)}t.check=s,s.toJSON=()=>"multi-sig output"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=n.OPS;function o(e){const t=n.compile(e);return t.length>1&&t[0]===i.OP_RETURN}t.check=o,o.toJSON=()=>"null data output";const a={check:o};t.output=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1);function i(e){const t=n.decompile(e);return 1===t.length&&n.isCanonicalScriptSignature(t[0])}t.check=i,i.toJSON=()=>"pubKey input"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(1);function o(e){const t=n.decompile(e);return 2===t.length&&n.isCanonicalPubKey(t[0])&&t[1]===i.OPS.OP_CHECKSIG}t.check=o,o.toJSON=()=>"pubKey output"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1);function i(e){const t=n.decompile(e);return 2===t.length&&n.isCanonicalScriptSignature(t[0])&&n.isCanonicalPubKey(t[1])}t.check=i,i.toJSON=()=>"pubKeyHash input"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(1);function o(e){const t=n.compile(e);return 25===t.length&&t[0]===i.OPS.OP_DUP&&t[1]===i.OPS.OP_HASH160&&20===t[2]&&t[23]===i.OPS.OP_EQUALVERIFY&&t[24]===i.OPS.OP_CHECKSIG}t.check=o,o.toJSON=()=>"pubKeyHash output"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(296);t.input=n;const i=r(297);t.output=i},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(83),o=r(84),a=r(85),s=r(127),u=r(128);function c(t,r){const c=n.decompile(t);if(c.length<1)return!1;const f=c[c.length-1];if(!e.isBuffer(f))return!1;const l=n.decompile(n.compile(c.slice(0,-1))),d=n.decompile(f);return!!d&&(!!n.isPushOnly(l)&&(1===c.length?u.check(d)||s.check(d):!(!a.input.check(l)||!a.output.check(d))||(!(!i.input.check(l,r)||!i.output.check(d))||!(!o.input.check(l)||!o.output.check(d)))))}t.check=c,c.toJSON=()=>"scriptHash input"}).call(this,r(0).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(1);function o(e){const t=n.compile(e);return 23===t.length&&t[0]===i.OPS.OP_HASH160&&20===t[1]&&t[22]===i.OPS.OP_EQUAL}t.check=o,o.toJSON=()=>"scriptHash output"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(299);t.output=n},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(1),o=r(16),a=r(3),s=e.from("aa21a9ed","hex");function u(e){const t=n.compile(e);return t.length>37&&t[0]===i.OPS.OP_RETURN&&36===t[1]&&t.slice(2,6).equals(s)}t.check=u,u.toJSON=()=>"Witness commitment output",t.encode=function(t){a(o.Hash256bit,t);const r=e.allocUnsafe(36);return s.copy(r,0),t.copy(r,4),n.compile([i.OPS.OP_RETURN,r])},t.decode=function(e){return a(u,e),n.decompile(e)[1].slice(4,36)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(301);t.input=n;const i=r(127);t.output=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1);function i(e){const t=n.decompile(e);return 2===t.length&&n.isCanonicalScriptSignature(t[0])&&(r=t[1],n.isCanonicalPubKey(r)&&33===r.length);var r}t.check=i,i.toJSON=()=>"witnessPubKeyHash input"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(303);t.input=n;const i=r(128);t.output=i},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(3),o=r(83),a=r(84),s=r(85);function u(t,r){if(i(i.Array,t),t.length<1)return!1;const u=t[t.length-1];if(!e.isBuffer(u))return!1;const c=n.decompile(u);if(!c||0===c.length)return!1;const f=n.compile(t.slice(0,-1));return!(!s.input.check(f)||!s.output.check(c))||(!(!o.input.check(f,r)||!o.output.check(c))||!(!a.input.check(f)||!a.output.check(c)))}t.check=u,u.toJSON=()=>"witnessScriptHash input"}).call(this,r(0).Buffer)},function(e,t,r){(function(t){function r(e,r){for(var n=e.length,i=[],o=0;o<n;o+=2){var a=e[o],s=o+1===n?a:e[o+1],u=t.concat([a,s]);i.push(r(u))}return i}e.exports=function(e,t){if(!Array.isArray(e))throw TypeError("Expected values Array");if("function"!=typeof t)throw TypeError("Expected digest Function");if(1===e.length)return e.concat();var n=[e],i=e;do{i=r(i,t),n.push(i)}while(i.length>1);return[].concat.apply([],n)}}).call(this,r(0).Buffer)},function(e,t,r){(function(t){function r(e){for(var t=1,r=e;r>1;r=r+1>>1)t+=r;return t}function n(e,t){return e+(1<<t)-1>>t}e.exports=function(e,t){var i=e.indexOf(t);if(-1===i)return null;for(var o=e.length,a=[],s=n(o,1);s>0&&r(s)!==o;)--s;if(0===s)throw new Error("Unknown solution");for(var u=0,c=0;c<o-1;){var f=n(s,u);++u;var l=i%2;l&&--i;var d=c+i,h=e[d],p=i===f-1?h:e[d+1];c>0?(a.push(l?h:null),a.push(l?null:p)):(a.push(h),a.push(p)),i=i/2|0,c+=f}return a.push(e[o-1]),a},e.exports.verify=function(e,r){for(var n=e[e.length-1],i=n,o=0;o<e.length-1;o+=2){var a=e[o]||i,s=e[o+1]||i;i=r(t.concat([a,s]))}return i.equals(n)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.TeleportDaoPayment=void 0;const i=r(129);class o extends i.BitcoinBase{payBurnRequest(e,t="normal"){return n(this,void 0,void 0,(function*(){if(!(this.currentAccount&&this.currentAccountType&&this.publicKey&&this.privateKey))throw new Error("account not initialized");let r=yield this.getExtendedUtxo({address:this.currentAccount,addressType:this.currentAccountType,publicKey:this.publicKey.toString("hex")}),n=yield this.transactionBuilder._getFeeRate(t),i=yield this.transactionBuilder.processUnsignedTransaction({extendedUtxo:r,targets:e,changeAddress:this.currentAccount,feeRate:n,fullAmount:!1}),o=yield this.signer.signPsbt(i,this.privateKey),a=this.signer.finalizePsbts([o]);return yield this.transactionBuilder.sendTx(a)}))}transferBitcoinToEth({lockerAddress:e,amount:t,fullAmount:r=!1,chainId:i,appId:o,recipientAddress:a,percentageFee:s,speed:u=0,isExchange:c=!1,exchangeTokenAddress:f="0x0000000000000000000000000000000000000000",outputAmount:l=0,deadline:d,isFixedToken:h=!1,feeSpeed:p="normal",staticFeeRate:b}){return n(this,void 0,void 0,(function*(){if(!(this.currentAccount&&this.currentAccountType&&this.publicKey&&this.privateKey))throw new Error("account not initialized");let n=yield this.getExtendedUtxo({address:this.currentAccount,addressType:this.currentAccountType,publicKey:this.publicKey.toString("hex")}),m=yield this.getBitcoinToEthUnsignedPsbt({changeAddress:this.currentAccount,extendedUtxo:n,lockerAddress:e,amount:t,fullAmount:r,chainId:i,appId:o,recipientAddress:a,percentageFee:s,speed:u,isExchange:c,exchangeTokenAddress:f,outputAmount:l,deadline:d,isFixedToken:h,feeSpeed:p,staticFeeRate:b}),g=yield this.signer.signPsbt(m,this.privateKey);return yield this.sendSignedPsbt(g)}))}getBitcoinToEthTargetOutputs({lockerAddress:e,amount:t,fullAmount:r=!1,chainId:i,appId:a,recipientAddress:s,percentageFee:u,speed:c=0,isExchange:f=!1,exchangeTokenAddress:l="0x0000000000000000000000000000000000000000",outputAmount:d=0,deadline:h=0,isFixedToken:p=!1}){return n(this,void 0,void 0,(function*(){let n=o.getTransferOpReturnData({chainId:i,appId:a,recipientAddress:s,percentageFee:u,speed:c,isExchange:f,exchangeTokenAddress:l,outputAmount:d,deadline:h,isFixedToken:p}),b=this.transactionBuilder.getOpReturnTarget(n);return r?[b]:[{address:e,value:t},b]}))}getBitcoinToEthUnsignedPsbt({changeAddress:e,extendedUtxo:t,lockerAddress:r,amount:i,fullAmount:o=!1,chainId:a,appId:s,recipientAddress:u,percentageFee:c,speed:f=0,isExchange:l=!1,exchangeTokenAddress:d="0x0000000000000000000000000000000000000000",outputAmount:h=0,deadline:p=0,isFixedToken:b=!1,feeSpeed:m="normal",staticFeeRate:g}){return n(this,void 0,void 0,(function*(){let n=g||(yield this.transactionBuilder._getFeeRate(m)),y=yield this.getBitcoinToEthTargetOutputs({lockerAddress:r,amount:i,fullAmount:o,chainId:a,appId:s,recipientAddress:u,percentageFee:c,speed:f,isExchange:l,exchangeTokenAddress:d,outputAmount:h,deadline:p,isFixedToken:b});return yield this.transactionBuilder.processUnsignedTransaction({extendedUtxo:t,targets:y,changeAddress:o?r:e,feeRate:n,fullAmount:o})}))}bitcoinToEthLend({lockerAddress:e,amount:t,chainId:r,appId:i,recipientAddress:a,percentageFee:s,mode:u=0,isBorrow:c=!1,tokenAddress:f="0x0000000000000000000000000000000000000000",borrowAmount:l=0,staticFeeRate:d}){return n(this,void 0,void 0,(function*(){if(!(this.currentAccount&&this.currentAccountType&&this.publicKey&&this.privateKey))throw new Error("account not initialized");let n=o.getLendingOpReturnData({chainId:r,appId:i,recipientAddress:a,percentageFee:s,mode:u,isBorrow:c,tokenAddress:f,borrowAmount:l}),h=this.transactionBuilder.getOpReturnTarget(n),p=yield this.transactionBuilder.getExtendedUtxo({address:this.currentAccount,addressType:this.currentAccountType,publicKey:this.publicKey.toString("hex")}),b=yield this.transactionBuilder.processUnsignedTransaction({extendedUtxo:p,targets:[{address:e,value:t},h],changeAddress:this.currentAccount,feeRate:d,fullAmount:!1}),m=yield this.signer.signPsbt(b,this.privateKey),g=this.signer.finalizePsbts([m]);return yield this.transactionBuilder.sendTx(g)}))}static getTransferOpReturnData({chainId:e,appId:t,recipientAddress:r,percentageFee:n,speed:i=0,isExchange:o=!1,exchangeTokenAddress:a="0x0000000000000000000000000000000000000000",outputAmount:s=0,deadline:u,isFixedToken:c=!1}){let f=Number(e).toString(16).padStart(2,"0")+Number(t).toString(16).padStart(4,"0")+r.replace("0x","").toLowerCase().padStart(40,"0")+Number((100*n).toFixed(0)).toString(16).padStart(4,"0")+(i?"01":"00");if(!o){if(52!==f.length)throw new Error("invalid data length");return f}if(f=f+a.replace("0x","").toLowerCase().padStart(40,"0")+Number(s).toString(16).padStart(56,"0")+Number(u).toString(16).padStart(8,"0")+(c?"01":"00"),158!==f.length)throw new Error("invalid data length");return f}static getLendingOpReturnData({chainId:e,appId:t,recipientAddress:r,percentageFee:n,mode:i,isBorrow:o=!1,tokenAddress:a="0x0000000000000000000000000000000000000000",borrowAmount:s=0}){let u=Number(e).toString(16).padStart(2,"0")+Number(t).toString(16).padStart(4,"0")+r.replace("0x","").toLowerCase().padStart(40,"0")+Number((100*n).toFixed(0)).toString(16).padStart(4,"0")+Number(i).toString(16).padStart(2,"0");if(!o){if(52!==u.length)throw new Error("invalid data length");return u}if(u=u+a.replace("0x","").toLowerCase().padStart(40,"0")+Number(s).toString(16).padStart(56,"0"),148!==u.length)throw new Error("invalid data length");return u}}t.TeleportDaoPayment=o,t.default=o},function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},a=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((n=n.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const u=s(r(308)),c=r(131),f=o(r(35));class l extends u.default{constructor(e,t,r=f.networks.bitcoin){super({network:r,testnet:null==t?void 0:t.includes("_testnet"),dustLimit:1e3}),this.btcInterface=new c.BitcoinInterface(e,t)}_getUtxo(e){return a(this,void 0,void 0,(function*(){return(yield this.btcInterface.getAddressesUtxo([e])).map(e=>({hash:e.txId,value:+e.value,index:+e.index}))}))}_getFeeRate(e="normal"){return a(this,void 0,void 0,(function*(){return this.btcInterface.getFeeRate(e)}))}_getTransactionHex(e){return a(this,void 0,void 0,(function*(){return this.btcInterface.provider.getRawTransaction(e)}))}sendTx(e){return a(this,void 0,void 0,(function*(){return yield this.btcInterface.provider.sendRawTransaction(e)}))}}t.default=l},function(e,t,r){"use strict";(function(e){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},a=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const s=o(r(35)),u=r(34),c=r(309),f=r(311),l=r(130),d={bytePerInput:{p2pkh:148,p2wpkh:68,"p2sh-p2wpkh":91,p2tr:58},baseTxBytes:12,bytePerOutput:{p2pkh:34,p2wpkh:31,p2sh:32,p2tr:43,default:35},opReturn:{dataLessThan75:31,dataMoreThan75:91}};t.default=class{constructor({network:e,testnet:t,feeMin:r=0,dustLimit:n,maximumNumberOfOutputsInTransaction:i=50}){this.testnet=t,this.network=e,this.maximumNumberOfOutputsInTransaction=i,this.feeMin=r,this.dustLimit=n||2*d.bytePerInput.p2pkh}_getUtxo(e){return a(this,void 0,void 0,(function*(){throw new Error("Do not call abstract method directly")}))}_getTransactionHex(e){return a(this,void 0,void 0,(function*(){throw new Error("Do not call abstract method directly")}))}createAddressObject(e){return(0,u.createAddressObjectByPublicKey)(e,this.network)}validateAddress(e){try{return(0,u.getAddressType)(e,this.network),!0}catch(e){return!1}}getOpReturnTarget(t){if(!(t.length>0))throw new Error("invalid data in hex");return{script:s.payments.embed({data:[e.from(t,"hex")],network:this.network}).output,value:0}}getExtendedUtxo(e){return a(this,void 0,void 0,(function*(){const t=(yield this._getUtxo(e.address)).map(t=>Object.assign(Object.assign({},t),{signerInfo:e}));if(!t||0===t.length)throw new Error("no utxo found");return t}))}helperHandleInputsAndOutputs({targets:e,extendedUtxo:t,feeRate:r,changeObject:n,selectType:i="normal"}){const o=t.filter(e=>e.value>+r*d.bytePerInput[e.signerInfo.addressType]);let a;switch(i){case"normal":a=c(o,e,Math.round(r));break;case"accumulative":a=l(o,e,Math.round(r));break;case"full":if(!e[0].address)throw new Error;a=f(o,[{address:e[0].address}],Math.round(r))}let{inputs:s,outputs:h,fee:p}=a;s&&h||(s=o,h=e,p=s.reduce((e,t)=>e+t.value,0)-h.reduce((e,t)=>e+t.value,0));const b=s.map(e=>d.bytePerInput[e.signerInfo.addressType]),m=h.map(e=>{if(e.address){let t="default";try{t=(0,u.getAddressType)(e.address,this.network)}catch(e){t="default"}return d.bytePerOutput[t]}return e.script?e.script.byteLength<75?d.opReturn.dataLessThan75:d.opReturn.dataMoreThan75:d.bytePerOutput.default}),g=(d.baseTxBytes+b.reduce((e,t)=>e+t,0)+m.reduce((e,t)=>e+t,0)+d.bytePerOutput.default)*Math.round(r);if(s.reduce((e,t)=>e+t.value,0)-h.filter(e=>e.address||e.script).reduce((e,t)=>e+t.value,0)-g<1e3){let e=s.reduce((e,t)=>e+t.value,0),t=h.filter(e=>e.address||e.script).reduce((e,t)=>e+t.value,0),r=e-t-g;throw new Error("not enough balance. details: "+JSON.stringify({spendableBalance:e,totalOutputAmount:t,txFee:g,need:r},null,2))}let y,v=p-g,w=h.findIndex(e=>!(null==e?void 0:e.address)&&!e.script&&(e.value||0)>0);if(w>=0||v>1e3){if(w>=0&&(v+=d.bytePerOutput.default*Math.round(r)),v<0&&(v=0),"full"===i)h[0].value=h[0].value+v,p-=v;else{if(!n)throw new Error("change not exist");y={address:n.address,value:w>=0?h[w].value+v:v},p-=v}w>=0&&h.splice(w,1)}return{inputs:s,fee:p,outputs:h,change:y}}filterAndConvertTxDataToStandardFormat({extendedUtxo:e,targets:t,changeObject:r,feeRate:n,selectType:i}){return a(this,void 0,void 0,(function*(){let{inputs:o,outputs:a,change:s,fee:u}=this.helperHandleInputsAndOutputs({targets:t,extendedUtxo:e,feeRate:n,changeObject:r,selectType:i});return{inputs:yield this.convertExtendedUtxoToInputs(o),outputs:a,change:s,fee:u,feeRate:n}}))}convertExtendedUtxoToInputs(t=[]){var r;return a(this,void 0,void 0,(function*(){let n=t,i=null,o=null;for(let t in n){let{address:a,publicKey:s,derivationPath:u,masterFingerprint:c,addressType:f}=n[t].signerInfo,l=this.createAddressObject({publicKey:e.from(s,"hex"),addressType:f});if(u&&c&&l.pubkey&&(n[t].bip32Derivation=[{path:u,pubkey:l.pubkey,masterFingerprint:e.from(c,"hex")}]),"p2pkh"===f)o&&i===n[t].hash||(o=yield this._getTransactionHex(n[t].hash),i=n[t].hash),n[t].nonWitnessUtxo=e.from(o,"hex");else if("p2wpkh"===f){if(!l.output)throw new Error("invalid signer info");n[t].witnessUtxo={script:l.output,value:n[t].value},n[t].signerInfo.includeHex&&(o&&i===n[t].hash||(o=yield this._getTransactionHex(n[t].hash),i=n[t].hash),n[t].nonWitnessUtxo=e.from(o,"hex"))}else if("p2sh-p2wpkh"===f){if(!l.output)throw new Error("invalid signer info");if(n[t].witnessUtxo={script:l.output,value:n[t].value},!(null===(r=null==l?void 0:l.redeem)||void 0===r?void 0:r.output))throw new Error("invalid signer info for p2sh address");n[t].redeemScript=l.redeem.output,n[t].signerInfo.includeHex&&(o&&i===n[t].hash||(o=yield this._getTransactionHex(n[t].hash),i=n[t].hash),n[t].nonWitnessUtxo=e.from(o,"hex"))}else if("p2tr"===f){if(!l.output)throw new Error("invalid signer info");if(n[t].witnessUtxo={script:l.output,value:n[t].value},!l.pubkey)throw new Error("invalid signer info for p2tr address (pubkey)");n[t].tapInternalKey=l.internalPubkey,n[t].signerInfo.includeHex&&(o&&i===n[t].hash||(o=yield this._getTransactionHex(n[t].hash),i=n[t].hash),n[t].nonWitnessUtxo=e.from(o,"hex"))}}return n}))}createUnsignedTransaction({inputs:e,outputs:t,change:r,fee:n,feeRate:i}){const{network:o}=this,a=new s.Psbt({network:o});a.setMaximumFeeRate(+(i+i/100).toFixed());for(const t of e){let{addressType:e}=t.signerInfo;switch(e){case"p2pkh":{let e={hash:t.hash,index:Number(t.index),nonWitnessUtxo:t.nonWitnessUtxo,sequence:4294967294,bip32Derivation:t.bip32Derivation};e.bip32Derivation||delete e.bip32Derivation,a.addInput(e);break}case"p2wpkh":{let e={hash:t.hash,index:Number(t.index),witnessUtxo:t.witnessUtxo,nonWitnessUtxo:t.nonWitnessUtxo,sequence:4294967294,bip32Derivation:t.bip32Derivation};e.bip32Derivation||delete e.bip32Derivation,e.nonWitnessUtxo||delete e.nonWitnessUtxo,a.addInput(e);break}case"p2sh-p2wpkh":{let e={hash:t.hash,index:Number(t.index),witnessUtxo:t.witnessUtxo,nonWitnessUtxo:t.nonWitnessUtxo,redeemScript:t.redeemScript,sequence:4294967294,bip32Derivation:t.bip32Derivation};e.bip32Derivation||delete e.bip32Derivation,e.nonWitnessUtxo||delete e.nonWitnessUtxo,a.addInput(e);break}case"p2tr":{let e={hash:t.hash,index:Number(t.index),witnessUtxo:t.witnessUtxo,nonWitnessUtxo:t.nonWitnessUtxo,tapInternalKey:t.tapInternalKey,sequence:4294967294,bip32Derivation:t.bip32Derivation};e.bip32Derivation||delete e.bip32Derivation,e.nonWitnessUtxo||delete e.nonWitnessUtxo,a.addInput(e);break}default:throw new Error("address type is incorrect")}}for(const e of t)a.addOutput(e);if(r&&0!==Object.keys(r).length&&a.addOutput(r),r&&0!==Object.keys(r).length&&a.txOutputs[t.length].address!==r.address)throw new Error("error change address");return{unsignedTransaction:a.toBase64(),outputs:t,inputs:e.map(e=>({hash:e.hash,value:Number(e.value),index:e.index,signerInfo:e.signerInfo})),fee:n,change:r}}processUnsignedTransaction({extendedUtxo:e,targets:t=[],changeAddress:r,fullAmount:n=!1,feeRate:i,selfTransaction:o=!1,selectType:s="normal"}){return a(this,void 0,void 0,(function*(){if(!o&&0===t.length)throw new Error("no target");let a="string"==typeof r?{address:r}:r;const{inputs:u,outputs:c,change:f,fee:l}=yield this.filterAndConvertTxDataToStandardFormat({extendedUtxo:e,targets:t,changeObject:a,feeRate:i,selectType:n?"full":s});return this.createUnsignedTransaction({inputs:u,outputs:c,change:f,fee:l,feeRate:i})}))}}}).call(this,r(0).Buffer)},function(e,t,r){var n=r(130),i=r(310),o=r(53);function a(e,t){return e.value-t*o.inputBytes(e)}e.exports=function(e,t,r){e=e.concat().sort((function(e,t){return a(t,r)-a(e,r)}));var o=i(e,t,r);return o.inputs?o:n(e,t,r)}},function(e,t,r){var n=r(53);e.exports=function(e,t,r){if(!isFinite(n.uintOrNaN(r)))return{};for(var i=n.transactionBytes([],t),o=0,a=[],s=n.sumOrNaN(t),u=n.dustThreshold({},r),c=0;c<e.length;++c){var f=e[c],l=n.inputBytes(f),d=r*(i+l),h=n.uintOrNaN(f.value);if(!(o+h>s+d+u)&&(i+=l,o+=h,a.push(f),!(o<s+d)))return n.finalize(a,t,r)}return{fee:r*i}}},function(e,t,r){var n=r(53);e.exports=function(e,t,r){if(!isFinite(n.uintOrNaN(r)))return{};var i=n.transactionBytes(e,t),o=r*i;if(0===t.length)return{fee:o};var a=n.sumOrNaN(e)-n.sumForgiving(t)-o;if(!isFinite(a)||a<0)return{fee:o};var s=t.reduce((function(e,t){return e+!isFinite(t.value)}),0);if(0===a&&0===s)return n.finalize(e,t,r);var u=t.reduce((function(e,t){return void 0!==t.value?e:e+1}),0),c=Math.floor(a/u);return t.every((function(e){return void 0!==e.value||c>n.dustThreshold(e,r)}))?(t=t.map((function(e){if(void 0!==e.value)return e;var t={};for(var r in e)t[r]=e[r];return t.value=c,t})),n.finalize(e,t,r)):{fee:o}}},function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},a=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.bitcoin=void 0,t.bitcoin=o(r(313)),a(r(338),t)},function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getApiProvider=t.getRpcProvider=t.ApiProviders=t.RPC=void 0;const s=a(r(314));t.RPC=s.default;const u=o(r(334));t.ApiProviders=u,t.getRpcProvider=function(e){const{url:t,headers:r,auth:n}=e;return new s.default({url:t,headers:r,auth:n})},t.getApiProvider=function(e,t){if(!u[e.provider])throw new Error("provider not supported");let r=!!(null==t?void 0:t.includes("_testnet"));return"NowNodes"===e.provider?new u.NowNodes({token:e.token,timeout:3e4},r):"BlockStream"===e.provider?new u.BlockStream(r,{token:e.token,timeout:3e4}):"MempoolSpace"===e.provider?new u.MempoolSpace(r,{token:e.token,timeout:3e4}):void 0}},function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((n=n.apply(e,t||[])).next())}))};const{getAxiosInstance:i}=r(54);class o{constructor({headers:e,url:t,auth:r}){this.axios=o.getAxiosInstance({baseUrl:t,headers:e,auth:r,timeout:18e4})}static getAxiosInstance(e){return i(e)}static getRpcBody(e,t=[]){return{jsonrpc:"2.0",id:"teleport-dao",method:e,params:t}}getChainInfo(){return n(this,void 0,void 0,(function*(){return(yield this.axios.post("/",o.getRpcBody("getblockchaininfo"))).data.result}))}getLatestBlockNumber(){return n(this,void 0,void 0,(function*(){return(yield this.axios.post("/",o.getRpcBody("getblockcount"))).data.result}))}getBlockHash(e){return n(this,void 0,void 0,(function*(){return(yield this.axios.post("/",o.getRpcBody("getblockhash",[Number(e)]))).data.result}))}getBlockByBlockHash(e,t=1){return n(this,void 0,void 0,(function*(){return(yield this.axios.post("/",o.getRpcBody("getblock",[e,Number(t)]))).data.result}))}getBlockHeaderByBlockHash(e){return n(this,void 0,void 0,(function*(){return(yield this.axios.post("/",o.getRpcBody("getblockheader",[e,!1]))).data.result}))}getBlockByBlockNumber(e,t){return n(this,void 0,void 0,(function*(){return this.getBlockByBlockHash(yield this.getBlockHash(e),t)}))}getTransaction(e){return n(this,void 0,void 0,(function*(){let t=(yield this.axios.post("/",o.getRpcBody("getrawtransaction",[e,!0]))).data.result,r=t.blockhash?yield this.getBlockByBlockHash(t.blockhash):{};return{txId:t.txid,version:t.version,locktime:t.locktime,blockNumber:r.height||null,blockHash:t.blockhash||null,vout:t.vout.map(e=>({address:e.scriptPubKey.address||null,script:e.scriptPubKey.hex,value:Number((1e8*Number(e.value)).toFixed())})),vin:t.vin.map(e=>({txId:e.txid,index:e.vout}))}}))}getRawTransaction(e){return n(this,void 0,void 0,(function*(){return(yield this.axios.post("/",o.getRpcBody("getrawtransaction",[e,!0]))).data.result.hex}))}getTxOutProof(e){return n(this,void 0,void 0,(function*(){return(yield this.axios.post("/",o.getRpcBody("gettxoutproof",[e,!0]))).data.result.hex}))}getBlockTransactionIds(e){return n(this,void 0,void 0,(function*(){return(yield this.getBlockByBlockHash(e)).tx}))}sendRawTransaction(e,t=.1){return n(this,void 0,void 0,(function*(){return(yield this.axios.post("/",o.getRpcBody("sendrawtransaction",[e,t]))).data.result}))}getBlockHeaderHex(e){return n(this,void 0,void 0,(function*(){const t=yield this.getBlockHash(e);return yield this.getBlockHeaderByBlockHash(t)}))}getEstimateFeeByNumberOfBlock(e){return n(this,void 0,void 0,(function*(){return(yield this.axios.post("/",o.getRpcBody("estimatesmartfee",[e,"ECONOMICAL"]))).data.result.feerate*Math.pow(10,5)}))}getFeeRate(e="normal"){return n(this,void 0,void 0,(function*(){let t;switch(e){case"slow":t=yield this.getEstimateFeeByNumberOfBlock(10);break;case"normal":t=yield this.getEstimateFeeByNumberOfBlock(6);break;case"fast":t=yield this.getEstimateFeeByNumberOfBlock(3);break;default:t=yield this.getEstimateFeeByNumberOfBlock(6)}return+t.toFixed()}))}}e.exports=o},function(e,t,r){e.exports=r(316)},function(e,t,r){"use strict";var n=r(6),i=r(132),o=r(317),a=r(139);var s=function e(t){var r=new o(t),s=i(o.prototype.request,r);return n.extend(s,o.prototype,r),n.extend(s,r),s.create=function(r){return e(a(t,r))},s}(r(86));s.Axios=o,s.CanceledError=r(55),s.CancelToken=r(331),s.isCancel=r(138),s.VERSION=r(140).version,s.toFormData=r(135),s.AxiosError=r(32),s.Cancel=s.CanceledError,s.all=function(e){return Promise.all(e)},s.spread=r(332),s.isAxiosError=r(333),e.exports=s,e.exports.default=s},function(e,t,r){"use strict";var n=r(6),i=r(133),o=r(318),a=r(319),s=r(139),u=r(137),c=r(330),f=c.validators;function l(e){this.defaults=e,this.interceptors={request:new o,response:new o}}l.prototype.request=function(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},(t=s(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var r=t.transitional;void 0!==r&&c.assertOptions(r,{silentJSONParsing:f.transitional(f.boolean),forcedJSONParsing:f.transitional(f.boolean),clarifyTimeoutError:f.transitional(f.boolean)},!1);var n=[],i=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(i=i&&e.synchronous,n.unshift(e.fulfilled,e.rejected))}));var o,u=[];if(this.interceptors.response.forEach((function(e){u.push(e.fulfilled,e.rejected)})),!i){var l=[a,void 0];for(Array.prototype.unshift.apply(l,n),l=l.concat(u),o=Promise.resolve(t);l.length;)o=o.then(l.shift(),l.shift());return o}for(var d=t;n.length;){var h=n.shift(),p=n.shift();try{d=h(d)}catch(e){p(e);break}}try{o=a(d)}catch(e){return Promise.reject(e)}for(;u.length;)o=o.then(u.shift(),u.shift());return o},l.prototype.getUri=function(e){e=s(this.defaults,e);var t=u(e.baseURL,e.url);return i(t,e.params,e.paramsSerializer)},n.forEach(["delete","get","head","options"],(function(e){l.prototype[e]=function(t,r){return this.request(s(r||{},{method:e,url:t,data:(r||{}).data}))}})),n.forEach(["post","put","patch"],(function(e){function t(t){return function(r,n,i){return this.request(s(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}l.prototype[e]=t(),l.prototype[e+"Form"]=t(!0)})),e.exports=l},function(e,t,r){"use strict";var n=r(6);function i(){this.handlers=[]}i.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},i.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},i.prototype.forEach=function(e){n.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=i},function(e,t,r){"use strict";var n=r(6),i=r(320),o=r(138),a=r(86),s=r(55);function u(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new s}e.exports=function(e){return u(e),e.headers=e.headers||{},e.data=i.call(e,e.data,e.headers,e.transformRequest),e.headers=n.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),n.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||a.adapter)(e).then((function(t){return u(e),t.data=i.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return o(t)||(u(e),t&&t.response&&(t.response.data=i.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},function(e,t,r){"use strict";var n=r(6),i=r(86);e.exports=function(e,t,r){var o=this||i;return n.forEach(r,(function(r){e=r.call(o,e,t)})),e}},function(e,t,r){"use strict";var n=r(6);e.exports=function(e,t){n.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))}},function(e,t,r){"use strict";var n=r(32);e.exports=function(e,t,r){var i=r.config.validateStatus;r.status&&i&&!i(r.status)?t(new n("Request failed with status code "+r.status,[n.ERR_BAD_REQUEST,n.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):e(r)}},function(e,t,r){"use strict";var n=r(6);e.exports=n.isStandardBrowserEnv()?{write:function(e,t,r,i,o,a){var s=[];s.push(e+"="+encodeURIComponent(t)),n.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),n.isString(i)&&s.push("path="+i),n.isString(o)&&s.push("domain="+o),!0===a&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(e,t,r){"use strict";e.exports=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}},function(e,t,r){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,r){"use strict";var n=r(6),i=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,r,o,a={};return e?(n.forEach(e.split("\n"),(function(e){if(o=e.indexOf(":"),t=n.trim(e.substr(0,o)).toLowerCase(),r=n.trim(e.substr(o+1)),t){if(a[t]&&i.indexOf(t)>=0)return;a[t]="set-cookie"===t?(a[t]?a[t]:[]).concat([r]):a[t]?a[t]+", "+r:r}})),a):a}},function(e,t,r){"use strict";var n=r(6);e.exports=n.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function i(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return e=i(window.location.href),function(t){var r=n.isString(t)?i(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0}},function(e,t,r){"use strict";e.exports=function(e){var t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}},function(e,t){e.exports=null},function(e,t,r){"use strict";var n=r(140).version,i=r(32),o={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){o[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));var a={};o.transitional=function(e,t,r){function o(e,t){return"[Axios v"+n+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return function(r,n,s){if(!1===e)throw new i(o(n," has been removed"+(t?" in "+t:"")),i.ERR_DEPRECATED);return t&&!a[n]&&(a[n]=!0,console.warn(o(n," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,n,s)}},e.exports={assertOptions:function(e,t,r){if("object"!=typeof e)throw new i("options must be an object",i.ERR_BAD_OPTION_VALUE);for(var n=Object.keys(e),o=n.length;o-- >0;){var a=n[o],s=t[a];if(s){var u=e[a],c=void 0===u||s(u,a,e);if(!0!==c)throw new i("option "+a+" must be "+c,i.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new i("Unknown option "+a,i.ERR_BAD_OPTION)}},validators:o}},function(e,t,r){"use strict";var n=r(55);function i(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var r=this;this.promise.then((function(e){if(r._listeners){var t,n=r._listeners.length;for(t=0;t<n;t++)r._listeners[t](e);r._listeners=null}})),this.promise.then=function(e){var t,n=new Promise((function(e){r.subscribe(e),t=e})).then(e);return n.cancel=function(){r.unsubscribe(t)},n},e((function(e){r.reason||(r.reason=new n(e),t(r.reason))}))}i.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},i.prototype.subscribe=function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]},i.prototype.unsubscribe=function(e){if(this._listeners){var t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}},i.source=function(){var e;return{token:new i((function(t){e=t})),cancel:e}},e.exports=i},function(e,t,r){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},function(e,t,r){"use strict";var n=r(6);e.exports=function(e){return n.isObject(e)&&!0===e.isAxiosError}},function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.MempoolSpace=t.NowNodes=t.BlockStream=void 0;const i=n(r(335));t.BlockStream=i.default;const o=n(r(336));t.MempoolSpace=o.default;const a=n(r(337));t.NowNodes=a.default},function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=i(r(141));class a extends o.default{constructor(e=!1,t){super(e?"https://blockstream.info/testnet/api":"https://blockstream.info/api")}getRecommendedFeeRate(e="normal"){return n(this,void 0,void 0,(function*(){throw new Error("not supported")}))}}t.default=a},function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=n(r(141));class o extends i.default{constructor(e=!1,t){super(e?"https://mempool.space/testnet/api":"https://mempool.space/api")}}t.default=o},function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((n=n.apply(e,t||[])).next())}))};const{getAxiosInstance:i}=r(54);e.exports=class{constructor({token:e,timeout:t=3e4},r=!1){this.baseURL=r?"https://btcbook-testnet.nownodes.io/":"https://btcbook.nownodes.io/",this.axios=i({baseUrl:this.baseURL,timeout:t,headers:{"api-key":e}})}getUtxos(e){return n(this,void 0,void 0,(function*(){return(yield this.axios.get("/api/v2/utxo/"+e)).data.map(t=>({address:e,txId:t.txid,index:t.vout,value:Number(t.value),blockNumber:+t.height}))}))}}},function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.TeleportDao=void 0;const i=r(54);class o{constructor(e){const t=e.includes("testnet")?"https://testnet.api.teleportdao.xyz/api/v1":"https://api.teleportdao.xyz/api/v1";this.api=(0,i.getAxiosInstance)({baseUrl:t,headers:{},timeout:18e4})}getLockers(e){return n(this,void 0,void 0,(function*(){return(yield this.api.get("/teleswap/lockers",{params:{network:e}})).data.data.lockers}))}}t.TeleportDao=o,t.default=o},function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getAxiosInstance=t.getRandomInteger=t.runWithRetries=t.sleep=void 0;const o=i(r(340));function a(e){return new Promise(t=>setTimeout(t,e))}t.sleep=a,t.runWithRetries=function(e,t={maxTries:2,retrySleep:1e3}){return n(this,void 0,void 0,(function*(){const r=t.maxTries||2,n=t.retrySleep||1e3;let i;for(let t=0;t<r;t+=1){try{return yield e()}catch(e){i=e}yield a(n)}throw i||new Error("function failed after retries")}))},t.getRandomInteger=function(e,t){return Math.floor(Math.random()*(t-e))+e},t.getAxiosInstance=function({baseUrl:e,timeout:t=1e4,headers:r={},auth:n}){let i,a=e;return i=o.default.create({baseURL:a,timeout:t,auth:n,headers:Object.assign({},r)}),i.interceptors.response.use(e=>e,e=>{if(e.response){const t=new Error(JSON.stringify({data:e.response.data,message:e.message}));return Promise.reject(t)}if(e.request){const t=new Error(e.message);return Promise.reject(t)}return Promise.reject(e)}),i}},function(e,t,r){e.exports=r(341)},function(e,t,r){"use strict";var n=r(7),i=r(142),o=r(342),a=r(149);var s=function e(t){var r=new o(t),s=i(o.prototype.request,r);return n.extend(s,o.prototype,r),n.extend(s,r),s.create=function(r){return e(a(t,r))},s}(r(87));s.Axios=o,s.CanceledError=r(56),s.CancelToken=r(356),s.isCancel=r(148),s.VERSION=r(150).version,s.toFormData=r(145),s.AxiosError=r(33),s.Cancel=s.CanceledError,s.all=function(e){return Promise.all(e)},s.spread=r(357),s.isAxiosError=r(358),e.exports=s,e.exports.default=s},function(e,t,r){"use strict";var n=r(7),i=r(143),o=r(343),a=r(344),s=r(149),u=r(147),c=r(355),f=c.validators;function l(e){this.defaults=e,this.interceptors={request:new o,response:new o}}l.prototype.request=function(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},(t=s(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var r=t.transitional;void 0!==r&&c.assertOptions(r,{silentJSONParsing:f.transitional(f.boolean),forcedJSONParsing:f.transitional(f.boolean),clarifyTimeoutError:f.transitional(f.boolean)},!1);var n=[],i=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(i=i&&e.synchronous,n.unshift(e.fulfilled,e.rejected))}));var o,u=[];if(this.interceptors.response.forEach((function(e){u.push(e.fulfilled,e.rejected)})),!i){var l=[a,void 0];for(Array.prototype.unshift.apply(l,n),l=l.concat(u),o=Promise.resolve(t);l.length;)o=o.then(l.shift(),l.shift());return o}for(var d=t;n.length;){var h=n.shift(),p=n.shift();try{d=h(d)}catch(e){p(e);break}}try{o=a(d)}catch(e){return Promise.reject(e)}for(;u.length;)o=o.then(u.shift(),u.shift());return o},l.prototype.getUri=function(e){e=s(this.defaults,e);var t=u(e.baseURL,e.url);return i(t,e.params,e.paramsSerializer)},n.forEach(["delete","get","head","options"],(function(e){l.prototype[e]=function(t,r){return this.request(s(r||{},{method:e,url:t,data:(r||{}).data}))}})),n.forEach(["post","put","patch"],(function(e){function t(t){return function(r,n,i){return this.request(s(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}l.prototype[e]=t(),l.prototype[e+"Form"]=t(!0)})),e.exports=l},function(e,t,r){"use strict";var n=r(7);function i(){this.handlers=[]}i.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},i.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},i.prototype.forEach=function(e){n.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=i},function(e,t,r){"use strict";var n=r(7),i=r(345),o=r(148),a=r(87),s=r(56);function u(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new s}e.exports=function(e){return u(e),e.headers=e.headers||{},e.data=i.call(e,e.data,e.headers,e.transformRequest),e.headers=n.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),n.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||a.adapter)(e).then((function(t){return u(e),t.data=i.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return o(t)||(u(e),t&&t.response&&(t.response.data=i.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},function(e,t,r){"use strict";var n=r(7),i=r(87);e.exports=function(e,t,r){var o=this||i;return n.forEach(r,(function(r){e=r.call(o,e,t)})),e}},function(e,t,r){"use strict";var n=r(7);e.exports=function(e,t){n.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))}},function(e,t,r){"use strict";var n=r(33);e.exports=function(e,t,r){var i=r.config.validateStatus;r.status&&i&&!i(r.status)?t(new n("Request failed with status code "+r.status,[n.ERR_BAD_REQUEST,n.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):e(r)}},function(e,t,r){"use strict";var n=r(7);e.exports=n.isStandardBrowserEnv()?{write:function(e,t,r,i,o,a){var s=[];s.push(e+"="+encodeURIComponent(t)),n.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),n.isString(i)&&s.push("path="+i),n.isString(o)&&s.push("domain="+o),!0===a&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(e,t,r){"use strict";e.exports=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}},function(e,t,r){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,r){"use strict";var n=r(7),i=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,r,o,a={};return e?(n.forEach(e.split("\n"),(function(e){if(o=e.indexOf(":"),t=n.trim(e.substr(0,o)).toLowerCase(),r=n.trim(e.substr(o+1)),t){if(a[t]&&i.indexOf(t)>=0)return;a[t]="set-cookie"===t?(a[t]?a[t]:[]).concat([r]):a[t]?a[t]+", "+r:r}})),a):a}},function(e,t,r){"use strict";var n=r(7);e.exports=n.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function i(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return e=i(window.location.href),function(t){var r=n.isString(t)?i(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0}},function(e,t,r){"use strict";e.exports=function(e){var t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}},function(e,t){e.exports=null},function(e,t,r){"use strict";var n=r(150).version,i=r(33),o={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){o[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));var a={};o.transitional=function(e,t,r){function o(e,t){return"[Axios v"+n+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return function(r,n,s){if(!1===e)throw new i(o(n," has been removed"+(t?" in "+t:"")),i.ERR_DEPRECATED);return t&&!a[n]&&(a[n]=!0,console.warn(o(n," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,n,s)}},e.exports={assertOptions:function(e,t,r){if("object"!=typeof e)throw new i("options must be an object",i.ERR_BAD_OPTION_VALUE);for(var n=Object.keys(e),o=n.length;o-- >0;){var a=n[o],s=t[a];if(s){var u=e[a],c=void 0===u||s(u,a,e);if(!0!==c)throw new i("option "+a+" must be "+c,i.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new i("Unknown option "+a,i.ERR_BAD_OPTION)}},validators:o}},function(e,t,r){"use strict";var n=r(56);function i(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var r=this;this.promise.then((function(e){if(r._listeners){var t,n=r._listeners.length;for(t=0;t<n;t++)r._listeners[t](e);r._listeners=null}})),this.promise.then=function(e){var t,n=new Promise((function(e){r.subscribe(e),t=e})).then(e);return n.cancel=function(){r.unsubscribe(t)},n},e((function(e){r.reason||(r.reason=new n(e),t(r.reason))}))}i.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},i.prototype.subscribe=function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]},i.prototype.unsubscribe=function(e){if(this._listeners){var t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}},i.source=function(){var e;return{token:new i((function(t){e=t})),cancel:e}},e.exports=i},function(e,t,r){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},function(e,t,r){"use strict";var n=r(7);e.exports=function(e){return n.isObject(e)&&!0===e.isAxiosError}},function(e,t,r){"use strict";const{requestTypes:n}=r(151).teleswap,{BigNumber:i}=r(369);function o(e){let t="4c"===e.slice(2,4)?e.slice(6):e.slice(4),r=(Number("0x"+t.slice(0,2)),t.slice(2,6));if(!r)return{status:!1,message:"invalid OP_RETURN data : "+t,code:"INVALID_APP_ID"};let o=Number("0x"+r);switch(Object.keys(n).find(e=>o>=n[e].appIdRange[0]&&o<=n[e].appIdRange[1])){case"transfer":case"exchange":return function(e){let t={requestType:"transfer"},r=0;return t.chainId=Number("0x"+e.slice(r,r+=2)),t.appId=Number("0x"+e.slice(r,r+=4)),t.recipientAddress="0x"+e.slice(r,r+=40),t.percentageFee=Number("0x"+e.slice(r,r+=4))/100,t.speed="01"===e.slice(r,r+=2),e.length===r?{status:!0,data:t}:(t.requestType="exchange",t.exchangeTokenAddress="0x"+e.slice(r,r+=40),t.outputAmount=new i("0x"+e.slice(r,r+=56)).toFixed(),t.deadline=new i("0x"+e.slice(r,r+=8)).toFixed(),t.isFixedToken="01"===e.slice(r,r+=2),e.length===r?{status:!0,data:t}:{status:!1,message:`invalid OP_RETURN data for requestType: 'transfer or exchange'. invalid data length : ${e.length} - valid length : ${r}`,code:"INVALID_OP_RETURN"})}(t);case"lend":return function(e){let t={requestType:"lend"},r=0;return t.chainId=Number("0x"+e.slice(r,r+=2)),t.appId=Number("0x"+e.slice(r,r+=4)),t.recipientAddress="0x"+e.slice(r,r+=40),t.percentageFee=Number("0x"+e.slice(r,r+=4))/100,t.mode=Number("0x"+e.slice(r,r+=2)),e.length===r?{status:!0,data:t}:(t.requestType="borrow",t.tokenAddress="0x"+e.slice(r,r+=40),t.borrowAmount=Number("0x"+e.slice(r,r+=56)),e.length===r?{status:!0,data:t}:{status:!1,message:`invalid OP_RETURN data for requestType: 'lend or borrow'. invalid data length : ${e.length} - valid length : ${r}`,code:"INVALID_OP_RETURN"})}(t);default:return{status:!1,message:"invalid appId : "+o,code:"INVALID_OP_RETURN"}}}e.exports={checkAndParseProtocolRequest:function(e,t,r={minTeleporterFeeAmount:0}){var n,i;let a=e.findIndex(e=>e.script.startsWith("6a"));if(a>=0){let s=(null===(n=e[a])||void 0===n?void 0:n.script)||null,u=(null===(i=e.findIndex(e=>e.address===t))||void 0===i?void 0:i.value)||0,c=u>=0&&e[u].value||0,f=o(s);return f.status?function(e,t,r,n,{minTeleporterFeeAmount:i=0}){return e?+e.percentageFee>100?{status:!1,message:"percentageFee greater than 100 is invalid. percentageFee: "+e.percentageFee,code:"INVALID_FEE"}:e.percentageFee/100*+r<=i?{status:!1,message:`fee amount is less than or equal minimum teleporter fee amount.percentageFee: ${e.percentageFee} - value: ${r} - feeAmount ${(e.percentageFee/100*+r).toFixed(8)} - minimumFee: ${i}`,code:"NOT_ACCEPTED_BY_TELEPORTER"}:{status:!0,data:e,requestOutputIndex:t,value:r,valueOutputIndex:n}:{status:!1,message:"no data to validate. it should not happen",code:"NOT_ACCEPTED_BY_TELEPORTER"}}(f.data,a,c,u,r):f}return{status:!1,message:"transaction outputs should contain OP_RETURN",code:"NO_OP_RETURN"}}}},function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)},a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.otherTokens=void 0,o(r(361),t),o(r(362),t),t.otherTokens=a(r(363))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.chainInfo=void 0,t.chainInfo={ethereum:{name:"ethereum",chainId:1},ethereum_testnet:{name:"goerli",chainId:3},bsc:{name:"binance_smart_chain",chainId:56},bsc_testnet:{name:"binance_smart_chain_testnet",chainId:97},polygon:{name:"polygon",chainId:137},polygon_testnet:{name:"mumbai",chainId:137}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hdWalletPath=void 0,t.hdWalletPath={bitcoin:{p2pkh:"m/44'/0'/0'",p2wpkh:"m/84'/0'/0'","p2sh-p2wpkh":"m/49'/0'/0'",p2sh:"m/80'/0'/0'",p2wsh:"m/85'/0'/0'","p2sh-p2wsh":"m/90'/0'/0'",p2tr:"m/84'/0'/0'"},ethereum:"m/44'/60'/0'"}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bsc=t.polygon=void 0,t.polygon={mainnet:{DAIAddress:"0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",USDTAddress:"0xc2132D05D31c914a87C6611C10748AEb04B58e8F",USDCAddress:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",WBTCAddress:"0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6",SANDAddress:"0xBbba073C31bF03b8ACf7c28EF0738DeCF3695683",WBNBAddress:"",WETHAddress:"0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",WMATICAddress:"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270"},testnet:{WMATICAddress:"0x9c3c9283d3e44854697cd22d3faa240cfb032889"}},t.bsc={mainnet:{USDTAddress:"0x55d398326f99059fF775485246999027B3197955",USDCAddress:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",WBNBAddress:"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",WETHAddress:"0x5DA5DA6933637c1cAfa5de9FdF2aCb1B3758C9e3"},testnet:{USDTAddress:"",USDCAddress:"",WBNBAddress:"0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd",WETHAddress:"0xd66c6B4F0be8CE5b39D52E0Fd1344c389929B378"}}},function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.tokensInfo=t.contractsInfo=t.requestTypes=t.bitcoinAddressTypes=void 0;var s=r(365);Object.defineProperty(t,"bitcoinAddressTypes",{enumerable:!0,get:function(){return s.addressTypeHelper}});var u=r(366);Object.defineProperty(t,"requestTypes",{enumerable:!0,get:function(){return a(u).default}}),t.contractsInfo=o(r(367)),t.tokensInfo=o(r(368))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addressTypeHelper=void 0,t.addressTypeHelper={addressTypesNumber:{p2pk:0,p2pkh:1,p2sh:2,p2wpkh:3,p2wsh:4,p2tr:5},addressTypes:["p2pk","p2pkh","p2sh","p2wpkh","p2wsh","p2tr"]},t.default=t.addressTypeHelper},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={transfer:{appIdRange:[1,1],default:1},exchange:{appIdRange:[10,30],default:20},lend:{appIdRange:[100,200],default:100}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bsc=t.polygon=void 0,t.polygon={mainnet:{exchangeConnectorAddress:"0x0C28968d8A3Af022F47D493402D35Cb42EFF0597",exchangeFactoryAddress:"0x5757371414417b8C6CAad45bAeF941aBc7d3Ab32",exchangeRouterAddress:"0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff",priceOracleAddress:"0x96b76ab42289688b68882cdccd071b2c39b0165e",relayAddress:"0x7DeB66341b1d499D7e699589d0cf665De4132EA3",lendingAddress:"",ccTransferAddress:"0x04367D74332137908BEF9acc0Ab00a299A823707",ccExchangeAddress:"0xD1E9Ff33EC28f9Dd8D99E685a2B0F29dCaa095a3",ccBurnAddress:"0x0009876C47F6b2f0BCB41eb9729736757486c75f",lockerAddress:"0xf5D6D369A7F4147F720AEAdd4C4f903aE8046166"},testnet:{exchangeConnectorAddress:"0x0C28968d8A3Af022F47D493402D35Cb42EFF0597",exchangeFactoryAddress:"0x5757371414417b8C6CAad45bAeF941aBc7d3Ab32",exchangeRouterAddress:"0x8954AfA98594b838bda56FE4C12a09D7739D179b",priceOracleAddress:"0x96B76aB42289688b68882CDcCd071B2C39b0165E",relayAddress:"0x5b845e3EB38d78cD5006C04b0Bc78692b5535F56",lendingAddress:"",ccTransferAddress:"0xbD97529bB755ac4f17e3Ef648b6230d3e93F84F0",ccExchangeAddress:"0x9D35634aBF331204CAd28BF9c37B49792A1E69e3",ccBurnAddress:"0x4779BB3c43C86baf60f7b30e0e19872B7d90ae7f",lockerAddress:"0xf5D6D369A7F4147F720AEAdd4C4f903aE8046166"}},t.bsc={mainnet:{exchangeConnectorAddress:"0x856D80F77349F675Ea7E3477aD75Ef57349e777b",exchangeFactoryAddress:"0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73",exchangeRouterAddress:"0x10ED43C718714eb63d5aA57B78B54704E256024E",priceOracleAddress:"0x7Aabb0779782247384A1C91844211516E93b1D63",relayAddress:"0xFcd688999c25D5493571543137cEeb4fbDb44D02",lendingAddress:"",ccTransferAddress:"0xA38aD0d52B89C20c2229E916358D2CeB45BeC5FF",ccExchangeAddress:"0xcA5416364720c7324A547d39b1db496A2DCd4F0D",ccBurnAddress:"0x2787D48e0B74125597DD479978a5DE09Bb9a3C15",lockerAddress:"0x84F74e97ebab432CeE185d601290cE0A483987A5"},testnet:{exchangeConnectorAddress:"0xF789b50D17CF214d5774ce1a52Fb6581d72118fE",exchangeFactoryAddress:"0xB7926C0430Afb07AA7DEfDE6DA862aE0Bde767bc",exchangeRouterAddress:"0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3",priceOracleAddress:"0xF364F92D5d0D4Ee173983da8b74e2eB1D7A319D2",relayAddress:"0x66840C47684338216fE0498CFd649186D662d8a0",lendingAddress:"",ccTransferAddress:"0x699Ab6dE8791B9E895Afa5B1e36a6F8F64294D0a",ccExchangeAddress:"0xA029A35027233C4640A815D3574f36f652A47C41",ccBurnAddress:"0x090aB5B43F440700F8E73fB822f81cAbE82fd05B",lockerAddress:"0xba44564920f2c5b69C7729FFd465b3095e08Ea35"}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bsc=t.polygon=void 0,t.polygon={mainnet:{teleBTCAddress:"0x3BF668Fe1ec79a84cA8481CEAD5dbb30d61cC685"},testnet:{teleBTCAddress:"0x515D720B9D219f1931205D5B8D842bE1Fe2FeBDE"}},t.bsc={mainnet:{teleBTCAddress:"0xC58C1117DA964aEbe91fEF88f6f5703e79bdA574"},testnet:{teleBTCAddress:"0x2dC0a21691a3A0B8ED353Bf43f964966e2a65Cfd"}}},function(e,t,r){var n;!function(i){"use strict";var o,a=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,s=Math.ceil,u=Math.floor,c="[BigNumber Error] ",f=c+"Number primitive has more than 15 significant digits: ",l=1e14,d=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],h=1e9;function p(e){var t=0|e;return e>0||e===t?t:t-1}function b(e){for(var t,r,n=1,i=e.length,o=e[0]+"";n<i;){for(r=14-(t=e[n++]+"").length;r--;t="0"+t);o+=t}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function m(e,t){var r,n,i=e.c,o=t.c,a=e.s,s=t.s,u=e.e,c=t.e;if(!a||!s)return null;if(r=i&&!i[0],n=o&&!o[0],r||n)return r?n?0:-s:a;if(a!=s)return a;if(r=a<0,n=u==c,!i||!o)return n?0:!i^r?1:-1;if(!n)return u>c^r?1:-1;for(s=(u=i.length)<(c=o.length)?u:c,a=0;a<s;a++)if(i[a]!=o[a])return i[a]>o[a]^r?1:-1;return u==c?0:u>c^r?1:-1}function g(e,t,r,n){if(e<t||e>r||e!==u(e))throw Error(c+(n||"Argument")+("number"==typeof e?e<t||e>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function y(e){var t=e.c.length-1;return p(e.e/14)==t&&e.c[t]%2!=0}function v(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function w(e,t,r){var n,i;if(t<0){for(i=r+".";++t;i+=r);e=i+e}else if(++t>(n=e.length)){for(i=r,t-=n;--t;i+=r);e+=i}else t<n&&(e=e.slice(0,t)+"."+e.slice(t));return e}(o=function e(t){var r,n,i,o,_,E,k,S,x,T=L.prototype={constructor:L,toString:null,valueOf:null},A=new L(1),P=20,O=4,I=-7,B=21,M=-1e7,R=1e7,N=!1,j=1,U=0,C={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},H="0123456789abcdefghijklmnopqrstuvwxyz",z=!0;function L(e,t){var r,o,s,c,l,d,h,p,b=this;if(!(b instanceof L))return new L(e,t);if(null==t){if(e&&!0===e._isBigNumber)return b.s=e.s,void(!e.c||e.e>R?b.c=b.e=null:e.e<M?b.c=[b.e=0]:(b.e=e.e,b.c=e.c.slice()));if((d="number"==typeof e)&&0*e==0){if(b.s=1/e<0?(e=-e,-1):1,e===~~e){for(c=0,l=e;l>=10;l/=10,c++);return void(c>R?b.c=b.e=null:(b.e=c,b.c=[e]))}p=String(e)}else{if(!a.test(p=String(e)))return i(b,p,d);b.s=45==p.charCodeAt(0)?(p=p.slice(1),-1):1}(c=p.indexOf("."))>-1&&(p=p.replace(".","")),(l=p.search(/e/i))>0?(c<0&&(c=l),c+=+p.slice(l+1),p=p.substring(0,l)):c<0&&(c=p.length)}else{if(g(t,2,H.length,"Base"),10==t&&z)return K(b=new L(e),P+b.e+1,O);if(p=String(e),d="number"==typeof e){if(0*e!=0)return i(b,p,d,t);if(b.s=1/e<0?(p=p.slice(1),-1):1,L.DEBUG&&p.replace(/^0\.0*|\./,"").length>15)throw Error(f+e)}else b.s=45===p.charCodeAt(0)?(p=p.slice(1),-1):1;for(r=H.slice(0,t),c=l=0,h=p.length;l<h;l++)if(r.indexOf(o=p.charAt(l))<0){if("."==o){if(l>c){c=h;continue}}else if(!s&&(p==p.toUpperCase()&&(p=p.toLowerCase())||p==p.toLowerCase()&&(p=p.toUpperCase()))){s=!0,l=-1,c=0;continue}return i(b,String(e),d,t)}d=!1,(c=(p=n(p,t,10,b.s)).indexOf("."))>-1?p=p.replace(".",""):c=p.length}for(l=0;48===p.charCodeAt(l);l++);for(h=p.length;48===p.charCodeAt(--h););if(p=p.slice(l,++h)){if(h-=l,d&&L.DEBUG&&h>15&&(e>9007199254740991||e!==u(e)))throw Error(f+b.s*e);if((c=c-l-1)>R)b.c=b.e=null;else if(c<M)b.c=[b.e=0];else{if(b.e=c,b.c=[],l=(c+1)%14,c<0&&(l+=14),l<h){for(l&&b.c.push(+p.slice(0,l)),h-=14;l<h;)b.c.push(+p.slice(l,l+=14));l=14-(p=p.slice(l)).length}else l-=h;for(;l--;p+="0");b.c.push(+p)}}else b.c=[b.e=0]}function D(e,t,r,n){var i,o,a,s,u;if(null==r?r=O:g(r,0,8),!e.c)return e.toString();if(i=e.c[0],a=e.e,null==t)u=b(e.c),u=1==n||2==n&&(a<=I||a>=B)?v(u,a):w(u,a,"0");else if(o=(e=K(new L(e),t,r)).e,s=(u=b(e.c)).length,1==n||2==n&&(t<=o||o<=I)){for(;s<t;u+="0",s++);u=v(u,o)}else if(t-=a,u=w(u,o,"0"),o+1>s){if(--t>0)for(u+=".";t--;u+="0");}else if((t+=o-s)>0)for(o+1==s&&(u+=".");t--;u+="0");return e.s<0&&i?"-"+u:u}function F(e,t){for(var r,n=1,i=new L(e[0]);n<e.length;n++){if(!(r=new L(e[n])).s){i=r;break}t.call(i,r)&&(i=r)}return i}function q(e,t,r){for(var n=1,i=t.length;!t[--i];t.pop());for(i=t[0];i>=10;i/=10,n++);return(r=n+14*r-1)>R?e.c=e.e=null:r<M?e.c=[e.e=0]:(e.e=r,e.c=t),e}function K(e,t,r,n){var i,o,a,c,f,h,p,b=e.c,m=d;if(b){e:{for(i=1,c=b[0];c>=10;c/=10,i++);if((o=t-i)<0)o+=14,a=t,p=(f=b[h=0])/m[i-a-1]%10|0;else if((h=s((o+1)/14))>=b.length){if(!n)break e;for(;b.length<=h;b.push(0));f=p=0,i=1,a=(o%=14)-14+1}else{for(f=c=b[h],i=1;c>=10;c/=10,i++);p=(a=(o%=14)-14+i)<0?0:f/m[i-a-1]%10|0}if(n=n||t<0||null!=b[h+1]||(a<0?f:f%m[i-a-1]),n=r<4?(p||n)&&(0==r||r==(e.s<0?3:2)):p>5||5==p&&(4==r||n||6==r&&(o>0?a>0?f/m[i-a]:0:b[h-1])%10&1||r==(e.s<0?8:7)),t<1||!b[0])return b.length=0,n?(t-=e.e+1,b[0]=m[(14-t%14)%14],e.e=-t||0):b[0]=e.e=0,e;if(0==o?(b.length=h,c=1,h--):(b.length=h+1,c=m[14-o],b[h]=a>0?u(f/m[i-a]%m[a])*c:0),n)for(;;){if(0==h){for(o=1,a=b[0];a>=10;a/=10,o++);for(a=b[0]+=c,c=1;a>=10;a/=10,c++);o!=c&&(e.e++,b[0]==l&&(b[0]=1));break}if(b[h]+=c,b[h]!=l)break;b[h--]=0,c=1}for(o=b.length;0===b[--o];b.pop());}e.e>R?e.c=e.e=null:e.e<M&&(e.c=[e.e=0])}return e}function W(e){var t,r=e.e;return null===r?e.toString():(t=b(e.c),t=r<=I||r>=B?v(t,r):w(t,r,"0"),e.s<0?"-"+t:t)}return L.clone=e,L.ROUND_UP=0,L.ROUND_DOWN=1,L.ROUND_CEIL=2,L.ROUND_FLOOR=3,L.ROUND_HALF_UP=4,L.ROUND_HALF_DOWN=5,L.ROUND_HALF_EVEN=6,L.ROUND_HALF_CEIL=7,L.ROUND_HALF_FLOOR=8,L.EUCLID=9,L.config=L.set=function(e){var t,r;if(null!=e){if("object"!=typeof e)throw Error(c+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(g(r=e[t],0,h,t),P=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(g(r=e[t],0,8,t),O=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((r=e[t])&&r.pop?(g(r[0],-h,0,t),g(r[1],0,h,t),I=r[0],B=r[1]):(g(r,-h,h,t),I=-(B=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if((r=e[t])&&r.pop)g(r[0],-h,-1,t),g(r[1],1,h,t),M=r[0],R=r[1];else{if(g(r,-h,h,t),!r)throw Error(c+t+" cannot be zero: "+r);M=-(R=r<0?-r:r)}if(e.hasOwnProperty(t="CRYPTO")){if((r=e[t])!==!!r)throw Error(c+t+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw N=!r,Error(c+"crypto unavailable");N=r}else N=r}if(e.hasOwnProperty(t="MODULO_MODE")&&(g(r=e[t],0,9,t),j=r),e.hasOwnProperty(t="POW_PRECISION")&&(g(r=e[t],0,h,t),U=r),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(r=e[t]))throw Error(c+t+" not an object: "+r);C=r}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(r=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(c+t+" invalid: "+r);z="0123456789"==r.slice(0,10),H=r}}return{DECIMAL_PLACES:P,ROUNDING_MODE:O,EXPONENTIAL_AT:[I,B],RANGE:[M,R],CRYPTO:N,MODULO_MODE:j,POW_PRECISION:U,FORMAT:C,ALPHABET:H}},L.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!L.DEBUG)return!0;var t,r,n=e.c,i=e.e,o=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===o||-1===o)&&i>=-h&&i<=h&&i===u(i)){if(0===n[0]){if(0===i&&1===n.length)return!0;break e}if((t=(i+1)%14)<1&&(t+=14),String(n[0]).length==t){for(t=0;t<n.length;t++)if((r=n[t])<0||r>=l||r!==u(r))break e;if(0!==r)return!0}}}else if(null===n&&null===i&&(null===o||1===o||-1===o))return!0;throw Error(c+"Invalid BigNumber: "+e)},L.maximum=L.max=function(){return F(arguments,T.lt)},L.minimum=L.min=function(){return F(arguments,T.gt)},L.random=(o=9007199254740992*Math.random()&2097151?function(){return u(9007199254740992*Math.random())}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,r,n,i,a,f=0,l=[],p=new L(A);if(null==e?e=P:g(e,0,h),i=s(e/14),N)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(i*=2));f<i;)(a=131072*t[f]+(t[f+1]>>>11))>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),t[f]=r[0],t[f+1]=r[1]):(l.push(a%1e14),f+=2);f=i/2}else{if(!crypto.randomBytes)throw N=!1,Error(c+"crypto unavailable");for(t=crypto.randomBytes(i*=7);f<i;)(a=281474976710656*(31&t[f])+1099511627776*t[f+1]+4294967296*t[f+2]+16777216*t[f+3]+(t[f+4]<<16)+(t[f+5]<<8)+t[f+6])>=9e15?crypto.randomBytes(7).copy(t,f):(l.push(a%1e14),f+=7);f=i/7}if(!N)for(;f<i;)(a=o())<9e15&&(l[f++]=a%1e14);for(e%=14,(i=l[--f])&&e&&(a=d[14-e],l[f]=u(i/a)*a);0===l[f];l.pop(),f--);if(f<0)l=[n=0];else{for(n=-1;0===l[0];l.splice(0,1),n-=14);for(f=1,a=l[0];a>=10;a/=10,f++);f<14&&(n-=14-f)}return p.e=n,p.c=l,p}),L.sum=function(){for(var e=1,t=arguments,r=new L(t[0]);e<t.length;)r=r.plus(t[e++]);return r},n=function(){function e(e,t,r,n){for(var i,o,a=[0],s=0,u=e.length;s<u;){for(o=a.length;o--;a[o]*=t);for(a[0]+=n.indexOf(e.charAt(s++)),i=0;i<a.length;i++)a[i]>r-1&&(null==a[i+1]&&(a[i+1]=0),a[i+1]+=a[i]/r|0,a[i]%=r)}return a.reverse()}return function(t,n,i,o,a){var s,u,c,f,l,d,h,p,m=t.indexOf("."),g=P,y=O;for(m>=0&&(f=U,U=0,t=t.replace(".",""),d=(p=new L(n)).pow(t.length-m),U=f,p.c=e(w(b(d.c),d.e,"0"),10,i,"0123456789"),p.e=p.c.length),c=f=(h=e(t,n,i,a?(s=H,"0123456789"):(s="0123456789",H))).length;0==h[--f];h.pop());if(!h[0])return s.charAt(0);if(m<0?--c:(d.c=h,d.e=c,d.s=o,h=(d=r(d,p,g,y,i)).c,l=d.r,c=d.e),m=h[u=c+g+1],f=i/2,l=l||u<0||null!=h[u+1],l=y<4?(null!=m||l)&&(0==y||y==(d.s<0?3:2)):m>f||m==f&&(4==y||l||6==y&&1&h[u-1]||y==(d.s<0?8:7)),u<1||!h[0])t=l?w(s.charAt(1),-g,s.charAt(0)):s.charAt(0);else{if(h.length=u,l)for(--i;++h[--u]>i;)h[u]=0,u||(++c,h=[1].concat(h));for(f=h.length;!h[--f];);for(m=0,t="";m<=f;t+=s.charAt(h[m++]));t=w(t,c,s.charAt(0))}return t}}(),r=function(){function e(e,t,r){var n,i,o,a,s=0,u=e.length,c=t%1e7,f=t/1e7|0;for(e=e.slice();u--;)s=((i=c*(o=e[u]%1e7)+(n=f*o+(a=e[u]/1e7|0)*c)%1e7*1e7+s)/r|0)+(n/1e7|0)+f*a,e[u]=i%r;return s&&(e=[s].concat(e)),e}function t(e,t,r,n){var i,o;if(r!=n)o=r>n?1:-1;else for(i=o=0;i<r;i++)if(e[i]!=t[i]){o=e[i]>t[i]?1:-1;break}return o}function r(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]<t[r]?1:0,e[r]=i*n+e[r]-t[r];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(n,i,o,a,s){var c,f,d,h,b,m,g,y,v,w,_,E,k,S,x,T,A,P=n.s==i.s?1:-1,O=n.c,I=i.c;if(!(O&&O[0]&&I&&I[0]))return new L(n.s&&i.s&&(O?!I||O[0]!=I[0]:I)?O&&0==O[0]||!I?0*P:P/0:NaN);for(v=(y=new L(P)).c=[],P=o+(f=n.e-i.e)+1,s||(s=l,f=p(n.e/14)-p(i.e/14),P=P/14|0),d=0;I[d]==(O[d]||0);d++);if(I[d]>(O[d]||0)&&f--,P<0)v.push(1),h=!0;else{for(S=O.length,T=I.length,d=0,P+=2,(b=u(s/(I[0]+1)))>1&&(I=e(I,b,s),O=e(O,b,s),T=I.length,S=O.length),k=T,_=(w=O.slice(0,T)).length;_<T;w[_++]=0);A=I.slice(),A=[0].concat(A),x=I[0],I[1]>=s/2&&x++;do{if(b=0,(c=t(I,w,T,_))<0){if(E=w[0],T!=_&&(E=E*s+(w[1]||0)),(b=u(E/x))>1)for(b>=s&&(b=s-1),g=(m=e(I,b,s)).length,_=w.length;1==t(m,w,g,_);)b--,r(m,T<g?A:I,g,s),g=m.length,c=1;else 0==b&&(c=b=1),g=(m=I.slice()).length;if(g<_&&(m=[0].concat(m)),r(w,m,_,s),_=w.length,-1==c)for(;t(I,w,T,_)<1;)b++,r(w,T<_?A:I,_,s),_=w.length}else 0===c&&(b++,w=[0]);v[d++]=b,w[0]?w[_++]=O[k]||0:(w=[O[k]],_=1)}while((k++<S||null!=w[0])&&P--);h=null!=w[0],v[0]||v.splice(0,1)}if(s==l){for(d=1,P=v[0];P>=10;P/=10,d++);K(y,o+(y.e=d+14*f-1)+1,a,h)}else y.e=f,y.r=+h;return y}}(),_=/^(-?)0([xbo])(?=\w[\w.]*$)/i,E=/^([^.]+)\.$/,k=/^\.([^.]+)$/,S=/^-?(Infinity|NaN)$/,x=/^\s*\+(?=[\w.])|^\s+|\s+$/g,i=function(e,t,r,n){var i,o=r?t:t.replace(x,"");if(S.test(o))e.s=isNaN(o)?null:o<0?-1:1;else{if(!r&&(o=o.replace(_,(function(e,t,r){return i="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=i?e:t})),n&&(i=n,o=o.replace(E,"$1").replace(k,"0.$1")),t!=o))return new L(o,i);if(L.DEBUG)throw Error(c+"Not a"+(n?" base "+n:"")+" number: "+t);e.s=null}e.c=e.e=null},T.absoluteValue=T.abs=function(){var e=new L(this);return e.s<0&&(e.s=1),e},T.comparedTo=function(e,t){return m(this,new L(e,t))},T.decimalPlaces=T.dp=function(e,t){var r,n,i,o=this;if(null!=e)return g(e,0,h),null==t?t=O:g(t,0,8),K(new L(o),e+o.e+1,t);if(!(r=o.c))return null;if(n=14*((i=r.length-1)-p(this.e/14)),i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},T.dividedBy=T.div=function(e,t){return r(this,new L(e,t),P,O)},T.dividedToIntegerBy=T.idiv=function(e,t){return r(this,new L(e,t),0,1)},T.exponentiatedBy=T.pow=function(e,t){var r,n,i,o,a,f,l,d,h=this;if((e=new L(e)).c&&!e.isInteger())throw Error(c+"Exponent not an integer: "+W(e));if(null!=t&&(t=new L(t)),a=e.e>14,!h.c||!h.c[0]||1==h.c[0]&&!h.e&&1==h.c.length||!e.c||!e.c[0])return d=new L(Math.pow(+W(h),a?e.s*(2-y(e)):+W(e))),t?d.mod(t):d;if(f=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new L(NaN);(n=!f&&h.isInteger()&&t.isInteger())&&(h=h.mod(t))}else{if(e.e>9&&(h.e>0||h.e<-1||(0==h.e?h.c[0]>1||a&&h.c[1]>=24e7:h.c[0]<8e13||a&&h.c[0]<=9999975e7)))return o=h.s<0&&y(e)?-0:0,h.e>-1&&(o=1/o),new L(f?1/o:o);U&&(o=s(U/14+2))}for(a?(r=new L(.5),f&&(e.s=1),l=y(e)):l=(i=Math.abs(+W(e)))%2,d=new L(A);;){if(l){if(!(d=d.times(h)).c)break;o?d.c.length>o&&(d.c.length=o):n&&(d=d.mod(t))}if(i){if(0===(i=u(i/2)))break;l=i%2}else if(K(e=e.times(r),e.e+1,1),e.e>14)l=y(e);else{if(0===(i=+W(e)))break;l=i%2}h=h.times(h),o?h.c&&h.c.length>o&&(h.c.length=o):n&&(h=h.mod(t))}return n?d:(f&&(d=A.div(d)),t?d.mod(t):o?K(d,U,O,void 0):d)},T.integerValue=function(e){var t=new L(this);return null==e?e=O:g(e,0,8),K(t,t.e+1,e)},T.isEqualTo=T.eq=function(e,t){return 0===m(this,new L(e,t))},T.isFinite=function(){return!!this.c},T.isGreaterThan=T.gt=function(e,t){return m(this,new L(e,t))>0},T.isGreaterThanOrEqualTo=T.gte=function(e,t){return 1===(t=m(this,new L(e,t)))||0===t},T.isInteger=function(){return!!this.c&&p(this.e/14)>this.c.length-2},T.isLessThan=T.lt=function(e,t){return m(this,new L(e,t))<0},T.isLessThanOrEqualTo=T.lte=function(e,t){return-1===(t=m(this,new L(e,t)))||0===t},T.isNaN=function(){return!this.s},T.isNegative=function(){return this.s<0},T.isPositive=function(){return this.s>0},T.isZero=function(){return!!this.c&&0==this.c[0]},T.minus=function(e,t){var r,n,i,o,a=this,s=a.s;if(t=(e=new L(e,t)).s,!s||!t)return new L(NaN);if(s!=t)return e.s=-t,a.plus(e);var u=a.e/14,c=e.e/14,f=a.c,d=e.c;if(!u||!c){if(!f||!d)return f?(e.s=-t,e):new L(d?a:NaN);if(!f[0]||!d[0])return d[0]?(e.s=-t,e):new L(f[0]?a:3==O?-0:0)}if(u=p(u),c=p(c),f=f.slice(),s=u-c){for((o=s<0)?(s=-s,i=f):(c=u,i=d),i.reverse(),t=s;t--;i.push(0));i.reverse()}else for(n=(o=(s=f.length)<(t=d.length))?s:t,s=t=0;t<n;t++)if(f[t]!=d[t]){o=f[t]<d[t];break}if(o&&(i=f,f=d,d=i,e.s=-e.s),(t=(n=d.length)-(r=f.length))>0)for(;t--;f[r++]=0);for(t=l-1;n>s;){if(f[--n]<d[n]){for(r=n;r&&!f[--r];f[r]=t);--f[r],f[n]+=l}f[n]-=d[n]}for(;0==f[0];f.splice(0,1),--c);return f[0]?q(e,f,c):(e.s=3==O?-1:1,e.c=[e.e=0],e)},T.modulo=T.mod=function(e,t){var n,i,o=this;return e=new L(e,t),!o.c||!e.s||e.c&&!e.c[0]?new L(NaN):!e.c||o.c&&!o.c[0]?new L(o):(9==j?(i=e.s,e.s=1,n=r(o,e,0,3),e.s=i,n.s*=i):n=r(o,e,0,j),(e=o.minus(n.times(e))).c[0]||1!=j||(e.s=o.s),e)},T.multipliedBy=T.times=function(e,t){var r,n,i,o,a,s,u,c,f,d,h,b,m,g,y=this,v=y.c,w=(e=new L(e,t)).c;if(!(v&&w&&v[0]&&w[0]))return!y.s||!e.s||v&&!v[0]&&!w||w&&!w[0]&&!v?e.c=e.e=e.s=null:(e.s*=y.s,v&&w?(e.c=[0],e.e=0):e.c=e.e=null),e;for(n=p(y.e/14)+p(e.e/14),e.s*=y.s,(u=v.length)<(d=w.length)&&(m=v,v=w,w=m,i=u,u=d,d=i),i=u+d,m=[];i--;m.push(0));for(g=l,1e7,i=d;--i>=0;){for(r=0,h=w[i]%1e7,b=w[i]/1e7|0,o=i+(a=u);o>i;)r=((c=h*(c=v[--a]%1e7)+(s=b*c+(f=v[a]/1e7|0)*h)%1e7*1e7+m[o]+r)/g|0)+(s/1e7|0)+b*f,m[o--]=c%g;m[o]=r}return r?++n:m.splice(0,1),q(e,m,n)},T.negated=function(){var e=new L(this);return e.s=-e.s||null,e},T.plus=function(e,t){var r,n=this,i=n.s;if(t=(e=new L(e,t)).s,!i||!t)return new L(NaN);if(i!=t)return e.s=-t,n.minus(e);var o=n.e/14,a=e.e/14,s=n.c,u=e.c;if(!o||!a){if(!s||!u)return new L(i/0);if(!s[0]||!u[0])return u[0]?e:new L(s[0]?n:0*i)}if(o=p(o),a=p(a),s=s.slice(),i=o-a){for(i>0?(a=o,r=u):(i=-i,r=s),r.reverse();i--;r.push(0));r.reverse()}for((i=s.length)-(t=u.length)<0&&(r=u,u=s,s=r,t=i),i=0;t;)i=(s[--t]=s[t]+u[t]+i)/l|0,s[t]=l===s[t]?0:s[t]%l;return i&&(s=[i].concat(s),++a),q(e,s,a)},T.precision=T.sd=function(e,t){var r,n,i,o=this;if(null!=e&&e!==!!e)return g(e,1,h),null==t?t=O:g(t,0,8),K(new L(o),e,t);if(!(r=o.c))return null;if(n=14*(i=r.length-1)+1,i=r[i]){for(;i%10==0;i/=10,n--);for(i=r[0];i>=10;i/=10,n++);}return e&&o.e+1>n&&(n=o.e+1),n},T.shiftedBy=function(e){return g(e,-9007199254740991,9007199254740991),this.times("1e"+e)},T.squareRoot=T.sqrt=function(){var e,t,n,i,o,a=this,s=a.c,u=a.s,c=a.e,f=P+4,l=new L("0.5");if(1!==u||!s||!s[0])return new L(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);if(0==(u=Math.sqrt(+W(a)))||u==1/0?(((t=b(s)).length+c)%2==0&&(t+="0"),u=Math.sqrt(+t),c=p((c+1)/2)-(c<0||c%2),n=new L(t=u==1/0?"5e"+c:(t=u.toExponential()).slice(0,t.indexOf("e")+1)+c)):n=new L(u+""),n.c[0])for((u=(c=n.e)+f)<3&&(u=0);;)if(o=n,n=l.times(o.plus(r(a,o,f,1))),b(o.c).slice(0,u)===(t=b(n.c)).slice(0,u)){if(n.e<c&&--u,"9999"!=(t=t.slice(u-3,u+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(K(n,n.e+P+2,1),e=!n.times(n).eq(a));break}if(!i&&(K(o,o.e+P+2,0),o.times(o).eq(a))){n=o;break}f+=4,u+=4,i=1}return K(n,n.e+P+1,O,e)},T.toExponential=function(e,t){return null!=e&&(g(e,0,h),e++),D(this,e,t,1)},T.toFixed=function(e,t){return null!=e&&(g(e,0,h),e=e+this.e+1),D(this,e,t)},T.toFormat=function(e,t,r){var n,i=this;if(null==r)null!=e&&t&&"object"==typeof t?(r=t,t=null):e&&"object"==typeof e?(r=e,e=t=null):r=C;else if("object"!=typeof r)throw Error(c+"Argument not an object: "+r);if(n=i.toFixed(e,t),i.c){var o,a=n.split("."),s=+r.groupSize,u=+r.secondaryGroupSize,f=r.groupSeparator||"",l=a[0],d=a[1],h=i.s<0,p=h?l.slice(1):l,b=p.length;if(u&&(o=s,s=u,u=o,b-=o),s>0&&b>0){for(o=b%s||s,l=p.substr(0,o);o<b;o+=s)l+=f+p.substr(o,s);u>0&&(l+=f+p.slice(o)),h&&(l="-"+l)}n=d?l+(r.decimalSeparator||"")+((u=+r.fractionGroupSize)?d.replace(new RegExp("\\d{"+u+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):d):l}return(r.prefix||"")+n+(r.suffix||"")},T.toFraction=function(e){var t,n,i,o,a,s,u,f,l,h,p,m,g=this,y=g.c;if(null!=e&&(!(u=new L(e)).isInteger()&&(u.c||1!==u.s)||u.lt(A)))throw Error(c+"Argument "+(u.isInteger()?"out of range: ":"not an integer: ")+W(u));if(!y)return new L(g);for(t=new L(A),l=n=new L(A),i=f=new L(A),m=b(y),a=t.e=m.length-g.e-1,t.c[0]=d[(s=a%14)<0?14+s:s],e=!e||u.comparedTo(t)>0?a>0?t:l:u,s=R,R=1/0,u=new L(m),f.c[0]=0;h=r(u,t,0,1),1!=(o=n.plus(h.times(i))).comparedTo(e);)n=i,i=o,l=f.plus(h.times(o=l)),f=o,t=u.minus(h.times(o=t)),u=o;return o=r(e.minus(n),i,0,1),f=f.plus(o.times(l)),n=n.plus(o.times(i)),f.s=l.s=g.s,p=r(l,i,a*=2,O).minus(g).abs().comparedTo(r(f,n,a,O).minus(g).abs())<1?[l,i]:[f,n],R=s,p},T.toNumber=function(){return+W(this)},T.toPrecision=function(e,t){return null!=e&&g(e,1,h),D(this,e,t,2)},T.toString=function(e){var t,r=this,i=r.s,o=r.e;return null===o?i?(t="Infinity",i<0&&(t="-"+t)):t="NaN":(null==e?t=o<=I||o>=B?v(b(r.c),o):w(b(r.c),o,"0"):10===e&&z?t=w(b((r=K(new L(r),P+o+1,O)).c),r.e,"0"):(g(e,2,H.length,"Base"),t=n(w(b(r.c),o,"0"),10,e,i,!0)),i<0&&r.c[0]&&(t="-"+t)),t},T.valueOf=T.toJSON=function(){return W(this)},T._isBigNumber=!0,null!=t&&L.set(t),L}()).default=o.BigNumber=o,void 0===(n=function(){return o}.call(t,r,t,e))||(e.exports=n)}()},function(e,t,r){"use strict";e.exports={getBurnTransactionInfo:function(e,t=[],r=[]){let n=t.findIndex(t=>t.address===e);if(n>=0){let i=t[n];i.vinIndex=n;let o=t.reduce((e,t)=>+e+ +t.value,0),a=[],s=[];for(let t in r){let n=Object.assign(Object.assign({},r[t]),{index:t});n.address===e?s.push(n):a.push(n)}return{receivers:a,changes:s,totalInputValue:o,lockerVin:i}}return null}}},function(e,t,r){"use strict";(function(e){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},a=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((n=n.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const u=r(35),c=s(r(75)),f=o(r(117)).ECPair;function l(t,r={},n){let i=t,o=f.fromPrivateKey(t,{network:n,compressed:!0});if(!o.privateKey)throw new Error("private key not exist");o.publicKey.toString("hex").startsWith("03")&&(i=c.default.privateNegate(o.privateKey));const a=c.default.privateAdd(i,(s=e.from(o.publicKey.toString("hex").slice(2),"hex"),l=null==r?void 0:r.tweakHash,u.crypto.taggedHash("TapTweak",e.concat(l?[s,l]:[s]))));var s,l;if(!a)throw new Error("Invalid tweaked private key!");return f.fromPrivateKey(e.from(a),{network:n})}t.default=class{constructor(e){this.network=e}signPsbt(e,t){return a(this,void 0,void 0,(function*(){const{network:r}=this,n=f.fromPrivateKey(t,{network:r,compressed:!0}),i=u.Psbt.fromBase64(e.unsignedTransaction,{network:r});let o=i.inputCount;for(let e=0;e<o;e+=1){if("nonstandard"===i.getInputType(e)){let r=l(t,void 0,this.network);yield i.signInputAsync(e,r)}else yield i.signInputAsync(e,n)}return i.toBase64()}))}finalizePsbts(e=[]){const t=e.map(e=>u.Psbt.fromBase64(e,{network:this.network})),r=1===t.length?t[0]:new u.Psbt({network:this.network}).combine(...t);return r.finalizeAllInputs(),r.extractTransaction().toHex()}}}).call(this,r(0).Buffer)}])}));
|
|
17
|
+
const i=BigInt(0),o=BigInt(1),a=BigInt(2),s=BigInt(3),u=BigInt(8),c=Object.freeze({a:i,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:o,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")}),f=(e,t)=>(e+t/a)/t,l={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(e){const{n:t}=c,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-o*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),a=r,s=BigInt("0x100000000000000000000000000000000"),u=f(a*e,t),l=f(-n*e,t);let d=j(e-u*r-l*i,t),h=j(-u*n-l*a,t);const p=d>s,b=h>s;if(p&&(d=t-d),b&&(h=t-h),d>s||h>s)throw new Error("splitScalarEndo: Endomorphism failed, k="+e);return{k1neg:p,k1:d,k2neg:b,k2:h}}};function d(e){const{a:t,b:r}=c,n=j(e*e),i=j(n*e);return j(i+t*e+r)}const h=c.a===i;class p extends Error{constructor(e){super(e)}}function b(e){if(!(e instanceof m))throw new TypeError("JacobianPoint expected")}class m{constructor(e,t,r){this.x=e,this.y=t,this.z=r}static fromAffine(e){if(!(e instanceof v))throw new TypeError("JacobianPoint#fromAffine: expected Point");return e.equals(v.ZERO)?m.ZERO:new m(e.x,e.y,o)}static toAffineBatch(e){const t=function(e,t=c.P){const r=new Array(e.length),n=C(e.reduce((e,n,o)=>n===i?e:(r[o]=e,j(e*n,t)),o),t);return e.reduceRight((e,n,o)=>n===i?e:(r[o]=j(e*r[o],t),j(e*n,t)),n),r}(e.map(e=>e.z));return e.map((e,r)=>e.toAffine(t[r]))}static normalizeZ(e){return m.toAffineBatch(e).map(m.fromAffine)}equals(e){b(e);const{x:t,y:r,z:n}=this,{x:i,y:o,z:a}=e,s=j(n*n),u=j(a*a),c=j(t*u),f=j(i*s),l=j(j(r*a)*u),d=j(j(o*n)*s);return c===f&&l===d}negate(){return new m(this.x,j(-this.y),this.z)}double(){const{x:e,y:t,z:r}=this,n=j(e*e),i=j(t*t),o=j(i*i),c=e+i,f=j(a*(j(c*c)-n-o)),l=j(s*n),d=j(l*l),h=j(d-a*f),p=j(l*(f-h)-u*o),b=j(a*t*r);return new m(h,p,b)}add(e){b(e);const{x:t,y:r,z:n}=this,{x:o,y:s,z:u}=e;if(o===i||s===i)return this;if(t===i||r===i)return e;const c=j(n*n),f=j(u*u),l=j(t*f),d=j(o*c),h=j(j(r*u)*f),p=j(j(s*n)*c),g=j(d-l),y=j(p-h);if(g===i)return y===i?this.double():m.ZERO;const v=j(g*g),w=j(g*v),_=j(l*v),E=j(y*y-w-a*_),k=j(y*(_-E)-h*w),S=j(n*u*g);return new m(E,k,S)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){const t=m.ZERO;if("bigint"==typeof e&&e===i)return t;let r=N(e);if(r===o)return this;if(!h){let e=t,n=this;for(;r>i;)r&o&&(e=e.add(n)),n=n.double(),r>>=o;return e}let{k1neg:n,k1:a,k2neg:s,k2:u}=l.splitScalar(r),c=t,f=t,d=this;for(;a>i||u>i;)a&o&&(c=c.add(d)),u&o&&(f=f.add(d)),d=d.double(),a>>=o,u>>=o;return n&&(c=c.negate()),s&&(f=f.negate()),f=new m(j(f.x*l.beta),f.y,f.z),c.add(f)}precomputeWindow(e){const t=h?128/e+1:256/e+1,r=[];let n=this,i=n;for(let o=0;o<t;o++){i=n,r.push(i);for(let t=1;t<2**(e-1);t++)i=i.add(n),r.push(i);n=i.double()}return r}wNAF(e,t){!t&&this.equals(m.BASE)&&(t=v.BASE);const r=t&&t._WINDOW_SIZE||1;if(256%r)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let n=t&&y.get(t);n||(n=this.precomputeWindow(r),t&&1!==r&&(n=m.normalizeZ(n),y.set(t,n)));let i=m.ZERO,a=m.BASE;const s=1+(h?128/r:256/r),u=2**(r-1),c=BigInt(2**r-1),f=2**r,l=BigInt(r);for(let t=0;t<s;t++){const r=t*u;let s=Number(e&c);e>>=l,s>u&&(s-=f,e+=o);const d=r,h=r+Math.abs(s)-1,p=t%2!=0,b=s<0;0===s?a=a.add(g(p,n[d])):i=i.add(g(b,n[h]))}return{p:i,f:a}}multiply(e,t){let r,n,i=N(e);if(h){const{k1neg:e,k1:o,k2neg:a,k2:s}=l.splitScalar(i);let{p:u,f:c}=this.wNAF(o,t),{p:f,f:d}=this.wNAF(s,t);u=g(e,u),f=g(a,f),f=new m(j(f.x*l.beta),f.y,f.z),r=u.add(f),n=c.add(d)}else{const{p:e,f:o}=this.wNAF(i,t);r=e,n=o}return m.normalizeZ([r,n])[0]}toAffine(e){const{x:t,y:r,z:n}=this,i=this.equals(m.ZERO);null==e&&(e=i?u:C(n));const a=e,s=j(a*a),c=j(s*a),f=j(t*s),l=j(r*c),d=j(n*a);if(i)return v.ZERO;if(d!==o)throw new Error("invZ was invalid");return new v(f,l)}}function g(e,t){const r=t.negate();return e?r:t}m.BASE=new m(c.Gx,c.Gy,o),m.ZERO=new m(i,o,i);const y=new WeakMap;class v{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,y.delete(this)}hasEvenY(){return this.y%a===i}static fromCompressedHex(e){const t=32===e.length,r=M(t?e:e.subarray(1));if(!q(r))throw new Error("Point is not on curve");let n=function(e){const{P:t}=c,r=BigInt(6),n=BigInt(11),i=BigInt(22),o=BigInt(23),u=BigInt(44),f=BigInt(88),l=e*e*e%t,d=l*l*e%t,h=U(d,s)*d%t,p=U(h,s)*d%t,b=U(p,a)*l%t,m=U(b,n)*b%t,g=U(m,i)*m%t,y=U(g,u)*g%t,v=U(y,f)*y%t,w=U(v,u)*g%t,_=U(w,s)*d%t,E=U(_,o)*m%t,k=U(E,r)*l%t,S=U(k,a);if(S*S%t!==e)throw new Error("Cannot find square root");return S}(d(r));const i=(n&o)===o;if(t)i&&(n=j(-n));else{1==(1&e[0])!==i&&(n=j(-n))}const u=new v(r,n);return u.assertValidity(),u}static fromUncompressedHex(e){const t=M(e.subarray(1,33)),r=M(e.subarray(33,65)),n=new v(t,r);return n.assertValidity(),n}static fromHex(e){const t=R(e),r=t.length,n=t[0];if(32===r)return this.fromCompressedHex(t);if(33===r&&(2===n||3===n))return this.fromCompressedHex(t);if(65===r&&4===n)return this.fromUncompressedHex(t);throw new Error("Point.fromHex: received invalid point. Expected 32-33 compressed bytes or 65 uncompressed bytes, not "+r)}static fromPrivateKey(e){return v.BASE.multiply(W(e))}static fromSignature(e,t,r){const{r:n,s:i}=G(t);if(![0,1,2,3].includes(r))throw new Error("Cannot recover: invalid recovery bit");const o=H(R(e)),{n:a}=c,s=2===r||3===r?n+a:n,u=C(s,a),f=j(-o*u,a),l=j(i*u,a),d=1&r?"03":"02",h=v.fromHex(d+A(s)),p=v.BASE.multiplyAndAddUnsafe(h,f,l);if(!p)throw new Error("Cannot recover signature: point at infinify");return p.assertValidity(),p}toRawBytes(e=!1){return B(this.toHex(e))}toHex(e=!1){const t=A(this.x);if(e){return`${this.hasEvenY()?"02":"03"}${t}`}return`04${t}${A(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const e="Point is not on elliptic curve",{x:t,y:r}=this;if(!q(t)||!q(r))throw new Error(e);const n=j(r*r);if(j(n-d(t))!==i)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new v(this.x,j(-this.y))}double(){return m.fromAffine(this).double().toAffine()}add(e){return m.fromAffine(this).add(m.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return m.fromAffine(this).multiply(e,this).toAffine()}multiplyAndAddUnsafe(e,t,r){const n=m.fromAffine(this),a=t===i||t===o||this!==v.BASE?n.multiplyUnsafe(t):n.multiply(t),s=m.fromAffine(e).multiplyUnsafe(r),u=a.add(s);return u.equals(m.ZERO)?void 0:u.toAffine()}}function w(e){return Number.parseInt(e[0],16)>=8?"00"+e:e}function _(e){if(e.length<2||2!==e[0])throw new Error("Invalid signature integer tag: "+x(e));const t=e[1],r=e.subarray(2,t+2);if(!t||r.length!==t)throw new Error("Invalid signature integer: wrong length");if(0===r[0]&&r[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:M(r),left:e.subarray(t+2)}}v.BASE=new v(c.Gx,c.Gy),v.ZERO=new v(i,i);class E{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromCompact(e){const t=e instanceof Uint8Array,r="Signature.fromCompact";if("string"!=typeof e&&!t)throw new TypeError(r+": Expected string or Uint8Array");const n=t?x(e):e;if(128!==n.length)throw new Error(r+": Expected 64-byte hex");return new E(I(n.slice(0,64)),I(n.slice(64,128)))}static fromDER(e){const t=e instanceof Uint8Array;if("string"!=typeof e&&!t)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:r,s:n}=function(e){if(e.length<2||48!=e[0])throw new Error("Invalid signature tag: "+x(e));if(e[1]!==e.length-2)throw new Error("Invalid signature: incorrect length");const{data:t,left:r}=_(e.subarray(2)),{data:n,left:i}=_(r);if(i.length)throw new Error("Invalid signature: left bytes after parsing: "+x(i));return{r:t,s:n}}(t?e:B(e));return new E(r,n)}static fromHex(e){return this.fromDER(e)}assertValidity(){const{r:e,s:t}=this;if(!F(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!F(t))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const e=c.n>>o;return this.s>e}normalizeS(){return this.hasHighS()?new E(this.r,j(-this.s,c.n)):this}toDERRawBytes(){return B(this.toDERHex())}toDERHex(){const e=w(O(this.s)),t=w(O(this.r)),r=e.length/2,n=t.length/2,i=O(r),o=O(n);return`30${O(n+r+4)}02${o}${t}02${i}${e}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return B(this.toCompactHex())}toCompactHex(){return A(this.r)+A(this.s)}}function k(...e){if(!e.every(e=>e instanceof Uint8Array))throw new Error("Uint8Array list expected");if(1===e.length)return e[0];const t=e.reduce((e,t)=>e+t.length,0),r=new Uint8Array(t);for(let t=0,n=0;t<e.length;t++){const i=e[t];r.set(i,n),n+=i.length}return r}const S=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function x(e){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");let t="";for(let r=0;r<e.length;r++)t+=S[e[r]];return t}const T=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function A(e){if("bigint"!=typeof e)throw new Error("Expected bigint");if(!(i<=e&&e<T))throw new Error("Expected number 0 <= n < 2^256");return e.toString(16).padStart(64,"0")}function P(e){const t=B(A(e));if(32!==t.length)throw new Error("Error: expected 32 bytes");return t}function O(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function I(e){if("string"!=typeof e)throw new TypeError("hexToNumber: expected string, got "+typeof e);return BigInt("0x"+e)}function B(e){if("string"!=typeof e)throw new TypeError("hexToBytes: expected string, got "+typeof e);if(e.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+e.length);const t=new Uint8Array(e.length/2);for(let r=0;r<t.length;r++){const n=2*r,i=e.slice(n,n+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");t[r]=o}return t}function M(e){return I(x(e))}function R(e){return e instanceof Uint8Array?Uint8Array.from(e):B(e)}function N(e){if("number"==typeof e&&Number.isSafeInteger(e)&&e>0)return BigInt(e);if("bigint"==typeof e&&F(e))return e;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function j(e,t=c.P){const r=e%t;return r>=i?r:t+r}function U(e,t){const{P:r}=c;let n=e;for(;t-- >i;)n*=n,n%=r;return n}function C(e,t=c.P){if(e===i||t<=i)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let r=j(e,t),n=t,a=i,s=o,u=o,f=i;for(;r!==i;){const e=n/r,t=n%r,i=a-u*e,o=s-f*e;n=r,r=t,a=u,s=f,u=i,f=o}if(n!==o)throw new Error("invert: does not exist");return j(a,t)}function H(e,t=!1){const r=function(e){const t=8*e.length-256,r=M(e);return t>0?r>>BigInt(t):r}(e);if(t)return r;const{n:n}=c;return r>=n?r-n:r}let z,L;class D{constructor(e,t){if(this.hashLen=e,this.qByteLen=t,"number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");this.v=new Uint8Array(e).fill(1),this.k=new Uint8Array(e).fill(0),this.counter=0}hmac(...e){return ye.hmacSha256(this.k,...e)}hmacSync(...e){return L(this.k,...e)}checkSync(){if("function"!=typeof L)throw new p("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}async reseed(e=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),e),this.v=await this.hmac(this.v),0!==e.length&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),e),this.v=await this.hmac(this.v))}reseedSync(e=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),e),this.v=this.hmacSync(this.v),0!==e.length&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),e),this.v=this.hmacSync(this.v))}async generate(){this.incr();let e=0;const t=[];for(;e<this.qByteLen;){this.v=await this.hmac(this.v);const r=this.v.slice();t.push(r),e+=this.v.length}return k(...t)}generateSync(){this.checkSync(),this.incr();let e=0;const t=[];for(;e<this.qByteLen;){this.v=this.hmacSync(this.v);const r=this.v.slice();t.push(r),e+=this.v.length}return k(...t)}}function F(e){return i<e&&e<c.n}function q(e){return i<e&&e<c.P}function K(e,t,r,n=!0){const{n:a}=c,s=H(e,!0);if(!F(s))return;const u=C(s,a),f=v.BASE.multiply(s),l=j(f.x,a);if(l===i)return;const d=j(u*j(t+r*l,a),a);if(d===i)return;let h=new E(l,d),p=(f.x===h.r?0:2)|Number(f.y&o);return n&&h.hasHighS()&&(h=h.normalizeS(),p^=1),{sig:h,recovery:p}}function W(e){let t;if("bigint"==typeof e)t=e;else if("number"==typeof e&&Number.isSafeInteger(e)&&e>0)t=BigInt(e);else if("string"==typeof e){if(64!==e.length)throw new Error("Expected 32 bytes of private key");t=I(e)}else{if(!(e instanceof Uint8Array))throw new TypeError("Expected valid private key");if(32!==e.length)throw new Error("Expected 32 bytes of private key");t=M(e)}if(!F(t))throw new Error("Expected private key: 0 < key < n");return t}function V(e){return e instanceof v?(e.assertValidity(),e):v.fromHex(e)}function G(e){if(e instanceof E)return e.assertValidity(),e;try{return E.fromDER(e)}catch(t){return E.fromCompact(e)}}function X(e,t=!1){return v.fromPrivateKey(e).toRawBytes(t)}function Y(e,t,r,n=!1){return v.fromSignature(e,t,r).toRawBytes(n)}function $(e){const t=e instanceof Uint8Array,r="string"==typeof e,n=(t||r)&&e.length;return t?33===n||65===n:r?66===n||130===n:e instanceof v}function J(e,t,r=!1){if($(e))throw new TypeError("getSharedSecret: first arg must be private key");if(!$(t))throw new TypeError("getSharedSecret: second arg must be public key");const n=V(t);return n.assertValidity(),n.multiply(W(e)).toRawBytes(r)}function Q(e){return M(e.length>32?e.slice(0,32):e)}function Z(e){const t=Q(e),r=j(t,c.n);return ee(r<i?t:r)}function ee(e){return P(e)}function te(e,t,r){if(null==e)throw new Error(`sign: expected valid message hash, not "${e}"`);const n=R(e),i=W(t),o=[ee(i),Z(n)];if(null!=r){!0===r&&(r=ye.randomBytes(32));const e=R(r);if(32!==e.length)throw new Error("sign: Expected 32 bytes of extra data");o.push(e)}return{seed:k(...o),m:Q(n),d:i}}function re(e,t){const{sig:r,recovery:n}=e,{der:i,recovered:o}=Object.assign({canonical:!0,der:!0},t),a=i?r.toDERRawBytes():r.toCompactRawBytes();return o?[a,n]:a}async function ne(e,t,r={}){const{seed:n,m:i,d:o}=te(e,t,r.extraEntropy),a=new D(32,32);let s;for(await a.reseed(n);!(s=K(await a.generate(),i,o,r.canonical));)await a.reseed();return re(s,r)}function ie(e,t,r={}){const{seed:n,m:i,d:o}=te(e,t,r.extraEntropy),a=new D(32,32);let s;for(a.reseedSync(n);!(s=K(a.generateSync(),i,o,r.canonical));)a.reseedSync();return re(s,r)}const oe={strict:!0};function ae(e,t,r,n=oe){let i;try{i=G(e),t=R(t)}catch(e){return!1}const{r:o,s:a}=i;if(n.strict&&i.hasHighS())return!1;const s=H(t);let u;try{u=V(r)}catch(e){return!1}const{n:f}=c,l=C(a,f),d=j(s*l,f),h=j(o*l,f),p=v.BASE.multiplyAndAddUnsafe(u,d,h);if(!p)return!1;return j(p.x,f)===o}function se(e){return j(M(e),c.n)}class ue{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromHex(e){const t=R(e);if(64!==t.length)throw new TypeError("SchnorrSignature.fromHex: expected 64 bytes, not "+t.length);const r=M(t.subarray(0,32)),n=M(t.subarray(32,64));return new ue(r,n)}assertValidity(){const{r:e,s:t}=this;if(!q(e)||!F(t))throw new Error("Invalid signature")}toHex(){return A(this.r)+A(this.s)}toRawBytes(){return B(this.toHex())}}class ce{constructor(e,t,r=ye.randomBytes()){if(null==e)throw new TypeError(`sign: Expected valid message, not "${e}"`);this.m=R(e);const{x:n,scalar:i}=this.getScalar(W(t));if(this.px=n,this.d=i,this.rand=R(r),32!==this.rand.length)throw new TypeError("sign: Expected 32 bytes of aux randomness")}getScalar(e){const t=v.fromPrivateKey(e),r=t.hasEvenY()?e:c.n-e;return{point:t,scalar:r,x:t.toRawX()}}initNonce(e,t){return P(e^M(t))}finalizeNonce(e){const t=j(M(e),c.n);if(t===i)throw new Error("sign: Creation of signature failed. k is zero");const{point:r,x:n,scalar:o}=this.getScalar(t);return{R:r,rx:n,k:o}}finalizeSig(e,t,r,n){return new ue(e.x,j(t+r*n,c.n)).toRawBytes()}error(){throw new Error("sign: Invalid signature produced")}async calc(){const{m:e,d:t,px:r,rand:n}=this,i=ye.taggedHash,o=this.initNonce(t,await i(me.aux,n)),{R:a,rx:s,k:u}=this.finalizeNonce(await i(me.nonce,o,r,e)),c=se(await i(me.challenge,s,r,e)),f=this.finalizeSig(a,u,c,t);return await de(f,e,r)||this.error(),f}calcSync(){const{m:e,d:t,px:r,rand:n}=this,i=ye.taggedHashSync,o=this.initNonce(t,i(me.aux,n)),{R:a,rx:s,k:u}=this.finalizeNonce(i(me.nonce,o,r,e)),c=se(i(me.challenge,s,r,e)),f=this.finalizeSig(a,u,c,t);return he(f,e,r)||this.error(),f}}function fe(e,t,r){const n=e instanceof ue,i=n?e:ue.fromHex(e);return n&&i.assertValidity(),{...i,m:R(t),P:V(r)}}function le(e,t,r,n){const i=v.BASE.multiplyAndAddUnsafe(t,W(r),j(-n,c.n));return!(!i||!i.hasEvenY()||i.x!==e)}async function de(e,t,r){try{const{r:n,s:i,m:o,P:a}=fe(e,t,r),s=se(await ye.taggedHash(me.challenge,P(n),a.toRawX(),o));return le(n,a,i,s)}catch(e){return!1}}function he(e,t,r){try{const{r:n,s:i,m:o,P:a}=fe(e,t,r),s=se(ye.taggedHashSync(me.challenge,P(n),a.toRawX(),o));return le(n,a,i,s)}catch(e){if(e instanceof p)throw e;return!1}}const pe={Signature:ue,getPublicKey:function(e){return v.fromPrivateKey(e).toRawX()},sign:async function(e,t,r){return new ce(e,t,r).calc()},verify:de,signSync:function(e,t,r){return new ce(e,t,r).calcSync()},verifySync:he};v.BASE._setWindowSize(8);const be={node:n,web:"object"==typeof self&&"crypto"in self?self.crypto:void 0},me={challenge:"BIP0340/challenge",aux:"BIP0340/aux",nonce:"BIP0340/nonce"},ge={},ye={bytesToHex:x,hexToBytes:B,concatBytes:k,mod:j,invert:C,isValidPrivateKey(e){try{return W(e),!0}catch(e){return!1}},_bigintTo32Bytes:P,_normalizePrivateKey:W,hashToPrivateKey:e=>{if((e=R(e)).length<40||e.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");return P(j(M(e),c.n-o)+o)},randomBytes:(e=32)=>{if(be.web)return be.web.getRandomValues(new Uint8Array(e));if(be.node){const{randomBytes:t}=be.node;return Uint8Array.from(t(e))}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>ye.hashToPrivateKey(ye.randomBytes(40)),precompute(e=8,t=v.BASE){const r=t===v.BASE?t:new v(t.x,t.y);return r._setWindowSize(e),r.multiply(s),r},sha256:async(...e)=>{if(be.web){const t=await be.web.subtle.digest("SHA-256",k(...e));return new Uint8Array(t)}if(be.node){const{createHash:t}=be.node,r=t("sha256");return e.forEach(e=>r.update(e)),Uint8Array.from(r.digest())}throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(e,...t)=>{if(be.web){const r=await be.web.subtle.importKey("raw",e,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),n=k(...t),i=await be.web.subtle.sign("HMAC",r,n);return new Uint8Array(i)}if(be.node){const{createHmac:r}=be.node,n=r("sha256",e);return t.forEach(e=>n.update(e)),Uint8Array.from(n.digest())}throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(e,...t)=>{let r=ge[e];if(void 0===r){const t=await ye.sha256(Uint8Array.from(e,e=>e.charCodeAt(0)));r=k(t,t),ge[e]=r}return ye.sha256(r,...t)},taggedHashSync:(e,...t)=>{if("function"!=typeof z)throw new p("sha256Sync is undefined, you need to set it");let r=ge[e];if(void 0===r){const t=z(Uint8Array.from(e,e=>e.charCodeAt(0)));r=k(t,t),ge[e]=r}return z(r,...t)},_JacobianPoint:m};Object.defineProperties(ye,{sha256Sync:{configurable:!1,get:()=>z,set(e){z||(z=e)}},hmacSha256Sync:{configurable:!1,get:()=>L,set(e){L||(L=e)}}})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(244);t.fromSeed=n.fromSeed,t.fromBase58=n.fromBase58,t.fromPublicKey=n.fromPublicKey,t.fromPrivateKey=n.fromPrivateKey},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(245),i=r(39),o=r(248),a=r(3),s=r(69),u=a.BufferN(32),c=a.compile({wif:a.UInt8,bip32:{public:a.UInt32,private:a.UInt32}}),f={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},l=Math.pow(2,31)-1;function d(e){return a.String(e)&&null!==e.match(/^(m\/)?(\d+'?\/)*\d+'?$/)}function h(e){return a.UInt32(e)&&e<=l}class p{constructor(e,t,r,n,i=0,o=0,s=0){this.__D=e,this.__Q=t,this.chainCode=r,this.network=n,this.__DEPTH=i,this.__INDEX=o,this.__PARENT_FINGERPRINT=s,a(c,n),this.lowR=!1}get depth(){return this.__DEPTH}get index(){return this.__INDEX}get parentFingerprint(){return this.__PARENT_FINGERPRINT}get publicKey(){return void 0===this.__Q&&(this.__Q=o.pointFromScalar(this.__D,!0)),this.__Q}get privateKey(){return this.__D}get identifier(){return n.hash160(this.publicKey)}get fingerprint(){return this.identifier.slice(0,4)}get compressed(){return!0}isNeutered(){return void 0===this.__D}neutered(){return g(this.publicKey,this.chainCode,this.network,this.depth,this.index,this.parentFingerprint)}toBase58(){const t=this.network,r=this.isNeutered()?t.bip32.public:t.bip32.private,n=e.allocUnsafe(78);return n.writeUInt32BE(r,0),n.writeUInt8(this.depth,4),n.writeUInt32BE(this.parentFingerprint,5),n.writeUInt32BE(this.index,9),this.chainCode.copy(n,13),this.isNeutered()?this.publicKey.copy(n,45):(n.writeUInt8(0,45),this.privateKey.copy(n,46)),i.encode(n)}toWIF(){if(!this.privateKey)throw new TypeError("Missing private key");return s.encode(this.network.wif,this.privateKey,!0)}derive(t){a(a.UInt32,t);const r=t>=2147483648,i=e.allocUnsafe(37);if(r){if(this.isNeutered())throw new TypeError("Missing private key for hardened child key");i[0]=0,this.privateKey.copy(i,1),i.writeUInt32BE(t,33)}else this.publicKey.copy(i,0),i.writeUInt32BE(t,33);const s=n.hmacSHA512(this.chainCode,i),u=s.slice(0,32),c=s.slice(32);if(!o.isPrivate(u))return this.derive(t+1);let f;if(this.isNeutered()){const e=o.pointAddScalar(this.publicKey,u,!0);if(null===e)return this.derive(t+1);f=g(e,c,this.network,this.depth+1,t,this.fingerprint.readUInt32BE(0))}else{const e=o.privateAdd(this.privateKey,u);if(null==e)return this.derive(t+1);f=m(e,c,this.network,this.depth+1,t,this.fingerprint.readUInt32BE(0))}return f}deriveHardened(e){return a(h,e),this.derive(e+2147483648)}derivePath(e){a(d,e);let t=e.split("/");if("m"===t[0]){if(this.parentFingerprint)throw new TypeError("Expected master, got child");t=t.slice(1)}return t.reduce((e,t)=>{let r;return"'"===t.slice(-1)?(r=parseInt(t.slice(0,-1),10),e.deriveHardened(r)):(r=parseInt(t,10),e.derive(r))},this)}sign(t,r){if(!this.privateKey)throw new Error("Missing private key");if(void 0===r&&(r=this.lowR),!1===r)return o.sign(t,this.privateKey);{let r=o.sign(t,this.privateKey);const n=e.alloc(32,0);let i=0;for(;r[0]>127;)i++,n.writeUIntLE(i,0,6),r=o.signWithEntropy(t,this.privateKey,n);return r}}verify(e,t){return o.verify(e,this.publicKey,t)}}function b(e,t,r){return m(e,t,r)}function m(e,t,r,n,i,s){if(a({privateKey:u,chainCode:u},{privateKey:e,chainCode:t}),r=r||f,!o.isPrivate(e))throw new TypeError("Private key not in range [1, n)");return new p(e,void 0,t,r,n,i,s)}function g(e,t,r,n,i,s){if(a({publicKey:a.BufferN(33),chainCode:u},{publicKey:e,chainCode:t}),r=r||f,!o.isPoint(e))throw new TypeError("Point is not on the curve");return new p(void 0,e,t,r,n,i,s)}t.fromBase58=function(e,t){const r=i.decode(e);if(78!==r.length)throw new TypeError("Invalid buffer length");t=t||f;const n=r.readUInt32BE(0);if(n!==t.bip32.private&&n!==t.bip32.public)throw new TypeError("Invalid network version");const o=r[4],a=r.readUInt32BE(5);if(0===o&&0!==a)throw new TypeError("Invalid parent fingerprint");const s=r.readUInt32BE(9);if(0===o&&0!==s)throw new TypeError("Invalid index");const u=r.slice(13,45);let c;if(n===t.bip32.private){if(0!==r.readUInt8(45))throw new TypeError("Invalid private key");c=m(r.slice(46,78),u,t,o,s,a)}else{c=g(r.slice(45,78),u,t,o,s,a)}return c},t.fromPrivateKey=b,t.fromPublicKey=function(e,t,r){return g(e,t,r)},t.fromSeed=function(t,r){if(a(a.Buffer,t),t.length<16)throw new TypeError("Seed should be at least 128 bits");if(t.length>64)throw new TypeError("Seed should be at most 512 bits");r=r||f;const i=n.hmacSHA512(e.from("Bitcoin seed","utf8"),t);return b(i.slice(0,32),i.slice(32),r)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(70),i=r(76);t.hash160=function(e){const t=n("sha256").update(e).digest();try{return n("rmd160").update(t).digest()}catch(e){return n("ripemd160").update(t).digest()}},t.hmacSHA512=function(e,t){return i("sha512",e).update(t).digest()}},function(e,t,r){"use strict";var n=r(2),i=r(4).Buffer,o=r(72),a=i.alloc(128);function s(e,t){o.call(this,"digest"),"string"==typeof t&&(t=i.from(t)),this._alg=e,this._key=t,t.length>64?t=e(t):t.length<64&&(t=i.concat([t,a],64));for(var r=this._ipad=i.allocUnsafe(64),n=this._opad=i.allocUnsafe(64),s=0;s<64;s++)r[s]=54^t[s],n[s]=92^t[s];this._hash=[r]}n(s,o),s.prototype._update=function(e){this._hash.push(e)},s.prototype._final=function(){var e=this._alg(i.concat(this._hash));return this._alg(i.concat([this._opad,e]))},e.exports=s},function(e,t,r){var n=r(100);e.exports=function(e){return(new n).update(e).digest()}},function(e,t,r){(function(t){const n=r(14),i=new(0,r(118).ec)("secp256k1"),o=r(270),a=t.alloc(32,0),s=t.from("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141","hex"),u=t.from("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f","hex"),c=i.curve.n,f=c.shrn(1),l=i.curve.g;function d(e){return t.isBuffer(e)&&32===e.length}function h(e){return!!d(e)&&e.compare(s)<0}function p(e){if(!t.isBuffer(e))return!1;if(e.length<33)return!1;const r=e[0],n=e.slice(1,33);if(0===n.compare(a))return!1;if(n.compare(u)>=0)return!1;if((2===r||3===r)&&33===e.length){try{w(e)}catch(e){return!1}return!0}const i=e.slice(33);return 0!==i.compare(a)&&(!(i.compare(u)>=0)&&(4===r&&65===e.length))}function b(e){return 4!==e[0]}function m(e){return!!d(e)&&(e.compare(a)>0&&e.compare(s)<0)}function g(e,t){return void 0===e&&void 0!==t?b(t):void 0===e||e}function y(e){return new n(e)}function v(e){return e.toArrayLike(t,"be",32)}function w(e){return i.curve.decodePoint(e)}function _(e,r){return t.from(e._encode(r))}function E(e,r,n){if(!d(e))throw new TypeError("Expected Hash");if(!m(r))throw new TypeError("Expected Private");if(void 0!==n&&!d(n))throw new TypeError("Expected Extra Data (32 bytes)");const i=y(r),a=y(e);let s,u;o(e,r,(function(e){const t=y(e),r=l.mul(t);return!r.isInfinity()&&(s=r.x.umod(c),0!==s.isZero()&&(u=t.invm(c).mul(a.add(i.mul(s))).umod(c),0!==u.isZero()))}),m,n),u.cmp(f)>0&&(u=c.sub(u));const h=t.allocUnsafe(64);return v(s).copy(h,0),v(u).copy(h,32),h}e.exports={isPoint:p,isPointCompressed:function(e){return!!p(e)&&b(e)},isPrivate:m,pointAdd:function(e,t,r){if(!p(e))throw new TypeError("Expected Point");if(!p(t))throw new TypeError("Expected Point");const n=w(e),i=w(t),o=n.add(i);return o.isInfinity()?null:_(o,g(r,e))},pointAddScalar:function(e,t,r){if(!p(e))throw new TypeError("Expected Point");if(!h(t))throw new TypeError("Expected Tweak");const n=g(r,e),i=w(e);if(0===t.compare(a))return _(i,n);const o=y(t),s=l.mul(o),u=i.add(s);return u.isInfinity()?null:_(u,n)},pointCompress:function(e,t){if(!p(e))throw new TypeError("Expected Point");const r=w(e);if(r.isInfinity())throw new TypeError("Expected Point");return _(r,g(t,e))},pointFromScalar:function(e,t){if(!m(e))throw new TypeError("Expected Private");const r=y(e),n=l.mul(r);return n.isInfinity()?null:_(n,g(t))},pointMultiply:function(e,t,r){if(!p(e))throw new TypeError("Expected Point");if(!h(t))throw new TypeError("Expected Tweak");const n=g(r,e),i=w(e),o=y(t),a=i.mul(o);return a.isInfinity()?null:_(a,n)},privateAdd:function(e,t){if(!m(e))throw new TypeError("Expected Private");if(!h(t))throw new TypeError("Expected Tweak");const r=y(e),n=y(t),i=v(r.add(n).umod(c));return m(i)?i:null},privateSub:function(e,t){if(!m(e))throw new TypeError("Expected Private");if(!h(t))throw new TypeError("Expected Tweak");const r=y(e),n=y(t),i=v(r.sub(n).umod(c));return m(i)?i:null},sign:function(e,t){return E(e,t)},signWithEntropy:function(e,t,r){return E(e,t,r)},verify:function(e,r,n,i){if(!d(e))throw new TypeError("Expected Hash");if(!p(r))throw new TypeError("Expected Point");if(!function(e){const r=e.slice(0,32),n=e.slice(32,64);return t.isBuffer(e)&&64===e.length&&r.compare(s)<0&&n.compare(s)<0}(n))throw new TypeError("Expected Signature");const o=w(r),a=y(n.slice(0,32)),u=y(n.slice(32,64));if(i&&u.cmp(f)>0)return!1;if(a.gtn(0)<=0)return!1;if(u.gtn(0)<=0)return!1;const h=y(e),b=u.invm(c),m=h.mul(b).umod(c),g=a.mul(b).umod(c),v=l.mulAdd(m,o,g);return!v.isInfinity()&&v.x.umod(c).eq(a)}}}).call(this,r(0).Buffer)},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t){},function(e){e.exports=JSON.parse('{"name":"elliptic","version":"6.5.4","description":"EC cryptography","main":"lib/elliptic.js","files":["lib"],"scripts":{"lint":"eslint lib test","lint:fix":"npm run lint -- --fix","unit":"istanbul test _mocha --reporter=spec test/index.js","test":"npm run lint && npm run unit","version":"grunt dist && git add dist/"},"repository":{"type":"git","url":"git@github.com:indutny/elliptic"},"keywords":["EC","Elliptic","curve","Cryptography"],"author":"Fedor Indutny <fedor@indutny.com>","license":"MIT","bugs":{"url":"https://github.com/indutny/elliptic/issues"},"homepage":"https://github.com/indutny/elliptic","devDependencies":{"brfs":"^2.0.2","coveralls":"^3.1.0","eslint":"^7.6.0","grunt":"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1","istanbul":"^0.4.5","mocha":"^8.0.1"},"dependencies":{"bn.js":"^4.11.9","brorand":"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1","inherits":"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"}}')},function(e,t){},function(e,t,r){"use strict";var n=r(11),i=r(14),o=r(2),a=r(49),s=n.assert;function u(e){a.call(this,"short",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function c(e,t,r,n){a.BasePoint.call(this,e,"affine"),null===t&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new i(t,16),this.y=new i(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function f(e,t,r,n){a.BasePoint.call(this,e,"jacobian"),null===t&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new i(0)):(this.x=new i(t,16),this.y=new i(r,16),this.z=new i(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}o(u,a),e.exports=u,u.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,r;if(e.beta)t=new i(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=(t=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(e.lambda)r=new i(e.lambda,16);else{var o=this._getEndoRoots(this.n);0===this.g.mul(o[0]).x.cmp(this.g.x.redMul(t))?r=o[0]:(r=o[1],s(0===this.g.mul(r).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:r,basis:e.basis?e.basis.map((function(e){return{a:new i(e.a,16),b:new i(e.b,16)}})):this._getEndoBasis(r)}}},u.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:i.mont(e),r=new i(2).toRed(t).redInvm(),n=r.redNeg(),o=new i(3).toRed(t).redNeg().redSqrt().redMul(r);return[n.redAdd(o).fromRed(),n.redSub(o).fromRed()]},u.prototype._getEndoBasis=function(e){for(var t,r,n,o,a,s,u,c,f,l=this.n.ushrn(Math.floor(this.n.bitLength()/2)),d=e,h=this.n.clone(),p=new i(1),b=new i(0),m=new i(0),g=new i(1),y=0;0!==d.cmpn(0);){var v=h.div(d);c=h.sub(v.mul(d)),f=m.sub(v.mul(p));var w=g.sub(v.mul(b));if(!n&&c.cmp(l)<0)t=u.neg(),r=p,n=c.neg(),o=f;else if(n&&2==++y)break;u=c,h=d,d=c,m=p,p=f,g=b,b=w}a=c.neg(),s=f;var _=n.sqr().add(o.sqr());return a.sqr().add(s.sqr()).cmp(_)>=0&&(a=t,s=r),n.negative&&(n=n.neg(),o=o.neg()),a.negative&&(a=a.neg(),s=s.neg()),[{a:n,b:o},{a:a,b:s}]},u.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),a=i.mul(r.a),s=o.mul(n.a),u=i.mul(r.b),c=o.mul(n.b);return{k1:e.sub(a).sub(s),k2:u.add(c).neg()}},u.prototype.pointFromX=function(e,t){(e=new i(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var o=n.fromRed().isOdd();return(t&&!o||!t&&o)&&(n=n.redNeg()),this.point(e,n)},u.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},u.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o<e.length;o++){var a=this._endoSplit(t[o]),s=e[o],u=s._getBeta();a.k1.negative&&(a.k1.ineg(),s=s.neg(!0)),a.k2.negative&&(a.k2.ineg(),u=u.neg(!0)),n[2*o]=s,n[2*o+1]=u,i[2*o]=a.k1,i[2*o+1]=a.k2}for(var c=this._wnafMulAdd(1,n,i,2*o,r),f=0;f<2*o;f++)n[f]=null,i[f]=null;return c},o(c,a.BasePoint),u.prototype.point=function(e,t,r){return new c(this,e,t,r)},u.prototype.pointFromJSON=function(e,t){return c.fromJSON(this,e,t)},c.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var t=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var r=this.curve,n=function(e){return r.point(e.x.redMul(r.endo.beta),e.y)};e.beta=t,t.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(n)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(n)}}}return t}},c.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},c.fromJSON=function(e,t,r){"string"==typeof t&&(t=JSON.parse(t));var n=e.point(t[0],t[1],r);if(!t[2])return n;function i(t){return e.point(t[0],t[1],r)}var o=t[2];return n.precomputed={beta:null,doubles:o.doubles&&{step:o.doubles.step,points:[n].concat(o.doubles.points.map(i))},naf:o.naf&&{wnd:o.naf.wnd,points:[n].concat(o.naf.points.map(i))}},n},c.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},c.prototype.isInfinity=function(){return this.inf},c.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},c.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),a=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},c.prototype.getX=function(){return this.x.fromRed()},c.prototype.getY=function(){return this.y.fromRed()},c.prototype.mul=function(e){return e=new i(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},c.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},c.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},c.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},c.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},c.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},o(f,a.BasePoint),u.prototype.jpoint=function(e,t,r){return new f(this,e,t,r)},f.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},f.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},f.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(r.redMul(this.z)),s=n.redSub(i),u=o.redSub(a);if(0===s.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=s.redSqr(),f=c.redMul(s),l=n.redMul(c),d=u.redSqr().redIAdd(f).redISub(l).redISub(l),h=u.redMul(l.redISub(d)).redISub(o.redMul(f)),p=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(d,h,p)},f.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),a=r.redSub(n),s=i.redSub(o);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),c=u.redMul(a),f=r.redMul(u),l=s.redSqr().redIAdd(c).redISub(f).redISub(f),d=s.redMul(f.redISub(l)).redISub(i.redMul(c)),h=this.z.redMul(a);return this.curve.jpoint(l,d,h)},f.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var r=this;for(t=0;t<e;t++)r=r.dbl();return r}var n=this.curve.a,i=this.curve.tinv,o=this.x,a=this.y,s=this.z,u=s.redSqr().redSqr(),c=a.redAdd(a);for(t=0;t<e;t++){var f=o.redSqr(),l=c.redSqr(),d=l.redSqr(),h=f.redAdd(f).redIAdd(f).redIAdd(n.redMul(u)),p=o.redMul(l),b=h.redSqr().redISub(p.redAdd(p)),m=p.redISub(b),g=h.redMul(m);g=g.redIAdd(g).redISub(d);var y=c.redMul(s);t+1<e&&(u=u.redMul(d)),o=b,s=y,c=g}return this.curve.jpoint(o,c.redMul(i),s)},f.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},f.prototype._zeroDbl=function(){var e,t,r;if(this.zOne){var n=this.x.redSqr(),i=this.y.redSqr(),o=i.redSqr(),a=this.x.redAdd(i).redSqr().redISub(n).redISub(o);a=a.redIAdd(a);var s=n.redAdd(n).redIAdd(n),u=s.redSqr().redISub(a).redISub(a),c=o.redIAdd(o);c=(c=c.redIAdd(c)).redIAdd(c),e=u,t=s.redMul(a.redISub(u)).redISub(c),r=this.y.redAdd(this.y)}else{var f=this.x.redSqr(),l=this.y.redSqr(),d=l.redSqr(),h=this.x.redAdd(l).redSqr().redISub(f).redISub(d);h=h.redIAdd(h);var p=f.redAdd(f).redIAdd(f),b=p.redSqr(),m=d.redIAdd(d);m=(m=m.redIAdd(m)).redIAdd(m),e=b.redISub(h).redISub(h),t=p.redMul(h.redISub(e)).redISub(m),r=(r=this.y.redMul(this.z)).redIAdd(r)}return this.curve.jpoint(e,t,r)},f.prototype._threeDbl=function(){var e,t,r;if(this.zOne){var n=this.x.redSqr(),i=this.y.redSqr(),o=i.redSqr(),a=this.x.redAdd(i).redSqr().redISub(n).redISub(o);a=a.redIAdd(a);var s=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),u=s.redSqr().redISub(a).redISub(a);e=u;var c=o.redIAdd(o);c=(c=c.redIAdd(c)).redIAdd(c),t=s.redMul(a.redISub(u)).redISub(c),r=this.y.redAdd(this.y)}else{var f=this.z.redSqr(),l=this.y.redSqr(),d=this.x.redMul(l),h=this.x.redSub(f).redMul(this.x.redAdd(f));h=h.redAdd(h).redIAdd(h);var p=d.redIAdd(d),b=(p=p.redIAdd(p)).redAdd(p);e=h.redSqr().redISub(b),r=this.y.redAdd(this.z).redSqr().redISub(l).redISub(f);var m=l.redSqr();m=(m=(m=m.redIAdd(m)).redIAdd(m)).redIAdd(m),t=h.redMul(p.redISub(e)).redISub(m)}return this.curve.jpoint(e,t,r)},f.prototype._dbl=function(){var e=this.curve.a,t=this.x,r=this.y,n=this.z,i=n.redSqr().redSqr(),o=t.redSqr(),a=r.redSqr(),s=o.redAdd(o).redIAdd(o).redIAdd(e.redMul(i)),u=t.redAdd(t),c=(u=u.redIAdd(u)).redMul(a),f=s.redSqr().redISub(c.redAdd(c)),l=c.redISub(f),d=a.redSqr();d=(d=(d=d.redIAdd(d)).redIAdd(d)).redIAdd(d);var h=s.redMul(l).redISub(d),p=r.redAdd(r).redMul(n);return this.curve.jpoint(f,h,p)},f.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr(),n=t.redSqr(),i=e.redAdd(e).redIAdd(e),o=i.redSqr(),a=this.x.redAdd(t).redSqr().redISub(e).redISub(n),s=(a=(a=(a=a.redIAdd(a)).redAdd(a).redIAdd(a)).redISub(o)).redSqr(),u=n.redIAdd(n);u=(u=(u=u.redIAdd(u)).redIAdd(u)).redIAdd(u);var c=i.redIAdd(a).redSqr().redISub(o).redISub(s).redISub(u),f=t.redMul(c);f=(f=f.redIAdd(f)).redIAdd(f);var l=this.x.redMul(s).redISub(f);l=(l=l.redIAdd(l)).redIAdd(l);var d=this.y.redMul(c.redMul(u.redISub(c)).redISub(a.redMul(s)));d=(d=(d=d.redIAdd(d)).redIAdd(d)).redIAdd(d);var h=this.z.redAdd(a).redSqr().redISub(r).redISub(s);return this.curve.jpoint(l,d,h)},f.prototype.mul=function(e,t){return e=new i(e,t),this.curve._wnafMul(this,e)},f.prototype.eq=function(e){if("affine"===e.type)return this.eq(e.toJ());if(this===e)return!0;var t=this.z.redSqr(),r=e.z.redSqr();if(0!==this.x.redMul(r).redISub(e.x.redMul(t)).cmpn(0))return!1;var n=t.redMul(this.z),i=r.redMul(e.z);return 0===this.y.redMul(i).redISub(e.y.redMul(n)).cmpn(0)},f.prototype.eqXToP=function(e){var t=this.z.redSqr(),r=e.toRed(this.curve.red).redMul(t);if(0===this.x.cmp(r))return!0;for(var n=e.clone(),i=this.curve.redN.redMul(t);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},f.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},f.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},function(e,t,r){"use strict";var n=r(14),i=r(2),o=r(49),a=r(11);function s(e){o.call(this,"mont",e),this.a=new n(e.a,16).toRed(this.red),this.b=new n(e.b,16).toRed(this.red),this.i4=new n(4).toRed(this.red).redInvm(),this.two=new n(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function u(e,t,r){o.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new n(t,16),this.z=new n(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}i(s,o),e.exports=s,s.prototype.validate=function(e){var t=e.normalize().x,r=t.redSqr(),n=r.redMul(t).redAdd(r.redMul(this.a)).redAdd(t);return 0===n.redSqrt().redSqr().cmp(n)},i(u,o.BasePoint),s.prototype.decodePoint=function(e,t){return this.point(a.toArray(e,t),1)},s.prototype.point=function(e,t){return new u(this,e,t)},s.prototype.pointFromJSON=function(e){return u.fromJSON(this,e)},u.prototype.precompute=function(){},u.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},u.fromJSON=function(e,t){return new u(e,t[0],t[1]||e.one)},u.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},u.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},u.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),r=e.redSub(t),n=e.redMul(t),i=r.redMul(t.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},u.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},u.prototype.diffAdd=function(e,t){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=e.x.redAdd(e.z),o=e.x.redSub(e.z).redMul(r),a=i.redMul(n),s=t.z.redMul(o.redAdd(a).redSqr()),u=t.x.redMul(o.redISub(a).redSqr());return this.curve.point(s,u)},u.prototype.mul=function(e){for(var t=e.clone(),r=this,n=this.curve.point(null,null),i=[];0!==t.cmpn(0);t.iushrn(1))i.push(t.andln(1));for(var o=i.length-1;o>=0;o--)0===i[o]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},u.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},u.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},u.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},u.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},u.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},function(e,t,r){"use strict";var n=r(11),i=r(14),o=r(2),a=r(49),s=n.assert;function u(e){this.twisted=1!=(0|e.a),this.mOneA=this.twisted&&-1==(0|e.a),this.extended=this.mOneA,a.call(this,"edwards",e),this.a=new i(e.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new i(e.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new i(e.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),s(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|e.c)}function c(e,t,r,n,o){a.BasePoint.call(this,e,"projective"),null===t&&null===r&&null===n?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new i(t,16),this.y=new i(r,16),this.z=n?new i(n,16):this.curve.one,this.t=o&&new i(o,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}o(u,a),e.exports=u,u.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},u.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},u.prototype.jpoint=function(e,t,r,n){return this.point(e,t,r,n)},u.prototype.pointFromX=function(e,t){(e=new i(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr(),n=this.c2.redSub(this.a.redMul(r)),o=this.one.redSub(this.c2.redMul(this.d).redMul(r)),a=n.redMul(o.redInvm()),s=a.redSqrt();if(0!==s.redSqr().redSub(a).cmp(this.zero))throw new Error("invalid point");var u=s.fromRed().isOdd();return(t&&!u||!t&&u)&&(s=s.redNeg()),this.point(e,s)},u.prototype.pointFromY=function(e,t){(e=new i(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr(),n=r.redSub(this.c2),o=r.redMul(this.d).redMul(this.c2).redSub(this.a),a=n.redMul(o.redInvm());if(0===a.cmp(this.zero)){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var s=a.redSqrt();if(0!==s.redSqr().redSub(a).cmp(this.zero))throw new Error("invalid point");return s.fromRed().isOdd()!==t&&(s=s.redNeg()),this.point(s,e)},u.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),r=e.y.redSqr(),n=t.redMul(this.a).redAdd(r),i=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(r)));return 0===n.cmp(i)},o(c,a.BasePoint),u.prototype.pointFromJSON=function(e){return c.fromJSON(this,e)},u.prototype.point=function(e,t,r,n){return new c(this,e,t,r,n)},c.fromJSON=function(e,t){return new c(e,t[0],t[1],t[2])},c.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},c.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},c.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(e),i=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),a=o.redSub(r),s=n.redSub(t),u=i.redMul(a),c=o.redMul(s),f=i.redMul(s),l=a.redMul(o);return this.curve.point(u,c,l,f)},c.prototype._projDbl=function(){var e,t,r,n,i,o,a=this.x.redAdd(this.y).redSqr(),s=this.x.redSqr(),u=this.y.redSqr();if(this.curve.twisted){var c=(n=this.curve._mulA(s)).redAdd(u);this.zOne?(e=a.redSub(s).redSub(u).redMul(c.redSub(this.curve.two)),t=c.redMul(n.redSub(u)),r=c.redSqr().redSub(c).redSub(c)):(i=this.z.redSqr(),o=c.redSub(i).redISub(i),e=a.redSub(s).redISub(u).redMul(o),t=c.redMul(n.redSub(u)),r=c.redMul(o))}else n=s.redAdd(u),i=this.curve._mulC(this.z).redSqr(),o=n.redSub(i).redSub(i),e=this.curve._mulC(a.redISub(n)).redMul(o),t=this.curve._mulC(n).redMul(s.redISub(u)),r=n.redMul(o);return this.curve.point(e,t,r)},c.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},c.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),r=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),i=this.z.redMul(e.z.redAdd(e.z)),o=r.redSub(t),a=i.redSub(n),s=i.redAdd(n),u=r.redAdd(t),c=o.redMul(a),f=s.redMul(u),l=o.redMul(u),d=a.redMul(s);return this.curve.point(c,f,d,l)},c.prototype._projAdd=function(e){var t,r,n=this.z.redMul(e.z),i=n.redSqr(),o=this.x.redMul(e.x),a=this.y.redMul(e.y),s=this.curve.d.redMul(o).redMul(a),u=i.redSub(s),c=i.redAdd(s),f=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(o).redISub(a),l=n.redMul(u).redMul(f);return this.curve.twisted?(t=n.redMul(c).redMul(a.redSub(this.curve._mulA(o))),r=u.redMul(c)):(t=n.redMul(c).redMul(a.redSub(o)),r=this.curve._mulC(u).redMul(c)),this.curve.point(l,t,r)},c.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},c.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},c.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!1)},c.prototype.jmulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!0)},c.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},c.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},c.prototype.getX=function(){return this.normalize(),this.x.fromRed()},c.prototype.getY=function(){return this.normalize(),this.y.fromRed()},c.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},c.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var r=e.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),0===this.x.cmp(t))return!0}},c.prototype.toP=c.prototype.normalize,c.prototype.mixedAdd=c.prototype.add},function(e,t,r){"use strict";t.sha1=r(257),t.sha224=r(258),t.sha256=r(123),t.sha384=r(259),t.sha512=r(124)},function(e,t,r){"use strict";var n=r(15),i=r(43),o=r(122),a=n.rotl32,s=n.sum32,u=n.sum32_5,c=o.ft_1,f=i.BlockHash,l=[1518500249,1859775393,2400959708,3395469782];function d(){if(!(this instanceof d))return new d;f.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}n.inherits(d,f),e.exports=d,d.blockSize=512,d.outSize=160,d.hmacStrength=80,d.padLength=64,d.prototype._update=function(e,t){for(var r=this.W,n=0;n<16;n++)r[n]=e[t+n];for(;n<r.length;n++)r[n]=a(r[n-3]^r[n-8]^r[n-14]^r[n-16],1);var i=this.h[0],o=this.h[1],f=this.h[2],d=this.h[3],h=this.h[4];for(n=0;n<r.length;n++){var p=~~(n/20),b=u(a(i,5),c(p,o,f,d),h,r[n],l[p]);h=d,d=f,f=a(o,30),o=i,i=b}this.h[0]=s(this.h[0],i),this.h[1]=s(this.h[1],o),this.h[2]=s(this.h[2],f),this.h[3]=s(this.h[3],d),this.h[4]=s(this.h[4],h)},d.prototype._digest=function(e){return"hex"===e?n.toHex32(this.h,"big"):n.split32(this.h,"big")}},function(e,t,r){"use strict";var n=r(15),i=r(123);function o(){if(!(this instanceof o))return new o;i.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}n.inherits(o,i),e.exports=o,o.blockSize=512,o.outSize=224,o.hmacStrength=192,o.padLength=64,o.prototype._digest=function(e){return"hex"===e?n.toHex32(this.h.slice(0,7),"big"):n.split32(this.h.slice(0,7),"big")}},function(e,t,r){"use strict";var n=r(15),i=r(124);function o(){if(!(this instanceof o))return new o;i.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}n.inherits(o,i),e.exports=o,o.blockSize=1024,o.outSize=384,o.hmacStrength=192,o.padLength=128,o.prototype._digest=function(e){return"hex"===e?n.toHex32(this.h.slice(0,12),"big"):n.split32(this.h.slice(0,12),"big")}},function(e,t,r){"use strict";var n=r(15),i=r(43),o=n.rotl32,a=n.sum32,s=n.sum32_3,u=n.sum32_4,c=i.BlockHash;function f(){if(!(this instanceof f))return new f;c.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}function l(e,t,r,n){return e<=15?t^r^n:e<=31?t&r|~t&n:e<=47?(t|~r)^n:e<=63?t&n|r&~n:t^(r|~n)}function d(e){return e<=15?0:e<=31?1518500249:e<=47?1859775393:e<=63?2400959708:2840853838}function h(e){return e<=15?1352829926:e<=31?1548603684:e<=47?1836072691:e<=63?2053994217:0}n.inherits(f,c),t.ripemd160=f,f.blockSize=512,f.outSize=160,f.hmacStrength=192,f.padLength=64,f.prototype._update=function(e,t){for(var r=this.h[0],n=this.h[1],i=this.h[2],c=this.h[3],f=this.h[4],y=r,v=n,w=i,_=c,E=f,k=0;k<80;k++){var S=a(o(u(r,l(k,n,i,c),e[p[k]+t],d(k)),m[k]),f);r=f,f=c,c=o(i,10),i=n,n=S,S=a(o(u(y,l(79-k,v,w,_),e[b[k]+t],h(k)),g[k]),E),y=E,E=_,_=o(w,10),w=v,v=S}S=s(this.h[1],i,_),this.h[1]=s(this.h[2],c,E),this.h[2]=s(this.h[3],f,y),this.h[3]=s(this.h[4],r,v),this.h[4]=s(this.h[0],n,w),this.h[0]=S},f.prototype._digest=function(e){return"hex"===e?n.toHex32(this.h,"little"):n.split32(this.h,"little")};var p=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],b=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],m=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],g=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]},function(e,t,r){"use strict";var n=r(15),i=r(24);function o(e,t,r){if(!(this instanceof o))return new o(e,t,r);this.Hash=e,this.blockSize=e.blockSize/8,this.outSize=e.outSize/8,this.inner=null,this.outer=null,this._init(n.toArray(t,r))}e.exports=o,o.prototype._init=function(e){e.length>this.blockSize&&(e=(new this.Hash).update(e).digest()),i(e.length<=this.blockSize);for(var t=e.length;t<this.blockSize;t++)e.push(0);for(t=0;t<e.length;t++)e[t]^=54;for(this.inner=(new this.Hash).update(e),t=0;t<e.length;t++)e[t]^=106;this.outer=(new this.Hash).update(e)},o.prototype.update=function(e,t){return this.inner.update(e,t),this},o.prototype.digest=function(e){return this.outer.update(this.inner.digest()),this.outer.digest(e)}},function(e,t){e.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}},function(e,t,r){"use strict";var n=r(14),i=r(264),o=r(11),a=r(77),s=r(120),u=o.assert,c=r(265),f=r(266);function l(e){if(!(this instanceof l))return new l(e);"string"==typeof e&&(u(Object.prototype.hasOwnProperty.call(a,e),"Unknown curve "+e),e=a[e]),e instanceof a.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}e.exports=l,l.prototype.keyPair=function(e){return new c(this,e)},l.prototype.keyFromPrivate=function(e,t){return c.fromPrivate(this,e,t)},l.prototype.keyFromPublic=function(e,t){return c.fromPublic(this,e,t)},l.prototype.genKeyPair=function(e){e||(e={});for(var t=new i({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||s(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),o=this.n.sub(new n(2));;){var a=new n(t.generate(r));if(!(a.cmp(o)>0))return a.iaddn(1),this.keyFromPrivate(a)}},l.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},l.prototype.sign=function(e,t,r,o){"object"==typeof r&&(o=r,r=null),o||(o={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new n(e,16));for(var a=this.n.byteLength(),s=t.getPrivate().toArray("be",a),u=e.toArray("be",a),c=new i({hash:this.hash,entropy:s,nonce:u,pers:o.pers,persEnc:o.persEnc||"utf8"}),l=this.n.sub(new n(1)),d=0;;d++){var h=o.k?o.k(d):new n(c.generate(this.n.byteLength()));if(!((h=this._truncateToN(h,!0)).cmpn(1)<=0||h.cmp(l)>=0)){var p=this.g.mul(h);if(!p.isInfinity()){var b=p.getX(),m=b.umod(this.n);if(0!==m.cmpn(0)){var g=h.invm(this.n).mul(m.mul(t.getPrivate()).iadd(e));if(0!==(g=g.umod(this.n)).cmpn(0)){var y=(p.getY().isOdd()?1:0)|(0!==b.cmp(m)?2:0);return o.canonical&&g.cmp(this.nh)>0&&(g=this.n.sub(g),y^=1),new f({r:m,s:g,recoveryParam:y})}}}}}},l.prototype.verify=function(e,t,r,i){e=this._truncateToN(new n(e,16)),r=this.keyFromPublic(r,i);var o=(t=new f(t,"hex")).r,a=t.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var s,u=a.invm(this.n),c=u.mul(e).umod(this.n),l=u.mul(o).umod(this.n);return this.curve._maxwellTrick?!(s=this.g.jmulAdd(c,r.getPublic(),l)).isInfinity()&&s.eqXToP(o):!(s=this.g.mulAdd(c,r.getPublic(),l)).isInfinity()&&0===s.getX().umod(this.n).cmp(o)},l.prototype.recoverPubKey=function(e,t,r,i){u((3&r)===r,"The recovery param is more than two bits"),t=new f(t,i);var o=this.n,a=new n(e),s=t.r,c=t.s,l=1&r,d=r>>1;if(s.cmp(this.curve.p.umod(this.curve.n))>=0&&d)throw new Error("Unable to find sencond key candinate");s=d?this.curve.pointFromX(s.add(this.curve.n),l):this.curve.pointFromX(s,l);var h=t.r.invm(o),p=o.sub(a).mul(h).umod(o),b=c.mul(h).umod(o);return this.g.mulAdd(p,s,b)},l.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new f(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},function(e,t,r){"use strict";var n=r(78),i=r(119),o=r(24);function a(e){if(!(this instanceof a))return new a(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=i.toArray(e.entropy,e.entropyEnc||"hex"),r=i.toArray(e.nonce,e.nonceEnc||"hex"),n=i.toArray(e.pers,e.persEnc||"hex");o(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}e.exports=a,a.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i<this.V.length;i++)this.K[i]=0,this.V[i]=1;this._update(n),this._reseed=1,this.reseedInterval=281474976710656},a.prototype._hmac=function(){return new n.hmac(this.hash,this.K)},a.prototype._update=function(e){var t=this._hmac().update(this.V).update([0]);e&&(t=t.update(e)),this.K=t.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())},a.prototype.reseed=function(e,t,r,n){"string"!=typeof t&&(n=r,r=t,t=null),e=i.toArray(e,t),r=i.toArray(r,n),o(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},a.prototype.generate=function(e,t,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var o=[];o.length<e;)this.V=this._hmac().update(this.V).digest(),o=o.concat(this.V);var a=o.slice(0,e);return this._update(r),this._reseed++,i.encode(a,t)}},function(e,t,r){"use strict";var n=r(14),i=r(11).assert;function o(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}e.exports=o,o.fromPublic=function(e,t,r){return t instanceof o?t:new o(e,{pub:t,pubEnc:r})},o.fromPrivate=function(e,t,r){return t instanceof o?t:new o(e,{priv:t,privEnc:r})},o.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},o.prototype.getPublic=function(e,t){return"string"==typeof e&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},o.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},o.prototype._importPrivate=function(e,t){this.priv=new n(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},o.prototype._importPublic=function(e,t){if(e.x||e.y)return"mont"===this.ec.curve.type?i(e.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||i(e.x&&e.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(e.x,e.y));this.pub=this.ec.curve.decodePoint(e,t)},o.prototype.derive=function(e){return e.validate()||i(e.validate(),"public point not validated"),e.mul(this.priv).getX()},o.prototype.sign=function(e,t,r){return this.ec.sign(e,this,t,r)},o.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},o.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"}},function(e,t,r){"use strict";var n=r(14),i=r(11),o=i.assert;function a(e,t){if(e instanceof a)return e;this._importDER(e,t)||(o(e.r&&e.s,"Signature without r or s"),this.r=new n(e.r,16),this.s=new n(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function s(){this.place=0}function u(e,t){var r=e[t.place++];if(!(128&r))return r;var n=15&r;if(0===n||n>4)return!1;for(var i=0,o=0,a=t.place;o<n;o++,a++)i<<=8,i|=e[a],i>>>=0;return!(i<=127)&&(t.place=a,i)}function c(e){for(var t=0,r=e.length-1;!e[t]&&!(128&e[t+1])&&t<r;)t++;return 0===t?e:e.slice(t)}function f(e,t){if(t<128)e.push(t);else{var r=1+(Math.log(t)/Math.LN2>>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}e.exports=a,a.prototype._importDER=function(e,t){e=i.toArray(e,t);var r=new s;if(48!==e[r.place++])return!1;var o=u(e,r);if(!1===o)return!1;if(o+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var a=u(e,r);if(!1===a)return!1;var c=e.slice(r.place,a+r.place);if(r.place+=a,2!==e[r.place++])return!1;var f=u(e,r);if(!1===f)return!1;if(e.length!==f+r.place)return!1;var l=e.slice(r.place,f+r.place);if(0===c[0]){if(!(128&c[1]))return!1;c=c.slice(1)}if(0===l[0]){if(!(128&l[1]))return!1;l=l.slice(1)}return this.r=new n(c),this.s=new n(l),this.recoveryParam=null,!0},a.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=c(t),r=c(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];f(n,t.length),(n=n.concat(t)).push(2),f(n,r.length);var o=n.concat(r),a=[48];return f(a,o.length),a=a.concat(o),i.encode(a,e)}},function(e,t,r){"use strict";var n=r(78),i=r(77),o=r(11),a=o.assert,s=o.parseBytes,u=r(268),c=r(269);function f(e){if(a("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof f))return new f(e);e=i[e].curve,this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=n.sha512}e.exports=f,f.prototype.sign=function(e,t){e=s(e);var r=this.keyFromSecret(t),n=this.hashInt(r.messagePrefix(),e),i=this.g.mul(n),o=this.encodePoint(i),a=this.hashInt(o,r.pubBytes(),e).mul(r.priv()),u=n.add(a).umod(this.curve.n);return this.makeSignature({R:i,S:u,Rencoded:o})},f.prototype.verify=function(e,t,r){e=s(e),t=this.makeSignature(t);var n=this.keyFromPublic(r),i=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S());return t.R().add(n.pub().mul(i)).eq(o)},f.prototype.hashInt=function(){for(var e=this.hash(),t=0;t<arguments.length;t++)e.update(arguments[t]);return o.intFromLE(e.digest()).umod(this.curve.n)},f.prototype.keyFromPublic=function(e){return u.fromPublic(this,e)},f.prototype.keyFromSecret=function(e){return u.fromSecret(this,e)},f.prototype.makeSignature=function(e){return e instanceof c?e:new c(this,e)},f.prototype.encodePoint=function(e){var t=e.getY().toArray("le",this.encodingLength);return t[this.encodingLength-1]|=e.getX().isOdd()?128:0,t},f.prototype.decodePoint=function(e){var t=(e=o.parseBytes(e)).length-1,r=e.slice(0,t).concat(-129&e[t]),n=0!=(128&e[t]),i=o.intFromLE(r);return this.curve.pointFromY(i,n)},f.prototype.encodeInt=function(e){return e.toArray("le",this.encodingLength)},f.prototype.decodeInt=function(e){return o.intFromLE(e)},f.prototype.isPoint=function(e){return e instanceof this.pointClass}},function(e,t,r){"use strict";var n=r(11),i=n.assert,o=n.parseBytes,a=n.cachedProperty;function s(e,t){this.eddsa=e,this._secret=o(t.secret),e.isPoint(t.pub)?this._pub=t.pub:this._pubBytes=o(t.pub)}s.fromPublic=function(e,t){return t instanceof s?t:new s(e,{pub:t})},s.fromSecret=function(e,t){return t instanceof s?t:new s(e,{secret:t})},s.prototype.secret=function(){return this._secret},a(s,"pubBytes",(function(){return this.eddsa.encodePoint(this.pub())})),a(s,"pub",(function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())})),a(s,"privBytes",(function(){var e=this.eddsa,t=this.hash(),r=e.encodingLength-1,n=t.slice(0,e.encodingLength);return n[0]&=248,n[r]&=127,n[r]|=64,n})),a(s,"priv",(function(){return this.eddsa.decodeInt(this.privBytes())})),a(s,"hash",(function(){return this.eddsa.hash().update(this.secret()).digest()})),a(s,"messagePrefix",(function(){return this.hash().slice(this.eddsa.encodingLength)})),s.prototype.sign=function(e){return i(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)},s.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)},s.prototype.getSecret=function(e){return i(this._secret,"KeyPair is public only"),n.encode(this.secret(),e)},s.prototype.getPublic=function(e){return n.encode(this.pubBytes(),e)},e.exports=s},function(e,t,r){"use strict";var n=r(14),i=r(11),o=i.assert,a=i.cachedProperty,s=i.parseBytes;function u(e,t){this.eddsa=e,"object"!=typeof t&&(t=s(t)),Array.isArray(t)&&(t={R:t.slice(0,e.encodingLength),S:t.slice(e.encodingLength)}),o(t.R&&t.S,"Signature without R or S"),e.isPoint(t.R)&&(this._R=t.R),t.S instanceof n&&(this._S=t.S),this._Rencoded=Array.isArray(t.R)?t.R:t.Rencoded,this._Sencoded=Array.isArray(t.S)?t.S:t.Sencoded}a(u,"S",(function(){return this.eddsa.decodeInt(this.Sencoded())})),a(u,"R",(function(){return this.eddsa.decodePoint(this.Rencoded())})),a(u,"Rencoded",(function(){return this.eddsa.encodePoint(this.R())})),a(u,"Sencoded",(function(){return this.eddsa.encodeInt(this.S())})),u.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},u.prototype.toHex=function(){return i.encode(this.toBytes(),"hex").toUpperCase()},e.exports=u},function(e,t,r){(function(t){const n=r(76),i=t.alloc(1,1),o=t.alloc(1,0);e.exports=function(e,r,a,s,u){let c=t.alloc(32,0),f=t.alloc(32,1);c=n("sha256",c).update(f).update(o).update(r).update(e).update(u||"").digest(),f=n("sha256",c).update(f).digest(),c=n("sha256",c).update(f).update(i).update(r).update(e).update(u||"").digest(),f=n("sha256",c).update(f).digest(),f=n("sha256",c).update(f).digest();let l=f;for(;!s(l)||!a(l);)c=n("sha256",c).update(f).update(o).digest(),f=n("sha256",c).update(f).digest(),f=n("sha256",c).update(f).digest(),l=f;return l}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(12),i=r(1),o=r(26),a=r(3),s=i.OPS;t.p2data=function(e,t){if(!e.data&&!e.output)throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),a({network:a.maybe(a.Object),output:a.maybe(a.Buffer),data:a.maybe(a.arrayOf(a.Buffer))},e);const r={name:"embed",network:e.network||n.bitcoin};if(o.prop(r,"output",()=>{if(e.data)return i.compile([s.OP_RETURN].concat(e.data))}),o.prop(r,"data",()=>{if(e.output)return i.decompile(e.output).slice(1)}),t.validate&&e.output){const t=i.decompile(e.output);if(t[0]!==s.OP_RETURN)throw new TypeError("Output is invalid");if(!t.slice(1).every(a.Buffer))throw new TypeError("Output is invalid");if(e.data&&!function(e,t){return e.length===t.length&&e.every((e,r)=>e.equals(t[r]))}(e.data,r.data))throw new TypeError("Data mismatch")}return Object.assign(r,e)}},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.decode=function(e,t,r){t=t||4,r=void 0===r||r;const n=e.length;if(0===n)return 0;if(n>t)throw new TypeError("Script number overflow");if(r&&0==(127&e[n-1])&&(n<=1||0==(128&e[n-2])))throw new Error("Non-minimally encoded script number");if(5===n){const t=e.readUInt32LE(0),r=e.readUInt8(4);return 128&r?-(4294967296*(-129&r)+t):4294967296*r+t}let i=0;for(let t=0;t<n;++t)i|=e[t]<<8*t;return 128&e[n-1]?-(i&~(128<<8*(n-1))):i},t.encode=function(t){let r=Math.abs(t);const n=(i=r)>2147483647?5:i>8388607?4:i>32767?3:i>127?2:i>0?1:0;var i;const o=e.allocUnsafe(n),a=t<0;for(let e=0;e<n;++e)o.writeUInt8(255&r,e),r>>=8;return 128&o[n-1]?o.writeUInt8(a?128:0,n-1):a&&(o[n-1]|=128),o}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(16),i=r(125),o=r(3),a=e.alloc(1,0);function s(t){let r=0;for(;0===t[r];)++r;return r===t.length?a:128&(t=t.slice(r))[0]?e.concat([a,t],1+t.length):t}function u(t){0===t[0]&&(t=t.slice(1));const r=e.alloc(32,0),n=Math.max(0,32-t.length);return t.copy(r,n),r}t.decode=function(t){const r=t.readUInt8(t.length-1),n=-129&r;if(n<=0||n>=4)throw new Error("Invalid hashType "+r);const o=i.decode(t.slice(0,-1)),a=u(o.r),s=u(o.s);return{signature:e.concat([a,s],64),hashType:r}},t.encode=function(t,r){o({signature:n.BufferN(64),hashType:n.UInt8},{signature:t,hashType:r});const a=-129&r;if(a<=0||a>=4)throw new Error("Invalid hashType "+r);const u=e.allocUnsafe(1);u.writeUInt8(r,0);const c=s(t.slice(0,32)),f=s(t.slice(32,64));return e.concat([i.encode(c,f),u])}}).call(this,r(0).Buffer)},function(e,t,r){(function(t){const n=r(76),i=t.alloc(1,1),o=t.alloc(1,0);e.exports=function(e,r,a,s,u){let c=t.alloc(32,0),f=t.alloc(32,1);c=n("sha256",c).update(f).update(o).update(r).update(e).update(u||"").digest(),f=n("sha256",c).update(f).digest(),c=n("sha256",c).update(f).update(i).update(r).update(e).update(u||"").digest(),f=n("sha256",c).update(f).digest(),f=n("sha256",c).update(f).digest();let l=f;for(;!s(l)||!a(l);)c=n("sha256",c).update(f).update(o).digest(),f=n("sha256",c).update(f).digest(),f=n("sha256",c).update(f).digest(),l=f;return l}}).call(this,r(0).Buffer)},function(e,t,r){var n=r(80);function i(e){return e<n.OP_PUSHDATA1?1:e<=255?2:e<=65535?3:5}e.exports={encodingLength:i,encode:function(e,t,r){var o=i(t);return 1===o?e.writeUInt8(t,r):2===o?(e.writeUInt8(n.OP_PUSHDATA1,r),e.writeUInt8(t,r+1)):3===o?(e.writeUInt8(n.OP_PUSHDATA2,r),e.writeUInt16LE(t,r+1)):(e.writeUInt8(n.OP_PUSHDATA4,r),e.writeUInt32LE(t,r+1)),o},decode:function(e,t){var r,i,o=e.readUInt8(t);if(o<n.OP_PUSHDATA1)r=o,i=1;else if(o===n.OP_PUSHDATA1){if(t+2>e.length)return null;r=e.readUInt8(t+1),i=2}else if(o===n.OP_PUSHDATA2){if(t+3>e.length)return null;r=e.readUInt16LE(t+1),i=3}else{if(t+5>e.length)return null;if(o!==n.OP_PUSHDATA4)throw new Error("Unexpected opcode");r=e.readUInt32LE(t+1),i=5}return{opcode:o,number:r,size:i}}}},function(e,t,r){var n=r(80),i={};for(var o in n){i[n[o]]=o}e.exports=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(12),i=r(1),o=r(26),a=i.OPS,s=r(3),u=r(25),c=a.OP_RESERVED;function f(e,t){return e.length===t.length&&e.every((e,r)=>e.equals(t[r]))}t.p2ms=function(e,t){if(!(e.input||e.output||e.pubkeys&&void 0!==e.m||e.signatures))throw new TypeError("Not enough data");function r(e){return i.isCanonicalScriptSignature(e)||void 0!==(t.allowIncomplete&&e===a.OP_0)}t=Object.assign({validate:!0},t||{}),s({network:s.maybe(s.Object),m:s.maybe(s.Number),n:s.maybe(s.Number),output:s.maybe(s.Buffer),pubkeys:s.maybe(s.arrayOf(u.isPoint)),signatures:s.maybe(s.arrayOf(r)),input:s.maybe(s.Buffer)},e);const l={network:e.network||n.bitcoin};let d=[],h=!1;function p(e){h||(h=!0,d=i.decompile(e),l.m=d[0]-c,l.n=d[d.length-2]-c,l.pubkeys=d.slice(1,-2))}if(o.prop(l,"output",()=>{if(e.m&&l.n&&e.pubkeys)return i.compile([].concat(c+e.m,e.pubkeys,c+l.n,a.OP_CHECKMULTISIG))}),o.prop(l,"m",()=>{if(l.output)return p(l.output),l.m}),o.prop(l,"n",()=>{if(l.pubkeys)return l.pubkeys.length}),o.prop(l,"pubkeys",()=>{if(e.output)return p(e.output),l.pubkeys}),o.prop(l,"signatures",()=>{if(e.input)return i.decompile(e.input).slice(1)}),o.prop(l,"input",()=>{if(e.signatures)return i.compile([a.OP_0].concat(e.signatures))}),o.prop(l,"witness",()=>{if(l.input)return[]}),o.prop(l,"name",()=>{if(l.m&&l.n)return`p2ms(${l.m} of ${l.n})`}),t.validate){if(e.output){if(p(e.output),!s.Number(d[0]))throw new TypeError("Output is invalid");if(!s.Number(d[d.length-2]))throw new TypeError("Output is invalid");if(d[d.length-1]!==a.OP_CHECKMULTISIG)throw new TypeError("Output is invalid");if(l.m<=0||l.n>16||l.m>l.n||l.n!==d.length-3)throw new TypeError("Output is invalid");if(!l.pubkeys.every(e=>u.isPoint(e)))throw new TypeError("Output is invalid");if(void 0!==e.m&&e.m!==l.m)throw new TypeError("m mismatch");if(void 0!==e.n&&e.n!==l.n)throw new TypeError("n mismatch");if(e.pubkeys&&!f(e.pubkeys,l.pubkeys))throw new TypeError("Pubkeys mismatch")}if(e.pubkeys){if(void 0!==e.n&&e.n!==e.pubkeys.length)throw new TypeError("Pubkey count mismatch");if(l.n=e.pubkeys.length,l.n<l.m)throw new TypeError("Pubkey count cannot be less than m")}if(e.signatures){if(e.signatures.length<l.m)throw new TypeError("Not enough signatures provided");if(e.signatures.length>l.m)throw new TypeError("Too many signatures provided")}if(e.input){if(e.input[0]!==a.OP_0)throw new TypeError("Input is invalid");if(0===l.signatures.length||!l.signatures.every(r))throw new TypeError("Input has invalid signature(s)");if(e.signatures&&!f(e.signatures,l.signatures))throw new TypeError("Signature mismatch");if(void 0!==e.m&&e.m!==e.signatures.length)throw new TypeError("Signature count mismatch")}}return Object.assign(l,e)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(12),i=r(1),o=r(26),a=r(3),s=i.OPS,u=r(25);t.p2pk=function(e,t){if(!(e.input||e.output||e.pubkey||e.input||e.signature))throw new TypeError("Not enough data");t=Object.assign({validate:!0},t||{}),a({network:a.maybe(a.Object),output:a.maybe(a.Buffer),pubkey:a.maybe(u.isPoint),signature:a.maybe(i.isCanonicalScriptSignature),input:a.maybe(a.Buffer)},e);const r=o.value(()=>i.decompile(e.input)),c={name:"p2pk",network:e.network||n.bitcoin};if(o.prop(c,"output",()=>{if(e.pubkey)return i.compile([e.pubkey,s.OP_CHECKSIG])}),o.prop(c,"pubkey",()=>{if(e.output)return e.output.slice(1,-1)}),o.prop(c,"signature",()=>{if(e.input)return r()[0]}),o.prop(c,"input",()=>{if(e.signature)return i.compile([e.signature])}),o.prop(c,"witness",()=>{if(c.input)return[]}),t.validate){if(e.output){if(e.output[e.output.length-1]!==s.OP_CHECKSIG)throw new TypeError("Output is invalid");if(!u.isPoint(c.pubkey))throw new TypeError("Output pubkey is invalid");if(e.pubkey&&!e.pubkey.equals(c.pubkey))throw new TypeError("Pubkey mismatch")}if(e.signature&&e.input&&!e.input.equals(c.input))throw new TypeError("Signature mismatch");if(e.input){if(1!==r().length)throw new TypeError("Input is invalid");if(!i.isCanonicalScriptSignature(c.signature))throw new TypeError("Input has invalid signature")}}return Object.assign(c,e)}},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(19),i=r(12),o=r(1),a=r(26),s=r(3),u=o.OPS,c=r(25),f=r(39);t.p2pkh=function(t,r){if(!(t.address||t.hash||t.output||t.pubkey||t.input))throw new TypeError("Not enough data");r=Object.assign({validate:!0},r||{}),s({network:s.maybe(s.Object),address:s.maybe(s.String),hash:s.maybe(s.BufferN(20)),output:s.maybe(s.BufferN(25)),pubkey:s.maybe(c.isPoint),signature:s.maybe(o.isCanonicalScriptSignature),input:s.maybe(s.Buffer)},t);const l=a.value(()=>{const e=f.decode(t.address);return{version:e.readUInt8(0),hash:e.slice(1)}}),d=a.value(()=>o.decompile(t.input)),h=t.network||i.bitcoin,p={name:"p2pkh",network:h};if(a.prop(p,"address",()=>{if(!p.hash)return;const t=e.allocUnsafe(21);return t.writeUInt8(h.pubKeyHash,0),p.hash.copy(t,1),f.encode(t)}),a.prop(p,"hash",()=>t.output?t.output.slice(3,23):t.address?l().hash:t.pubkey||p.pubkey?n.hash160(t.pubkey||p.pubkey):void 0),a.prop(p,"output",()=>{if(p.hash)return o.compile([u.OP_DUP,u.OP_HASH160,p.hash,u.OP_EQUALVERIFY,u.OP_CHECKSIG])}),a.prop(p,"pubkey",()=>{if(t.input)return d()[1]}),a.prop(p,"signature",()=>{if(t.input)return d()[0]}),a.prop(p,"input",()=>{if(t.pubkey&&t.signature)return o.compile([t.signature,t.pubkey])}),a.prop(p,"witness",()=>{if(p.input)return[]}),r.validate){let r=e.from([]);if(t.address){if(l().version!==h.pubKeyHash)throw new TypeError("Invalid version or Network mismatch");if(20!==l().hash.length)throw new TypeError("Invalid address");r=l().hash}if(t.hash){if(r.length>0&&!r.equals(t.hash))throw new TypeError("Hash mismatch");r=t.hash}if(t.output){if(25!==t.output.length||t.output[0]!==u.OP_DUP||t.output[1]!==u.OP_HASH160||20!==t.output[2]||t.output[23]!==u.OP_EQUALVERIFY||t.output[24]!==u.OP_CHECKSIG)throw new TypeError("Output is invalid");const e=t.output.slice(3,23);if(r.length>0&&!r.equals(e))throw new TypeError("Hash mismatch");r=e}if(t.pubkey){const e=n.hash160(t.pubkey);if(r.length>0&&!r.equals(e))throw new TypeError("Hash mismatch");r=e}if(t.input){const e=d();if(2!==e.length)throw new TypeError("Input is invalid");if(!o.isCanonicalScriptSignature(e[0]))throw new TypeError("Input has invalid signature");if(!c.isPoint(e[1]))throw new TypeError("Input has invalid pubkey");if(t.signature&&!t.signature.equals(e[0]))throw new TypeError("Signature mismatch");if(t.pubkey&&!t.pubkey.equals(e[1]))throw new TypeError("Pubkey mismatch");const i=n.hash160(e[1]);if(r.length>0&&!r.equals(i))throw new TypeError("Hash mismatch")}}return Object.assign(p,t)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(19),i=r(12),o=r(1),a=r(26),s=r(3),u=o.OPS,c=r(39);t.p2sh=function(t,r){if(!(t.address||t.hash||t.output||t.redeem||t.input))throw new TypeError("Not enough data");r=Object.assign({validate:!0},r||{}),s({network:s.maybe(s.Object),address:s.maybe(s.String),hash:s.maybe(s.BufferN(20)),output:s.maybe(s.BufferN(23)),redeem:s.maybe({network:s.maybe(s.Object),output:s.maybe(s.Buffer),input:s.maybe(s.Buffer),witness:s.maybe(s.arrayOf(s.Buffer))}),input:s.maybe(s.Buffer),witness:s.maybe(s.arrayOf(s.Buffer))},t);let f=t.network;f||(f=t.redeem&&t.redeem.network||i.bitcoin);const l={network:f},d=a.value(()=>{const e=c.decode(t.address);return{version:e.readUInt8(0),hash:e.slice(1)}}),h=a.value(()=>o.decompile(t.input)),p=a.value(()=>{const e=h();return{network:f,output:e[e.length-1],input:o.compile(e.slice(0,-1)),witness:t.witness||[]}});if(a.prop(l,"address",()=>{if(!l.hash)return;const t=e.allocUnsafe(21);return t.writeUInt8(l.network.scriptHash,0),l.hash.copy(t,1),c.encode(t)}),a.prop(l,"hash",()=>t.output?t.output.slice(2,22):t.address?d().hash:l.redeem&&l.redeem.output?n.hash160(l.redeem.output):void 0),a.prop(l,"output",()=>{if(l.hash)return o.compile([u.OP_HASH160,l.hash,u.OP_EQUAL])}),a.prop(l,"redeem",()=>{if(t.input)return p()}),a.prop(l,"input",()=>{if(t.redeem&&t.redeem.input&&t.redeem.output)return o.compile([].concat(o.decompile(t.redeem.input),t.redeem.output))}),a.prop(l,"witness",()=>l.redeem&&l.redeem.witness?l.redeem.witness:l.input?[]:void 0),a.prop(l,"name",()=>{const e=["p2sh"];return void 0!==l.redeem&&e.push(l.redeem.name),e.join("-")}),r.validate){let r=e.from([]);if(t.address){if(d().version!==f.scriptHash)throw new TypeError("Invalid version or Network mismatch");if(20!==d().hash.length)throw new TypeError("Invalid address");r=d().hash}if(t.hash){if(r.length>0&&!r.equals(t.hash))throw new TypeError("Hash mismatch");r=t.hash}if(t.output){if(23!==t.output.length||t.output[0]!==u.OP_HASH160||20!==t.output[1]||t.output[22]!==u.OP_EQUAL)throw new TypeError("Output is invalid");const e=t.output.slice(2,22);if(r.length>0&&!r.equals(e))throw new TypeError("Hash mismatch");r=e}const i=e=>{if(e.output){const t=o.decompile(e.output);if(!t||t.length<1)throw new TypeError("Redeem.output too short");const i=n.hash160(e.output);if(r.length>0&&!r.equals(i))throw new TypeError("Hash mismatch");r=i}if(e.input){const t=e.input.length>0,r=e.witness&&e.witness.length>0;if(!t&&!r)throw new TypeError("Empty input");if(t&&r)throw new TypeError("Input and witness provided");if(t){const t=o.decompile(e.input);if(!o.isPushOnly(t))throw new TypeError("Non push-only scriptSig")}}};if(t.input){const t=h();if(!t||t.length<1)throw new TypeError("Input too short");if(!e.isBuffer(p().output))throw new TypeError("Input is invalid");i(p())}if(t.redeem){if(t.redeem.network&&t.redeem.network!==f)throw new TypeError("Network mismatch");if(t.input){const e=p();if(t.redeem.output&&!t.redeem.output.equals(e.output))throw new TypeError("Redeem.output mismatch");if(t.redeem.input&&!t.redeem.input.equals(e.input))throw new TypeError("Redeem.input mismatch")}i(t.redeem)}if(t.witness&&t.redeem&&t.redeem.witness&&!function(e,t){return e.length===t.length&&e.every((e,r)=>e.equals(t[r]))}(t.redeem.witness,t.witness))throw new TypeError("Witness and redeem.witness mismatch")}return Object.assign(l,t)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(19),i=r(12),o=r(1),a=r(26),s=r(3),u=o.OPS,c=r(25),f=r(81),l=e.alloc(0);t.p2wpkh=function(t,r){if(!(t.address||t.hash||t.output||t.pubkey||t.witness))throw new TypeError("Not enough data");r=Object.assign({validate:!0},r||{}),s({address:s.maybe(s.String),hash:s.maybe(s.BufferN(20)),input:s.maybe(s.BufferN(0)),network:s.maybe(s.Object),output:s.maybe(s.BufferN(22)),pubkey:s.maybe(c.isPoint),signature:s.maybe(o.isCanonicalScriptSignature),witness:s.maybe(s.arrayOf(s.Buffer))},t);const d=a.value(()=>{const r=f.decode(t.address),n=r.words.shift(),i=f.fromWords(r.words);return{version:n,prefix:r.prefix,data:e.from(i)}}),h=t.network||i.bitcoin,p={name:"p2wpkh",network:h};if(a.prop(p,"address",()=>{if(!p.hash)return;const e=f.toWords(p.hash);return e.unshift(0),f.encode(h.bech32,e)}),a.prop(p,"hash",()=>t.output?t.output.slice(2,22):t.address?d().data:t.pubkey||p.pubkey?n.hash160(t.pubkey||p.pubkey):void 0),a.prop(p,"output",()=>{if(p.hash)return o.compile([u.OP_0,p.hash])}),a.prop(p,"pubkey",()=>t.pubkey?t.pubkey:t.witness?t.witness[1]:void 0),a.prop(p,"signature",()=>{if(t.witness)return t.witness[0]}),a.prop(p,"input",()=>{if(p.witness)return l}),a.prop(p,"witness",()=>{if(t.pubkey&&t.signature)return[t.signature,t.pubkey]}),r.validate){let r=e.from([]);if(t.address){if(h&&h.bech32!==d().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(0!==d().version)throw new TypeError("Invalid address version");if(20!==d().data.length)throw new TypeError("Invalid address data");r=d().data}if(t.hash){if(r.length>0&&!r.equals(t.hash))throw new TypeError("Hash mismatch");r=t.hash}if(t.output){if(22!==t.output.length||t.output[0]!==u.OP_0||20!==t.output[1])throw new TypeError("Output is invalid");if(r.length>0&&!r.equals(t.output.slice(2)))throw new TypeError("Hash mismatch");r=t.output.slice(2)}if(t.pubkey){const e=n.hash160(t.pubkey);if(r.length>0&&!r.equals(e))throw new TypeError("Hash mismatch");if(r=e,!c.isPoint(t.pubkey)||33!==t.pubkey.length)throw new TypeError("Invalid pubkey for p2wpkh")}if(t.witness){if(2!==t.witness.length)throw new TypeError("Witness is invalid");if(!o.isCanonicalScriptSignature(t.witness[0]))throw new TypeError("Witness has invalid signature");if(!c.isPoint(t.witness[1])||33!==t.witness[1].length)throw new TypeError("Witness has invalid pubkey");if(t.signature&&!t.signature.equals(t.witness[0]))throw new TypeError("Signature mismatch");if(t.pubkey&&!t.pubkey.equals(t.witness[1]))throw new TypeError("Pubkey mismatch");const e=n.hash160(t.witness[1]);if(r.length>0&&!r.equals(e))throw new TypeError("Hash mismatch")}}return Object.assign(p,t)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(19),i=r(12),o=r(1),a=r(26),s=r(3),u=o.OPS,c=r(25),f=r(81),l=e.alloc(0);function d(t){return!(!e.isBuffer(t)||65!==t.length||4!==t[0]||!c.isPoint(t))}t.p2wsh=function(t,r){if(!(t.address||t.hash||t.output||t.redeem||t.witness))throw new TypeError("Not enough data");r=Object.assign({validate:!0},r||{}),s({network:s.maybe(s.Object),address:s.maybe(s.String),hash:s.maybe(s.BufferN(32)),output:s.maybe(s.BufferN(34)),redeem:s.maybe({input:s.maybe(s.Buffer),network:s.maybe(s.Object),output:s.maybe(s.Buffer),witness:s.maybe(s.arrayOf(s.Buffer))}),input:s.maybe(s.BufferN(0)),witness:s.maybe(s.arrayOf(s.Buffer))},t);const c=a.value(()=>{const r=f.decode(t.address),n=r.words.shift(),i=f.fromWords(r.words);return{version:n,prefix:r.prefix,data:e.from(i)}}),h=a.value(()=>o.decompile(t.redeem.input));let p=t.network;p||(p=t.redeem&&t.redeem.network||i.bitcoin);const b={network:p};if(a.prop(b,"address",()=>{if(!b.hash)return;const e=f.toWords(b.hash);return e.unshift(0),f.encode(p.bech32,e)}),a.prop(b,"hash",()=>t.output?t.output.slice(2):t.address?c().data:b.redeem&&b.redeem.output?n.sha256(b.redeem.output):void 0),a.prop(b,"output",()=>{if(b.hash)return o.compile([u.OP_0,b.hash])}),a.prop(b,"redeem",()=>{if(t.witness)return{output:t.witness[t.witness.length-1],input:l,witness:t.witness.slice(0,-1)}}),a.prop(b,"input",()=>{if(b.witness)return l}),a.prop(b,"witness",()=>{if(t.redeem&&t.redeem.input&&t.redeem.input.length>0&&t.redeem.output&&t.redeem.output.length>0){const e=o.toStack(h());return b.redeem=Object.assign({witness:e},t.redeem),b.redeem.input=l,[].concat(e,t.redeem.output)}if(t.redeem&&t.redeem.output&&t.redeem.witness)return[].concat(t.redeem.witness,t.redeem.output)}),a.prop(b,"name",()=>{const e=["p2wsh"];return void 0!==b.redeem&&e.push(b.redeem.name),e.join("-")}),r.validate){let r=e.from([]);if(t.address){if(c().prefix!==p.bech32)throw new TypeError("Invalid prefix or Network mismatch");if(0!==c().version)throw new TypeError("Invalid address version");if(32!==c().data.length)throw new TypeError("Invalid address data");r=c().data}if(t.hash){if(r.length>0&&!r.equals(t.hash))throw new TypeError("Hash mismatch");r=t.hash}if(t.output){if(34!==t.output.length||t.output[0]!==u.OP_0||32!==t.output[1])throw new TypeError("Output is invalid");const e=t.output.slice(2);if(r.length>0&&!r.equals(e))throw new TypeError("Hash mismatch");r=e}if(t.redeem){if(t.redeem.network&&t.redeem.network!==p)throw new TypeError("Network mismatch");if(t.redeem.input&&t.redeem.input.length>0&&t.redeem.witness&&t.redeem.witness.length>0)throw new TypeError("Ambiguous witness source");if(t.redeem.output){if(0===o.decompile(t.redeem.output).length)throw new TypeError("Redeem.output is invalid");const e=n.sha256(t.redeem.output);if(r.length>0&&!r.equals(e))throw new TypeError("Hash mismatch");r=e}if(t.redeem.input&&!o.isPushOnly(h()))throw new TypeError("Non push-only scriptSig");if(t.witness&&t.redeem.witness&&!function(e,t){return e.length===t.length&&e.every((e,r)=>e.equals(t[r]))}(t.witness,t.redeem.witness))throw new TypeError("Witness and redeem.witness mismatch");if(t.redeem.input&&h().some(d)||t.redeem.output&&(o.decompile(t.redeem.output)||[]).some(d))throw new TypeError("redeem.input or redeem.output contains uncompressed pubkey")}if(t.witness&&t.witness.length>0){const e=t.witness[t.witness.length-1];if(t.redeem&&t.redeem.output&&!t.redeem.output.equals(e))throw new TypeError("Witness and redeem.output mismatch");if(t.witness.some(d)||(o.decompile(e)||[]).some(d))throw new TypeError("Witness contains uncompressed pubkey")}}return Object.assign(b,t)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t,n){var i=r(4).Buffer,o=t.crypto||t.msCrypto;o&&o.getRandomValues?e.exports=function(e,t){if(e>4294967295)throw new RangeError("requested too many random bytes");var r=i.allocUnsafe(e);if(e>0)if(e>65536)for(var a=0;a<e;a+=65536)o.getRandomValues(r.slice(a,a+65536));else o.getRandomValues(r);if("function"==typeof t)return n.nextTick((function(){t(null,r)}));return r}:e.exports=function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}}).call(this,r(17),r(10))},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(51),i=r(19),o=r(52),a=r(16),s=r(126),u=r(3),c=r(37),f=new TypeError("Cannot compute merkle root for zero transactions"),l=new TypeError("Cannot compute witness commit for non-segwit block");class d{constructor(){this.version=1,this.prevHash=void 0,this.merkleRoot=void 0,this.timestamp=0,this.witnessCommit=void 0,this.bits=0,this.nonce=0,this.transactions=void 0}static fromBuffer(e){if(e.length<80)throw new Error("Buffer too small (< 80 bytes)");const t=new n.BufferReader(e),r=new d;if(r.version=t.readInt32(),r.prevHash=t.readSlice(32),r.merkleRoot=t.readSlice(32),r.timestamp=t.readUInt32(),r.bits=t.readUInt32(),r.nonce=t.readUInt32(),80===e.length)return r;const i=()=>{const e=o.Transaction.fromBuffer(t.buffer.slice(t.offset),!0);return t.offset+=e.byteLength(),e},a=t.readVarInt();r.transactions=[];for(let e=0;e<a;++e){const e=i();r.transactions.push(e)}const s=r.getWitnessCommit();return s&&(r.witnessCommit=s),r}static fromHex(t){return d.fromBuffer(e.from(t,"hex"))}static calculateTarget(t){const r=((4278190080&t)>>24)-3,n=8388607&t,i=e.alloc(32,0);return i.writeUIntBE(n,29-r,3),i}static calculateMerkleRoot(t,r){if(u([{getHash:a.Function}],t),0===t.length)throw f;if(r&&!h(t))throw l;const n=t.map(e=>e.getHash(r)),o=s(n,i.hash256);return r?i.hash256(e.concat([o,t[0].ins[0].witness[0]])):o}getWitnessCommit(){if(!h(this.transactions))return null;const t=this.transactions[0].outs.filter(t=>t.script.slice(0,6).equals(e.from("6a24aa21a9ed","hex"))).map(e=>e.script.slice(6,38));if(0===t.length)return null;const r=t[t.length-1];return r instanceof e&&32===r.length?r:null}hasWitnessCommit(){return this.witnessCommit instanceof e&&32===this.witnessCommit.length||null!==this.getWitnessCommit()}hasWitness(){return(e=this.transactions)instanceof Array&&e.some(e=>"object"==typeof e&&e.ins instanceof Array&&e.ins.some(e=>"object"==typeof e&&e.witness instanceof Array&&e.witness.length>0));var e}weight(){return 3*this.byteLength(!1,!1)+this.byteLength(!1,!0)}byteLength(e,t=!0){return e||!this.transactions?80:80+c.encodingLength(this.transactions.length)+this.transactions.reduce((e,r)=>e+r.byteLength(t),0)}getHash(){return i.hash256(this.toBuffer(!0))}getId(){return n.reverseBuffer(this.getHash()).toString("hex")}getUTCDate(){const e=new Date(0);return e.setUTCSeconds(this.timestamp),e}toBuffer(t){const r=e.allocUnsafe(this.byteLength(t)),i=new n.BufferWriter(r);return i.writeInt32(this.version),i.writeSlice(this.prevHash),i.writeSlice(this.merkleRoot),i.writeUInt32(this.timestamp),i.writeUInt32(this.bits),i.writeUInt32(this.nonce),t||!this.transactions||(c.encode(this.transactions.length,r,i.offset),i.offset+=c.encode.bytes,this.transactions.forEach(e=>{const t=e.byteLength();e.toBuffer(r,i.offset),i.offset+=t})),r}toHex(e){return this.toBuffer(e).toString("hex")}checkTxRoots(){const e=this.hasWitnessCommit();return!(!e&&this.hasWitness())&&(this.__checkMerkleRoot()&&(!e||this.__checkWitnessCommit()))}checkProofOfWork(){const e=n.reverseBuffer(this.getHash()),t=d.calculateTarget(this.bits);return e.compare(t)<=0}__checkMerkleRoot(){if(!this.transactions)throw f;const e=d.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(e)}__checkWitnessCommit(){if(!this.transactions)throw f;if(!this.hasWitnessCommit())throw l;const e=d.calculateMerkleRoot(this.transactions,!0);return 0===this.witnessCommit.compare(e)}}function h(e){return e instanceof Array&&e[0]&&e[0].ins&&e[0].ins instanceof Array&&e[0].ins[0]&&e[0].ins[0].witness&&e[0].ins[0].witness instanceof Array&&e[0].ins[0].witness.length>0}t.Block=d}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(93),i=r(22),o=r(66),a=r(79),s=r(51),u=r(19),c=r(82),f=r(12),l=r(50),d=r(1),h=r(52),p={network:f.bitcoin,maximumFeeRate:5e3};class b{constructor(e={},t=new n.Psbt(new g)){this.data=t,this.opts=Object.assign({},p,e),this.__CACHE={__NON_WITNESS_UTXO_TX_CACHE:[],__NON_WITNESS_UTXO_BUF_CACHE:[],__TX_IN_CACHE:{},__TX:this.data.globalMap.unsignedTx.tx,__UNSAFE_SIGN_NONSEGWIT:!1},0===this.data.inputs.length&&this.setVersion(2);const r=(e,t,r,n)=>Object.defineProperty(e,t,{enumerable:r,writable:n});r(this,"__CACHE",!1,!0),r(this,"opts",!1,!0)}static fromBase64(t,r={}){const n=e.from(t,"base64");return this.fromBuffer(n,r)}static fromHex(t,r={}){const n=e.from(t,"hex");return this.fromBuffer(n,r)}static fromBuffer(e,t={}){const r=n.Psbt.fromBuffer(e,m),i=new b(t,r);var o,a;return o=i.__CACHE.__TX,a=i.__CACHE,o.ins.forEach(e=>{M(a,e)}),i}get inputCount(){return this.data.inputs.length}get version(){return this.__CACHE.__TX.version}set version(e){this.setVersion(e)}get locktime(){return this.__CACHE.__TX.locktime}set locktime(e){this.setLocktime(e)}get txInputs(){return this.__CACHE.__TX.ins.map(e=>({hash:s.cloneBuffer(e.hash),index:e.index,sequence:e.sequence}))}get txOutputs(){return this.__CACHE.__TX.outs.map(e=>{let t;try{t=a.fromOutputScript(e.script,this.opts.network)}catch(e){}return{script:s.cloneBuffer(e.script),value:e.value,address:t}})}combine(...e){return this.data.combine(...e.map(e=>e.data)),this}clone(){const e=b.fromBuffer(this.data.toBuffer());return e.opts=JSON.parse(JSON.stringify(this.opts)),e}setMaximumFeeRate(e){O(e),this.opts.maximumFeeRate=e}setVersion(e){O(e),I(this.data.inputs,"setVersion");const t=this.__CACHE;return t.__TX.version=e,t.__EXTRACTED_TX=void 0,this}setLocktime(e){O(e),I(this.data.inputs,"setLocktime");const t=this.__CACHE;return t.__TX.locktime=e,t.__EXTRACTED_TX=void 0,this}setInputSequence(e,t){O(t),I(this.data.inputs,"setInputSequence");const r=this.__CACHE;if(r.__TX.ins.length<=e)throw new Error("Input index too high");return r.__TX.ins[e].sequence=t,r.__EXTRACTED_TX=void 0,this}addInputs(e){return e.forEach(e=>this.addInput(e)),this}addInput(e){if(arguments.length>1||!e||void 0===e.hash||void 0===e.index)throw new Error("Invalid arguments for Psbt.addInput. Requires single object with at least [hash] and [index]");I(this.data.inputs,"addInput"),e.witnessScript&&Y(e.witnessScript);const t=this.__CACHE;this.data.addInput(e);M(t,t.__TX.ins[t.__TX.ins.length-1]);const r=this.data.inputs.length-1,n=this.data.inputs[r];return n.nonWitnessUtxo&&q(this.__CACHE,n,r),t.__FEE=void 0,t.__FEE_RATE=void 0,t.__EXTRACTED_TX=void 0,this}addOutputs(e){return e.forEach(e=>this.addOutput(e)),this}addOutput(e){if(arguments.length>1||!e||void 0===e.value||void 0===e.address&&void 0===e.script)throw new Error("Invalid arguments for Psbt.addOutput. Requires single object with at least [script or address] and [value]");I(this.data.inputs,"addOutput");const{address:t}=e;if("string"==typeof t){const{network:r}=this.opts,n=a.toOutputScript(t,r);e=Object.assign(e,{script:n})}const r=this.__CACHE;return this.data.addOutput(e),r.__FEE=void 0,r.__FEE_RATE=void 0,r.__EXTRACTED_TX=void 0,this}extractTransaction(e){if(!this.data.inputs.every(w))throw new Error("Not finalized");const t=this.__CACHE;if(e||function(e,t,r){const n=t.__FEE_RATE||e.getFeeRate(),i=t.__EXTRACTED_TX.virtualSize(),o=n*i;if(n>=r.maximumFeeRate)throw new Error(`Warning: You are paying around ${(o/1e8).toFixed(8)} in fees, which is ${n} satoshi per byte for a transaction with a VSize of ${i} bytes (segwit counted as 0.25 byte per byte). Use setMaximumFeeRate method to raise your threshold, or pass true to the first arg of extractTransaction.`)}(this,t,this.opts),t.__EXTRACTED_TX)return t.__EXTRACTED_TX;const r=t.__TX.clone();return K(this.data.inputs,r,t,!0),r}getFeeRate(){return U("__FEE_RATE","fee rate",this.data.inputs,this.__CACHE)}getFee(){return U("__FEE","fee",this.data.inputs,this.__CACHE)}finalizeAllInputs(){return o.checkForInput(this.data.inputs,0),Q(this.data.inputs.length).forEach(e=>this.finalizeInput(e)),this}finalizeInput(e,t=C){const r=o.checkForInput(this.data.inputs,e),{script:n,isP2SH:i,isP2WSH:a,isSegwit:s}=function(e,t,r){const n=r.__TX,i={script:null,isSegwit:!1,isP2SH:!1,isP2WSH:!1};if(i.isP2SH=!!t.redeemScript,i.isP2WSH=!!t.witnessScript,t.witnessScript)i.script=t.witnessScript;else if(t.redeemScript)i.script=t.redeemScript;else if(t.nonWitnessUtxo){const o=W(r,t,e),a=n.ins[e].index;i.script=o.outs[a].script}else t.witnessUtxo&&(i.script=t.witnessUtxo.script);(t.witnessScript||x(i.script))&&(i.isSegwit=!0);return i}(e,r,this.__CACHE);if(!n)throw new Error("No script found for input #"+e);!function(e){if(!e.sighashType||!e.partialSig)return;const{partialSig:t,sighashType:r}=e;t.forEach(e=>{const{hashType:t}=d.signature.decode(e.signature);if(r!==t)throw new Error("Signature sighash does not match input sighash type")})}(r);const{finalScriptSig:u,finalScriptWitness:c}=t(e,r,n,s,i,a);if(u&&this.data.updateInput(e,{finalScriptSig:u}),c&&this.data.updateInput(e,{finalScriptWitness:c}),!u&&!c)throw new Error("Unknown error finalizing input #"+e);return this.data.clearFinalizedInput(e),this}getInputType(t){const r=o.checkForInput(this.data.inputs,t),n=X(V(t,r,this.__CACHE),t,"input",r.redeemScript||function(t){if(!t)return;const r=d.decompile(t);if(!r)return;const n=r[r.length-1];if(!e.isBuffer(n)||G(n)||(i=n,d.isCanonicalScriptSignature(i)))return;var i;if(!d.decompile(n))return;return n}(r.finalScriptSig),r.witnessScript||function(e){if(!e)return;const t=D(e),r=t[t.length-1];if(G(r))return;if(!d.decompile(r))return;return r}(r.finalScriptWitness));return("raw"===n.type?"":n.type+"-")+J(n.meaningfulScript)}inputHasPubkey(e,t){return function(e,t,r,n){const i=V(r,t,n),{meaningfulScript:o}=X(i,r,"input",t.redeemScript,t.witnessScript);return $(e,o)}(t,o.checkForInput(this.data.inputs,e),e,this.__CACHE)}inputHasHDKey(e,t){const r=o.checkForInput(this.data.inputs,e),n=P(t);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}outputHasPubkey(e,t){return function(e,t,r,n){const i=n.__TX.outs[r].script,{meaningfulScript:o}=X(i,r,"output",t.redeemScript,t.witnessScript);return $(e,o)}(t,o.checkForOutput(this.data.outputs,e),e,this.__CACHE)}outputHasHDKey(e,t){const r=o.checkForOutput(this.data.outputs,e),n=P(t);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}validateSignaturesOfAllInputs(){o.checkForInput(this.data.inputs,0);return Q(this.data.inputs.length).map(e=>this.validateSignaturesOfInput(e)).reduce((e,t)=>!0===t&&e,!0)}validateSignaturesOfInput(e,t){const r=this.data.inputs[e],n=(r||{}).partialSig;if(!r||!n||n.length<1)throw new Error("No signatures to validate");const i=t?n.filter(e=>e.pubkey.equals(t)):n;if(i.length<1)throw new Error("No signatures for this pubkey");const o=[];let a,s,u;for(const t of i){const n=d.signature.decode(t.signature),{hash:i,script:f}=u!==n.hashType?z(e,Object.assign({},r,{sighashType:n.hashType}),this.__CACHE,!0):{hash:a,script:s};u=n.hashType,a=i,s=f,B(t.pubkey,f,"verify");const l=c.fromPublicKey(t.pubkey);o.push(l.verify(i,n.signature))}return o.every(e=>!0===e)}signAllInputsHD(e,t=[h.Transaction.SIGHASH_ALL]){if(!e||!e.publicKey||!e.fingerprint)throw new Error("Need HDSigner to sign input");const r=[];for(const n of Q(this.data.inputs.length))try{this.signInputHD(n,e,t),r.push(!0)}catch(e){r.push(!1)}if(r.every(e=>!1===e))throw new Error("No inputs were signed");return this}signAllInputsHDAsync(e,t=[h.Transaction.SIGHASH_ALL]){return new Promise((r,n)=>{if(!e||!e.publicKey||!e.fingerprint)return n(new Error("Need HDSigner to sign input"));const i=[],o=[];for(const r of Q(this.data.inputs.length))o.push(this.signInputHDAsync(r,e,t).then(()=>{i.push(!0)},()=>{i.push(!1)}));return Promise.all(o).then(()=>{if(i.every(e=>!1===e))return n(new Error("No inputs were signed"));r()})})}signInputHD(e,t,r=[h.Transaction.SIGHASH_ALL]){if(!t||!t.publicKey||!t.fingerprint)throw new Error("Need HDSigner to sign input");return L(e,this.data.inputs,t).forEach(t=>this.signInput(e,t,r)),this}signInputHDAsync(e,t,r=[h.Transaction.SIGHASH_ALL]){return new Promise((n,i)=>{if(!t||!t.publicKey||!t.fingerprint)return i(new Error("Need HDSigner to sign input"));const o=L(e,this.data.inputs,t).map(t=>this.signInputAsync(e,t,r));return Promise.all(o).then(()=>{n()}).catch(i)})}signAllInputs(e,t=[h.Transaction.SIGHASH_ALL]){if(!e||!e.publicKey)throw new Error("Need Signer to sign input");const r=[];for(const n of Q(this.data.inputs.length))try{this.signInput(n,e,t),r.push(!0)}catch(e){r.push(!1)}if(r.every(e=>!1===e))throw new Error("No inputs were signed");return this}signAllInputsAsync(e,t=[h.Transaction.SIGHASH_ALL]){return new Promise((r,n)=>{if(!e||!e.publicKey)return n(new Error("Need Signer to sign input"));const i=[],o=[];for(const[r]of this.data.inputs.entries())o.push(this.signInputAsync(r,e,t).then(()=>{i.push(!0)},()=>{i.push(!1)}));return Promise.all(o).then(()=>{if(i.every(e=>!1===e))return n(new Error("No inputs were signed"));r()})})}signInput(e,t,r=[h.Transaction.SIGHASH_ALL]){if(!t||!t.publicKey)throw new Error("Need Signer to sign input");const{hash:n,sighashType:i}=H(this.data.inputs,e,t.publicKey,this.__CACHE,r),o=[{pubkey:t.publicKey,signature:d.signature.encode(t.sign(n),i)}];return this.data.updateInput(e,{partialSig:o}),this}signInputAsync(e,t,r=[h.Transaction.SIGHASH_ALL]){return Promise.resolve().then(()=>{if(!t||!t.publicKey)throw new Error("Need Signer to sign input");const{hash:n,sighashType:i}=H(this.data.inputs,e,t.publicKey,this.__CACHE,r);return Promise.resolve(t.sign(n)).then(r=>{const n=[{pubkey:t.publicKey,signature:d.signature.encode(r,i)}];this.data.updateInput(e,{partialSig:n})})})}toBuffer(){return y(this.__CACHE),this.data.toBuffer()}toHex(){return y(this.__CACHE),this.data.toHex()}toBase64(){return y(this.__CACHE),this.data.toBase64()}updateGlobal(e){return this.data.updateGlobal(e),this}updateInput(e,t){return t.witnessScript&&Y(t.witnessScript),this.data.updateInput(e,t),t.nonWitnessUtxo&&q(this.__CACHE,this.data.inputs[e],e),this}updateOutput(e,t){return this.data.updateOutput(e,t),this}addUnknownKeyValToGlobal(e){return this.data.addUnknownKeyValToGlobal(e),this}addUnknownKeyValToInput(e,t){return this.data.addUnknownKeyValToInput(e,t),this}addUnknownKeyValToOutput(e,t){return this.data.addUnknownKeyValToOutput(e,t),this}clearFinalizedInput(e){return this.data.clearFinalizedInput(e),this}}t.Psbt=b;const m=e=>new g(e);class g{constructor(t=e.from([2,0,0,0,0,0,0,0,0,0])){this.tx=h.Transaction.fromBuffer(t),function(e){if(!e.ins.every(e=>e.script&&0===e.script.length&&e.witness&&0===e.witness.length))throw new Error("Format Error: Transaction ScriptSigs are not empty")}(this.tx),Object.defineProperty(this,"tx",{enumerable:!1,writable:!0})}getInputOutputCounts(){return{inputCount:this.tx.ins.length,outputCount:this.tx.outs.length}}addInput(t){if(void 0===t.hash||void 0===t.index||!e.isBuffer(t.hash)&&"string"!=typeof t.hash||"number"!=typeof t.index)throw new Error("Error adding input.");const r="string"==typeof t.hash?s.reverseBuffer(e.from(t.hash,"hex")):t.hash;this.tx.addInput(r,t.index,t.sequence)}addOutput(t){if(void 0===t.script||void 0===t.value||!e.isBuffer(t.script)||"number"!=typeof t.value)throw new Error("Error adding output.");this.tx.addOutput(t.script,t.value)}toBuffer(){return this.tx.toBuffer()}}function y(e){if(!1!==e.__UNSAFE_SIGN_NONSEGWIT)throw new Error("Not BIP174 compliant, can not export")}function v(e,t,r){if(!t)return!1;let n;if(n=r?r.map(e=>{const r=c.fromPublicKey(e,{compressed:!0}).publicKey;return t.find(e=>e.pubkey.equals(r))}).filter(e=>!!e):t,n.length>e)throw new Error("Too many signatures");return n.length===e}function w(e){return!!e.finalScriptSig||!!e.finalScriptWitness}function _(e){return t=>{try{return e({output:t}),!0}catch(e){return!1}}}const E=_(l.p2ms),k=_(l.p2pk),S=_(l.p2pkh),x=_(l.p2wpkh),T=_(l.p2wsh),A=_(l.p2sh);function P(e){return t=>!!t.masterFingerprint.equals(e.fingerprint)&&!!e.derivePath(t.path).publicKey.equals(t.pubkey)}function O(e){if("number"!=typeof e||e!==Math.floor(e)||e>4294967295||e<0)throw new Error("Invalid 32 bit integer")}function I(t,r){t.forEach(t=>{let n=!1,i=[];if(0===(t.partialSig||[]).length){if(!t.finalScriptSig&&!t.finalScriptWitness)return;i=function(t){const r=t.finalScriptSig&&d.decompile(t.finalScriptSig)||[],n=t.finalScriptWitness&&d.decompile(t.finalScriptWitness)||[];return r.concat(n).filter(t=>e.isBuffer(t)&&d.isCanonicalScriptSignature(t)).map(e=>({signature:e}))}(t)}else i=t.partialSig;if(i.forEach(e=>{const{hashType:t}=d.signature.decode(e.signature),i=[];t&h.Transaction.SIGHASH_ANYONECANPAY&&i.push("addInput");switch(31&t){case h.Transaction.SIGHASH_ALL:break;case h.Transaction.SIGHASH_SINGLE:case h.Transaction.SIGHASH_NONE:i.push("addOutput"),i.push("setInputSequence")}-1===i.indexOf(r)&&(n=!0)}),n)throw new Error("Can not modify transaction, signatures exist.")})}function B(e,t,r){if(!$(e,t))throw new Error(`Can not ${r} for this input with the key ${e.toString("hex")}`)}function M(t,r){const n=s.reverseBuffer(e.from(r.hash)).toString("hex")+":"+r.index;if(t.__TX_IN_CACHE[n])throw new Error("Duplicate input detected.");t.__TX_IN_CACHE[n]=1}function R(e,t){return(r,n,i,o)=>{const a=e({redeem:{output:i}}).output;if(!n.equals(a))throw new Error(`${t} for ${o} #${r} doesn't match the scriptPubKey in the prevout`)}}const N=R(l.p2sh,"Redeem script"),j=R(l.p2wsh,"Witness script");function U(e,t,r,n){if(!r.every(w))throw new Error("PSBT must be finalized to calculate "+t);if("__FEE_RATE"===e&&n.__FEE_RATE)return n.__FEE_RATE;if("__FEE"===e&&n.__FEE)return n.__FEE;let i,o=!0;return n.__EXTRACTED_TX?(i=n.__EXTRACTED_TX,o=!1):i=n.__TX.clone(),K(r,i,n,o),"__FEE_RATE"===e?n.__FEE_RATE:"__FEE"===e?n.__FEE:void 0}function C(e,t,r,n,i,o){const a=J(r);if(!function(e,t,r){switch(r){case"pubkey":case"pubkeyhash":case"witnesspubkeyhash":return v(1,e.partialSig);case"multisig":const r=l.p2ms({output:t});return v(r.m,e.partialSig,r.pubkeys);default:return!1}}(t,r,a))throw new Error("Can not finalize input #"+e);return function(e,t,r,n,i,o){let a,s;const u=function(e,t,r){let n;switch(t){case"multisig":const t=function(e,t){return l.p2ms({output:e}).pubkeys.map(e=>(t.filter(t=>t.pubkey.equals(e))[0]||{}).signature).filter(e=>!!e)}(e,r);n=l.p2ms({output:e,signatures:t});break;case"pubkey":n=l.p2pk({output:e,signature:r[0].signature});break;case"pubkeyhash":n=l.p2pkh({output:e,pubkey:r[0].pubkey,signature:r[0].signature});break;case"witnesspubkeyhash":n=l.p2wpkh({output:e,pubkey:r[0].pubkey,signature:r[0].signature})}return n}(e,t,r),c=o?l.p2wsh({redeem:u}):null,f=i?l.p2sh({redeem:c||u}):null;n?(s=F(c?c.witness:u.witness),f&&(a=f.input)):a=f?f.input:u.input;return{finalScriptSig:a,finalScriptWitness:s}}(r,a,t.partialSig,n,i,o)}function H(e,t,r,n,i){const a=o.checkForInput(e,t),{hash:s,sighashType:u,script:c}=z(t,a,n,!1,i);return B(r,c,"sign"),{hash:s,sighashType:u}}function z(e,t,r,n,i){const o=r.__TX,a=t.sighashType||h.Transaction.SIGHASH_ALL;if(i&&i.indexOf(a)<0){const e=function(e){let t=e&h.Transaction.SIGHASH_ANYONECANPAY?"SIGHASH_ANYONECANPAY | ":"";switch(31&e){case h.Transaction.SIGHASH_ALL:t+="SIGHASH_ALL";break;case h.Transaction.SIGHASH_SINGLE:t+="SIGHASH_SINGLE";break;case h.Transaction.SIGHASH_NONE:t+="SIGHASH_NONE"}return t}(a);throw new Error("Sighash type is not allowed. Retry the sign method passing the sighashTypes array of whitelisted types. Sighash type: "+e)}let s,u;if(t.nonWitnessUtxo){const n=W(r,t,e),i=o.ins[e].hash,a=n.getHash();if(!i.equals(a))throw new Error(`Non-witness UTXO hash for input #${e} doesn't match the hash specified in the prevout`);const s=o.ins[e].index;u=n.outs[s]}else{if(!t.witnessUtxo)throw new Error("Need a Utxo input item for signing");u=t.witnessUtxo}const{meaningfulScript:c,type:f}=X(u.script,e,"input",t.redeemScript,t.witnessScript);if(["p2sh-p2wsh","p2wsh"].indexOf(f)>=0)s=o.hashForWitnessV0(e,c,u.value,a);else if(x(c)){const t=l.p2pkh({hash:c.slice(2)}).output;s=o.hashForWitnessV0(e,t,u.value,a)}else{if(void 0===t.nonWitnessUtxo&&!1===r.__UNSAFE_SIGN_NONSEGWIT)throw new Error(`Input #${e} has witnessUtxo but non-segwit script: `+c.toString("hex"));n||!1===r.__UNSAFE_SIGN_NONSEGWIT||console.warn("Warning: Signing non-segwit inputs without the full parent transaction means there is a chance that a miner could feed you incorrect information to trick you into paying large fees. This behavior is the same as the old TransactionBuilder class when signing non-segwit scripts. You are not able to export this Psbt with toBuffer|toBase64|toHex since it is not BIP174 compliant.\n*********************\nPROCEED WITH CAUTION!\n*********************"),s=o.hashForSignature(e,c,a)}return{script:c,sighashType:a,hash:s}}function L(e,t,r){const n=o.checkForInput(t,e);if(!n.bip32Derivation||0===n.bip32Derivation.length)throw new Error("Need bip32Derivation to sign with HD");const i=n.bip32Derivation.map(e=>e.masterFingerprint.equals(r.fingerprint)?e:void 0).filter(e=>!!e);if(0===i.length)throw new Error("Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint");return i.map(e=>{const t=r.derivePath(e.path);if(!e.pubkey.equals(t.publicKey))throw new Error("pubkey did not match bip32Derivation");return t})}function D(e){let t=0;function r(){const r=i.decode(e,t);return t+=i.decode.bytes,r}function n(){return n=r(),t+=n,e.slice(t-n,t);var n}return function(){const e=r(),t=[];for(let r=0;r<e;r++)t.push(n());return t}()}function F(t){let r=e.allocUnsafe(0);function n(t){const n=r.length,o=i.encodingLength(t);r=e.concat([r,e.allocUnsafe(o)]),i.encode(t,r,n)}function o(t){n(t.length),function(t){r=e.concat([r,e.from(t)])}(t)}var a;return n((a=t).length),a.forEach(o),r}function q(e,t,r){e.__NON_WITNESS_UTXO_BUF_CACHE[r]=t.nonWitnessUtxo;const n=h.Transaction.fromBuffer(t.nonWitnessUtxo);e.__NON_WITNESS_UTXO_TX_CACHE[r]=n;const i=e,o=r;delete t.nonWitnessUtxo,Object.defineProperty(t,"nonWitnessUtxo",{enumerable:!0,get(){const e=i.__NON_WITNESS_UTXO_BUF_CACHE[o],t=i.__NON_WITNESS_UTXO_TX_CACHE[o];if(void 0!==e)return e;{const e=t.toBuffer();return i.__NON_WITNESS_UTXO_BUF_CACHE[o]=e,e}},set(e){i.__NON_WITNESS_UTXO_BUF_CACHE[o]=e}})}function K(e,t,r,n){let i=0;e.forEach((e,o)=>{if(n&&e.finalScriptSig&&(t.ins[o].script=e.finalScriptSig),n&&e.finalScriptWitness&&(t.ins[o].witness=D(e.finalScriptWitness)),e.witnessUtxo)i+=e.witnessUtxo.value;else if(e.nonWitnessUtxo){const n=W(r,e,o),a=t.ins[o].index,s=n.outs[a];i+=s.value}});const o=t.outs.reduce((e,t)=>e+t.value,0),a=i-o;if(a<0)throw new Error("Outputs are spending more than Inputs");const s=t.virtualSize();r.__FEE=a,r.__EXTRACTED_TX=t,r.__FEE_RATE=Math.floor(a/s)}function W(e,t,r){const n=e.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||q(e,t,r),n[r]}function V(e,t,r){if(void 0!==t.witnessUtxo)return t.witnessUtxo.script;if(void 0!==t.nonWitnessUtxo){return W(r,t,e).outs[r.__TX.ins[e].index].script}throw new Error("Can't find pubkey in input without Utxo data")}function G(e){return 33===e.length&&d.isCanonicalPubKey(e)}function X(e,t,r,n,i){const o=A(e),a=o&&n&&T(n),s=T(e);if(o&&void 0===n)throw new Error("scriptPubkey is P2SH but redeemScript missing");if((s||a)&&void 0===i)throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");let u;return a?(u=i,N(t,e,n,r),j(t,n,i,r),Y(u)):s?(u=i,j(t,e,i,r),Y(u)):o?(u=n,N(t,e,n,r)):u=e,{meaningfulScript:u,type:a?"p2sh-p2wsh":o?"p2sh":s?"p2wsh":"raw"}}function Y(e){if(x(e)||A(e))throw new Error("P2WPKH or P2SH can not be contained within P2WSH")}function $(e,t){const r=u.hash160(e),n=d.decompile(t);if(null===n)throw new Error("Unknown script error");return n.some(t=>"number"!=typeof t&&(t.equals(e)||t.equals(r)))}function J(e){return x(e)?"witnesspubkeyhash":S(e)?"pubkeyhash":E(e)?"multisig":k(e)?"pubkey":"nonstandard"}function Q(e){return[...Array(e).keys()]}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(79),i=r(51),o=r(287),a=r(19),s=r(82),u=r(12),c=r(50),f=r(1),l=r(1),d=r(52),h=r(16),p=r(3),b=o.types,m=new Set(["p2pkh","p2pk","p2wpkh","p2ms","p2sh-p2pkh","p2sh-p2pk","p2sh-p2wpkh","p2sh-p2ms","p2wsh-p2pkh","p2wsh-p2pk","p2wsh-p2ms","p2sh-p2wsh-p2pkh","p2sh-p2wsh-p2pk","p2sh-p2wsh-p2ms"]);function g(e,t,r){try{p(e,t)}catch(e){throw new Error(r)}}class y{constructor(e=u.bitcoin,t=2500){this.network=e,this.maximumFeeRate=t,this.__PREV_TX_SET={},this.__INPUTS=[],this.__TX=new d.Transaction,this.__TX.version=2,this.__USE_LOW_R=!1,console.warn("Deprecation Warning: TransactionBuilder will be removed in the future. (v6.x.x or later) Please use the Psbt class instead. Examples of usage are available in the transactions-psbt.js integration test file on our Github. A high level explanation is available in the psbt.ts and psbt.js files as well.")}static fromTransaction(e,t){const r=new y(t);return r.setVersion(e.version),r.setLockTime(e.locktime),e.outs.forEach(e=>{r.addOutput(e.script,e.value)}),e.ins.forEach(e=>{r.__addInputUnsafe(e.hash,e.index,{sequence:e.sequence,script:e.script,witness:e.witness})}),r.__INPUTS.forEach((t,r)=>{!function(e,t,r){if(e.redeemScriptType!==b.P2MS||!e.redeemScript)return;if(e.pubkeys.length===e.signatures.length)return;const n=e.signatures.concat();e.signatures=e.pubkeys.map(i=>{const o=s.fromPublicKey(i);let a;return n.some((i,s)=>{if(!i)return!1;const u=f.signature.decode(i),c=t.hashForSignature(r,e.redeemScript,u.hashType);return!!o.verify(c,u.signature)&&(n[s]=void 0,a=i,!0)}),a})}(t,e,r)}),r}setLowR(e){return p(p.maybe(p.Boolean),e),void 0===e&&(e=!0),this.__USE_LOW_R=e,e}setLockTime(e){if(p(h.UInt32,e),this.__INPUTS.some(e=>!!e.signatures&&e.signatures.some(e=>void 0!==e)))throw new Error("No, this would invalidate signatures");this.__TX.locktime=e}setVersion(e){p(h.UInt32,e),this.__TX.version=e}addInput(t,r,n,o){if(!this.__canModifyInputs())throw new Error("No, this would invalidate signatures");let a;if("string"==typeof(s=t)||s instanceof String)t=i.reverseBuffer(e.from(t,"hex"));else if(function(e){return e instanceof d.Transaction}(t)){const e=t.outs[r];o=e.script,a=e.value,t=t.getHash(!1)}var s;return this.__addInputUnsafe(t,r,{sequence:n,prevOutScript:o,value:a})}addOutput(e,t){if(!this.__canModifyOutputs())throw new Error("No, this would invalidate signatures");return"string"==typeof e&&(e=n.toOutputScript(e,this.network)),this.__TX.addOutput(e,t)}build(){return this.__build(!1)}buildIncomplete(){return this.__build(!0)}sign(e,t,r,n,i,o){!function({input:e,ourPubKey:t,keyPair:r,signatureHash:n,hashType:i,useLowR:o}){let a=!1;for(const[s,u]of e.pubkeys.entries()){if(!t.equals(u))continue;if(e.signatures[s])throw new Error("Signature already exists");if(33!==t.length&&e.hasWitness)throw new Error("BIP143 rejects uncompressed public keys in P2WPKH or P2WSH");const c=r.sign(n,o);e.signatures[s]=f.signature.encode(c,i),a=!0}if(!a)throw new Error("Key pair cannot sign for this input")}(function(e,t,r,n,i,o,a,s,u,l,y){let _;if("number"==typeof i)console.warn("DEPRECATED: TransactionBuilder sign method arguments will change in v6, please use the TxbSignArg interface"),_=i;else{if("object"!=typeof i)throw new TypeError("TransactionBuilder sign first arg must be TxbSignArg or number");!function(e,t){if(!m.has(t.prevOutScriptType))throw new TypeError(`Unknown prevOutScriptType "${t.prevOutScriptType}"`);g(p.Number,t.vin,"sign must include vin parameter as Number (input index)"),g(h.Signer,t.keyPair,"sign must include keyPair parameter as Signer interface"),g(p.maybe(p.Number),t.hashType,"sign hashType parameter must be a number");const r=(e[t.vin]||[]).prevOutType,n=t.prevOutScriptType;switch(n){case"p2pkh":if(r&&"pubkeyhash"!==r)throw new TypeError(`input #${t.vin} is not of type p2pkh: ${r}`);g(p.value(void 0),t.witnessScript,n+" requires NO witnessScript"),g(p.value(void 0),t.redeemScript,n+" requires NO redeemScript"),g(p.value(void 0),t.witnessValue,n+" requires NO witnessValue");break;case"p2pk":if(r&&"pubkey"!==r)throw new TypeError(`input #${t.vin} is not of type p2pk: ${r}`);g(p.value(void 0),t.witnessScript,n+" requires NO witnessScript"),g(p.value(void 0),t.redeemScript,n+" requires NO redeemScript"),g(p.value(void 0),t.witnessValue,n+" requires NO witnessValue");break;case"p2wpkh":if(r&&"witnesspubkeyhash"!==r)throw new TypeError(`input #${t.vin} is not of type p2wpkh: ${r}`);g(p.value(void 0),t.witnessScript,n+" requires NO witnessScript"),g(p.value(void 0),t.redeemScript,n+" requires NO redeemScript"),g(h.Satoshi,t.witnessValue,n+" requires witnessValue");break;case"p2ms":if(r&&"multisig"!==r)throw new TypeError(`input #${t.vin} is not of type p2ms: ${r}`);g(p.value(void 0),t.witnessScript,n+" requires NO witnessScript"),g(p.value(void 0),t.redeemScript,n+" requires NO redeemScript"),g(p.value(void 0),t.witnessValue,n+" requires NO witnessValue");break;case"p2sh-p2wpkh":if(r&&"scripthash"!==r)throw new TypeError(`input #${t.vin} is not of type p2sh-p2wpkh: ${r}`);g(p.value(void 0),t.witnessScript,n+" requires NO witnessScript"),g(p.Buffer,t.redeemScript,n+" requires redeemScript"),g(h.Satoshi,t.witnessValue,n+" requires witnessValue");break;case"p2sh-p2ms":case"p2sh-p2pk":case"p2sh-p2pkh":if(r&&"scripthash"!==r)throw new TypeError(`input #${t.vin} is not of type ${n}: ${r}`);g(p.value(void 0),t.witnessScript,n+" requires NO witnessScript"),g(p.Buffer,t.redeemScript,n+" requires redeemScript"),g(p.value(void 0),t.witnessValue,n+" requires NO witnessValue");break;case"p2wsh-p2ms":case"p2wsh-p2pk":case"p2wsh-p2pkh":if(r&&"witnessscripthash"!==r)throw new TypeError(`input #${t.vin} is not of type ${n}: ${r}`);g(p.Buffer,t.witnessScript,n+" requires witnessScript"),g(p.value(void 0),t.redeemScript,n+" requires NO redeemScript"),g(h.Satoshi,t.witnessValue,n+" requires witnessValue");break;case"p2sh-p2wsh-p2ms":case"p2sh-p2wsh-p2pk":case"p2sh-p2wsh-p2pkh":if(r&&"scripthash"!==r)throw new TypeError(`input #${t.vin} is not of type ${n}: ${r}`);g(p.Buffer,t.witnessScript,n+" requires witnessScript"),g(p.Buffer,t.redeemScript,n+" requires witnessScript"),g(h.Satoshi,t.witnessValue,n+" requires witnessScript")}}(t,i),({vin:_,keyPair:o,redeemScript:a,hashType:s,witnessValue:u,witnessScript:l}=i)}if(void 0===o)throw new Error("sign requires keypair");if(o.network&&o.network!==e)throw new TypeError("Inconsistent network");if(!t[_])throw new Error("No input at index: "+_);if(s=s||d.Transaction.SIGHASH_ALL,r(s))throw new Error("Transaction needs outputs");const E=t[_];if(void 0!==E.redeemScript&&a&&!E.redeemScript.equals(a))throw new Error("Inconsistent redeemScript");const k=o.publicKey||o.getPublicKey&&o.getPublicKey();if(!w(E)){if(void 0!==u){if(void 0!==E.value&&E.value!==u)throw new Error("Input did not match witnessValue");p(h.Satoshi,u),E.value=u}if(!w(E)){const e=function(e,t,r,n){if(r&&n){const i=c.p2wsh({redeem:{output:n}}),o=c.p2wsh({output:r}),a=c.p2sh({redeem:{output:r}}),s=c.p2sh({redeem:i});if(!i.hash.equals(o.hash))throw new Error("Witness script inconsistent with prevOutScript");if(!a.hash.equals(s.hash))throw new Error("Redeem script inconsistent with prevOutScript");const u=v(i.redeem.output,t);if(!u.pubkeys)throw new Error(u.type+" not supported as witnessScript ("+f.toASM(n)+")");e.signatures&&e.signatures.some(e=>void 0!==e)&&(u.signatures=e.signatures);const l=n;if(u.type===b.P2WPKH)throw new Error("P2SH(P2WSH(P2WPKH)) is a consensus failure");return{redeemScript:r,redeemScriptType:b.P2WSH,witnessScript:n,witnessScriptType:u.type,prevOutType:b.P2SH,prevOutScript:a.output,hasWitness:!0,signScript:l,signType:u.type,pubkeys:u.pubkeys,signatures:u.signatures,maxSignatures:u.maxSignatures}}if(r){const n=c.p2sh({redeem:{output:r}});if(e.prevOutScript){let t;try{t=c.p2sh({output:e.prevOutScript})}catch(e){throw new Error("PrevOutScript must be P2SH")}if(!n.hash.equals(t.hash))throw new Error("Redeem script inconsistent with prevOutScript")}const i=v(n.redeem.output,t);if(!i.pubkeys)throw new Error(i.type+" not supported as redeemScript ("+f.toASM(r)+")");e.signatures&&e.signatures.some(e=>void 0!==e)&&(i.signatures=e.signatures);let o=r;return i.type===b.P2WPKH&&(o=c.p2pkh({pubkey:i.pubkeys[0]}).output),{redeemScript:r,redeemScriptType:i.type,prevOutType:b.P2SH,prevOutScript:n.output,hasWitness:i.type===b.P2WPKH,signScript:o,signType:i.type,pubkeys:i.pubkeys,signatures:i.signatures,maxSignatures:i.maxSignatures}}if(n){const r=c.p2wsh({redeem:{output:n}});if(e.prevOutScript){const t=c.p2wsh({output:e.prevOutScript});if(!r.hash.equals(t.hash))throw new Error("Witness script inconsistent with prevOutScript")}const i=v(r.redeem.output,t);if(!i.pubkeys)throw new Error(i.type+" not supported as witnessScript ("+f.toASM(n)+")");e.signatures&&e.signatures.some(e=>void 0!==e)&&(i.signatures=e.signatures);const o=n;if(i.type===b.P2WPKH)throw new Error("P2WSH(P2WPKH) is a consensus failure");return{witnessScript:n,witnessScriptType:i.type,prevOutType:b.P2WSH,prevOutScript:r.output,hasWitness:!0,signScript:o,signType:i.type,pubkeys:i.pubkeys,signatures:i.signatures,maxSignatures:i.maxSignatures}}if(e.prevOutType&&e.prevOutScript){if(e.prevOutType===b.P2SH)throw new Error("PrevOutScript is "+e.prevOutType+", requires redeemScript");if(e.prevOutType===b.P2WSH)throw new Error("PrevOutScript is "+e.prevOutType+", requires witnessScript");if(!e.prevOutScript)throw new Error("PrevOutScript is missing");const r=v(e.prevOutScript,t);if(!r.pubkeys)throw new Error(r.type+" not supported ("+f.toASM(e.prevOutScript)+")");e.signatures&&e.signatures.some(e=>void 0!==e)&&(r.signatures=e.signatures);let n=e.prevOutScript;return r.type===b.P2WPKH&&(n=c.p2pkh({pubkey:r.pubkeys[0]}).output),{prevOutType:r.type,prevOutScript:e.prevOutScript,hasWitness:r.type===b.P2WPKH,signScript:n,signType:r.type,pubkeys:r.pubkeys,signatures:r.signatures,maxSignatures:r.maxSignatures}}const i=c.p2pkh({pubkey:t}).output;return{prevOutType:b.P2PKH,prevOutScript:i,hasWitness:!1,signScript:i,signType:b.P2PKH,pubkeys:[t],signatures:[void 0]}}(E,k,a,l);Object.assign(E,e)}if(!w(E))throw Error(E.prevOutType+" not supported")}let S;S=E.hasWitness?n.hashForWitnessV0(_,E.signScript,E.value,s):n.hashForSignature(_,E.signScript,s);return{input:E,ourPubKey:k,keyPair:o,signatureHash:S,hashType:s,useLowR:!!y}}(this.network,this.__INPUTS,this.__needsOutputs.bind(this),this.__TX,e,t,r,n,i,o,this.__USE_LOW_R))}__addInputUnsafe(e,t,r){if(d.Transaction.isCoinbaseHash(e))throw new Error("coinbase inputs not supported");const n=e.toString("hex")+":"+t;if(void 0!==this.__PREV_TX_SET[n])throw new Error("Duplicate TxOut: "+n);let i={};if(void 0!==r.script&&(i=function e(t,r,n,i){if(0===t.length&&0===r.length)return{};if(!n){let e=o.input(t,!0),i=o.witness(r,!0);e===b.NONSTANDARD&&(e=void 0),i===b.NONSTANDARD&&(i=void 0),n=e||i}switch(n){case b.P2WPKH:{const{output:e,pubkey:t,signature:n}=c.p2wpkh({witness:r});return{prevOutScript:e,prevOutType:b.P2WPKH,pubkeys:[t],signatures:[n]}}case b.P2PKH:{const{output:e,pubkey:r,signature:n}=c.p2pkh({input:t});return{prevOutScript:e,prevOutType:b.P2PKH,pubkeys:[r],signatures:[n]}}case b.P2PK:{const{signature:e}=c.p2pk({input:t});return{prevOutType:b.P2PK,pubkeys:[void 0],signatures:[e]}}case b.P2MS:{const{m:e,pubkeys:r,signatures:n}=c.p2ms({input:t,output:i},{allowIncomplete:!0});return{prevOutType:b.P2MS,pubkeys:r,signatures:n,maxSignatures:e}}}if(n===b.P2SH){const{output:n,redeem:i}=c.p2sh({input:t,witness:r}),a=o.output(i.output),s=e(i.input,i.witness,a,i.output);return s.prevOutType?{prevOutScript:n,prevOutType:b.P2SH,redeemScript:i.output,redeemScriptType:s.prevOutType,witnessScript:s.witnessScript,witnessScriptType:s.witnessScriptType,pubkeys:s.pubkeys,signatures:s.signatures}:{}}if(n===b.P2WSH){const{output:n,redeem:i}=c.p2wsh({input:t,witness:r}),a=o.output(i.output);let s;return s=a===b.P2WPKH?e(i.input,i.witness,a):e(f.compile(i.witness),[],a,i.output),s.prevOutType?{prevOutScript:n,prevOutType:b.P2WSH,witnessScript:i.output,witnessScriptType:s.prevOutType,pubkeys:s.pubkeys,signatures:s.signatures}:{}}return{prevOutType:b.NONSTANDARD,prevOutScript:t}}(r.script,r.witness||[])),void 0!==r.value&&(i.value=r.value),!i.prevOutScript&&r.prevOutScript){let e;if(!i.pubkeys&&!i.signatures){const t=v(r.prevOutScript);t.pubkeys&&(i.pubkeys=t.pubkeys,i.signatures=t.signatures),e=t.type}i.prevOutScript=r.prevOutScript,i.prevOutType=e||o.output(r.prevOutScript)}const a=this.__TX.addInput(e,t,r.sequence,r.scriptSig);return this.__INPUTS[a]=i,this.__PREV_TX_SET[n]=!0,a}__build(e){if(!e){if(!this.__TX.ins.length)throw new Error("Transaction has no inputs");if(!this.__TX.outs.length)throw new Error("Transaction has no outputs")}const t=this.__TX.clone();if(this.__INPUTS.forEach((r,n)=>{if(!r.prevOutType&&!e)throw new Error("Transaction is not complete");const i=function e(t,r,n){const i=r.pubkeys||[];let o=r.signatures||[];switch(t){case b.P2PKH:if(0===i.length)break;if(0===o.length)break;return c.p2pkh({pubkey:i[0],signature:o[0]});case b.P2WPKH:if(0===i.length)break;if(0===o.length)break;return c.p2wpkh({pubkey:i[0],signature:o[0]});case b.P2PK:if(0===i.length)break;if(0===o.length)break;return c.p2pk({signature:o[0]});case b.P2MS:{const e=r.maxSignatures;o=n?o.map(e=>e||l.OPS.OP_0):o.filter(e=>e);const t=!n||e===o.length;return c.p2ms({m:e,pubkeys:i,signatures:o},{allowIncomplete:n,validate:t})}case b.P2SH:{const t=e(r.redeemScriptType,r,n);if(!t)return;return c.p2sh({redeem:{output:t.output||r.redeemScript,input:t.input,witness:t.witness}})}case b.P2WSH:{const t=e(r.witnessScriptType,r,n);if(!t)return;return c.p2wsh({redeem:{output:r.witnessScript,input:t.input,witness:t.witness}})}}}(r.prevOutType,r,e);if(i)t.setInputScript(n,i.input),t.setWitness(n,i.witness);else{if(!e&&r.prevOutType===b.NONSTANDARD)throw new Error("Unknown input type");if(!e)throw new Error("Not enough information")}}),!e&&this.__overMaximumFees(t.virtualSize()))throw new Error("Transaction has absurd fees");return t}__canModifyInputs(){return this.__INPUTS.every(e=>!e.signatures||e.signatures.every(e=>{if(!e)return!0;return 0!=(_(e)&d.Transaction.SIGHASH_ANYONECANPAY)}))}__needsOutputs(e){return e===d.Transaction.SIGHASH_ALL?0===this.__TX.outs.length:0===this.__TX.outs.length&&this.__INPUTS.some(e=>!!e.signatures&&e.signatures.some(e=>{if(!e)return!1;return!(_(e)&d.Transaction.SIGHASH_NONE)}))}__canModifyOutputs(){const e=this.__TX.ins.length,t=this.__TX.outs.length;return this.__INPUTS.every(r=>void 0===r.signatures||r.signatures.every(r=>{if(!r)return!0;const n=31&_(r);return n===d.Transaction.SIGHASH_NONE||n===d.Transaction.SIGHASH_SINGLE&&e<=t}))}__overMaximumFees(e){return(this.__INPUTS.reduce((e,t)=>e+(t.value>>>0),0)-this.__TX.outs.reduce((e,t)=>e+t.value,0))/e>this.maximumFeeRate}}function v(e,t){p(h.Buffer,e);const r=o.output(e);switch(r){case b.P2PKH:{if(!t)return{type:r};const n=c.p2pkh({output:e}).hash,i=a.hash160(t);return n.equals(i)?{type:r,pubkeys:[t],signatures:[void 0]}:{type:r}}case b.P2WPKH:{if(!t)return{type:r};const n=c.p2wpkh({output:e}).hash,i=a.hash160(t);return n.equals(i)?{type:r,pubkeys:[t],signatures:[void 0]}:{type:r}}case b.P2PK:return{type:r,pubkeys:[c.p2pk({output:e}).pubkey],signatures:[void 0]};case b.P2MS:{const t=c.p2ms({output:e});return{type:r,pubkeys:t.pubkeys,signatures:t.pubkeys.map(()=>{}),maxSignatures:t.m}}}return{type:r}}function w(e){return void 0!==e.signScript&&void 0!==e.signType&&void 0!==e.pubkeys&&void 0!==e.signatures&&e.signatures.length===e.pubkeys.length&&e.pubkeys.length>0&&(!1===e.hasWitness||void 0!==e.value)}function _(e){return e.readUInt8(e.length-1)}t.TransactionBuilder=y}).call(this,r(0).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(83),o=r(290),a=r(84),s=r(85),u=r(295),c=r(298),f=r(300),l=r(302),d={P2MS:"multisig",NONSTANDARD:"nonstandard",NULLDATA:"nulldata",P2PK:"pubkey",P2PKH:"pubkeyhash",P2SH:"scripthash",P2WPKH:"witnesspubkeyhash",P2WSH:"witnessscripthash",WITNESS_COMMITMENT:"witnesscommitment"};t.types=d,t.output=function(e){if(f.output.check(e))return d.P2WPKH;if(l.output.check(e))return d.P2WSH;if(s.output.check(e))return d.P2PKH;if(u.output.check(e))return d.P2SH;const t=n.decompile(e);if(!t)throw new TypeError("Invalid script");return i.output.check(t)?d.P2MS:a.output.check(t)?d.P2PK:c.output.check(t)?d.WITNESS_COMMITMENT:o.output.check(t)?d.NULLDATA:d.NONSTANDARD},t.input=function(e,t){const r=n.decompile(e);if(!r)throw new TypeError("Invalid script");return s.input.check(r)?d.P2PKH:u.input.check(r,t)?d.P2SH:i.input.check(r,t)?d.P2MS:a.input.check(r)?d.P2PK:d.NONSTANDARD},t.witness=function(e,t){const r=n.decompile(e);if(!r)throw new TypeError("Invalid script");return f.input.check(r)?d.P2WPKH:l.input.check(r,t)?d.P2WSH:d.NONSTANDARD}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(1);function o(e){return e===i.OPS.OP_0||n.isCanonicalScriptSignature(e)}function a(e,t){const r=n.decompile(e);return!(r.length<2)&&(r[0]===i.OPS.OP_0&&(t?r.slice(1).every(o):r.slice(1).every(n.isCanonicalScriptSignature)))}t.check=a,a.toJSON=()=>"multisig input"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(1),o=r(16),a=i.OPS.OP_RESERVED;function s(e,t){const r=n.decompile(e);if(r.length<4)return!1;if(r[r.length-1]!==i.OPS.OP_CHECKMULTISIG)return!1;if(!o.Number(r[0]))return!1;if(!o.Number(r[r.length-2]))return!1;const s=r[0]-a,u=r[r.length-2]-a;if(s<=0)return!1;if(u>16)return!1;if(s>u)return!1;if(u!==r.length-3)return!1;if(t)return!0;return r.slice(1,-2).every(n.isCanonicalPubKey)}t.check=s,s.toJSON=()=>"multi-sig output"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=n.OPS;function o(e){const t=n.compile(e);return t.length>1&&t[0]===i.OP_RETURN}t.check=o,o.toJSON=()=>"null data output";const a={check:o};t.output=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1);function i(e){const t=n.decompile(e);return 1===t.length&&n.isCanonicalScriptSignature(t[0])}t.check=i,i.toJSON=()=>"pubKey input"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(1);function o(e){const t=n.decompile(e);return 2===t.length&&n.isCanonicalPubKey(t[0])&&t[1]===i.OPS.OP_CHECKSIG}t.check=o,o.toJSON=()=>"pubKey output"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1);function i(e){const t=n.decompile(e);return 2===t.length&&n.isCanonicalScriptSignature(t[0])&&n.isCanonicalPubKey(t[1])}t.check=i,i.toJSON=()=>"pubKeyHash input"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(1);function o(e){const t=n.compile(e);return 25===t.length&&t[0]===i.OPS.OP_DUP&&t[1]===i.OPS.OP_HASH160&&20===t[2]&&t[23]===i.OPS.OP_EQUALVERIFY&&t[24]===i.OPS.OP_CHECKSIG}t.check=o,o.toJSON=()=>"pubKeyHash output"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(296);t.input=n;const i=r(297);t.output=i},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(83),o=r(84),a=r(85),s=r(127),u=r(128);function c(t,r){const c=n.decompile(t);if(c.length<1)return!1;const f=c[c.length-1];if(!e.isBuffer(f))return!1;const l=n.decompile(n.compile(c.slice(0,-1))),d=n.decompile(f);return!!d&&(!!n.isPushOnly(l)&&(1===c.length?u.check(d)||s.check(d):!(!a.input.check(l)||!a.output.check(d))||(!(!i.input.check(l,r)||!i.output.check(d))||!(!o.input.check(l)||!o.output.check(d)))))}t.check=c,c.toJSON=()=>"scriptHash input"}).call(this,r(0).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(1);function o(e){const t=n.compile(e);return 23===t.length&&t[0]===i.OPS.OP_HASH160&&20===t[1]&&t[22]===i.OPS.OP_EQUAL}t.check=o,o.toJSON=()=>"scriptHash output"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(299);t.output=n},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(1),o=r(16),a=r(3),s=e.from("aa21a9ed","hex");function u(e){const t=n.compile(e);return t.length>37&&t[0]===i.OPS.OP_RETURN&&36===t[1]&&t.slice(2,6).equals(s)}t.check=u,u.toJSON=()=>"Witness commitment output",t.encode=function(t){a(o.Hash256bit,t);const r=e.allocUnsafe(36);return s.copy(r,0),t.copy(r,4),n.compile([i.OPS.OP_RETURN,r])},t.decode=function(e){return a(u,e),n.decompile(e)[1].slice(4,36)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(301);t.input=n;const i=r(127);t.output=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1);function i(e){const t=n.decompile(e);return 2===t.length&&n.isCanonicalScriptSignature(t[0])&&(r=t[1],n.isCanonicalPubKey(r)&&33===r.length);var r}t.check=i,i.toJSON=()=>"witnessPubKeyHash input"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(303);t.input=n;const i=r(128);t.output=i},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(3),o=r(83),a=r(84),s=r(85);function u(t,r){if(i(i.Array,t),t.length<1)return!1;const u=t[t.length-1];if(!e.isBuffer(u))return!1;const c=n.decompile(u);if(!c||0===c.length)return!1;const f=n.compile(t.slice(0,-1));return!(!s.input.check(f)||!s.output.check(c))||(!(!o.input.check(f,r)||!o.output.check(c))||!(!a.input.check(f)||!a.output.check(c)))}t.check=u,u.toJSON=()=>"witnessScriptHash input"}).call(this,r(0).Buffer)},function(e,t,r){(function(t){function r(e,r){for(var n=e.length,i=[],o=0;o<n;o+=2){var a=e[o],s=o+1===n?a:e[o+1],u=t.concat([a,s]);i.push(r(u))}return i}e.exports=function(e,t){if(!Array.isArray(e))throw TypeError("Expected values Array");if("function"!=typeof t)throw TypeError("Expected digest Function");if(1===e.length)return e.concat();var n=[e],i=e;do{i=r(i,t),n.push(i)}while(i.length>1);return[].concat.apply([],n)}}).call(this,r(0).Buffer)},function(e,t,r){(function(t){function r(e){for(var t=1,r=e;r>1;r=r+1>>1)t+=r;return t}function n(e,t){return e+(1<<t)-1>>t}e.exports=function(e,t){var i=e.indexOf(t);if(-1===i)return null;for(var o=e.length,a=[],s=n(o,1);s>0&&r(s)!==o;)--s;if(0===s)throw new Error("Unknown solution");for(var u=0,c=0;c<o-1;){var f=n(s,u);++u;var l=i%2;l&&--i;var d=c+i,h=e[d],p=i===f-1?h:e[d+1];c>0?(a.push(l?h:null),a.push(l?null:p)):(a.push(h),a.push(p)),i=i/2|0,c+=f}return a.push(e[o-1]),a},e.exports.verify=function(e,r){for(var n=e[e.length-1],i=n,o=0;o<e.length-1;o+=2){var a=e[o]||i,s=e[o+1]||i;i=r(t.concat([a,s]))}return i.equals(n)}}).call(this,r(0).Buffer)},function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.TeleportDaoPayment=void 0;const i=r(129);class o extends i.BitcoinBase{payBurnRequest(e,t="normal"){return n(this,void 0,void 0,(function*(){if(!(this.currentAccount&&this.currentAccountType&&this.publicKey&&this.privateKey))throw new Error("account not initialized");let r=yield this.getExtendedUtxo({address:this.currentAccount,addressType:this.currentAccountType,publicKey:this.publicKey.toString("hex")}),n=yield this.transactionBuilder._getFeeRate(t),i=yield this.transactionBuilder.processUnsignedTransaction({extendedUtxo:r,targets:e,changeAddress:this.currentAccount,feeRate:n,fullAmount:!1}),o=yield this.signer.signPsbt(i,this.privateKey),a=this.signer.finalizePsbts([o]);return yield this.transactionBuilder.sendTx(a)}))}transferBitcoinToEth({lockerAddress:e,amount:t,fullAmount:r=!1,chainId:i,appId:o,recipientAddress:a,percentageFee:s,speed:u=0,isExchange:c=!1,exchangeTokenAddress:f="0x0000000000000000000000000000000000000000",outputAmount:l=0,deadline:d,isFixedToken:h=!1,feeSpeed:p="normal",staticFeeRate:b}){return n(this,void 0,void 0,(function*(){if(!(this.currentAccount&&this.currentAccountType&&this.publicKey&&this.privateKey))throw new Error("account not initialized");let n=yield this.getExtendedUtxo({address:this.currentAccount,addressType:this.currentAccountType,publicKey:this.publicKey.toString("hex")}),m=yield this.getBitcoinToEthUnsignedPsbt({changeAddress:this.currentAccount,extendedUtxo:n,lockerAddress:e,amount:t,fullAmount:r,chainId:i,appId:o,recipientAddress:a,percentageFee:s,speed:u,isExchange:c,exchangeTokenAddress:f,outputAmount:l,deadline:d,isFixedToken:h,feeSpeed:p,staticFeeRate:b}),g=yield this.signer.signPsbt(m,this.privateKey);return yield this.sendSignedPsbt(g)}))}getBitcoinToEthTargetOutputs({lockerAddress:e,amount:t,fullAmount:r=!1,chainId:i,appId:a,recipientAddress:s,percentageFee:u,speed:c=0,isExchange:f=!1,exchangeTokenAddress:l="0x0000000000000000000000000000000000000000",outputAmount:d=0,deadline:h=0,isFixedToken:p=!1}){return n(this,void 0,void 0,(function*(){let n=o.getTransferOpReturnData({chainId:i,appId:a,recipientAddress:s,percentageFee:u,speed:c,isExchange:f,exchangeTokenAddress:l,outputAmount:d,deadline:h,isFixedToken:p}),b=this.transactionBuilder.getOpReturnTarget(n);return r?[b]:[{address:e,value:t},b]}))}getBitcoinToEthUnsignedPsbt({changeAddress:e,extendedUtxo:t,lockerAddress:r,amount:i,fullAmount:o=!1,chainId:a,appId:s,recipientAddress:u,percentageFee:c,speed:f=0,isExchange:l=!1,exchangeTokenAddress:d="0x0000000000000000000000000000000000000000",outputAmount:h=0,deadline:p=0,isFixedToken:b=!1,feeSpeed:m="normal",staticFeeRate:g}){return n(this,void 0,void 0,(function*(){let n=g||(yield this.transactionBuilder._getFeeRate(m)),y=yield this.getBitcoinToEthTargetOutputs({lockerAddress:r,amount:i,fullAmount:o,chainId:a,appId:s,recipientAddress:u,percentageFee:c,speed:f,isExchange:l,exchangeTokenAddress:d,outputAmount:h,deadline:p,isFixedToken:b});return yield this.transactionBuilder.processUnsignedTransaction({extendedUtxo:t,targets:y,changeAddress:o?r:e,feeRate:n,fullAmount:o})}))}bitcoinToEthLend({lockerAddress:e,amount:t,chainId:r,appId:i,recipientAddress:a,percentageFee:s,mode:u=0,isBorrow:c=!1,tokenAddress:f="0x0000000000000000000000000000000000000000",borrowAmount:l=0,staticFeeRate:d}){return n(this,void 0,void 0,(function*(){if(!(this.currentAccount&&this.currentAccountType&&this.publicKey&&this.privateKey))throw new Error("account not initialized");let n=o.getLendingOpReturnData({chainId:r,appId:i,recipientAddress:a,percentageFee:s,mode:u,isBorrow:c,tokenAddress:f,borrowAmount:l}),h=this.transactionBuilder.getOpReturnTarget(n),p=yield this.transactionBuilder.getExtendedUtxo({address:this.currentAccount,addressType:this.currentAccountType,publicKey:this.publicKey.toString("hex")}),b=yield this.transactionBuilder.processUnsignedTransaction({extendedUtxo:p,targets:[{address:e,value:t},h],changeAddress:this.currentAccount,feeRate:d,fullAmount:!1}),m=yield this.signer.signPsbt(b,this.privateKey),g=this.signer.finalizePsbts([m]);return yield this.transactionBuilder.sendTx(g)}))}static getTransferOpReturnData({chainId:e,appId:t,recipientAddress:r,percentageFee:n,speed:i=0,isExchange:o=!1,exchangeTokenAddress:a="0x0000000000000000000000000000000000000000",outputAmount:s=0,deadline:u,isFixedToken:c=!1}){let f=Number(e).toString(16).padStart(2,"0")+Number(t).toString(16).padStart(4,"0")+r.replace("0x","").toLowerCase().padStart(40,"0")+Number((100*n).toFixed(0)).toString(16).padStart(4,"0")+(i?"01":"00");if(!o){if(52!==f.length)throw new Error("invalid data length");return f}if(f=f+a.replace("0x","").toLowerCase().padStart(40,"0")+Number(s).toString(16).padStart(56,"0")+Number(u).toString(16).padStart(8,"0")+(c?"01":"00"),158!==f.length)throw new Error("invalid data length");return f}static getLendingOpReturnData({chainId:e,appId:t,recipientAddress:r,percentageFee:n,mode:i,isBorrow:o=!1,tokenAddress:a="0x0000000000000000000000000000000000000000",borrowAmount:s=0}){let u=Number(e).toString(16).padStart(2,"0")+Number(t).toString(16).padStart(4,"0")+r.replace("0x","").toLowerCase().padStart(40,"0")+Number((100*n).toFixed(0)).toString(16).padStart(4,"0")+Number(i).toString(16).padStart(2,"0");if(!o){if(52!==u.length)throw new Error("invalid data length");return u}if(u=u+a.replace("0x","").toLowerCase().padStart(40,"0")+Number(s).toString(16).padStart(56,"0"),148!==u.length)throw new Error("invalid data length");return u}}t.TeleportDaoPayment=o,t.default=o},function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},a=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((n=n.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const u=s(r(308)),c=r(131),f=o(r(35));class l extends u.default{constructor(e,t,r=f.networks.bitcoin){super({network:r,testnet:null==t?void 0:t.includes("_testnet"),dustLimit:1e3}),this.btcInterface=new c.BitcoinInterface(e,t)}_getUtxo(e){return a(this,void 0,void 0,(function*(){return(yield this.btcInterface.getAddressesUtxo([e])).map(e=>({hash:e.txId,value:+e.value,index:+e.index}))}))}_getFeeRate(e="normal"){return a(this,void 0,void 0,(function*(){return this.btcInterface.getFeeRate(e)}))}_getTransactionHex(e){return a(this,void 0,void 0,(function*(){return this.btcInterface.provider.getRawTransaction(e)}))}sendTx(e){return a(this,void 0,void 0,(function*(){return yield this.btcInterface.provider.sendRawTransaction(e)}))}}t.default=l},function(e,t,r){"use strict";(function(e){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},a=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const s=o(r(35)),u=r(34),c=r(309),f=r(311),l=r(130),d={bytePerInput:{p2pkh:148,p2wpkh:68,"p2sh-p2wpkh":91,p2tr:65},baseTxBytes:12,bytePerOutput:{p2pkh:34,p2wpkh:31,p2sh:32,p2tr:43,default:35},opReturn:{dataLessThan75:31,dataMoreThan75:91}};t.default=class{constructor({network:e,testnet:t,feeMin:r=0,dustLimit:n,maximumNumberOfOutputsInTransaction:i=50}){this.testnet=t,this.network=e,this.maximumNumberOfOutputsInTransaction=i,this.feeMin=r,this.dustLimit=n||2*d.bytePerInput.p2pkh}_getUtxo(e){return a(this,void 0,void 0,(function*(){throw new Error("Do not call abstract method directly")}))}_getTransactionHex(e){return a(this,void 0,void 0,(function*(){throw new Error("Do not call abstract method directly")}))}createAddressObject(e){return(0,u.createAddressObjectByPublicKey)(e,this.network)}validateAddress(e){try{return(0,u.getAddressType)(e,this.network),!0}catch(e){return!1}}getOpReturnTarget(t){if(!(t.length>0))throw new Error("invalid data in hex");return{script:s.payments.embed({data:[e.from(t,"hex")],network:this.network}).output,value:0}}getExtendedUtxo(e){return a(this,void 0,void 0,(function*(){const t=(yield this._getUtxo(e.address)).map(t=>Object.assign(Object.assign({},t),{signerInfo:e}));if(!t||0===t.length)throw new Error("no utxo found");return t}))}helperHandleInputsAndOutputs({targets:e,extendedUtxo:t,feeRate:r,changeObject:n,selectType:i="normal"}){const o=t.filter(e=>e.value>+r*d.bytePerInput[e.signerInfo.addressType]);let a;switch(i){case"normal":a=c(o,e,Math.round(r));break;case"accumulative":a=l(o,e,Math.round(r));break;case"full":if(!e[0].address)throw new Error;a=f(o,[{address:e[0].address}],Math.round(r))}let{inputs:s,outputs:h,fee:p}=a;s&&h||(s=o,h=e,p=s.reduce((e,t)=>e+t.value,0)-h.reduce((e,t)=>e+t.value,0));const b=s.map(e=>d.bytePerInput[e.signerInfo.addressType]),m=h.map(e=>{if(console.log("r",e),e.address){let t="default";try{t=(0,u.getAddressType)(e.address,this.network)}catch(e){t="default"}return d.bytePerOutput[t]}if(e.script)return e.script.byteLength<75?d.opReturn.dataLessThan75:d.opReturn.dataMoreThan75;let t="default";try{console.log(null==n?void 0:n.address),t=(0,u.getAddressType)((null==n?void 0:n.address)||"",this.network)}catch(e){t="default"}return d.bytePerOutput[t]}),g=(d.baseTxBytes+b.reduce((e,t)=>e+t,0)+m.reduce((e,t)=>e+t,0)+d.bytePerOutput.default)*Math.round(r);if(s.reduce((e,t)=>e+t.value,0)-h.filter(e=>e.address||e.script).reduce((e,t)=>e+t.value,0)-g<1e3){let e=s.reduce((e,t)=>e+t.value,0),t=h.filter(e=>e.address||e.script).reduce((e,t)=>e+t.value,0),r=e-t-g;throw new Error("not enough balance. details: "+JSON.stringify({spendableBalance:e,totalOutputAmount:t,txFee:g,need:r},null,2))}let y,v=p-g,w=h.findIndex(e=>!(null==e?void 0:e.address)&&!e.script&&(e.value||0)>0);if(w>=0||v>1e3){if(w>=0&&(v+=d.bytePerOutput.default*Math.round(r)),v<0&&(v=0),"full"===i)h[0].value=h[0].value+v,p-=v;else{if(!n)throw new Error("change not exist");y={address:n.address,value:w>=0?h[w].value+v:v},p-=v}w>=0&&h.splice(w,1)}return{inputs:s,fee:p,outputs:h,change:y}}filterAndConvertTxDataToStandardFormat({extendedUtxo:e,targets:t,changeObject:r,feeRate:n,selectType:i}){return a(this,void 0,void 0,(function*(){let{inputs:o,outputs:a,change:s,fee:u}=this.helperHandleInputsAndOutputs({targets:t,extendedUtxo:e,feeRate:n,changeObject:r,selectType:i});return{inputs:yield this.convertExtendedUtxoToInputs(o),outputs:a,change:s,fee:u,feeRate:n}}))}convertExtendedUtxoToInputs(t=[]){var r;return a(this,void 0,void 0,(function*(){let n=t,i=null,o=null;for(let t in n){let{address:a,publicKey:s,derivationPath:u,masterFingerprint:c,addressType:f}=n[t].signerInfo,l=this.createAddressObject({publicKey:e.from(s,"hex"),addressType:f});if(u&&c&&l.pubkey&&(n[t].bip32Derivation=[{path:u,pubkey:l.pubkey,masterFingerprint:e.from(c,"hex")}]),"p2pkh"===f)o&&i===n[t].hash||(o=yield this._getTransactionHex(n[t].hash),i=n[t].hash),n[t].nonWitnessUtxo=e.from(o,"hex");else if("p2wpkh"===f){if(!l.output)throw new Error("invalid signer info");n[t].witnessUtxo={script:l.output,value:n[t].value},n[t].signerInfo.includeHex&&(o&&i===n[t].hash||(o=yield this._getTransactionHex(n[t].hash),i=n[t].hash),n[t].nonWitnessUtxo=e.from(o,"hex"))}else if("p2sh-p2wpkh"===f){if(!l.output)throw new Error("invalid signer info");if(n[t].witnessUtxo={script:l.output,value:n[t].value},!(null===(r=null==l?void 0:l.redeem)||void 0===r?void 0:r.output))throw new Error("invalid signer info for p2sh address");n[t].redeemScript=l.redeem.output,n[t].signerInfo.includeHex&&(o&&i===n[t].hash||(o=yield this._getTransactionHex(n[t].hash),i=n[t].hash),n[t].nonWitnessUtxo=e.from(o,"hex"))}else if("p2tr"===f){if(!l.output)throw new Error("invalid signer info");if(n[t].witnessUtxo={script:l.output,value:n[t].value},!l.pubkey)throw new Error("invalid signer info for p2tr address (pubkey)");n[t].tapInternalKey=l.internalPubkey,n[t].signerInfo.includeHex&&(o&&i===n[t].hash||(o=yield this._getTransactionHex(n[t].hash),i=n[t].hash),n[t].nonWitnessUtxo=e.from(o,"hex"))}}return n}))}createUnsignedTransaction({inputs:e,outputs:t,change:r,fee:n,feeRate:i}){const{network:o}=this,a=new s.Psbt({network:o});a.setMaximumFeeRate(+(i+i/100).toFixed());for(const t of e){let{addressType:e}=t.signerInfo;switch(e){case"p2pkh":{let e={hash:t.hash,index:Number(t.index),nonWitnessUtxo:t.nonWitnessUtxo,sequence:4294967294,bip32Derivation:t.bip32Derivation};e.bip32Derivation||delete e.bip32Derivation,a.addInput(e);break}case"p2wpkh":{let e={hash:t.hash,index:Number(t.index),witnessUtxo:t.witnessUtxo,nonWitnessUtxo:t.nonWitnessUtxo,sequence:4294967294,bip32Derivation:t.bip32Derivation};e.bip32Derivation||delete e.bip32Derivation,e.nonWitnessUtxo||delete e.nonWitnessUtxo,a.addInput(e);break}case"p2sh-p2wpkh":{let e={hash:t.hash,index:Number(t.index),witnessUtxo:t.witnessUtxo,nonWitnessUtxo:t.nonWitnessUtxo,redeemScript:t.redeemScript,sequence:4294967294,bip32Derivation:t.bip32Derivation};e.bip32Derivation||delete e.bip32Derivation,e.nonWitnessUtxo||delete e.nonWitnessUtxo,a.addInput(e);break}case"p2tr":{let e={hash:t.hash,index:Number(t.index),witnessUtxo:t.witnessUtxo,nonWitnessUtxo:t.nonWitnessUtxo,tapInternalKey:t.tapInternalKey,sequence:4294967294,bip32Derivation:t.bip32Derivation};e.bip32Derivation||delete e.bip32Derivation,e.nonWitnessUtxo||delete e.nonWitnessUtxo,a.addInput(e);break}default:throw new Error("address type is incorrect")}}for(const e of t)a.addOutput(e);if(r&&0!==Object.keys(r).length&&a.addOutput(r),r&&0!==Object.keys(r).length&&a.txOutputs[t.length].address!==r.address)throw new Error("error change address");return{unsignedTransaction:a.toBase64(),outputs:t,inputs:e.map(e=>({hash:e.hash,value:Number(e.value),index:e.index,signerInfo:e.signerInfo})),fee:n,change:r}}processUnsignedTransaction({extendedUtxo:e,targets:t=[],changeAddress:r,fullAmount:n=!1,feeRate:i,selfTransaction:o=!1,selectType:s="normal"}){return a(this,void 0,void 0,(function*(){if(!o&&0===t.length)throw new Error("no target");let a="string"==typeof r?{address:r}:r;const{inputs:u,outputs:c,change:f,fee:l}=yield this.filterAndConvertTxDataToStandardFormat({extendedUtxo:e,targets:t,changeObject:a,feeRate:i,selectType:n?"full":s});return this.createUnsignedTransaction({inputs:u,outputs:c,change:f,fee:l,feeRate:i})}))}}}).call(this,r(0).Buffer)},function(e,t,r){var n=r(130),i=r(310),o=r(53);function a(e,t){return e.value-t*o.inputBytes(e)}e.exports=function(e,t,r){e=e.concat().sort((function(e,t){return a(t,r)-a(e,r)}));var o=i(e,t,r);return o.inputs?o:n(e,t,r)}},function(e,t,r){var n=r(53);e.exports=function(e,t,r){if(!isFinite(n.uintOrNaN(r)))return{};for(var i=n.transactionBytes([],t),o=0,a=[],s=n.sumOrNaN(t),u=n.dustThreshold({},r),c=0;c<e.length;++c){var f=e[c],l=n.inputBytes(f),d=r*(i+l),h=n.uintOrNaN(f.value);if(!(o+h>s+d+u)&&(i+=l,o+=h,a.push(f),!(o<s+d)))return n.finalize(a,t,r)}return{fee:r*i}}},function(e,t,r){var n=r(53);e.exports=function(e,t,r){if(!isFinite(n.uintOrNaN(r)))return{};var i=n.transactionBytes(e,t),o=r*i;if(0===t.length)return{fee:o};var a=n.sumOrNaN(e)-n.sumForgiving(t)-o;if(!isFinite(a)||a<0)return{fee:o};var s=t.reduce((function(e,t){return e+!isFinite(t.value)}),0);if(0===a&&0===s)return n.finalize(e,t,r);var u=t.reduce((function(e,t){return void 0!==t.value?e:e+1}),0),c=Math.floor(a/u);return t.every((function(e){return void 0!==e.value||c>n.dustThreshold(e,r)}))?(t=t.map((function(e){if(void 0!==e.value)return e;var t={};for(var r in e)t[r]=e[r];return t.value=c,t})),n.finalize(e,t,r)):{fee:o}}},function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},a=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.bitcoin=void 0,t.bitcoin=o(r(313)),a(r(338),t)},function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getApiProvider=t.getRpcProvider=t.ApiProviders=t.RPC=void 0;const s=a(r(314));t.RPC=s.default;const u=o(r(334));t.ApiProviders=u,t.getRpcProvider=function(e){const{url:t,headers:r,auth:n}=e;return new s.default({url:t,headers:r,auth:n})},t.getApiProvider=function(e,t){if(!u[e.provider])throw new Error("provider not supported");let r=!!(null==t?void 0:t.includes("_testnet"));return"NowNodes"===e.provider?new u.NowNodes({token:e.token,timeout:3e4},r):"BlockStream"===e.provider?new u.BlockStream(r,{token:e.token,timeout:3e4}):"MempoolSpace"===e.provider?new u.MempoolSpace(r,{token:e.token,timeout:3e4}):void 0}},function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((n=n.apply(e,t||[])).next())}))};const{getAxiosInstance:i}=r(54);class o{constructor({headers:e,url:t,auth:r}){this.axios=o.getAxiosInstance({baseUrl:t,headers:e,auth:r,timeout:18e4})}static getAxiosInstance(e){return i(e)}static getRpcBody(e,t=[]){return{jsonrpc:"2.0",id:"teleport-dao",method:e,params:t}}getChainInfo(){return n(this,void 0,void 0,(function*(){return(yield this.axios.post("/",o.getRpcBody("getblockchaininfo"))).data.result}))}getLatestBlockNumber(){return n(this,void 0,void 0,(function*(){return(yield this.axios.post("/",o.getRpcBody("getblockcount"))).data.result}))}getBlockHash(e){return n(this,void 0,void 0,(function*(){return(yield this.axios.post("/",o.getRpcBody("getblockhash",[Number(e)]))).data.result}))}getBlockByBlockHash(e,t=1){return n(this,void 0,void 0,(function*(){return(yield this.axios.post("/",o.getRpcBody("getblock",[e,Number(t)]))).data.result}))}getBlockHeaderByBlockHash(e){return n(this,void 0,void 0,(function*(){return(yield this.axios.post("/",o.getRpcBody("getblockheader",[e,!1]))).data.result}))}getBlockByBlockNumber(e,t){return n(this,void 0,void 0,(function*(){return this.getBlockByBlockHash(yield this.getBlockHash(e),t)}))}getTransaction(e){return n(this,void 0,void 0,(function*(){let t=(yield this.axios.post("/",o.getRpcBody("getrawtransaction",[e,!0]))).data.result,r=t.blockhash?yield this.getBlockByBlockHash(t.blockhash):{};return{txId:t.txid,version:t.version,locktime:t.locktime,blockNumber:r.height||null,blockHash:t.blockhash||null,vout:t.vout.map(e=>({address:e.scriptPubKey.address||null,script:e.scriptPubKey.hex,value:Number((1e8*Number(e.value)).toFixed())})),vin:t.vin.map(e=>({txId:e.txid,index:e.vout}))}}))}getRawTransaction(e){return n(this,void 0,void 0,(function*(){return(yield this.axios.post("/",o.getRpcBody("getrawtransaction",[e,!0]))).data.result.hex}))}getTxOutProof(e){return n(this,void 0,void 0,(function*(){return(yield this.axios.post("/",o.getRpcBody("gettxoutproof",[e,!0]))).data.result.hex}))}getBlockTransactionIds(e){return n(this,void 0,void 0,(function*(){return(yield this.getBlockByBlockHash(e)).tx}))}sendRawTransaction(e,t=.1){return n(this,void 0,void 0,(function*(){return(yield this.axios.post("/",o.getRpcBody("sendrawtransaction",[e,t]))).data.result}))}getBlockHeaderHex(e){return n(this,void 0,void 0,(function*(){const t=yield this.getBlockHash(e);return yield this.getBlockHeaderByBlockHash(t)}))}getEstimateFeeByNumberOfBlock(e){return n(this,void 0,void 0,(function*(){return(yield this.axios.post("/",o.getRpcBody("estimatesmartfee",[e,"ECONOMICAL"]))).data.result.feerate*Math.pow(10,5)}))}getFeeRate(e="normal"){return n(this,void 0,void 0,(function*(){let t;switch(e){case"slow":t=yield this.getEstimateFeeByNumberOfBlock(10);break;case"normal":t=yield this.getEstimateFeeByNumberOfBlock(6);break;case"fast":t=yield this.getEstimateFeeByNumberOfBlock(3);break;default:t=yield this.getEstimateFeeByNumberOfBlock(6)}return+t.toFixed()}))}}e.exports=o},function(e,t,r){e.exports=r(316)},function(e,t,r){"use strict";var n=r(6),i=r(132),o=r(317),a=r(139);var s=function e(t){var r=new o(t),s=i(o.prototype.request,r);return n.extend(s,o.prototype,r),n.extend(s,r),s.create=function(r){return e(a(t,r))},s}(r(86));s.Axios=o,s.CanceledError=r(55),s.CancelToken=r(331),s.isCancel=r(138),s.VERSION=r(140).version,s.toFormData=r(135),s.AxiosError=r(32),s.Cancel=s.CanceledError,s.all=function(e){return Promise.all(e)},s.spread=r(332),s.isAxiosError=r(333),e.exports=s,e.exports.default=s},function(e,t,r){"use strict";var n=r(6),i=r(133),o=r(318),a=r(319),s=r(139),u=r(137),c=r(330),f=c.validators;function l(e){this.defaults=e,this.interceptors={request:new o,response:new o}}l.prototype.request=function(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},(t=s(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var r=t.transitional;void 0!==r&&c.assertOptions(r,{silentJSONParsing:f.transitional(f.boolean),forcedJSONParsing:f.transitional(f.boolean),clarifyTimeoutError:f.transitional(f.boolean)},!1);var n=[],i=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(i=i&&e.synchronous,n.unshift(e.fulfilled,e.rejected))}));var o,u=[];if(this.interceptors.response.forEach((function(e){u.push(e.fulfilled,e.rejected)})),!i){var l=[a,void 0];for(Array.prototype.unshift.apply(l,n),l=l.concat(u),o=Promise.resolve(t);l.length;)o=o.then(l.shift(),l.shift());return o}for(var d=t;n.length;){var h=n.shift(),p=n.shift();try{d=h(d)}catch(e){p(e);break}}try{o=a(d)}catch(e){return Promise.reject(e)}for(;u.length;)o=o.then(u.shift(),u.shift());return o},l.prototype.getUri=function(e){e=s(this.defaults,e);var t=u(e.baseURL,e.url);return i(t,e.params,e.paramsSerializer)},n.forEach(["delete","get","head","options"],(function(e){l.prototype[e]=function(t,r){return this.request(s(r||{},{method:e,url:t,data:(r||{}).data}))}})),n.forEach(["post","put","patch"],(function(e){function t(t){return function(r,n,i){return this.request(s(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}l.prototype[e]=t(),l.prototype[e+"Form"]=t(!0)})),e.exports=l},function(e,t,r){"use strict";var n=r(6);function i(){this.handlers=[]}i.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},i.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},i.prototype.forEach=function(e){n.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=i},function(e,t,r){"use strict";var n=r(6),i=r(320),o=r(138),a=r(86),s=r(55);function u(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new s}e.exports=function(e){return u(e),e.headers=e.headers||{},e.data=i.call(e,e.data,e.headers,e.transformRequest),e.headers=n.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),n.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||a.adapter)(e).then((function(t){return u(e),t.data=i.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return o(t)||(u(e),t&&t.response&&(t.response.data=i.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},function(e,t,r){"use strict";var n=r(6),i=r(86);e.exports=function(e,t,r){var o=this||i;return n.forEach(r,(function(r){e=r.call(o,e,t)})),e}},function(e,t,r){"use strict";var n=r(6);e.exports=function(e,t){n.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))}},function(e,t,r){"use strict";var n=r(32);e.exports=function(e,t,r){var i=r.config.validateStatus;r.status&&i&&!i(r.status)?t(new n("Request failed with status code "+r.status,[n.ERR_BAD_REQUEST,n.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):e(r)}},function(e,t,r){"use strict";var n=r(6);e.exports=n.isStandardBrowserEnv()?{write:function(e,t,r,i,o,a){var s=[];s.push(e+"="+encodeURIComponent(t)),n.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),n.isString(i)&&s.push("path="+i),n.isString(o)&&s.push("domain="+o),!0===a&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(e,t,r){"use strict";e.exports=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}},function(e,t,r){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,r){"use strict";var n=r(6),i=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,r,o,a={};return e?(n.forEach(e.split("\n"),(function(e){if(o=e.indexOf(":"),t=n.trim(e.substr(0,o)).toLowerCase(),r=n.trim(e.substr(o+1)),t){if(a[t]&&i.indexOf(t)>=0)return;a[t]="set-cookie"===t?(a[t]?a[t]:[]).concat([r]):a[t]?a[t]+", "+r:r}})),a):a}},function(e,t,r){"use strict";var n=r(6);e.exports=n.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function i(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return e=i(window.location.href),function(t){var r=n.isString(t)?i(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0}},function(e,t,r){"use strict";e.exports=function(e){var t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}},function(e,t){e.exports=null},function(e,t,r){"use strict";var n=r(140).version,i=r(32),o={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){o[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));var a={};o.transitional=function(e,t,r){function o(e,t){return"[Axios v"+n+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return function(r,n,s){if(!1===e)throw new i(o(n," has been removed"+(t?" in "+t:"")),i.ERR_DEPRECATED);return t&&!a[n]&&(a[n]=!0,console.warn(o(n," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,n,s)}},e.exports={assertOptions:function(e,t,r){if("object"!=typeof e)throw new i("options must be an object",i.ERR_BAD_OPTION_VALUE);for(var n=Object.keys(e),o=n.length;o-- >0;){var a=n[o],s=t[a];if(s){var u=e[a],c=void 0===u||s(u,a,e);if(!0!==c)throw new i("option "+a+" must be "+c,i.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new i("Unknown option "+a,i.ERR_BAD_OPTION)}},validators:o}},function(e,t,r){"use strict";var n=r(55);function i(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var r=this;this.promise.then((function(e){if(r._listeners){var t,n=r._listeners.length;for(t=0;t<n;t++)r._listeners[t](e);r._listeners=null}})),this.promise.then=function(e){var t,n=new Promise((function(e){r.subscribe(e),t=e})).then(e);return n.cancel=function(){r.unsubscribe(t)},n},e((function(e){r.reason||(r.reason=new n(e),t(r.reason))}))}i.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},i.prototype.subscribe=function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]},i.prototype.unsubscribe=function(e){if(this._listeners){var t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}},i.source=function(){var e;return{token:new i((function(t){e=t})),cancel:e}},e.exports=i},function(e,t,r){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},function(e,t,r){"use strict";var n=r(6);e.exports=function(e){return n.isObject(e)&&!0===e.isAxiosError}},function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.MempoolSpace=t.NowNodes=t.BlockStream=void 0;const i=n(r(335));t.BlockStream=i.default;const o=n(r(336));t.MempoolSpace=o.default;const a=n(r(337));t.NowNodes=a.default},function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=i(r(141));class a extends o.default{constructor(e=!1,t){super(e?"https://blockstream.info/testnet/api":"https://blockstream.info/api")}getRecommendedFeeRate(e="normal"){return n(this,void 0,void 0,(function*(){throw new Error("not supported")}))}}t.default=a},function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=n(r(141));class o extends i.default{constructor(e=!1,t){super(e?"https://mempool.space/testnet/api":"https://mempool.space/api")}}t.default=o},function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((n=n.apply(e,t||[])).next())}))};const{getAxiosInstance:i}=r(54);e.exports=class{constructor({token:e,timeout:t=3e4},r=!1){this.baseURL=r?"https://btcbook-testnet.nownodes.io/":"https://btcbook.nownodes.io/",this.axios=i({baseUrl:this.baseURL,timeout:t,headers:{"api-key":e}})}getUtxos(e){return n(this,void 0,void 0,(function*(){return(yield this.axios.get("/api/v2/utxo/"+e)).data.map(t=>({address:e,txId:t.txid,index:t.vout,value:Number(t.value),blockNumber:+t.height}))}))}}},function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.TeleportDao=void 0;const i=r(54);class o{constructor(e){const t=e.includes("testnet")?"https://testnet.api.teleportdao.xyz/api/v1":"https://api.teleportdao.xyz/api/v1";this.api=(0,i.getAxiosInstance)({baseUrl:t,headers:{},timeout:18e4})}getLockers(e){return n(this,void 0,void 0,(function*(){return(yield this.api.get("/teleswap/lockers",{params:{network:e}})).data.data.lockers}))}}t.TeleportDao=o,t.default=o},function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getAxiosInstance=t.getRandomInteger=t.runWithRetries=t.sleep=void 0;const o=i(r(340));function a(e){return new Promise(t=>setTimeout(t,e))}t.sleep=a,t.runWithRetries=function(e,t={maxTries:2,retrySleep:1e3}){return n(this,void 0,void 0,(function*(){const r=t.maxTries||2,n=t.retrySleep||1e3;let i;for(let t=0;t<r;t+=1){try{return yield e()}catch(e){i=e}yield a(n)}throw i||new Error("function failed after retries")}))},t.getRandomInteger=function(e,t){return Math.floor(Math.random()*(t-e))+e},t.getAxiosInstance=function({baseUrl:e,timeout:t=1e4,headers:r={},auth:n}){let i,a=e;return i=o.default.create({baseURL:a,timeout:t,auth:n,headers:Object.assign({},r)}),i.interceptors.response.use(e=>e,e=>{if(e.response){const t=new Error(JSON.stringify({data:e.response.data,message:e.message}));return Promise.reject(t)}if(e.request){const t=new Error(e.message);return Promise.reject(t)}return Promise.reject(e)}),i}},function(e,t,r){e.exports=r(341)},function(e,t,r){"use strict";var n=r(7),i=r(142),o=r(342),a=r(149);var s=function e(t){var r=new o(t),s=i(o.prototype.request,r);return n.extend(s,o.prototype,r),n.extend(s,r),s.create=function(r){return e(a(t,r))},s}(r(87));s.Axios=o,s.CanceledError=r(56),s.CancelToken=r(356),s.isCancel=r(148),s.VERSION=r(150).version,s.toFormData=r(145),s.AxiosError=r(33),s.Cancel=s.CanceledError,s.all=function(e){return Promise.all(e)},s.spread=r(357),s.isAxiosError=r(358),e.exports=s,e.exports.default=s},function(e,t,r){"use strict";var n=r(7),i=r(143),o=r(343),a=r(344),s=r(149),u=r(147),c=r(355),f=c.validators;function l(e){this.defaults=e,this.interceptors={request:new o,response:new o}}l.prototype.request=function(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},(t=s(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var r=t.transitional;void 0!==r&&c.assertOptions(r,{silentJSONParsing:f.transitional(f.boolean),forcedJSONParsing:f.transitional(f.boolean),clarifyTimeoutError:f.transitional(f.boolean)},!1);var n=[],i=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(i=i&&e.synchronous,n.unshift(e.fulfilled,e.rejected))}));var o,u=[];if(this.interceptors.response.forEach((function(e){u.push(e.fulfilled,e.rejected)})),!i){var l=[a,void 0];for(Array.prototype.unshift.apply(l,n),l=l.concat(u),o=Promise.resolve(t);l.length;)o=o.then(l.shift(),l.shift());return o}for(var d=t;n.length;){var h=n.shift(),p=n.shift();try{d=h(d)}catch(e){p(e);break}}try{o=a(d)}catch(e){return Promise.reject(e)}for(;u.length;)o=o.then(u.shift(),u.shift());return o},l.prototype.getUri=function(e){e=s(this.defaults,e);var t=u(e.baseURL,e.url);return i(t,e.params,e.paramsSerializer)},n.forEach(["delete","get","head","options"],(function(e){l.prototype[e]=function(t,r){return this.request(s(r||{},{method:e,url:t,data:(r||{}).data}))}})),n.forEach(["post","put","patch"],(function(e){function t(t){return function(r,n,i){return this.request(s(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}l.prototype[e]=t(),l.prototype[e+"Form"]=t(!0)})),e.exports=l},function(e,t,r){"use strict";var n=r(7);function i(){this.handlers=[]}i.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},i.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},i.prototype.forEach=function(e){n.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=i},function(e,t,r){"use strict";var n=r(7),i=r(345),o=r(148),a=r(87),s=r(56);function u(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new s}e.exports=function(e){return u(e),e.headers=e.headers||{},e.data=i.call(e,e.data,e.headers,e.transformRequest),e.headers=n.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),n.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||a.adapter)(e).then((function(t){return u(e),t.data=i.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return o(t)||(u(e),t&&t.response&&(t.response.data=i.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},function(e,t,r){"use strict";var n=r(7),i=r(87);e.exports=function(e,t,r){var o=this||i;return n.forEach(r,(function(r){e=r.call(o,e,t)})),e}},function(e,t,r){"use strict";var n=r(7);e.exports=function(e,t){n.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))}},function(e,t,r){"use strict";var n=r(33);e.exports=function(e,t,r){var i=r.config.validateStatus;r.status&&i&&!i(r.status)?t(new n("Request failed with status code "+r.status,[n.ERR_BAD_REQUEST,n.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):e(r)}},function(e,t,r){"use strict";var n=r(7);e.exports=n.isStandardBrowserEnv()?{write:function(e,t,r,i,o,a){var s=[];s.push(e+"="+encodeURIComponent(t)),n.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),n.isString(i)&&s.push("path="+i),n.isString(o)&&s.push("domain="+o),!0===a&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(e,t,r){"use strict";e.exports=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}},function(e,t,r){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,r){"use strict";var n=r(7),i=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,r,o,a={};return e?(n.forEach(e.split("\n"),(function(e){if(o=e.indexOf(":"),t=n.trim(e.substr(0,o)).toLowerCase(),r=n.trim(e.substr(o+1)),t){if(a[t]&&i.indexOf(t)>=0)return;a[t]="set-cookie"===t?(a[t]?a[t]:[]).concat([r]):a[t]?a[t]+", "+r:r}})),a):a}},function(e,t,r){"use strict";var n=r(7);e.exports=n.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function i(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return e=i(window.location.href),function(t){var r=n.isString(t)?i(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0}},function(e,t,r){"use strict";e.exports=function(e){var t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}},function(e,t){e.exports=null},function(e,t,r){"use strict";var n=r(150).version,i=r(33),o={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){o[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));var a={};o.transitional=function(e,t,r){function o(e,t){return"[Axios v"+n+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return function(r,n,s){if(!1===e)throw new i(o(n," has been removed"+(t?" in "+t:"")),i.ERR_DEPRECATED);return t&&!a[n]&&(a[n]=!0,console.warn(o(n," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,n,s)}},e.exports={assertOptions:function(e,t,r){if("object"!=typeof e)throw new i("options must be an object",i.ERR_BAD_OPTION_VALUE);for(var n=Object.keys(e),o=n.length;o-- >0;){var a=n[o],s=t[a];if(s){var u=e[a],c=void 0===u||s(u,a,e);if(!0!==c)throw new i("option "+a+" must be "+c,i.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new i("Unknown option "+a,i.ERR_BAD_OPTION)}},validators:o}},function(e,t,r){"use strict";var n=r(56);function i(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var r=this;this.promise.then((function(e){if(r._listeners){var t,n=r._listeners.length;for(t=0;t<n;t++)r._listeners[t](e);r._listeners=null}})),this.promise.then=function(e){var t,n=new Promise((function(e){r.subscribe(e),t=e})).then(e);return n.cancel=function(){r.unsubscribe(t)},n},e((function(e){r.reason||(r.reason=new n(e),t(r.reason))}))}i.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},i.prototype.subscribe=function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]},i.prototype.unsubscribe=function(e){if(this._listeners){var t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}},i.source=function(){var e;return{token:new i((function(t){e=t})),cancel:e}},e.exports=i},function(e,t,r){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},function(e,t,r){"use strict";var n=r(7);e.exports=function(e){return n.isObject(e)&&!0===e.isAxiosError}},function(e,t,r){"use strict";const{requestTypes:n}=r(151).teleswap,{BigNumber:i}=r(369);function o(e){let t="4c"===e.slice(2,4)?e.slice(6):e.slice(4),r=(Number("0x"+t.slice(0,2)),t.slice(2,6));if(!r)return{status:!1,message:"invalid OP_RETURN data : "+t,code:"INVALID_APP_ID"};let o=Number("0x"+r);switch(Object.keys(n).find(e=>o>=n[e].appIdRange[0]&&o<=n[e].appIdRange[1])){case"transfer":case"exchange":return function(e){let t={requestType:"transfer"},r=0;return t.chainId=Number("0x"+e.slice(r,r+=2)),t.appId=Number("0x"+e.slice(r,r+=4)),t.recipientAddress="0x"+e.slice(r,r+=40),t.percentageFee=Number("0x"+e.slice(r,r+=4))/100,t.speed="01"===e.slice(r,r+=2),e.length===r?{status:!0,data:t}:(t.requestType="exchange",t.exchangeTokenAddress="0x"+e.slice(r,r+=40),t.outputAmount=new i("0x"+e.slice(r,r+=56)).toFixed(),t.deadline=new i("0x"+e.slice(r,r+=8)).toFixed(),t.isFixedToken="01"===e.slice(r,r+=2),e.length===r?{status:!0,data:t}:{status:!1,message:`invalid OP_RETURN data for requestType: 'transfer or exchange'. invalid data length : ${e.length} - valid length : ${r}`,code:"INVALID_OP_RETURN"})}(t);case"lend":return function(e){let t={requestType:"lend"},r=0;return t.chainId=Number("0x"+e.slice(r,r+=2)),t.appId=Number("0x"+e.slice(r,r+=4)),t.recipientAddress="0x"+e.slice(r,r+=40),t.percentageFee=Number("0x"+e.slice(r,r+=4))/100,t.mode=Number("0x"+e.slice(r,r+=2)),e.length===r?{status:!0,data:t}:(t.requestType="borrow",t.tokenAddress="0x"+e.slice(r,r+=40),t.borrowAmount=Number("0x"+e.slice(r,r+=56)),e.length===r?{status:!0,data:t}:{status:!1,message:`invalid OP_RETURN data for requestType: 'lend or borrow'. invalid data length : ${e.length} - valid length : ${r}`,code:"INVALID_OP_RETURN"})}(t);default:return{status:!1,message:"invalid appId : "+o,code:"INVALID_OP_RETURN"}}}e.exports={checkAndParseProtocolRequest:function(e,t,r={minTeleporterFeeAmount:0}){var n,i;let a=e.findIndex(e=>e.script.startsWith("6a"));if(a>=0){let s=(null===(n=e[a])||void 0===n?void 0:n.script)||null,u=(null===(i=e.findIndex(e=>e.address===t))||void 0===i?void 0:i.value)||0,c=u>=0&&e[u].value||0,f=o(s);return f.status?function(e,t,r,n,{minTeleporterFeeAmount:i=0}){return e?+e.percentageFee>100?{status:!1,message:"percentageFee greater than 100 is invalid. percentageFee: "+e.percentageFee,code:"INVALID_FEE"}:e.percentageFee/100*+r<=i?{status:!1,message:`fee amount is less than or equal minimum teleporter fee amount.percentageFee: ${e.percentageFee} - value: ${r} - feeAmount ${(e.percentageFee/100*+r).toFixed(8)} - minimumFee: ${i}`,code:"NOT_ACCEPTED_BY_TELEPORTER"}:{status:!0,data:e,requestOutputIndex:t,value:r,valueOutputIndex:n}:{status:!1,message:"no data to validate. it should not happen",code:"NOT_ACCEPTED_BY_TELEPORTER"}}(f.data,a,c,u,r):f}return{status:!1,message:"transaction outputs should contain OP_RETURN",code:"NO_OP_RETURN"}}}},function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)},a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.otherTokens=void 0,o(r(361),t),o(r(362),t),t.otherTokens=a(r(363))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.chainInfo=void 0,t.chainInfo={ethereum:{name:"ethereum",chainId:1},ethereum_testnet:{name:"goerli",chainId:3},bsc:{name:"binance_smart_chain",chainId:56},bsc_testnet:{name:"binance_smart_chain_testnet",chainId:97},polygon:{name:"polygon",chainId:137},polygon_testnet:{name:"mumbai",chainId:137}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.hdWalletPath=void 0,t.hdWalletPath={bitcoin:{p2pkh:"m/44'/0'/0'",p2wpkh:"m/84'/0'/0'","p2sh-p2wpkh":"m/49'/0'/0'",p2sh:"m/80'/0'/0'",p2wsh:"m/85'/0'/0'","p2sh-p2wsh":"m/90'/0'/0'",p2tr:"m/84'/0'/0'"},ethereum:"m/44'/60'/0'"}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bsc=t.polygon=void 0,t.polygon={mainnet:{DAIAddress:"0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",USDTAddress:"0xc2132D05D31c914a87C6611C10748AEb04B58e8F",USDCAddress:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",WBTCAddress:"0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6",SANDAddress:"0xBbba073C31bF03b8ACf7c28EF0738DeCF3695683",WBNBAddress:"",WETHAddress:"0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",WMATICAddress:"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270"},testnet:{WMATICAddress:"0x9c3c9283d3e44854697cd22d3faa240cfb032889"}},t.bsc={mainnet:{USDTAddress:"0x55d398326f99059fF775485246999027B3197955",USDCAddress:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",WBNBAddress:"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",WETHAddress:"0x5DA5DA6933637c1cAfa5de9FdF2aCb1B3758C9e3"},testnet:{USDTAddress:"",USDCAddress:"",WBNBAddress:"0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd",WETHAddress:"0xd66c6B4F0be8CE5b39D52E0Fd1344c389929B378"}}},function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.tokensInfo=t.contractsInfo=t.requestTypes=t.bitcoinAddressTypes=void 0;var s=r(365);Object.defineProperty(t,"bitcoinAddressTypes",{enumerable:!0,get:function(){return s.addressTypeHelper}});var u=r(366);Object.defineProperty(t,"requestTypes",{enumerable:!0,get:function(){return a(u).default}}),t.contractsInfo=o(r(367)),t.tokensInfo=o(r(368))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addressTypeHelper=void 0,t.addressTypeHelper={addressTypesNumber:{p2pk:0,p2pkh:1,p2sh:2,p2wpkh:3,p2wsh:4,p2tr:5},addressTypes:["p2pk","p2pkh","p2sh","p2wpkh","p2wsh","p2tr"]},t.default=t.addressTypeHelper},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default={transfer:{appIdRange:[1,1],default:1},exchange:{appIdRange:[10,30],default:20},lend:{appIdRange:[100,200],default:100}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bsc=t.polygon=void 0,t.polygon={mainnet:{exchangeConnectorAddress:"0x0C28968d8A3Af022F47D493402D35Cb42EFF0597",exchangeFactoryAddress:"0x5757371414417b8C6CAad45bAeF941aBc7d3Ab32",exchangeRouterAddress:"0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff",priceOracleAddress:"0x96b76ab42289688b68882cdccd071b2c39b0165e",relayAddress:"0x7DeB66341b1d499D7e699589d0cf665De4132EA3",lendingAddress:"",ccTransferAddress:"0x04367D74332137908BEF9acc0Ab00a299A823707",ccExchangeAddress:"0xD1E9Ff33EC28f9Dd8D99E685a2B0F29dCaa095a3",ccBurnAddress:"0x0009876C47F6b2f0BCB41eb9729736757486c75f",lockerAddress:"0xf5D6D369A7F4147F720AEAdd4C4f903aE8046166"},testnet:{exchangeConnectorAddress:"0x0C28968d8A3Af022F47D493402D35Cb42EFF0597",exchangeFactoryAddress:"0x5757371414417b8C6CAad45bAeF941aBc7d3Ab32",exchangeRouterAddress:"0x8954AfA98594b838bda56FE4C12a09D7739D179b",priceOracleAddress:"0x96B76aB42289688b68882CDcCd071B2C39b0165E",relayAddress:"0x5b845e3EB38d78cD5006C04b0Bc78692b5535F56",lendingAddress:"",ccTransferAddress:"0xbD97529bB755ac4f17e3Ef648b6230d3e93F84F0",ccExchangeAddress:"0x9D35634aBF331204CAd28BF9c37B49792A1E69e3",ccBurnAddress:"0x4779BB3c43C86baf60f7b30e0e19872B7d90ae7f",lockerAddress:"0xf5D6D369A7F4147F720AEAdd4C4f903aE8046166"}},t.bsc={mainnet:{exchangeConnectorAddress:"0x856D80F77349F675Ea7E3477aD75Ef57349e777b",exchangeFactoryAddress:"0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73",exchangeRouterAddress:"0x10ED43C718714eb63d5aA57B78B54704E256024E",priceOracleAddress:"0x7Aabb0779782247384A1C91844211516E93b1D63",relayAddress:"0xFcd688999c25D5493571543137cEeb4fbDb44D02",lendingAddress:"",ccTransferAddress:"0xA38aD0d52B89C20c2229E916358D2CeB45BeC5FF",ccExchangeAddress:"0xcA5416364720c7324A547d39b1db496A2DCd4F0D",ccBurnAddress:"0x2787D48e0B74125597DD479978a5DE09Bb9a3C15",lockerAddress:"0x84F74e97ebab432CeE185d601290cE0A483987A5"},testnet:{exchangeConnectorAddress:"0xF789b50D17CF214d5774ce1a52Fb6581d72118fE",exchangeFactoryAddress:"0xB7926C0430Afb07AA7DEfDE6DA862aE0Bde767bc",exchangeRouterAddress:"0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3",priceOracleAddress:"0xF364F92D5d0D4Ee173983da8b74e2eB1D7A319D2",relayAddress:"0x66840C47684338216fE0498CFd649186D662d8a0",lendingAddress:"",ccTransferAddress:"0x699Ab6dE8791B9E895Afa5B1e36a6F8F64294D0a",ccExchangeAddress:"0xA029A35027233C4640A815D3574f36f652A47C41",ccBurnAddress:"0x090aB5B43F440700F8E73fB822f81cAbE82fd05B",lockerAddress:"0xba44564920f2c5b69C7729FFd465b3095e08Ea35"}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bsc=t.polygon=void 0,t.polygon={mainnet:{teleBTCAddress:"0x3BF668Fe1ec79a84cA8481CEAD5dbb30d61cC685"},testnet:{teleBTCAddress:"0x515D720B9D219f1931205D5B8D842bE1Fe2FeBDE"}},t.bsc={mainnet:{teleBTCAddress:"0xC58C1117DA964aEbe91fEF88f6f5703e79bdA574"},testnet:{teleBTCAddress:"0x2dC0a21691a3A0B8ED353Bf43f964966e2a65Cfd"}}},function(e,t,r){var n;!function(i){"use strict";var o,a=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,s=Math.ceil,u=Math.floor,c="[BigNumber Error] ",f=c+"Number primitive has more than 15 significant digits: ",l=1e14,d=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],h=1e9;function p(e){var t=0|e;return e>0||e===t?t:t-1}function b(e){for(var t,r,n=1,i=e.length,o=e[0]+"";n<i;){for(r=14-(t=e[n++]+"").length;r--;t="0"+t);o+=t}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function m(e,t){var r,n,i=e.c,o=t.c,a=e.s,s=t.s,u=e.e,c=t.e;if(!a||!s)return null;if(r=i&&!i[0],n=o&&!o[0],r||n)return r?n?0:-s:a;if(a!=s)return a;if(r=a<0,n=u==c,!i||!o)return n?0:!i^r?1:-1;if(!n)return u>c^r?1:-1;for(s=(u=i.length)<(c=o.length)?u:c,a=0;a<s;a++)if(i[a]!=o[a])return i[a]>o[a]^r?1:-1;return u==c?0:u>c^r?1:-1}function g(e,t,r,n){if(e<t||e>r||e!==u(e))throw Error(c+(n||"Argument")+("number"==typeof e?e<t||e>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function y(e){var t=e.c.length-1;return p(e.e/14)==t&&e.c[t]%2!=0}function v(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function w(e,t,r){var n,i;if(t<0){for(i=r+".";++t;i+=r);e=i+e}else if(++t>(n=e.length)){for(i=r,t-=n;--t;i+=r);e+=i}else t<n&&(e=e.slice(0,t)+"."+e.slice(t));return e}(o=function e(t){var r,n,i,o,_,E,k,S,x,T=L.prototype={constructor:L,toString:null,valueOf:null},A=new L(1),P=20,O=4,I=-7,B=21,M=-1e7,R=1e7,N=!1,j=1,U=0,C={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},H="0123456789abcdefghijklmnopqrstuvwxyz",z=!0;function L(e,t){var r,o,s,c,l,d,h,p,b=this;if(!(b instanceof L))return new L(e,t);if(null==t){if(e&&!0===e._isBigNumber)return b.s=e.s,void(!e.c||e.e>R?b.c=b.e=null:e.e<M?b.c=[b.e=0]:(b.e=e.e,b.c=e.c.slice()));if((d="number"==typeof e)&&0*e==0){if(b.s=1/e<0?(e=-e,-1):1,e===~~e){for(c=0,l=e;l>=10;l/=10,c++);return void(c>R?b.c=b.e=null:(b.e=c,b.c=[e]))}p=String(e)}else{if(!a.test(p=String(e)))return i(b,p,d);b.s=45==p.charCodeAt(0)?(p=p.slice(1),-1):1}(c=p.indexOf("."))>-1&&(p=p.replace(".","")),(l=p.search(/e/i))>0?(c<0&&(c=l),c+=+p.slice(l+1),p=p.substring(0,l)):c<0&&(c=p.length)}else{if(g(t,2,H.length,"Base"),10==t&&z)return K(b=new L(e),P+b.e+1,O);if(p=String(e),d="number"==typeof e){if(0*e!=0)return i(b,p,d,t);if(b.s=1/e<0?(p=p.slice(1),-1):1,L.DEBUG&&p.replace(/^0\.0*|\./,"").length>15)throw Error(f+e)}else b.s=45===p.charCodeAt(0)?(p=p.slice(1),-1):1;for(r=H.slice(0,t),c=l=0,h=p.length;l<h;l++)if(r.indexOf(o=p.charAt(l))<0){if("."==o){if(l>c){c=h;continue}}else if(!s&&(p==p.toUpperCase()&&(p=p.toLowerCase())||p==p.toLowerCase()&&(p=p.toUpperCase()))){s=!0,l=-1,c=0;continue}return i(b,String(e),d,t)}d=!1,(c=(p=n(p,t,10,b.s)).indexOf("."))>-1?p=p.replace(".",""):c=p.length}for(l=0;48===p.charCodeAt(l);l++);for(h=p.length;48===p.charCodeAt(--h););if(p=p.slice(l,++h)){if(h-=l,d&&L.DEBUG&&h>15&&(e>9007199254740991||e!==u(e)))throw Error(f+b.s*e);if((c=c-l-1)>R)b.c=b.e=null;else if(c<M)b.c=[b.e=0];else{if(b.e=c,b.c=[],l=(c+1)%14,c<0&&(l+=14),l<h){for(l&&b.c.push(+p.slice(0,l)),h-=14;l<h;)b.c.push(+p.slice(l,l+=14));l=14-(p=p.slice(l)).length}else l-=h;for(;l--;p+="0");b.c.push(+p)}}else b.c=[b.e=0]}function D(e,t,r,n){var i,o,a,s,u;if(null==r?r=O:g(r,0,8),!e.c)return e.toString();if(i=e.c[0],a=e.e,null==t)u=b(e.c),u=1==n||2==n&&(a<=I||a>=B)?v(u,a):w(u,a,"0");else if(o=(e=K(new L(e),t,r)).e,s=(u=b(e.c)).length,1==n||2==n&&(t<=o||o<=I)){for(;s<t;u+="0",s++);u=v(u,o)}else if(t-=a,u=w(u,o,"0"),o+1>s){if(--t>0)for(u+=".";t--;u+="0");}else if((t+=o-s)>0)for(o+1==s&&(u+=".");t--;u+="0");return e.s<0&&i?"-"+u:u}function F(e,t){for(var r,n=1,i=new L(e[0]);n<e.length;n++){if(!(r=new L(e[n])).s){i=r;break}t.call(i,r)&&(i=r)}return i}function q(e,t,r){for(var n=1,i=t.length;!t[--i];t.pop());for(i=t[0];i>=10;i/=10,n++);return(r=n+14*r-1)>R?e.c=e.e=null:r<M?e.c=[e.e=0]:(e.e=r,e.c=t),e}function K(e,t,r,n){var i,o,a,c,f,h,p,b=e.c,m=d;if(b){e:{for(i=1,c=b[0];c>=10;c/=10,i++);if((o=t-i)<0)o+=14,a=t,p=(f=b[h=0])/m[i-a-1]%10|0;else if((h=s((o+1)/14))>=b.length){if(!n)break e;for(;b.length<=h;b.push(0));f=p=0,i=1,a=(o%=14)-14+1}else{for(f=c=b[h],i=1;c>=10;c/=10,i++);p=(a=(o%=14)-14+i)<0?0:f/m[i-a-1]%10|0}if(n=n||t<0||null!=b[h+1]||(a<0?f:f%m[i-a-1]),n=r<4?(p||n)&&(0==r||r==(e.s<0?3:2)):p>5||5==p&&(4==r||n||6==r&&(o>0?a>0?f/m[i-a]:0:b[h-1])%10&1||r==(e.s<0?8:7)),t<1||!b[0])return b.length=0,n?(t-=e.e+1,b[0]=m[(14-t%14)%14],e.e=-t||0):b[0]=e.e=0,e;if(0==o?(b.length=h,c=1,h--):(b.length=h+1,c=m[14-o],b[h]=a>0?u(f/m[i-a]%m[a])*c:0),n)for(;;){if(0==h){for(o=1,a=b[0];a>=10;a/=10,o++);for(a=b[0]+=c,c=1;a>=10;a/=10,c++);o!=c&&(e.e++,b[0]==l&&(b[0]=1));break}if(b[h]+=c,b[h]!=l)break;b[h--]=0,c=1}for(o=b.length;0===b[--o];b.pop());}e.e>R?e.c=e.e=null:e.e<M&&(e.c=[e.e=0])}return e}function W(e){var t,r=e.e;return null===r?e.toString():(t=b(e.c),t=r<=I||r>=B?v(t,r):w(t,r,"0"),e.s<0?"-"+t:t)}return L.clone=e,L.ROUND_UP=0,L.ROUND_DOWN=1,L.ROUND_CEIL=2,L.ROUND_FLOOR=3,L.ROUND_HALF_UP=4,L.ROUND_HALF_DOWN=5,L.ROUND_HALF_EVEN=6,L.ROUND_HALF_CEIL=7,L.ROUND_HALF_FLOOR=8,L.EUCLID=9,L.config=L.set=function(e){var t,r;if(null!=e){if("object"!=typeof e)throw Error(c+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(g(r=e[t],0,h,t),P=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(g(r=e[t],0,8,t),O=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((r=e[t])&&r.pop?(g(r[0],-h,0,t),g(r[1],0,h,t),I=r[0],B=r[1]):(g(r,-h,h,t),I=-(B=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if((r=e[t])&&r.pop)g(r[0],-h,-1,t),g(r[1],1,h,t),M=r[0],R=r[1];else{if(g(r,-h,h,t),!r)throw Error(c+t+" cannot be zero: "+r);M=-(R=r<0?-r:r)}if(e.hasOwnProperty(t="CRYPTO")){if((r=e[t])!==!!r)throw Error(c+t+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw N=!r,Error(c+"crypto unavailable");N=r}else N=r}if(e.hasOwnProperty(t="MODULO_MODE")&&(g(r=e[t],0,9,t),j=r),e.hasOwnProperty(t="POW_PRECISION")&&(g(r=e[t],0,h,t),U=r),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(r=e[t]))throw Error(c+t+" not an object: "+r);C=r}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(r=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(c+t+" invalid: "+r);z="0123456789"==r.slice(0,10),H=r}}return{DECIMAL_PLACES:P,ROUNDING_MODE:O,EXPONENTIAL_AT:[I,B],RANGE:[M,R],CRYPTO:N,MODULO_MODE:j,POW_PRECISION:U,FORMAT:C,ALPHABET:H}},L.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!L.DEBUG)return!0;var t,r,n=e.c,i=e.e,o=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===o||-1===o)&&i>=-h&&i<=h&&i===u(i)){if(0===n[0]){if(0===i&&1===n.length)return!0;break e}if((t=(i+1)%14)<1&&(t+=14),String(n[0]).length==t){for(t=0;t<n.length;t++)if((r=n[t])<0||r>=l||r!==u(r))break e;if(0!==r)return!0}}}else if(null===n&&null===i&&(null===o||1===o||-1===o))return!0;throw Error(c+"Invalid BigNumber: "+e)},L.maximum=L.max=function(){return F(arguments,T.lt)},L.minimum=L.min=function(){return F(arguments,T.gt)},L.random=(o=9007199254740992*Math.random()&2097151?function(){return u(9007199254740992*Math.random())}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,r,n,i,a,f=0,l=[],p=new L(A);if(null==e?e=P:g(e,0,h),i=s(e/14),N)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(i*=2));f<i;)(a=131072*t[f]+(t[f+1]>>>11))>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),t[f]=r[0],t[f+1]=r[1]):(l.push(a%1e14),f+=2);f=i/2}else{if(!crypto.randomBytes)throw N=!1,Error(c+"crypto unavailable");for(t=crypto.randomBytes(i*=7);f<i;)(a=281474976710656*(31&t[f])+1099511627776*t[f+1]+4294967296*t[f+2]+16777216*t[f+3]+(t[f+4]<<16)+(t[f+5]<<8)+t[f+6])>=9e15?crypto.randomBytes(7).copy(t,f):(l.push(a%1e14),f+=7);f=i/7}if(!N)for(;f<i;)(a=o())<9e15&&(l[f++]=a%1e14);for(e%=14,(i=l[--f])&&e&&(a=d[14-e],l[f]=u(i/a)*a);0===l[f];l.pop(),f--);if(f<0)l=[n=0];else{for(n=-1;0===l[0];l.splice(0,1),n-=14);for(f=1,a=l[0];a>=10;a/=10,f++);f<14&&(n-=14-f)}return p.e=n,p.c=l,p}),L.sum=function(){for(var e=1,t=arguments,r=new L(t[0]);e<t.length;)r=r.plus(t[e++]);return r},n=function(){function e(e,t,r,n){for(var i,o,a=[0],s=0,u=e.length;s<u;){for(o=a.length;o--;a[o]*=t);for(a[0]+=n.indexOf(e.charAt(s++)),i=0;i<a.length;i++)a[i]>r-1&&(null==a[i+1]&&(a[i+1]=0),a[i+1]+=a[i]/r|0,a[i]%=r)}return a.reverse()}return function(t,n,i,o,a){var s,u,c,f,l,d,h,p,m=t.indexOf("."),g=P,y=O;for(m>=0&&(f=U,U=0,t=t.replace(".",""),d=(p=new L(n)).pow(t.length-m),U=f,p.c=e(w(b(d.c),d.e,"0"),10,i,"0123456789"),p.e=p.c.length),c=f=(h=e(t,n,i,a?(s=H,"0123456789"):(s="0123456789",H))).length;0==h[--f];h.pop());if(!h[0])return s.charAt(0);if(m<0?--c:(d.c=h,d.e=c,d.s=o,h=(d=r(d,p,g,y,i)).c,l=d.r,c=d.e),m=h[u=c+g+1],f=i/2,l=l||u<0||null!=h[u+1],l=y<4?(null!=m||l)&&(0==y||y==(d.s<0?3:2)):m>f||m==f&&(4==y||l||6==y&&1&h[u-1]||y==(d.s<0?8:7)),u<1||!h[0])t=l?w(s.charAt(1),-g,s.charAt(0)):s.charAt(0);else{if(h.length=u,l)for(--i;++h[--u]>i;)h[u]=0,u||(++c,h=[1].concat(h));for(f=h.length;!h[--f];);for(m=0,t="";m<=f;t+=s.charAt(h[m++]));t=w(t,c,s.charAt(0))}return t}}(),r=function(){function e(e,t,r){var n,i,o,a,s=0,u=e.length,c=t%1e7,f=t/1e7|0;for(e=e.slice();u--;)s=((i=c*(o=e[u]%1e7)+(n=f*o+(a=e[u]/1e7|0)*c)%1e7*1e7+s)/r|0)+(n/1e7|0)+f*a,e[u]=i%r;return s&&(e=[s].concat(e)),e}function t(e,t,r,n){var i,o;if(r!=n)o=r>n?1:-1;else for(i=o=0;i<r;i++)if(e[i]!=t[i]){o=e[i]>t[i]?1:-1;break}return o}function r(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]<t[r]?1:0,e[r]=i*n+e[r]-t[r];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(n,i,o,a,s){var c,f,d,h,b,m,g,y,v,w,_,E,k,S,x,T,A,P=n.s==i.s?1:-1,O=n.c,I=i.c;if(!(O&&O[0]&&I&&I[0]))return new L(n.s&&i.s&&(O?!I||O[0]!=I[0]:I)?O&&0==O[0]||!I?0*P:P/0:NaN);for(v=(y=new L(P)).c=[],P=o+(f=n.e-i.e)+1,s||(s=l,f=p(n.e/14)-p(i.e/14),P=P/14|0),d=0;I[d]==(O[d]||0);d++);if(I[d]>(O[d]||0)&&f--,P<0)v.push(1),h=!0;else{for(S=O.length,T=I.length,d=0,P+=2,(b=u(s/(I[0]+1)))>1&&(I=e(I,b,s),O=e(O,b,s),T=I.length,S=O.length),k=T,_=(w=O.slice(0,T)).length;_<T;w[_++]=0);A=I.slice(),A=[0].concat(A),x=I[0],I[1]>=s/2&&x++;do{if(b=0,(c=t(I,w,T,_))<0){if(E=w[0],T!=_&&(E=E*s+(w[1]||0)),(b=u(E/x))>1)for(b>=s&&(b=s-1),g=(m=e(I,b,s)).length,_=w.length;1==t(m,w,g,_);)b--,r(m,T<g?A:I,g,s),g=m.length,c=1;else 0==b&&(c=b=1),g=(m=I.slice()).length;if(g<_&&(m=[0].concat(m)),r(w,m,_,s),_=w.length,-1==c)for(;t(I,w,T,_)<1;)b++,r(w,T<_?A:I,_,s),_=w.length}else 0===c&&(b++,w=[0]);v[d++]=b,w[0]?w[_++]=O[k]||0:(w=[O[k]],_=1)}while((k++<S||null!=w[0])&&P--);h=null!=w[0],v[0]||v.splice(0,1)}if(s==l){for(d=1,P=v[0];P>=10;P/=10,d++);K(y,o+(y.e=d+14*f-1)+1,a,h)}else y.e=f,y.r=+h;return y}}(),_=/^(-?)0([xbo])(?=\w[\w.]*$)/i,E=/^([^.]+)\.$/,k=/^\.([^.]+)$/,S=/^-?(Infinity|NaN)$/,x=/^\s*\+(?=[\w.])|^\s+|\s+$/g,i=function(e,t,r,n){var i,o=r?t:t.replace(x,"");if(S.test(o))e.s=isNaN(o)?null:o<0?-1:1;else{if(!r&&(o=o.replace(_,(function(e,t,r){return i="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=i?e:t})),n&&(i=n,o=o.replace(E,"$1").replace(k,"0.$1")),t!=o))return new L(o,i);if(L.DEBUG)throw Error(c+"Not a"+(n?" base "+n:"")+" number: "+t);e.s=null}e.c=e.e=null},T.absoluteValue=T.abs=function(){var e=new L(this);return e.s<0&&(e.s=1),e},T.comparedTo=function(e,t){return m(this,new L(e,t))},T.decimalPlaces=T.dp=function(e,t){var r,n,i,o=this;if(null!=e)return g(e,0,h),null==t?t=O:g(t,0,8),K(new L(o),e+o.e+1,t);if(!(r=o.c))return null;if(n=14*((i=r.length-1)-p(this.e/14)),i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},T.dividedBy=T.div=function(e,t){return r(this,new L(e,t),P,O)},T.dividedToIntegerBy=T.idiv=function(e,t){return r(this,new L(e,t),0,1)},T.exponentiatedBy=T.pow=function(e,t){var r,n,i,o,a,f,l,d,h=this;if((e=new L(e)).c&&!e.isInteger())throw Error(c+"Exponent not an integer: "+W(e));if(null!=t&&(t=new L(t)),a=e.e>14,!h.c||!h.c[0]||1==h.c[0]&&!h.e&&1==h.c.length||!e.c||!e.c[0])return d=new L(Math.pow(+W(h),a?e.s*(2-y(e)):+W(e))),t?d.mod(t):d;if(f=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new L(NaN);(n=!f&&h.isInteger()&&t.isInteger())&&(h=h.mod(t))}else{if(e.e>9&&(h.e>0||h.e<-1||(0==h.e?h.c[0]>1||a&&h.c[1]>=24e7:h.c[0]<8e13||a&&h.c[0]<=9999975e7)))return o=h.s<0&&y(e)?-0:0,h.e>-1&&(o=1/o),new L(f?1/o:o);U&&(o=s(U/14+2))}for(a?(r=new L(.5),f&&(e.s=1),l=y(e)):l=(i=Math.abs(+W(e)))%2,d=new L(A);;){if(l){if(!(d=d.times(h)).c)break;o?d.c.length>o&&(d.c.length=o):n&&(d=d.mod(t))}if(i){if(0===(i=u(i/2)))break;l=i%2}else if(K(e=e.times(r),e.e+1,1),e.e>14)l=y(e);else{if(0===(i=+W(e)))break;l=i%2}h=h.times(h),o?h.c&&h.c.length>o&&(h.c.length=o):n&&(h=h.mod(t))}return n?d:(f&&(d=A.div(d)),t?d.mod(t):o?K(d,U,O,void 0):d)},T.integerValue=function(e){var t=new L(this);return null==e?e=O:g(e,0,8),K(t,t.e+1,e)},T.isEqualTo=T.eq=function(e,t){return 0===m(this,new L(e,t))},T.isFinite=function(){return!!this.c},T.isGreaterThan=T.gt=function(e,t){return m(this,new L(e,t))>0},T.isGreaterThanOrEqualTo=T.gte=function(e,t){return 1===(t=m(this,new L(e,t)))||0===t},T.isInteger=function(){return!!this.c&&p(this.e/14)>this.c.length-2},T.isLessThan=T.lt=function(e,t){return m(this,new L(e,t))<0},T.isLessThanOrEqualTo=T.lte=function(e,t){return-1===(t=m(this,new L(e,t)))||0===t},T.isNaN=function(){return!this.s},T.isNegative=function(){return this.s<0},T.isPositive=function(){return this.s>0},T.isZero=function(){return!!this.c&&0==this.c[0]},T.minus=function(e,t){var r,n,i,o,a=this,s=a.s;if(t=(e=new L(e,t)).s,!s||!t)return new L(NaN);if(s!=t)return e.s=-t,a.plus(e);var u=a.e/14,c=e.e/14,f=a.c,d=e.c;if(!u||!c){if(!f||!d)return f?(e.s=-t,e):new L(d?a:NaN);if(!f[0]||!d[0])return d[0]?(e.s=-t,e):new L(f[0]?a:3==O?-0:0)}if(u=p(u),c=p(c),f=f.slice(),s=u-c){for((o=s<0)?(s=-s,i=f):(c=u,i=d),i.reverse(),t=s;t--;i.push(0));i.reverse()}else for(n=(o=(s=f.length)<(t=d.length))?s:t,s=t=0;t<n;t++)if(f[t]!=d[t]){o=f[t]<d[t];break}if(o&&(i=f,f=d,d=i,e.s=-e.s),(t=(n=d.length)-(r=f.length))>0)for(;t--;f[r++]=0);for(t=l-1;n>s;){if(f[--n]<d[n]){for(r=n;r&&!f[--r];f[r]=t);--f[r],f[n]+=l}f[n]-=d[n]}for(;0==f[0];f.splice(0,1),--c);return f[0]?q(e,f,c):(e.s=3==O?-1:1,e.c=[e.e=0],e)},T.modulo=T.mod=function(e,t){var n,i,o=this;return e=new L(e,t),!o.c||!e.s||e.c&&!e.c[0]?new L(NaN):!e.c||o.c&&!o.c[0]?new L(o):(9==j?(i=e.s,e.s=1,n=r(o,e,0,3),e.s=i,n.s*=i):n=r(o,e,0,j),(e=o.minus(n.times(e))).c[0]||1!=j||(e.s=o.s),e)},T.multipliedBy=T.times=function(e,t){var r,n,i,o,a,s,u,c,f,d,h,b,m,g,y=this,v=y.c,w=(e=new L(e,t)).c;if(!(v&&w&&v[0]&&w[0]))return!y.s||!e.s||v&&!v[0]&&!w||w&&!w[0]&&!v?e.c=e.e=e.s=null:(e.s*=y.s,v&&w?(e.c=[0],e.e=0):e.c=e.e=null),e;for(n=p(y.e/14)+p(e.e/14),e.s*=y.s,(u=v.length)<(d=w.length)&&(m=v,v=w,w=m,i=u,u=d,d=i),i=u+d,m=[];i--;m.push(0));for(g=l,1e7,i=d;--i>=0;){for(r=0,h=w[i]%1e7,b=w[i]/1e7|0,o=i+(a=u);o>i;)r=((c=h*(c=v[--a]%1e7)+(s=b*c+(f=v[a]/1e7|0)*h)%1e7*1e7+m[o]+r)/g|0)+(s/1e7|0)+b*f,m[o--]=c%g;m[o]=r}return r?++n:m.splice(0,1),q(e,m,n)},T.negated=function(){var e=new L(this);return e.s=-e.s||null,e},T.plus=function(e,t){var r,n=this,i=n.s;if(t=(e=new L(e,t)).s,!i||!t)return new L(NaN);if(i!=t)return e.s=-t,n.minus(e);var o=n.e/14,a=e.e/14,s=n.c,u=e.c;if(!o||!a){if(!s||!u)return new L(i/0);if(!s[0]||!u[0])return u[0]?e:new L(s[0]?n:0*i)}if(o=p(o),a=p(a),s=s.slice(),i=o-a){for(i>0?(a=o,r=u):(i=-i,r=s),r.reverse();i--;r.push(0));r.reverse()}for((i=s.length)-(t=u.length)<0&&(r=u,u=s,s=r,t=i),i=0;t;)i=(s[--t]=s[t]+u[t]+i)/l|0,s[t]=l===s[t]?0:s[t]%l;return i&&(s=[i].concat(s),++a),q(e,s,a)},T.precision=T.sd=function(e,t){var r,n,i,o=this;if(null!=e&&e!==!!e)return g(e,1,h),null==t?t=O:g(t,0,8),K(new L(o),e,t);if(!(r=o.c))return null;if(n=14*(i=r.length-1)+1,i=r[i]){for(;i%10==0;i/=10,n--);for(i=r[0];i>=10;i/=10,n++);}return e&&o.e+1>n&&(n=o.e+1),n},T.shiftedBy=function(e){return g(e,-9007199254740991,9007199254740991),this.times("1e"+e)},T.squareRoot=T.sqrt=function(){var e,t,n,i,o,a=this,s=a.c,u=a.s,c=a.e,f=P+4,l=new L("0.5");if(1!==u||!s||!s[0])return new L(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);if(0==(u=Math.sqrt(+W(a)))||u==1/0?(((t=b(s)).length+c)%2==0&&(t+="0"),u=Math.sqrt(+t),c=p((c+1)/2)-(c<0||c%2),n=new L(t=u==1/0?"5e"+c:(t=u.toExponential()).slice(0,t.indexOf("e")+1)+c)):n=new L(u+""),n.c[0])for((u=(c=n.e)+f)<3&&(u=0);;)if(o=n,n=l.times(o.plus(r(a,o,f,1))),b(o.c).slice(0,u)===(t=b(n.c)).slice(0,u)){if(n.e<c&&--u,"9999"!=(t=t.slice(u-3,u+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(K(n,n.e+P+2,1),e=!n.times(n).eq(a));break}if(!i&&(K(o,o.e+P+2,0),o.times(o).eq(a))){n=o;break}f+=4,u+=4,i=1}return K(n,n.e+P+1,O,e)},T.toExponential=function(e,t){return null!=e&&(g(e,0,h),e++),D(this,e,t,1)},T.toFixed=function(e,t){return null!=e&&(g(e,0,h),e=e+this.e+1),D(this,e,t)},T.toFormat=function(e,t,r){var n,i=this;if(null==r)null!=e&&t&&"object"==typeof t?(r=t,t=null):e&&"object"==typeof e?(r=e,e=t=null):r=C;else if("object"!=typeof r)throw Error(c+"Argument not an object: "+r);if(n=i.toFixed(e,t),i.c){var o,a=n.split("."),s=+r.groupSize,u=+r.secondaryGroupSize,f=r.groupSeparator||"",l=a[0],d=a[1],h=i.s<0,p=h?l.slice(1):l,b=p.length;if(u&&(o=s,s=u,u=o,b-=o),s>0&&b>0){for(o=b%s||s,l=p.substr(0,o);o<b;o+=s)l+=f+p.substr(o,s);u>0&&(l+=f+p.slice(o)),h&&(l="-"+l)}n=d?l+(r.decimalSeparator||"")+((u=+r.fractionGroupSize)?d.replace(new RegExp("\\d{"+u+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):d):l}return(r.prefix||"")+n+(r.suffix||"")},T.toFraction=function(e){var t,n,i,o,a,s,u,f,l,h,p,m,g=this,y=g.c;if(null!=e&&(!(u=new L(e)).isInteger()&&(u.c||1!==u.s)||u.lt(A)))throw Error(c+"Argument "+(u.isInteger()?"out of range: ":"not an integer: ")+W(u));if(!y)return new L(g);for(t=new L(A),l=n=new L(A),i=f=new L(A),m=b(y),a=t.e=m.length-g.e-1,t.c[0]=d[(s=a%14)<0?14+s:s],e=!e||u.comparedTo(t)>0?a>0?t:l:u,s=R,R=1/0,u=new L(m),f.c[0]=0;h=r(u,t,0,1),1!=(o=n.plus(h.times(i))).comparedTo(e);)n=i,i=o,l=f.plus(h.times(o=l)),f=o,t=u.minus(h.times(o=t)),u=o;return o=r(e.minus(n),i,0,1),f=f.plus(o.times(l)),n=n.plus(o.times(i)),f.s=l.s=g.s,p=r(l,i,a*=2,O).minus(g).abs().comparedTo(r(f,n,a,O).minus(g).abs())<1?[l,i]:[f,n],R=s,p},T.toNumber=function(){return+W(this)},T.toPrecision=function(e,t){return null!=e&&g(e,1,h),D(this,e,t,2)},T.toString=function(e){var t,r=this,i=r.s,o=r.e;return null===o?i?(t="Infinity",i<0&&(t="-"+t)):t="NaN":(null==e?t=o<=I||o>=B?v(b(r.c),o):w(b(r.c),o,"0"):10===e&&z?t=w(b((r=K(new L(r),P+o+1,O)).c),r.e,"0"):(g(e,2,H.length,"Base"),t=n(w(b(r.c),o,"0"),10,e,i,!0)),i<0&&r.c[0]&&(t="-"+t)),t},T.valueOf=T.toJSON=function(){return W(this)},T._isBigNumber=!0,null!=t&&L.set(t),L}()).default=o.BigNumber=o,void 0===(n=function(){return o}.call(t,r,t,e))||(e.exports=n)}()},function(e,t,r){"use strict";e.exports={getBurnTransactionInfo:function(e,t=[],r=[]){let n=t.findIndex(t=>t.address===e);if(n>=0){let i=t[n];i.vinIndex=n;let o=t.reduce((e,t)=>+e+ +t.value,0),a=[],s=[];for(let t in r){let n=Object.assign(Object.assign({},r[t]),{index:t});n.address===e?s.push(n):a.push(n)}return{receivers:a,changes:s,totalInputValue:o,lockerVin:i}}return null}}},function(e,t,r){"use strict";(function(e){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},a=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((n=n.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const u=r(35),c=s(r(75)),f=o(r(117)).ECPair;function l(t,r={},n){let i=t,o=f.fromPrivateKey(t,{network:n,compressed:!0});if(!o.privateKey)throw new Error("private key not exist");o.publicKey.toString("hex").startsWith("03")&&(i=c.default.privateNegate(o.privateKey));const a=c.default.privateAdd(i,(s=e.from(o.publicKey.toString("hex").slice(2),"hex"),l=null==r?void 0:r.tweakHash,u.crypto.taggedHash("TapTweak",e.concat(l?[s,l]:[s]))));var s,l;if(!a)throw new Error("Invalid tweaked private key!");return f.fromPrivateKey(e.from(a),{network:n})}t.default=class{constructor(e){this.network=e}signPsbt(e,t){return a(this,void 0,void 0,(function*(){const{network:r}=this,n=f.fromPrivateKey(t,{network:r,compressed:!0}),i=u.Psbt.fromBase64(e.unsignedTransaction,{network:r});let o=i.inputCount;for(let e=0;e<o;e+=1){if("nonstandard"===i.getInputType(e)){let r=l(t,void 0,this.network);yield i.signInputAsync(e,r)}else yield i.signInputAsync(e,n)}return i.toBase64()}))}finalizePsbts(e=[]){const t=e.map(e=>u.Psbt.fromBase64(e,{network:this.network})),r=1===t.length?t[0]:new u.Psbt({network:this.network}).combine(...t);return r.finalizeAllInputs(),r.extractTransaction().toHex()}}}).call(this,r(0).Buffer)}])}));
|