bo-crypto-address-validator
Version:
Wallet address validator for Bitcoin and other Altcoins.
1 lines • 121 kB
JavaScript
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).WAValidator=t()}}(function(){return function o(a,s,u){function f(e,t){if(!s[e]){if(!a[e]){var r="function"==typeof require&&require;if(!t&&r)return r(e,!0);if(c)return c(e,!0);var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}var i=s[e]={exports:{}};a[e][0].call(i.exports,function(t){return f(a[e][1][t]||t)},i,i.exports,o,a,s,u)}return s[e].exports}for(var c="function"==typeof require&&require,t=0;t<u.length;t++)f(u[t]);return f}({1:[function(t,e,r){var h=t("safe-buffer").Buffer;e.exports=function(u){for(var s={},f=u.length,c=u.charAt(0),t=0;t<u.length;t++){var e=u.charAt(t);if(void 0!==s[e])throw new TypeError(e+" is ambiguous");s[e]=t}function r(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return h.allocUnsafe(0);for(var e=[0],r=0;r<t.length;r++){var n=s[t[r]];if(void 0===n)return;for(var i=0,o=n;i<e.length;++i)o+=e[i]*f,e[i]=255&o,o>>=8;for(;0<o;)e.push(255&o),o>>=8}for(var a=0;t[a]===c&&a<t.length-1;++a)e.push(0);return h.from(e.reverse())}return{encode:function(t){if(0===t.length)return"";for(var e=[0],r=0;r<t.length;++r){for(var n=0,i=t[r];n<e.length;++n)i+=e[n]<<8,e[n]=i%f,i=i/f|0;for(;0<i;)e.push(i%f),i=i/f|0}for(var o="",a=0;0===t[a]&&a<t.length-1;++a)o+=c;for(var s=e.length-1;0<=s;--s)o+=u[e[s]];return o},decodeUnsafe:r,decode:function(t){var e=r(t);if(e)return e;throw new Error("Non-base"+f+" character")}}}},{"safe-buffer":37}],2:[function(t,e,r){"use strict";r.byteLength=function(t){var e=p(t),r=e[0],n=e[1];return 3*(r+n)/4-n},r.toByteArray=function(t){for(var e,r=p(t),n=r[0],i=r[1],o=new l((f=n,c=i,3*(f+c)/4-c)),a=0,s=0<i?n-4:n,u=0;u<s;u+=4)e=h[t.charCodeAt(u)]<<18|h[t.charCodeAt(u+1)]<<12|h[t.charCodeAt(u+2)]<<6|h[t.charCodeAt(u+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=255&e;var f,c;2===i&&(e=h[t.charCodeAt(u)]<<2|h[t.charCodeAt(u+1)]>>4,o[a++]=255&e);1===i&&(e=h[t.charCodeAt(u)]<<10|h[t.charCodeAt(u+1)]<<4|h[t.charCodeAt(u+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e);return o},r.fromByteArray=function(t){for(var e,r=t.length,n=r%3,i=[],o=0,a=r-n;o<a;o+=16383)i.push(u(t,o,a<o+16383?a:o+16383));1===n?(e=t[r-1],i.push(s[e>>2]+s[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],i.push(s[e>>10]+s[e>>4&63]+s[e<<2&63]+"="));return i.join("")};for(var s=[],h=[],l="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0,o=n.length;i<o;++i)s[i]=n[i],h[n.charCodeAt(i)]=i;function p(t){var e=t.length;if(0<e%4)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function u(t,e,r){for(var n,i,o=[],a=e;a<r;a+=3)n=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),o.push(s[(i=n)>>18&63]+s[i>>12&63]+s[i>>6&63]+s[63&i]);return o.join("")}h["-".charCodeAt(0)]=62,h["_".charCodeAt(0)]=63},{}],3:[function(t,e,r){var X=function(u){"use strict";var y=1e7,h=7,e=9007199254740992,r=b(e),l=Math.log(e);function p(t,e){return void 0===t?p[0]:void 0!==e?10==+e?D(t):F(t,e):D(t)}function d(t,e){this.value=t,this.sign=e,this.isSmall=!1}function v(t){this.value=t,this.sign=t<0,this.isSmall=!0}function g(t){return-e<t&&t<e}function b(t){return t<1e7?[t]:t<1e14?[t%1e7,Math.floor(t/1e7)]:[t%1e7,Math.floor(t/1e7)%1e7,Math.floor(t/1e14)]}function w(t){m(t);var e=t.length;if(e<4&&I(t,r)<0)switch(e){case 0:return 0;case 1:return t[0];case 2:return t[0]+t[1]*y;default:return t[0]+(t[1]+t[2]*y)*y}return t}function m(t){for(var e=t.length;0===t[--e];);t.length=e+1}function _(t){for(var e=new Array(t),r=-1;++r<t;)e[r]=0;return e}function A(t){return 0<t?Math.floor(t):Math.ceil(t)}function n(t,e){var r,n,i=t.length,o=e.length,a=new Array(i),s=0,u=y;for(n=0;n<o;n++)s=u<=(r=t[n]+e[n]+s)?1:0,a[n]=r-s*u;for(;n<i;)s=(r=t[n]+s)===u?1:0,a[n++]=r-s*u;return 0<s&&a.push(s),a}function E(t,e){return t.length>=e.length?n(t,e):n(e,t)}function i(t,e){var r,n,i=t.length,o=new Array(i),a=y;for(n=0;n<i;n++)r=t[n]-a+e,e=Math.floor(r/a),o[n]=r-e*a,e+=1;for(;0<e;)o[n++]=e%a,e=Math.floor(e/a);return o}function x(t,e){var r,n,i=t.length,o=e.length,a=new Array(i),s=0,u=y;for(r=0;r<o;r++)(n=t[r]-s-e[r])<0?(n+=u,s=1):s=0,a[r]=n;for(r=o;r<i;r++){if(!((n=t[r]-s)<0)){a[r++]=n;break}n+=u,a[r]=n}for(;r<i;r++)a[r]=t[r];return m(a),a}function f(t,e,r){var n,i,o=t.length,a=new Array(o),s=-e,u=y;for(n=0;n<o;n++)i=t[n]+s,s=Math.floor(i/u),i%=u,a[n]=i<0?i+u:i;return"number"==typeof(a=w(a))?(r&&(a=-a),new v(a)):new d(a,r)}function B(t,e){var r,n,i,o,a=t.length,s=e.length,u=_(a+s),f=y;for(i=0;i<a;++i){o=t[i];for(var c=0;c<s;++c)r=o*e[c]+u[i+c],n=Math.floor(r/f),u[i+c]=r-n*f,u[i+c+1]+=n}return m(u),u}function k(t,e){var r,n,i=t.length,o=new Array(i),a=y,s=0;for(n=0;n<i;n++)r=t[n]*e+s,s=Math.floor(r/a),o[n]=r-s*a;for(;0<s;)o[n++]=s%a,s=Math.floor(s/a);return o}function S(t,e){for(var r=[];0<e--;)r.push(0);return r.concat(t)}function o(t,e,r){return new d(t<y?k(e,t):B(e,b(t)),r)}function a(t){var e,r,n,i,o=t.length,a=_(o+o),s=y;for(n=0;n<o;n++){r=0-(i=t[n])*i;for(var u=n;u<o;u++)e=i*t[u]*2+a[n+u]+r,r=Math.floor(e/s),a[n+u]=e-r*s;a[n+o]=r}return m(a),a}function U(t,e){var r,n,i,o,a=t.length,s=_(a),u=y;for(i=0,r=a-1;0<=r;--r)i=(o=i*u+t[r])-(n=A(o/e))*e,s[r]=0|n;return[s,0|i]}function M(t,e){var r,n,i=D(e),o=t.value,a=i.value;if(0===a)throw new Error("Cannot divide by zero");if(t.isSmall)return i.isSmall?[new v(A(o/a)),new v(o%a)]:[p[0],t];if(i.isSmall){if(1===a)return[t,p[0]];if(-1==a)return[t.negate(),p[0]];var s=Math.abs(a);if(s<y){n=w((r=U(o,s))[0]);var u=r[1];return t.sign&&(u=-u),"number"==typeof n?(t.sign!==i.sign&&(n=-n),[new v(n),new v(u)]):[new d(n,t.sign!==i.sign),new v(u)]}a=b(s)}var f=I(o,a);if(-1===f)return[p[0],t];if(0===f)return[p[t.sign===i.sign?1:-1],p[0]];n=(r=o.length+a.length<=200?function(t,e){var r,n,i,o,a,s,u,f=t.length,c=e.length,h=y,l=_(e.length),p=e[c-1],d=Math.ceil(h/(2*p)),v=k(t,d),g=k(e,d);for(v.length<=f&&v.push(0),g.push(0),p=g[c-1],n=f-c;0<=n;n--){for(r=h-1,v[n+c]!==p&&(r=Math.floor((v[n+c]*h+v[n+c-1])/p)),o=i=0,s=g.length,a=0;a<s;a++)i+=r*g[a],u=Math.floor(i/h),o+=v[n+a]-(i-u*h),i=u,o<0?(v[n+a]=o+h,o=-1):(v[n+a]=o,o=0);for(;0!==o;){for(r-=1,a=i=0;a<s;a++)(i+=v[n+a]-h+g[a])<0?(v[n+a]=i+h,i=0):(v[n+a]=i,i=1);o+=i}l[n]=r}return v=U(v,d)[0],[w(l),w(v)]}(o,a):function(t,e){for(var r,n,i,o,a,s=t.length,u=e.length,f=[],c=[],h=y;s;)if(c.unshift(t[--s]),m(c),I(c,e)<0)f.push(0);else{i=c[(n=c.length)-1]*h+c[n-2],o=e[u-1]*h+e[u-2],u<n&&(i=(i+1)*h),r=Math.ceil(i/o);do{if(I(a=k(e,r),c)<=0)break;r--}while(r);f.push(r),c=x(c,a)}return f.reverse(),[w(f),w(c)]}(o,a))[0];var c=t.sign!==i.sign,h=r[1],l=t.sign;return"number"==typeof n?(c&&(n=-n),n=new v(n)):n=new d(n,c),"number"==typeof h?(l&&(h=-h),h=new v(h)):h=new d(h,l),[n,h]}function I(t,e){if(t.length!==e.length)return t.length>e.length?1:-1;for(var r=t.length-1;0<=r;r--)if(t[r]!==e[r])return t[r]>e[r]?1:-1;return 0}function c(t){var e=t.abs();return!e.isUnit()&&(!!(e.equals(2)||e.equals(3)||e.equals(5))||!(e.isEven()||e.isDivisibleBy(3)||e.isDivisibleBy(5))&&(!!e.lesser(49)||void 0))}function T(t,e){for(var r,n,i,o=t.prev(),a=o,s=0;a.isEven();)a=a.divide(2),s++;t:for(n=0;n<e.length;n++)if(!t.lesser(e[n])&&!(i=X(e[n]).modPow(a,t)).equals(p[1])&&!i.equals(o)){for(r=s-1;0!=r;r--){if((i=i.square().mod(t)).isUnit())return!1;if(i.equals(o))continue t}return!1}return!0}d.prototype=Object.create(p.prototype),v.prototype=Object.create(p.prototype),d.prototype.plus=d.prototype.add=function(t){var e=D(t);if(this.sign!==e.sign)return this.subtract(e.negate());var r=this.value,n=e.value;return e.isSmall?new d(i(r,Math.abs(n)),this.sign):new d(E(r,n),this.sign)},v.prototype.plus=v.prototype.add=function(t){var e=D(t),r=this.value;if(r<0!==e.sign)return this.subtract(e.negate());var n=e.value;if(e.isSmall){if(g(r+n))return new v(r+n);n=b(Math.abs(n))}return new d(i(n,Math.abs(r)),r<0)},d.prototype.minus=d.prototype.subtract=function(t){var e=D(t);if(this.sign!==e.sign)return this.add(e.negate());var r,n,i,o,a=this.value,s=e.value;return e.isSmall?f(a,Math.abs(s),this.sign):(r=a,n=s,i=this.sign,0<=I(r,n)?o=x(r,n):(o=x(n,r),i=!i),"number"==typeof(o=w(o))?(i&&(o=-o),new v(o)):new d(o,i))},v.prototype.minus=v.prototype.subtract=function(t){var e=D(t),r=this.value;if(r<0!==e.sign)return this.add(e.negate());var n=e.value;return e.isSmall?new v(r-n):f(n,Math.abs(r),0<=r)},d.prototype.negate=function(){return new d(this.value,!this.sign)},v.prototype.negate=function(){var t=this.sign,e=new v(-this.value);return e.sign=!t,e},d.prototype.abs=function(){return new d(this.value,!1)},v.prototype.abs=function(){return new v(Math.abs(this.value))},d.prototype.times=d.prototype.multiply=function(t){var e,r,n,i=D(t),o=this.value,a=i.value,s=this.sign!==i.sign;if(i.isSmall){if(0===a)return p[0];if(1===a)return this;if(-1===a)return this.negate();if((e=Math.abs(a))<y)return new d(k(o,e),s);a=b(e)}return r=o.length,n=a.length,new d(0<-.012*r-.012*n+15e-6*r*n?function t(e,r){var n=Math.max(e.length,r.length);if(n<=30)return B(e,r);n=Math.ceil(n/2);var i=e.slice(n),o=e.slice(0,n),a=r.slice(n),s=r.slice(0,n),u=t(o,s),f=t(i,a),c=E(E(u,S(x(x(t(E(o,i),E(s,a)),u),f),n)),S(f,2*n));return m(c),c}(o,a):B(o,a),s)},v.prototype._multiplyBySmall=function(t){return g(t.value*this.value)?new v(t.value*this.value):o(Math.abs(t.value),b(Math.abs(this.value)),this.sign!==t.sign)},d.prototype._multiplyBySmall=function(t){return 0===t.value?p[0]:1===t.value?this:-1===t.value?this.negate():o(Math.abs(t.value),this.value,this.sign!==t.sign)},v.prototype.times=v.prototype.multiply=function(t){return D(t)._multiplyBySmall(this)},d.prototype.square=function(){return new d(a(this.value),!1)},v.prototype.square=function(){var t=this.value*this.value;return g(t)?new v(t):new d(a(b(Math.abs(this.value))),!1)},v.prototype.divmod=d.prototype.divmod=function(t){var e=M(this,t);return{quotient:e[0],remainder:e[1]}},v.prototype.over=v.prototype.divide=d.prototype.over=d.prototype.divide=function(t){return M(this,t)[0]},v.prototype.remainder=v.prototype.mod=d.prototype.remainder=d.prototype.mod=function(t){return M(this,t)[1]},d.prototype.pow=function(t){var e,r,n,i=D(t),o=this.value,a=i.value;if(0===a)return p[1];if(0===o)return p[0];if(1===o)return p[1];if(-1===o)return i.isEven()?p[1]:p[-1];if(i.sign)return p[0];if(!i.isSmall)throw new Error("The exponent "+i.toString()+" is too large.");if(this.isSmall&&g(e=Math.pow(o,a)))return new v(A(e));for(r=this,n=p[1];!0&a&&(n=n.times(r),--a),0!==a;)a/=2,r=r.square();return n},v.prototype.pow=d.prototype.pow,v.prototype.modPow=d.prototype.modPow=function(t,e){if(t=D(t),(e=D(e)).isZero())throw new Error("Cannot take modPow with modulus 0");for(var r=p[1],n=this.mod(e);t.isPositive();){if(n.isZero())return p[0];t.isOdd()&&(r=r.multiply(n).mod(e)),t=t.divide(2),n=n.square().mod(e)}return r},d.prototype.compareAbs=function(t){var e=D(t),r=this.value,n=e.value;return e.isSmall?1:I(r,n)},v.prototype.compareAbs=function(t){var e=D(t),r=Math.abs(this.value),n=e.value;return e.isSmall?r===(n=Math.abs(n))?0:n<r?1:-1:-1},d.prototype.compareTo=d.prototype.compare=function(t){if(t===1/0)return-1;if(t===-1/0)return 1;var e=D(t),r=this.value,n=e.value;return this.sign!==e.sign?e.sign?1:-1:e.isSmall?this.sign?-1:1:I(r,n)*(this.sign?-1:1)},v.prototype.compareTo=v.prototype.compare=function(t){if(t===1/0)return-1;if(t===-1/0)return 1;var e=D(t),r=this.value,n=e.value;return e.isSmall?r==n?0:n<r?1:-1:r<0!==e.sign?r<0?-1:1:r<0?1:-1},v.prototype.eq=v.prototype.equals=d.prototype.eq=d.prototype.equals=function(t){return 0===this.compare(t)},v.prototype.neq=v.prototype.notEquals=d.prototype.neq=d.prototype.notEquals=function(t){return 0!==this.compare(t)},v.prototype.gt=v.prototype.greater=d.prototype.gt=d.prototype.greater=function(t){return 0<this.compare(t)},v.prototype.lt=v.prototype.lesser=d.prototype.lt=d.prototype.lesser=function(t){return this.compare(t)<0},v.prototype.geq=v.prototype.greaterOrEquals=d.prototype.geq=d.prototype.greaterOrEquals=function(t){return 0<=this.compare(t)},v.prototype.leq=v.prototype.lesserOrEquals=d.prototype.leq=d.prototype.lesserOrEquals=function(t){return this.compare(t)<=0},d.prototype.isEven=function(){return 0==(1&this.value[0])},v.prototype.isEven=function(){return 0==(1&this.value)},d.prototype.isOdd=function(){return 1==(1&this.value[0])},v.prototype.isOdd=function(){return 1==(1&this.value)},d.prototype.isPositive=function(){return!this.sign},v.prototype.isPositive=function(){return 0<this.value},d.prototype.isNegative=function(){return this.sign},v.prototype.isNegative=function(){return this.value<0},d.prototype.isUnit=function(){return!1},v.prototype.isUnit=function(){return 1===Math.abs(this.value)},d.prototype.isZero=function(){return!1},v.prototype.isZero=function(){return 0===this.value},v.prototype.isDivisibleBy=d.prototype.isDivisibleBy=function(t){var e=D(t),r=e.value;return 0!==r&&(1===r||(2===r?this.isEven():this.mod(e).equals(p[0])))},v.prototype.isPrime=d.prototype.isPrime=function(t){var e=c(this);if(e!==u)return e;var r=this.abs(),n=r.bitLength();if(n<=64)return T(r,[2,325,9375,28178,450775,9780504,1795265022]);for(var i=Math.log(2)*n,o=Math.ceil(!0===t?2*Math.pow(i,2):i),a=[],s=0;s<o;s++)a.push(X(s+2));return T(r,a)},v.prototype.isProbablePrime=d.prototype.isProbablePrime=function(t){var e=c(this);if(e!==u)return e;for(var r=this.abs(),n=t===u?5:t,i=[],o=0;o<n;o++)i.push(X.randBetween(2,r.minus(2)));return T(r,i)},v.prototype.modInv=d.prototype.modInv=function(t){for(var e,r,n,i=X.zero,o=X.one,a=D(t),s=this.abs();!s.equals(X.zero);)e=a.divide(s),r=i,n=a,i=o,a=s,o=r.subtract(e.multiply(o)),s=n.subtract(e.multiply(s));if(!a.equals(1))throw new Error(this.toString()+" and "+t.toString()+" are not co-prime");return-1===i.compare(0)&&(i=i.add(t)),this.isNegative()?i.negate():i},d.prototype.next=function(){var t=this.value;return this.sign?f(t,1,this.sign):new d(i(t,1),this.sign)},v.prototype.next=function(){var t=this.value;return t+1<e?new v(t+1):new d(r,!1)},d.prototype.prev=function(){var t=this.value;return this.sign?new d(i(t,1),!0):f(t,1,this.sign)},v.prototype.prev=function(){var t=this.value;return-e<t-1?new v(t-1):new d(r,!0)};for(var s=[1];2*s[s.length-1]<=y;)s.push(2*s[s.length-1]);var C=s.length,O=s[C-1];function R(t){return("number"==typeof t||"string"==typeof t)&&+Math.abs(t)<=y||t instanceof d&&t.value.length<=1}function L(t,e,r){e=D(e);for(var n=t.isNegative(),i=e.isNegative(),o=n?t.not():t,a=i?e.not():e,s=0,u=0,f=null,c=null,h=[];!o.isZero()||!a.isZero();)s=(f=M(o,O))[1].toJSNumber(),n&&(s=O-1-s),u=(c=M(a,O))[1].toJSNumber(),i&&(u=O-1-u),o=f[0],a=c[0],h.push(r(s,u));for(var l=0!==r(n?1:0,i?1:0)?X(-1):X(0),p=h.length-1;0<=p;p-=1)l=l.multiply(O).add(X(h[p]));return l}v.prototype.shiftLeft=d.prototype.shiftLeft=function(t){if(!R(t))throw new Error(String(t)+" is too large for shifting.");if((t=+t)<0)return this.shiftRight(-t);var e=this;if(e.isZero())return e;for(;C<=t;)e=e.multiply(O),t-=C-1;return e.multiply(s[t])},v.prototype.shiftRight=d.prototype.shiftRight=function(t){var e;if(!R(t))throw new Error(String(t)+" is too large for shifting.");if((t=+t)<0)return this.shiftLeft(-t);for(var r=this;C<=t;){if(r.isZero()||r.isNegative()&&r.isUnit())return r;r=(e=M(r,O))[1].isNegative()?e[0].prev():e[0],t-=C-1}return(e=M(r,s[t]))[1].isNegative()?e[0].prev():e[0]},v.prototype.not=d.prototype.not=function(){return this.negate().prev()},v.prototype.and=d.prototype.and=function(t){return L(this,t,function(t,e){return t&e})},v.prototype.or=d.prototype.or=function(t){return L(this,t,function(t,e){return t|e})},v.prototype.xor=d.prototype.xor=function(t){return L(this,t,function(t,e){return t^e})};var N=1<<30,H=(y&-y)*(y&-y)|N;function j(t){var e=t.value,r="number"==typeof e?e|N:e[0]+e[1]*y|H;return r&-r}function q(t,e){return t=D(t),e=D(e),t.greater(e)?t:e}function P(t,e){return t=D(t),e=D(e),t.lesser(e)?t:e}function z(t,e){if(t=D(t).abs(),e=D(e).abs(),t.equals(e))return t;if(t.isZero())return e;if(e.isZero())return t;for(var r,n,i=p[1];t.isEven()&&e.isEven();)r=Math.min(j(t),j(e)),t=t.divide(r),e=e.divide(r),i=i.multiply(r);for(;t.isEven();)t=t.divide(j(t));do{for(;e.isEven();)e=e.divide(j(e));t.greater(e)&&(n=e,e=t,t=n),e=e.subtract(t)}while(!e.isZero());return i.isUnit()?t:t.multiply(i)}v.prototype.bitLength=d.prototype.bitLength=function(){var t=this;return t.compareTo(X(0))<0&&(t=t.negate().subtract(X(1))),0===t.compareTo(X(0))?X(0):X(function t(e,r){if(r.compareTo(e)<=0){var n=t(e,r.square(r)),i=n.p,o=n.e,a=i.multiply(r);return a.compareTo(e)<=0?{p:a,e:2*o+1}:{p:i,e:2*o}}return{p:X(1),e:0}}(t,X(2)).e).add(X(1))};var F=function(t,e){for(var r=t.length,n=Math.abs(e),i=0;i<r;i++){if("-"!==(u=t[i].toLowerCase())&&/[a-z0-9]/.test(u)){if(/[0-9]/.test(u)&&n<=+u){if("1"===u&&1===n)continue;throw new Error(u+" is not a valid digit in base "+e+".")}if(u.charCodeAt(0)-87>=n)throw new Error(u+" is not a valid digit in base "+e+".")}}if(2<=e&&e<=36&&r<=l/Math.log(e)){var o=parseInt(t,e);if(isNaN(o))throw new Error(u+" is not a valid digit in base "+e+".");return new v(parseInt(t,e))}e=D(e);var a=[],s="-"===t[0];for(i=s?1:0;i<t.length;i++){var u,f=(u=t[i].toLowerCase()).charCodeAt(0);if(48<=f&&f<=57)a.push(D(u));else if(97<=f&&f<=122)a.push(D(u.charCodeAt(0)-87));else{if("<"!==u)throw new Error(u+" is not a valid character");for(var c=i;">"!==t[++i];);a.push(D(t.slice(c+1,i)))}}return $(a,e,s)};function $(t,e,r){var n,i=p[0],o=p[1];for(n=t.length-1;0<=n;n--)i=i.add(t[n].times(o)),o=o.times(e);return r?i.negate():i}function V(t){return t<=35?"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t):"<"+t+">"}function J(t,e){if((e=X(e)).isZero()){if(t.isZero())return{value:[0],isNegative:!1};throw new Error("Cannot convert nonzero numbers to base 0.")}if(e.equals(-1)){if(t.isZero())return{value:[0],isNegative:!1};if(t.isNegative())return{value:[].concat.apply([],Array.apply(null,Array(-t)).map(Array.prototype.valueOf,[1,0])),isNegative:!1};var r=Array.apply(null,Array(+t-1)).map(Array.prototype.valueOf,[0,1]);return r.unshift([1]),{value:[].concat.apply([],r),isNegative:!1}}var n=!1;if(t.isNegative()&&e.isPositive()&&(n=!0,t=t.abs()),e.equals(1))return t.isZero()?{value:[0],isNegative:!1}:{value:Array.apply(null,Array(+t)).map(Number.prototype.valueOf,1),isNegative:n};for(var i,o=[],a=t;a.isNegative()||0<=a.compareAbs(e);){a=(i=a.divmod(e)).quotient;var s=i.remainder;s.isNegative()&&(s=e.minus(s).abs(),a=a.next()),o.push(s.toJSNumber())}return o.push(a.toJSNumber()),{value:o.reverse(),isNegative:n}}function Z(t,e){var r=J(t,e);return(r.isNegative?"-":"")+r.value.map(V).join("")}function Y(t){if(g(+t)){var e=+t;if(e===A(e))return new v(e);throw new Error("Invalid integer: "+t)}var r="-"===t[0];r&&(t=t.slice(1));var n=t.split(/e/i);if(2<n.length)throw new Error("Invalid integer: "+n.join("e"));if(2===n.length){var i=n[1];if("+"===i[0]&&(i=i.slice(1)),(i=+i)!==A(i)||!g(i))throw new Error("Invalid integer: "+i+" is not a valid exponent.");var o=n[0],a=o.indexOf(".");if(0<=a&&(i-=o.length-a-1,o=o.slice(0,a)+o.slice(a+1)),i<0)throw new Error("Cannot include negative exponent part for integers");t=o+=new Array(i+1).join("0")}if(!/^([0-9][0-9]*)$/.test(t))throw new Error("Invalid integer: "+t);for(var s=[],u=t.length,f=h,c=u-f;0<u;)s.push(+t.slice(c,u)),(c-=f)<0&&(c=0),u-=f;return m(s),new d(s,r)}function D(t){return"number"==typeof t?function(t){if(g(t)){if(t!==A(t))throw new Error(t+" is not an integer.");return new v(t)}return Y(t.toString())}(t):"string"==typeof t?Y(t):t}d.prototype.toArray=function(t){return J(this,t)},v.prototype.toArray=function(t){return J(this,t)},d.prototype.toString=function(t){if(t===u&&(t=10),10!==t)return Z(this,t);for(var e,r=this.value,n=r.length,i=String(r[--n]);0<=--n;)e=String(r[n]),i+="0000000".slice(e.length)+e;return(this.sign?"-":"")+i},v.prototype.toString=function(t){return t===u&&(t=10),10!=t?Z(this,t):String(this.value)},d.prototype.toJSON=v.prototype.toJSON=function(){return this.toString()},d.prototype.toJSNumber=d.prototype.valueOf=function(){return parseInt(this.toString(),10)},v.prototype.toJSNumber=v.prototype.valueOf=function(){return this.value};for(var t=0;t<1e3;t++)p[t]=new v(t),0<t&&(p[-t]=new v(-t));return p.one=p[1],p.zero=p[0],p.minusOne=p[-1],p.max=q,p.min=P,p.gcd=z,p.lcm=function(t,e){return t=D(t).abs(),e=D(e).abs(),t.divide(z(t,e)).multiply(e)},p.isInstance=function(t){return t instanceof d||t instanceof v},p.randBetween=function(t,e){var r=P(t=D(t),e=D(e)),n=q(t,e).subtract(r).add(1);if(n.isSmall)return r.add(Math.floor(Math.random()*n));for(var i=[],o=!0,a=n.value.length-1;0<=a;a--){var s=o?n.value[a]:y,u=A(Math.random()*s);i.unshift(u),u<s&&(o=!1)}return i=w(i),r.add("number"==typeof i?new v(i):new d(i,!1))},p.fromArray=function(t,e,r){return $(t.map(D),D(e||10),r)},p}();void 0!==e&&e.hasOwnProperty("exports")&&(e.exports=X)},{}],4:[function(t,e,r){"use strict";var n=t("base64-js"),o=t("ieee754");r.Buffer=h,r.SlowBuffer=function(t){+t!=t&&(t=0);return h.alloc(+t)},r.INSPECT_MAX_BYTES=50;var i=2147483647;function a(t){if(i<t)throw new RangeError("Invalid typed array length");var e=new Uint8Array(t);return e.__proto__=h.prototype,e}function h(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return f(t)}return s(t,e,r)}function s(t,e,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return N(t)||t&&N(t.buffer)?function(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');var n;n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r);return n.__proto__=h.prototype,n}(t,e,r):"string"==typeof t?function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!h.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|p(t,e),n=a(r),i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e):function(t){if(h.isBuffer(t)){var e=0|l(t.length),r=a(e);return 0===r.length||t.copy(r,0,0,e),r}if(t){if(ArrayBuffer.isView(t)||"length"in t)return"number"!=typeof t.length||H(t.length)?a(0):c(t);if("Buffer"===t.type&&Array.isArray(t.data))return c(t.data)}throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.")}(t)}function u(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('"size" argument must not be negative')}function f(t){return u(t),a(t<0?0:0|l(t))}function c(t){for(var e=t.length<0?0:0|l(t.length),r=a(e),n=0;n<e;n+=1)r[n]=255&t[n];return r}function l(t){if(i<=t)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function p(t,e){if(h.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||N(t))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return O(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return R(t).length;default:if(n)return O(t).length;e=(""+e).toLowerCase(),n=!0}}function d(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):2147483647<r?r=2147483647:r<-2147483648&&(r=-2147483648),H(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=h.from(e,n)),h.isBuffer(e))return 0===e.length?-1:g(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):g(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function g(t,e,r,n,i){var o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s/=a=2,u/=2,r/=2}function f(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var c=-1;for(o=r;o<s;o++)if(f(t,o)===f(e,-1===c?0:o-c)){if(-1===c&&(c=o),o-c+1===u)return c*a}else-1!==c&&(o-=o-c),c=-1}else for(s<r+u&&(r=s-u),o=r;0<=o;o--){for(var h=!0,l=0;l<u;l++)if(f(t,o+l)!==f(e,l)){h=!1;break}if(h)return o}return-1}function y(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?i<(n=Number(n))&&(n=i):n=i;var o=e.length;o/2<n&&(n=o/2);for(var a=0;a<n;++a){var s=parseInt(e.substr(2*a,2),16);if(H(s))return a;t[r+a]=s}return a}function b(t,e,r,n){return L(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function w(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function m(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i<r;){var o,a,s,u,f=t[i],c=null,h=239<f?4:223<f?3:191<f?2:1;if(i+h<=r)switch(h){case 1:f<128&&(c=f);break;case 2:128==(192&(o=t[i+1]))&&127<(u=(31&f)<<6|63&o)&&(c=u);break;case 3:o=t[i+1],a=t[i+2],128==(192&o)&&128==(192&a)&&2047<(u=(15&f)<<12|(63&o)<<6|63&a)&&(u<55296||57343<u)&&(c=u);break;case 4:o=t[i+1],a=t[i+2],s=t[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&65535<(u=(15&f)<<18|(63&o)<<12|(63&a)<<6|63&s)&&u<1114112&&(c=u)}null===c?(c=65533,h=1):65535<c&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=h}return function(t){var e=t.length;if(e<=_)return String.fromCharCode.apply(String,t);var r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=_));return r}(n)}r.kMaxLength=i,(h.TYPED_ARRAY_SUPPORT=function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()}catch(t){return!1}}())||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(h.prototype,"parent",{get:function(){if(this instanceof h)return this.buffer}}),Object.defineProperty(h.prototype,"offset",{get:function(){if(this instanceof h)return this.byteOffset}}),"undefined"!=typeof Symbol&&Symbol.species&&h[Symbol.species]===h&&Object.defineProperty(h,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),h.poolSize=8192,h.from=function(t,e,r){return s(t,e,r)},h.prototype.__proto__=Uint8Array.prototype,h.__proto__=Uint8Array,h.alloc=function(t,e,r){return i=e,o=r,u(n=t),n<=0?a(n):void 0!==i?"string"==typeof o?a(n).fill(i,o):a(n).fill(i):a(n);var n,i,o},h.allocUnsafe=function(t){return f(t)},h.allocUnsafeSlow=function(t){return f(t)},h.isBuffer=function(t){return null!=t&&!0===t._isBuffer},h.compare=function(t,e){if(!h.isBuffer(t)||!h.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},h.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},h.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return h.alloc(0);var r;if(void 0===e)for(r=e=0;r<t.length;++r)e+=t[r].length;var n=h.allocUnsafe(e),i=0;for(r=0;r<t.length;++r){var o=t[r];if(ArrayBuffer.isView(o)&&(o=h.from(o)),!h.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i),i+=o.length}return n},h.byteLength=p,h.prototype._isBuffer=!0,h.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)d(this,e,e+1);return this},h.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)d(this,e,e+3),d(this,e+1,e+2);return this},h.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)d(this,e,e+7),d(this,e+1,e+6),d(this,e+2,e+5),d(this,e+3,e+4);return this},h.prototype.toLocaleString=h.prototype.toString=function(){var t=this.length;return 0===t?"":0===arguments.length?m(this,0,t):function(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return x(this,e,r);case"utf8":case"utf-8":return m(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return E(this,e,r);case"base64":return w(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},h.prototype.equals=function(t){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===h.compare(this,t)},h.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return 0<this.length&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),"<Buffer "+t+">"},h.prototype.compare=function(t,e,r,n,i){if(!h.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(i<=n&&r<=e)return 0;if(i<=n)return-1;if(r<=e)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),s=Math.min(o,a),u=this.slice(n,i),f=t.slice(e,r),c=0;c<s;++c)if(u[c]!==f[c]){o=u[c],a=f[c];break}return o<a?-1:a<o?1:0},h.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},h.prototype.indexOf=function(t,e,r){return v(this,t,e,r,!0)},h.prototype.lastIndexOf=function(t,e,r){return v(this,t,e,r,!1)},h.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||i<r)&&(r=i),0<t.length&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o,a,s,u,f,c,h,l,p,d=!1;;)switch(n){case"hex":return y(this,t,e,r);case"utf8":case"utf-8":return l=e,p=r,L(O(t,(h=this).length-l),h,l,p);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return b(this,t,e,r);case"base64":return u=this,f=e,c=r,L(R(t),u,f,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return a=e,s=r,L(function(t,e){for(var r,n,i,o=[],a=0;a<t.length&&!((e-=2)<0);++a)r=t.charCodeAt(a),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(t,(o=this).length-a),o,a,s);default:if(d)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var _=4096;function A(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function E(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function x(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||n<r)&&(r=n);for(var i="",o=e;o<r;++o)i+=C(t[o]);return i}function B(t,e,r){for(var n=t.slice(e,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function k(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(r<t+e)throw new RangeError("Trying to access beyond buffer length")}function S(t,e,r,n,i,o){if(!h.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(i<e||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function U(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function M(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function I(t,e,r,n,i){return e=+e,r>>>=0,i||U(t,0,r,8),o.write(t,e,r,n,52,8),r+8}h.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):r<t&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):r<e&&(e=r),e<t&&(e=t);var n=this.subarray(t,e);return n.__proto__=h.prototype,n},h.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return n},h.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t+--e],i=1;0<e&&(i*=256);)n+=this[t+--e]*i;return n},h.prototype.readUInt8=function(t,e){return t>>>=0,e||k(t,1,this.length),this[t]},h.prototype.readUInt16LE=function(t,e){return t>>>=0,e||k(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUInt16BE=function(t,e){return t>>>=0,e||k(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUInt32LE=function(t,e){return t>>>=0,e||k(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUInt32BE=function(t,e){return t>>>=0,e||k(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return(i*=128)<=n&&(n-=Math.pow(2,8*e)),n},h.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||k(t,e,this.length);for(var n=e,i=1,o=this[t+--n];0<n&&(i*=256);)o+=this[t+--n]*i;return(i*=128)<=o&&(o-=Math.pow(2,8*e)),o},h.prototype.readInt8=function(t,e){return t>>>=0,e||k(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){t>>>=0,e||k(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt16BE=function(t,e){t>>>=0,e||k(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},h.prototype.readInt32LE=function(t,e){return t>>>=0,e||k(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return t>>>=0,e||k(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readFloatLE=function(t,e){return t>>>=0,e||k(t,4,this.length),o.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return t>>>=0,e||k(t,4,this.length),o.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return t>>>=0,e||k(t,8,this.length),o.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return t>>>=0,e||k(t,8,this.length),o.read(this,t,!1,52,8)},h.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||S(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},h.prototype.writeUIntBE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||S(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;0<=--i&&(o*=256);)this[e+i]=t/o&255;return e+r},h.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,1,255,0),this[e]=255&t,e+1},h.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},h.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);S(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o<r&&(a*=256);)t<0&&0===s&&0!==this[e+o-1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},h.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);S(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;0<=--o&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},h.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},h.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||S(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeFloatLE=function(t,e,r){return M(this,t,e,!0,r)},h.prototype.writeFloatBE=function(t,e,r){return M(this,t,e,!1,r)},h.prototype.writeDoubleLE=function(t,e,r){return I(this,t,e,!0,r)},h.prototype.writeDoubleBE=function(t,e,r){return I(this,t,e,!1,r)},h.prototype.copy=function(t,e,r,n){if(!h.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),0<n&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var i=n-r;if(this===t&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(e,r,n);else if(this===t&&r<e&&e<n)for(var o=i-1;0<=o;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,n),e);return i},h.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!h.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){var i=t.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(t=i)}}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var o;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o<r;++o)this[o]=t;else{var a=h.isBuffer(t)?t:new h(t,n),s=a.length;if(0===s)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<r-e;++o)this[o+e]=a[o%s]}return this};var T=/[^+/0-9A-Za-z-_]/g;function C(t){return t<16?"0"+t.toString(16):t.toString(16)}function O(t,e){var r;e=e||1/0;for(var n=t.length,i=null,o=[],a=0;a<n;++a){if(55295<(r=t.charCodeAt(a))&&r<57344){if(!i){if(56319<r){-1<(e-=3)&&o.push(239,191,189);continue}if(a+1===n){-1<(e-=3)&&o.push(239,191,189);continue}i=r;continue}if(r<56320){-1<(e-=3)&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&-1<(e-=3)&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function R(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(T,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function L(t,e,r,n){for(var i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function N(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function H(t){return t!=t}},{"base64-js":2,ieee754:34}],5:[function(t,e,r){"use strict";var i=t("./validation").validate,o={q:0,p:1,z:2,r:3,y:4,9:5,x:6,8:7,g:8,f:9,2:10,t:11,v:12,d:13,w:14,0:15,s:16,3:17,j:18,n:19,5:20,4:21,k:22,h:23,c:24,e:25,6:26,m:27,u:28,a:29,7:30,l:31};e.exports={encode:function(t){i(t instanceof Uint8Array,"Invalid data: "+t+".");for(var e="",r=0;r<t.length;++r){var n=t[r];i(0<=n&&n<32,"Invalid value: "+n+"."),e+="qpzry9x8gf2tvdw0s3jn54khce6mua7l"[n]}return e},decode:function(t){i("string"==typeof t,"Invalid base32-encoded string: "+t+".");for(var e=new Uint8Array(t.length),r=0;r<t.length;++r){var n=t[r];i(n in o,"Invalid value: "+n+"."),e[r]=o[n]}return e}}},{"./validation":8}],6:[function(t,e,r){"use strict";var f=t("./base32"),s=t("big-integer"),c=t("./convertBits"),n=t("./validation"),h=n.validate;var l=n.ValidationError,p=["bitcoincash","bchtest","bchreg"];function d(t){for(var e=new Uint8Array(t.length),r=0;r<t.length;++r)e[r]=31&t[r].charCodeAt(0);return e}function v(t,e){var r=new Uint8Array(t.length+e.length);return r.set(t),r.set(e,t.length),r}function g(t){for(var e=[656907472481,522768456162,0xf33e5fb3c4,748107326120,130178868336],r=s(1),n=0;n<t.length;++n){var i=t[n],o=r.shiftRight(35);r=r.and(34359738367).shiftLeft(5).xor(i);for(var a=0;a<e.length;++a)o.shiftRight(a).and(1).equals(1)&&(r=r.xor(e[a]))}return r.xor(1)}function y(t){return t===t.toLowerCase()||t===t.toUpperCase()}e.exports={encode:function(t,e,r){var n;h("string"==typeof t&&y(n=t)&&-1!==p.indexOf(n.toLowerCase()),"Invalid prefix: "+t+"."),h("string"==typeof e,"Invalid type: "+e+"."),h(r instanceof Uint8Array,"Invalid hash: "+r+".");var i,o=v(d(t),new Uint8Array(1)),a=function(t){switch(t){case"P2PKH":return 0;case"P2SH":return 8;default:throw new l("Invalid type: "+t+".")}}(e)+function(t){switch(8*t.length){case 160:return 0;case 192:return 1;case 224:return 2;case 256:return 3;case 320:return 4;case 384:return 5;case 448:return 6;case 512:return 7;default:throw new l("Invalid hash size: "+t.length+".")}}(r),s=(i=v(new Uint8Array([a]),r),c(i,8,5)),u=v(s,function(t){for(var e=new Uint8Array(8),r=0;r<8;++r)e[7-r]=t.and(31).toJSNumber(),t=t.shiftRight(5);return e}(g(v(v(o,s),new Uint8Array(8)))));return t+":"+f.encode(u)},decode:function(t){h("string"==typeof t&&y(t),"Invalid address: "+t+".");var e=t.toLowerCase().split(":");h(2===e.length,"Missing prefix: "+t+".");var r,n=e[0],i=f.decode(e[1]);h((r=i,g(v(v(d(n),new Uint8Array(1)),r)).equals(0)),"Invalid checksum: "+t+".");var o,a=(o=i.subarray(0,-8),c(o,5,8,!0)),s=a[0],u=a.subarray(1);return h(function(t){switch(7&t){case 0:return 160;case 1:return 192;case 2:return 224;case 3:return 256;case 4:return 320;case 5:return 384;case 6:return 448;case 7:return 512}}(s)===8*u.length,"Invalid hash size: "+t+"."),{prefix:n,type:function(t){switch(120&t){case 0:return"P2PKH";case 8:return"P2SH";default:throw new l("Invalid address type in version byte: "+t+".")}}(s),hash:u}},ValidationError:l}},{"./base32":5,"./convertBits":7,"./validation":8,"big-integer":3}],7:[function(t,e,r){"use strict";var l=t("./validation").validate;e.exports=function(t,e,r,n){for(var i=n?Math.floor(t.length*e/r):Math.ceil(t.length*e/r),o=(1<<r)-1,a=new Uint8Array(i),s=0,u=0,f=0,c=0;c<t.length;++c){var h=t[c];for(l(0<=h&&h>>e==0,"Invalid value: "+h+"."),u=u<<e|h,f+=e;r<=f;)f-=r,a[s]=u>>f&o,++s}return n?l(f<e&&0==(u<<r-f&o),"Input cannot be converted to "+r+" bits without padding, but strict mode was used."):0<f&&(a[s]=u<<r-f&o,++s),a}},{"./validation":8}],8:[function(t,e,r){"use strict";function n(t){var e=new Error;this.name=e.name="ValidationError",this.message=e.message=t,this.stack=e.stack}n.prototype=Object.create(Error.prototype),e.exports={ValidationError:n,validate:function(t,e){if(!t)throw new n(e)}}},{}],9:[function(t,e,r){"use strict";e.exports=t("./es6/crc1").default},{"./es6/crc1":20}],10:[function(t,e,r){"use strict";e.exports=t("./es6/crc16").default},{"./es6/crc16":21}],11:[function(t,e,r){"use strict";e.exports=t("./es6/crc16ccitt").default},{"./es6/crc16ccitt":22}],12:[function(t,e,r){"use strict";e.exports=t("./es6/crc16kermit").default},{"./es6/crc16kermit":23}],13:[function(t,e,r){"use strict";e.exports=t("./es6/crc16modbus").default},{"./es6/crc16modbus":24}],14:[function(t,e,r){"use strict";e.exports=t("./es6/crc16xmodem").default},{"./es6/crc16xmodem":25}],15:[function(t,e,r){"use strict";e.exports=t("./es6/crc24").default},{"./es6/crc24":26}],16:[function(t,e,r){"use strict";e.exports=t("./es6/crc32").default},{"./es6/crc32":27}],17:[function(t,e,r){"use strict";e.exports=t("./es6/crc8").default},{"./es6/crc8":28}],18:[function(t,e,r){"use strict";e.exports=t("./es6/crc81wire").default},{"./es6/crc81wire":29}],19:[function(t,e,r){"use strict";e.exports=t("./es6/crcjam").default},{"./es6/crcjam":30}],20:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=n(t("./create_buffer"));function n(t){return t&&t.__esModule?t:{default:t}}var i=(0,n(t("./define_crc")).default)("crc1",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=~~e,n=0,i=0;i<t.length;i++){n+=t[i]}return(r+=n%256)%256});r.default=i},{"./create_buffer":31,"./define_crc":32,buffer:4}],21:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,49345,49537,320,49921,960,640,49729,50689,1728,1920,51009,1280,50625,50305,1088,52225,3264,3456,52545,3840,53185,52865,3648,2560,51905,52097,2880,51457,2496,2176,51265,55297,6336,6528,55617,6912,56257,55937,6720,7680,57025,57217,8e3,56577,7616,7296,56385,5120,54465,54657,5440,55041,6080,5760,54849,53761,4800,4992,54081,4352,53697,53377,4160,61441,12480,12672,61761,13056,62401,62081,12864,13824,63169,63361,14144,62721,13760,13440,62529,15360,64705,64897,15680,65281,16320,16e3,65089,64001,15040,15232,64321,14592,63937,63617,14400,10240,59585,59777,10560,60161,11200,10880,59969,60929,11968,12160,61249,11520,60865,60545,11328,58369,9408,9600,58689,9984,59329,59009,9792,8704,58049,58241,9024,57601,8640,8320,57409,40961,24768,24960,41281,25344,41921,41601,25152,26112,42689,42881,26432,42241,26048,25728,42049,27648,44225,44417,27968,44801,28608,28288,44609,43521,27328,27520,43841,26880,43457,43137,26688,30720,47297,47489,31040,47873,31680,31360,47681,48641,32448,32640,48961,32e3,48577,48257,31808,46081,29888,30080,46401,30464,47041,46721,30272,29184,45761,45953,29504,45313,29120,28800,45121,20480,37057,37249,20800,37633,21440,21120,37441,38401,22208,22400,38721,21760,38337,38017,21568,39937,23744,23936,40257,24320,40897,40577,24128,23040,39617,39809,23360,39169,22976,22656,38977,34817,18624,18816,35137,19200,35777,35457,19008,19968,36545,36737,20288,36097,19904,19584,35905,17408,33985,34177,17728,34561,18368,18048,34369,33281,17088,17280,33601,16640,33217,32897,16448];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("crc-16",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=~~e,n=0;n<t.length;n++){var i=t[n];r=65535&(s[255&(r^i)]^r>>8)}return r});r.default=u},{"./create_buffer":31,"./define_crc":32,buffer:4}],22:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];"undefined"!=typeof Int32Array&&(s=new Int32Array(s));var u=(0,n.default)("ccitt",function(t,e){o.Buffer.isBuffer(t)||(t=(0,a.default)(t));for(var r=void 0!==e?~~e:65535,n=0;n<t.length;n++){var i=t[n];r=65535&(s[255&(r>>8^i)]^r<<8)}return r});r.default=u},{"./create_buffer":31,"./define_crc":32,buffer:4}],23:[function(t,e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=t("buffer"),a=i(t("./create_buffer")),n=i(t("./define_crc"));function i(t){return t&&t.__esModule?t:{default:t}}var s=[0,4489,8978,12955,17956,22445,25910,29887,35912,40385,44890,48851,51820,56293,59774,63735,4225,264,13203,8730,22181,18220,30135,25662,40137,36160,49115,44626,56045,52068,63999,59510,8450,12427,528,5017,26406,30383,17460,21949,44362,48323,36440,40913,60270,64231,51324,55797,12675,8202,4753,792,30631,26158,21685,17724,48587,44098,40665,36688,64495,60006,55549,51572,16900,21389,24854,28831,1056,5545,10034,14011,52812,57285,60766,64727,34920,39393,43898,47859,21125,17164,29079,24606,5281,1320,14259,9786,570