>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(g[e])return g[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new y;else if("p192"===e)t=new w;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new _}return g[e]=t,t},S.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},S.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},S.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},S.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},S.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},S.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},S.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},S.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},S.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},S.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},S.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},S.prototype.isqr=function(e){return this.imul(e,e.clone())},S.prototype.sqr=function(e){return this.mul(e,e)},S.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var s=new o(1).toRed(this),u=s.redNeg(),c=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new o(2*h*h).toRed(this);0!==this.pow(h,c).cmp(u);)h.redIAdd(u);for(var f=this.pow(h,i),l=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=a;0!==d.cmp(s);){for(var m=d,g=0;0!==m.cmp(s);g++)m=m.redSqr();n(g=0;n--){for(var c=t.words[n],h=u-1;h>=0;h--){var f=c>>h&1;i!==r[0]&&(i=this.sqr(i)),0!==f||0!==a?(a<<=1,a|=f,(4===++s||0===n&&0===h)&&(i=this.mul(i,r[a]),s=0,a=0)):s=0}u=26}return i},S.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},S.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new M(e)},i(M,S),M.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},M.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},M.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},M.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},M.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,this)}).call(this,r(28)(e))},function(e,t,r){"use strict";var n=r(3),i=function(e){return!!n.isString(e)&&/^[0-9a-fA-F]+$/.test(e)};e.exports={isValidJSON:function(e){var t;if(!n.isString(e))return!1;try{t=JSON.parse(e)}catch(e){return!1}return"object"==typeof t},isHexa:i,isHexaString:i,cloneArray:function(e){return[].concat(e)},defineImmutable:function(e,t){return Object.keys(t).forEach((function(r){Object.defineProperty(e,r,{configurable:!1,enumerable:!0,value:t[r]})})),e},isNaturalNumber:function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e&&e>=0}}},function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t){var r,n,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(e){if(r===setTimeout)return setTimeout(e,0);if((r===o||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:o}catch(e){r=o}try{n="function"==typeof clearTimeout?clearTimeout:a}catch(e){n=a}}();var u,c=[],h=!1,f=-1;function l(){h&&u&&(h=!1,u.length?c=u.concat(c):f=-1,c.length&&d())}function d(){if(!h){var e=s(l);h=!0;for(var t=c.length;t;){for(u=c,c=[];++f1)for(var r=1;re.size?r=n.trim(r,o):o0&&0==(127&e[e.length-1])&&(e.length<=1||0==(128&e[e.length-2])))throw new Error("non-minimally encoded script number");return n.fromSM(e,{endian:"little"})},n.prototype.toScriptNumBuffer=function(){return this.toSM({endian:"little"})},n.trim=function(e,t){return e.slice(t-e.length,e.length)},n.pad=function(e,r,n){for(var i=t.alloc(n),o=0;oa)n=e(n);else if(n73)return!1;if(48!==e[0])return!1;if(e[1]!==e.length-3)return!1;var t=e[3];if(5+t>=e.length)return!1;var r=e[5+t];if(t+r+7!==e.length)return!1;var n=e.slice(4);if(2!==e[2])return!1;if(0===t)return!1;if(128&n[0])return!1;if(t>1&&0===n[0]&&!(128&n[1]))return!1;var i=e.slice(6+t);return 2===e[6+t-2]&&(0!==r&&(!(128&i[0])&&!(r>1&&0===i[0]&&!(128&i[1]))))},u.prototype.hasLowS=function(){return!this.s.lt(new n(1))&&!this.s.gt(new n("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex"))},u.prototype.hasDefinedHashtype=function(){if(!s.isNaturalNumber(this.nhashtype))return!1;var e=this.nhashtype&~u.SIGHASH_ANYONECANPAY;return!(eu.SIGHASH_SINGLE)},u.prototype.toTxFormat=function(){var e=this.toDER(),r=t.alloc(1);return r.writeUInt8(this.nhashtype,0),t.concat([e,r])},u.SIGHASH_ALL=1,u.SIGHASH_NONE=2,u.SIGHASH_SINGLE=3,u.SIGHASH_ANYONECANPAY=128,e.exports=u}).call(this,r(0).Buffer)},function(e,t,r){e.exports=r(181),e.exports.Interpreter=r(368)},function(e,t,r){"use strict";var n=t,i=r(6),o=r(16),a=r(134);n.assert=o,n.toArray=a.toArray,n.zero2=a.zero2,n.toHex=a.toHex,n.encode=a.encode,n.getNAF=function(e,t,r){var n=new Array(Math.max(e.bitLength(),r)+1);n.fill(0);for(var i=1<(i>>1)-1?(i>>1)-u:u,o.isubn(s)):s=0,n[a]=s,o.iushrn(1)}return n},n.getJSF=function(e,t){var r=[[],[]];e=e.clone(),t=t.clone();for(var n=0,i=0;e.cmpn(-n)>0||t.cmpn(-i)>0;){var o,a,s,u=e.andln(3)+n&3,c=t.andln(3)+i&3;if(3===u&&(u=-1),3===c&&(c=-1),0==(1&u))o=0;else o=3!==(s=e.andln(7)+n&7)&&5!==s||2!==c?u:-u;if(r[0].push(o),0==(1&c))a=0;else a=3!==(s=t.andln(7)+i&7)&&5!==s||2!==u?c:-c;r[1].push(a),2*n===o+1&&(n=1-n),2*i===a+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return r},n.cachedProperty=function(e,t,r){var n="_"+t;e.prototype[t]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(e){return"string"==typeof e?n.toArray(e,"hex"):e},n.intFromLE=function(e){return new i(e,"hex","le")}},function(e,t){function r(e,t){if(!e)throw new Error(t||"Assertion failed")}e.exports=r,r.equal=function(e,t,r){if(e!=t)throw new Error(r||"Assertion failed: "+e+" != "+t)}},function(e,t,r){"use strict";var n=r(3);function i(e,t){return e.replace("{0}",t[0]).replace("{1}",t[1]).replace("{2}",t[2])}var o=function(e,t){var r=function(){if(n.isString(t.message))this.message=i(t.message,arguments);else{if(!n.isFunction(t.message))throw new Error("Invalid error definition for "+t.name);this.message=t.message.apply(null,arguments)}this.stack=this.message+"\n"+(new Error).stack};return(r.prototype=Object.create(e.prototype)).name=e.prototype.name+t.name,e[t.name]=r,t.errors&&a(r,t.errors),r},a=function(e,t){n.each(t,(function(t){o(e,t)}))},s={Error:function(){this.message="Internal error",this.stack=this.message+"\n"+(new Error).stack}};s.Error.prototype=Object.create(Error.prototype),s.Error.prototype.name="bitcore.Error";var u,c=r(328);u=s.Error,a(u,c),e.exports=s.Error,e.exports.extend=function(e){return o(s.Error,e)}},function(e,t,r){"use strict";var n=r(16),i=r(1);function o(e,t){return 55296==(64512&e.charCodeAt(t))&&(!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1)))}function a(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function s(e){return 1===e.length?"0"+e:e}function u(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}t.inherits=i,t.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),i=0;i>6|192,r[n++]=63&a|128):o(e,i)?(a=65536+((1023&a)<<10)+(1023&e.charCodeAt(++i)),r[n++]=a>>18|240,r[n++]=a>>12&63|128,r[n++]=a>>6&63|128,r[n++]=63&a|128):(r[n++]=a>>12|224,r[n++]=a>>6&63|128,r[n++]=63&a|128)}else for(i=0;i>>0}return a},t.split32=function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},t.rotr32=function(e,t){return e>>>t|e<<32-t},t.rotl32=function(e,t){return e<>>32-t},t.sum32=function(e,t){return e+t>>>0},t.sum32_3=function(e,t,r){return e+t+r>>>0},t.sum32_4=function(e,t,r,n){return e+t+r+n>>>0},t.sum32_5=function(e,t,r,n,i){return e+t+r+n+i>>>0},t.sum64=function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,a=(o>>0,e[t+1]=o},t.sum64_hi=function(e,t,r,n){return(t+n>>>0>>0},t.sum64_lo=function(e,t,r,n){return t+n>>>0},t.sum64_4_hi=function(e,t,r,n,i,o,a,s){var u=0,c=t;return u+=(c=c+n>>>0)>>0)>>0)>>0},t.sum64_4_lo=function(e,t,r,n,i,o,a,s){return t+n+o+s>>>0},t.sum64_5_hi=function(e,t,r,n,i,o,a,s,u,c){var h=0,f=t;return h+=(f=f+n>>>0)>>0)>>0)>>0)>>0},t.sum64_5_lo=function(e,t,r,n,i,o,a,s,u,c){return t+n+o+s+c>>>0},t.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},t.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},t.shr64_hi=function(e,t,r){return e>>>r},t.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},function(e,t,r){"use strict";(function(t){var n=r(10),i=r(38),o=r(11),a=r(7),s=r(32),u=r(3),c=r(4);function h(e,t){if(!(this instanceof h))return new h(e,t);if(c.checkArgument(e,"First argument is required, please include public key data."),e instanceof h)return e;t=t||{};var r=this._classifyArgs(e,t);return r.point.validate(),a.defineImmutable(this,{point:r.point,compressed:r.compressed,network:r.network||s.defaultNetwork}),this}h.prototype._classifyArgs=function(e,r){var n={compressed:u.isUndefined(r.compressed)||r.compressed};if(e instanceof i)n.point=e;else if(e.x&&e.y)n=h._transformObject(e);else if("string"==typeof e)n=h._transformDER(t.from(e,"hex"));else if(h._isBuffer(e))n=h._transformDER(e);else{if(!h._isPrivateKey(e))throw new TypeError("First argument is an unrecognized data format.");n=h._transformPrivateKey(e)}return n.network||(n.network=u.isUndefined(r.network)?void 0:s.get(r.network)),n},h._isPrivateKey=function(e){return e instanceof r(48)},h._isBuffer=function(e){return e instanceof t||e instanceof Uint8Array},h._transformPrivateKey=function(e){c.checkArgument(h._isPrivateKey(e),"Must be an instance of PrivateKey");var t={};return t.point=i.getG().mul(e.bn),t.compressed=e.compressed,t.network=e.network,t},h._transformDER=function(e,t){c.checkArgument(h._isBuffer(e),"Must be a hex buffer of DER encoded public key");var r,o,a,s,f={};if(t=!!u.isUndefined(t)||t,4!==e[0]&&(t||6!==e[0]&&7!==e[0]))if(3===e[0])a=e.slice(1),r=new n(a),(f=h._transformX(!0,r)).compressed=!0;else{if(2!==e[0])throw new TypeError("Invalid DER format public key");a=e.slice(1),r=new n(a),(f=h._transformX(!1,r)).compressed=!0}else{if(a=e.slice(1,33),s=e.slice(33,65),32!==a.length||32!==s.length||65!==e.length)throw new TypeError("Length of x and y must be 32 bytes");r=new n(a),o=new n(s),f.point=new i(r,o),f.compressed=!1}return f},h._transformX=function(e,t){c.checkArgument("boolean"==typeof e,"Must specify whether y is odd or not (true or false)");var r={};return r.point=i.fromX(e,t),r},h._transformObject=function(e){var t=new n(e.x,"hex"),r=new n(e.y,"hex");return new h(new i(t,r),{compressed:e.compressed})},h.fromPrivateKey=function(e){c.checkArgument(h._isPrivateKey(e),"Must be an instance of PrivateKey");var t=h._transformPrivateKey(e);return new h(t.point,{compressed:t.compressed,network:t.network})},h.fromDER=h.fromBuffer=function(e,t){c.checkArgument(h._isBuffer(e),"Must be a hex buffer of DER encoded public key");var r=h._transformDER(e,t);return new h(r.point,{compressed:r.compressed})},h.fromPoint=function(e,t){return c.checkArgument(e instanceof i,"First argument must be an instance of Point."),new h(e,{compressed:t})},h.fromString=function(e,r){var n=t.from(e,r||"hex"),i=h._transformDER(n);return new h(i.point,{compressed:i.compressed})},h.fromX=function(e,t){var r=h._transformX(e,t);return new h(r.point,{compressed:r.compressed})},h.getValidationError=function(e){var t;try{new h(e)}catch(e){t=e}return t},h.isValid=function(e){return!h.getValidationError(e)},h.prototype.toObject=h.prototype.toJSON=function(){return{x:this.point.getX().toString("hex",2),y:this.point.getY().toString("hex",2),compressed:this.compressed}},h.prototype.toBuffer=h.prototype.toDER=function(){var e,r=this.point.getX(),n=this.point.getY(),i=r.toBuffer({size:32}),o=n.toBuffer({size:32});return this.compressed?(e=o[o.length-1]%2?t.from([3]):t.from([2]),t.concat([e,i])):(e=t.from([4]),t.concat([e,i,o]))},h.prototype._getID=function(){return o.sha256ripemd160(this.toBuffer())},h.prototype.toAddress=function(e,t){return r(20).fromPublicKey(this,e||this.network,t)},h.prototype.toString=function(){return this.toDER().toString("hex")},h.prototype.inspect=function(){return""},e.exports=h}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){var n=r(3),i=r(4),o=r(17),a=r(49),s=r(366),u=r(32),c=r(11),h=r(7),f=r(19);function l(e,t,r,o){if(!(this instanceof l))return new l(e,t,r);if(n.isArray(e)&&n.isNumber(t))return l.createMultisig(e,t,r,!1,o);if(e instanceof l)return e;if(i.checkArgument(e,"First argument is required, please include address data.","guide/address.html"),t&&!u.get(t))throw new TypeError('Second argument must be "livenet" or "testnet".');if(r&&r!==l.PayToPublicKeyHash&&r!==l.PayToScriptHash&&r!==l.PayToWitnessPublicKeyHash&&r!==l.PayToWitnessScriptHash)throw new TypeError('Third argument must be "pubkeyhash", "scripthash", "witnesspubkeyhash", or "witnessscripthash".');var a=this._classifyArguments(e,t,r);return a.network=a.network||u.get(t)||u.defaultNetwork,a.type=a.type||r||l.PayToPublicKeyHash,h.defineImmutable(this,{hashBuffer:a.hashBuffer,network:a.network,type:a.type}),this}l.prototype._classifyArguments=function(e,r,i){if(!(e instanceof t||e instanceof Uint8Array)||20!==e.length&&32!==e.length){if((e instanceof t||e instanceof Uint8Array)&&e.length>=21)return l._transformBuffer(e,r,i);if(e instanceof f)return l._transformPublicKey(e,r,i);if(e instanceof d)return l._transformScript(e,r);if("string"==typeof e)return l._transformString(e,r,i);if(n.isObject(e))return l._transformObject(e);throw new TypeError("First argument is an unrecognized data format.")}return l._transformHash(e,r,i)},l.PayToPublicKeyHash="pubkeyhash",l.PayToScriptHash="scripthash",l.PayToWitnessPublicKeyHash="witnesspubkeyhash",l.PayToWitnessScriptHash="witnessscripthash",l._transformHash=function(e,r,n){var i={};if(!(e instanceof t||e instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(20!==e.length&&32!==e.length)throw new TypeError("Address hashbuffers must be either 20 or 32 bytes.");return i.hashBuffer=e,i.network=u.get(r)||u.defaultNetwork,i.type=n,i},l._transformObject=function(e){return i.checkArgument(e.hash||e.hashBuffer,"Must provide a `hash` or `hashBuffer` property"),i.checkArgument(e.type,"Must provide a `type` property"),{hashBuffer:e.hash?t.from(e.hash,"hex"):e.hashBuffer,network:u.get(e.network)||u.defaultNetwork,type:e.type}},l._classifyFromVersion=function(e){var t={};if(e.length>21){var r=s.decode(e.toString("utf8"));if(0!==r.version)throw new TypeError("Only witness v0 addresses are supported.");if(20===r.data.length)t.type=l.PayToWitnessPublicKeyHash;else{if(32!==r.data.length)throw new TypeError("Witness data must be either 20 or 32 bytes.");t.type=l.PayToWitnessScriptHash}t.network=u.get(r.prefix,"bech32prefix")}else{var n=u.get(e[0],"pubkeyhash"),i=u.get(e[0],"scripthash");n?(t.network=n,t.type=l.PayToPublicKeyHash):i&&(t.network=i,t.type=l.PayToScriptHash)}return t},l._transformBuffer=function(e,r,n){var i={};if(!(e instanceof t||e instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(e.length<21)throw new TypeError("Address buffer is incorrect length.");var o=u.get(r),a=l._classifyFromVersion(e);if(r&&!o)throw new TypeError("Unknown network");if(!a.network||o&&o.xpubkey!==a.network.xpubkey)throw new TypeError("Address has mismatched network type.");if(!a.type||n&&n!==a.type)throw new TypeError("Address has mismatched type.");return e.length>21?i.hashBuffer=s.decode(e.toString("utf8")).data:i.hashBuffer=e.slice(1),i.network=a.network,i.type=a.type,i},l._transformPublicKey=function(e,t,r){var n={};if(!(e instanceof f))throw new TypeError("Address must be an instance of PublicKey.");if(r&&r!==l.PayToScriptHash&&r!==l.PayToWitnessPublicKeyHash&&r!==l.PayToPublicKeyHash)throw new TypeError("Type must be either pubkeyhash, witnesspubkeyhash, or scripthash to transform public key.");if(!e.compressed&&(r===l.PayToScriptHash||r===l.PayToWitnessPublicKeyHash))throw new TypeError("Witness addresses must use compressed public keys.");return r===l.PayToScriptHash?n.hashBuffer=c.sha256ripemd160(d.buildWitnessV0Out(e).toBuffer()):n.hashBuffer=c.sha256ripemd160(e.toBuffer()),n.type=r||l.PayToPublicKeyHash,n},l._transformScript=function(e,t){i.checkArgument(e instanceof d,"script must be a Script instance");var r=e.getAddressInfo(t);if(!r)throw new o.Script.CantDeriveAddress(e);return r},l.createMultisig=function(e,t,r,i,o){if(r=r||e[0].network||u.defaultNetwork,o&&o!==l.PayToScriptHash&&o!==l.PayToWitnessScriptHash)throw new TypeError("Type must be either scripthash or witnessscripthash to create multisig.");if(i||o===l.PayToWitnessScriptHash){e=n.map(e,f);for(var a=0;a100)throw new TypeError("address string is too long");if(r&&!u.get(r))throw new TypeError("Unknown network");e=e.trim();try{return l._transformBuffer(t.from(e,"utf8"),r,n)}catch(e){if(n===l.PayToWitnessPublicKeyHash||n===l.PayToWitnessScriptHash)throw e}var i=a.decode(e);return l._transformBuffer(i,r,n)},l.fromPublicKey=function(e,t,r){var n=l._transformPublicKey(e,t,r);return t=t||u.defaultNetwork,new l(n.hashBuffer,t,n.type)},l.fromPublicKeyHash=function(e,t){var r=l._transformHash(e);return new l(r.hashBuffer,t,l.PayToPublicKeyHash)},l.fromScriptHash=function(e,t,r){i.checkArgument(e,"hash parameter is required");var n=l._transformHash(e);if(r===l.PayToWitnessScriptHash&&32!==e.length)throw new TypeError("Address hashbuffer must be exactly 32 bytes for v0 witness script hash.");r=r||l.PayToScriptHash;return new l(n.hashBuffer,t,r)},l.payingTo=function(e,t,r){var n;i.checkArgument(e,"script is required"),i.checkArgument(e instanceof d,"script must be instance of Script"),n=r===l.PayToWitnessScriptHash?c.sha256(e.toBuffer()):c.sha256ripemd160(e.toBuffer());r=r||l.PayToScriptHash;return l.fromScriptHash(n,t,r)},l.fromScript=function(e,t){i.checkArgument(e instanceof d,"script must be a Script instance");var r=l._transformScript(e,t);return new l(r.hashBuffer,t,r.type)},l.fromBuffer=function(e,t,r){var n=l._transformBuffer(e,t,r);return new l(n.hashBuffer,n.network,n.type)},l.fromString=function(e,t,r){var n=l._transformString(e,t,r);return new l(n.hashBuffer,n.network,n.type)},l.fromObject=function(e){return i.checkState(h.isHexa(e.hash),'Unexpected hash property, "'+e.hash+'", expected to be hex.'),new l(t.from(e.hash,"hex"),e.network,e.type)},l.getValidationError=function(e,t,r){var n;try{new l(e,t,r)}catch(e){n=e}return n},l.isValid=function(e,t,r){return!l.getValidationError(e,t,r)},l.prototype.isPayToPublicKeyHash=function(){return this.type===l.PayToPublicKeyHash},l.prototype.isPayToScriptHash=function(){return this.type===l.PayToScriptHash},l.prototype.isPayToWitnessPublicKeyHash=function(){return this.type===l.PayToWitnessPublicKeyHash},l.prototype.isPayToWitnessScriptHash=function(){return this.type===l.PayToWitnessScriptHash},l.prototype.toBuffer=function(){if(this.isPayToWitnessPublicKeyHash()||this.isPayToWitnessScriptHash())return t.from(this.toString(),"utf8");var e=t.from([this.network[this.type]]);return t.concat([e,this.hashBuffer])},l.prototype.toObject=l.prototype.toJSON=function(){return{hash:this.hashBuffer.toString("hex"),type:this.type,network:this.network.toString()}},l.prototype.toString=function(){if(this.isPayToWitnessPublicKeyHash()||this.isPayToWitnessScriptHash()){var e=this.network.bech32prefix;return s.encode(e,0,this.hashBuffer)}return a.encode(this.toBuffer())},l.prototype.inspect=function(){return""},e.exports=l;var d=r(14)}).call(this,r(0).Buffer)},function(e,t,r){"use strict";(function(t){var n=r(3),i=r(4),o=r(5),a=r(10),s=function e(r){if(!(this instanceof e))return new e(r);if(!n.isUndefined(r))if(t.isBuffer(r))this.set({buf:r});else if(n.isString(r))this.set({buf:t.from(r,"hex")});else{if(!n.isObject(r))throw new TypeError("Unrecognized argument for BufferReader");var i=r;this.set(i)}};s.prototype.set=function(e){return this.buf=e.buf||this.buf||void 0,this.pos=e.pos||this.pos||0,this},s.prototype.eof=function(){return!this.buf||this.pos>=this.buf.length},s.prototype.finished=s.prototype.eof,s.prototype.read=function(e){i.checkArgument(!n.isUndefined(e),"Must specify a length");var t=this.buf.slice(this.pos,this.pos+e);return this.pos=this.pos+e,t},s.prototype.readAll=function(){var e=this.buf.slice(this.pos,this.buf.length);return this.pos=this.buf.length,e},s.prototype.readUInt8=function(){var e=this.buf.readUInt8(this.pos);return this.pos=this.pos+1,e},s.prototype.readUInt16BE=function(){var e=this.buf.readUInt16BE(this.pos);return this.pos=this.pos+2,e},s.prototype.readUInt16LE=function(){var e=this.buf.readUInt16LE(this.pos);return this.pos=this.pos+2,e},s.prototype.readUInt32BE=function(){var e=this.buf.readUInt32BE(this.pos);return this.pos=this.pos+4,e},s.prototype.readUInt32LE=function(){var e=this.buf.readUInt32LE(this.pos);return this.pos=this.pos+4,e},s.prototype.readInt32LE=function(){var e=this.buf.readInt32LE(this.pos);return this.pos=this.pos+4,e},s.prototype.readUInt64BEBN=function(){var e=this.buf.slice(this.pos,this.pos+8),t=a.fromBuffer(e);return this.pos=this.pos+8,t},s.prototype.readUInt64LEBN=function(){var e,t=this.buf.readUInt32LE(this.pos),r=4294967296*this.buf.readUInt32LE(this.pos+4)+t;if(r<=9007199254740991)e=new a(r);else{var n=Array.prototype.slice.call(this.buf,this.pos,this.pos+8);e=new a(n,10,"le")}return this.pos=this.pos+8,e},s.prototype.readVarintNum=function(){var e=this.readUInt8();switch(e){case 253:return this.readUInt16LE();case 254:return this.readUInt32LE();case 255:var t=this.readUInt64LEBN().toNumber();if(t<=Math.pow(2,53))return t;throw new Error("number too large to retain precision - use readVarintBN");default:return e}},s.prototype.readVarLengthBuffer=function(){var e=this.readVarintNum(),t=this.read(e);return i.checkState(t.length===e,"Invalid length while reading varlength buffer. Expected to read: "+e+" and read "+t.length),t},s.prototype.readVarintBuf=function(){switch(this.buf.readUInt8(this.pos)){case 253:return this.read(3);case 254:return this.read(5);case 255:return this.read(9);default:return this.read(1)}},s.prototype.readVarintBN=function(){var e=this.readUInt8();switch(e){case 253:return new a(this.readUInt16LE());case 254:return new a(this.readUInt32LE());case 255:return this.readUInt64LEBN();default:return new a(e)}},s.prototype.reverse=function(){for(var e=t.alloc(this.buf.length),r=0;r9007199254740991?"transaction txout satoshis greater than max safe integer":this._satoshis!==this._satoshisBN.toNumber()?"transaction txout satoshis has corrupted value":this._satoshis<0&&"transaction txout negative"},f.prototype.toObject=f.prototype.toJSON=function(){var e={satoshis:this.satoshis};return e.script=this._scriptBuffer.toString("hex"),e},f.fromObject=function(e){return new f(e)},f.prototype.setScriptFromBuffer=function(e){this._scriptBuffer=e;try{this._script=u.fromBuffer(this._scriptBuffer),this._script._isOutput=!0}catch(e){if(!(e instanceof h.Script.InvalidBuffer))throw e;this._script=null}},f.prototype.setScript=function(e){if(e instanceof u)this._scriptBuffer=e.toBuffer(),this._script=e,this._script._isOutput=!0;else if(n.isString(e))this._script=u.fromString(e),this._scriptBuffer=this._script.toBuffer(),this._script._isOutput=!0;else{if(!o.isBuffer(e))throw new TypeError("Invalid argument type: script");this.setScriptFromBuffer(e)}return this},f.prototype.inspect=function(){var e;return e=this.script?this.script.inspect():this._scriptBuffer.toString("hex"),"