@smartledger/bsv 3.2.0 → 3.2.1

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/bsv.min.js CHANGED
@@ -1,37 +1,37 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.bsv=e():t.bsv=e()}("undefined"!=typeof self?self:this,(function(){return function(t){var e={};function r(i){if(e[i])return e[i].exports;var n=e[i]={i:i,l:!1,exports:{}};return t[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=t,r.c=e,r.d=function(t,e,i){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(i,n,function(e){return t[e]}.bind(null,n));return i},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=7)}([function(t,e,r){"use strict";(function(t){
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.bsv=e():t.bsv=e()}("undefined"!=typeof self?self:this,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=4)}([function(t,e,r){"use strict";(function(t){
2
2
  /*!
3
3
  * The buffer module from node.js, for the browser.
4
4
  *
5
5
  * @author Feross Aboukhadijeh <http://feross.org>
6
6
  * @license MIT
7
7
  */
8
- var i=r(78),n=r(79),o=r(80);function s(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(s()<e)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=c.prototype:(null===t&&(t=new c(e)),t.length=e),t}function c(t,e,r){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(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 h(this,t)}return u(this,t,e,r)}function u(t,e,r,i){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,i){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(i||0))throw new RangeError("'length' is out of bounds");e=void 0===r&&void 0===i?new Uint8Array(e):void 0===i?new Uint8Array(e,r):new Uint8Array(e,r,i);c.TYPED_ARRAY_SUPPORT?(t=e).__proto__=c.prototype:t=d(t,e);return t}(t,e,r,i):"string"==typeof e?function(t,e,r){"string"==typeof r&&""!==r||(r="utf8");if(!c.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var i=0|l(e,r),n=(t=a(t,i)).write(e,r);n!==i&&(t=t.slice(0,n));return t}(t,e,r):function(t,e){if(c.isBuffer(e)){var r=0|p(e.length);return 0===(t=a(t,r)).length||e.copy(t,0,0,r),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(i=e.length)!=i?a(t,0):d(t,e);if("Buffer"===e.type&&o(e.data))return d(t,e.data)}var i;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function f(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function h(t,e){if(f(e),t=a(t,e<0?0:0|p(e)),!c.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function d(t,e){var r=e.length<0?0:0|p(e.length);t=a(t,r);for(var i=0;i<r;i+=1)t[i]=255&e[i];return t}function p(t){if(t>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|t}function l(t,e){if(c.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return D(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return K(t).length;default:if(i)return D(t).length;e=(""+e).toLowerCase(),i=!0}}function g(t,e,r){var i=!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 A(this,e,r);case"ascii":return E(this,e,r);case"latin1":case"binary":return k(this,e,r);case"base64":return P(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,r);default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}function m(t,e,r){var i=t[e];t[e]=t[r],t[r]=i}function b(t,e,r,i,n){if(0===t.length)return-1;if("string"==typeof r?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=n?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(n)return-1;r=t.length-1}else if(r<0){if(!n)return-1;r=0}if("string"==typeof e&&(e=c.from(e,i)),c.isBuffer(e))return 0===e.length?-1:y(t,e,r,i,n);if("number"==typeof e)return e&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,i,n);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,i,n){var o,s=1,a=t.length,c=e.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(t.length<2||e.length<2)return-1;s=2,a/=2,c/=2,r/=2}function u(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(n){var f=-1;for(o=r;o<a;o++)if(u(t,o)===u(e,-1===f?0:o-f)){if(-1===f&&(f=o),o-f+1===c)return f*s}else-1!==f&&(o-=o-f),f=-1}else for(r+c>a&&(r=a-c),o=r;o>=0;o--){for(var h=!0,d=0;d<c;d++)if(u(t,o+d)!==u(e,d)){h=!1;break}if(h)return o}return-1}function v(t,e,r,i){r=Number(r)||0;var n=t.length-r;i?(i=Number(i))>n&&(i=n):i=n;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");i>o/2&&(i=o/2);for(var s=0;s<i;++s){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))return s;t[r+s]=a}return s}function S(t,e,r,i){return z(D(e,t.length-r),t,r,i)}function _(t,e,r,i){return z(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,i)}function w(t,e,r,i){return _(t,e,r,i)}function I(t,e,r,i){return z(K(e),t,r,i)}function O(t,e,r,i){return z(function(t,e){for(var r,i,n,o=[],s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),i=r>>8,n=r%256,o.push(n),o.push(i);return o}(e,t.length-r),t,r,i)}function P(t,e,r){return 0===e&&r===t.length?i.fromByteArray(t):i.fromByteArray(t.slice(e,r))}function A(t,e,r){r=Math.min(t.length,r);for(var i=[],n=e;n<r;){var o,s,a,c,u=t[n],f=null,h=u>239?4:u>223?3:u>191?2:1;if(n+h<=r)switch(h){case 1:u<128&&(f=u);break;case 2:128==(192&(o=t[n+1]))&&(c=(31&u)<<6|63&o)>127&&(f=c);break;case 3:o=t[n+1],s=t[n+2],128==(192&o)&&128==(192&s)&&(c=(15&u)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(f=c);break;case 4:o=t[n+1],s=t[n+2],a=t[n+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(f=c)}null===f?(f=65533,h=1):f>65535&&(f-=65536,i.push(f>>>10&1023|55296),f=56320|1023&f),i.push(f),n+=h}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);var r="",i=0;for(;i<e;)r+=String.fromCharCode.apply(String,t.slice(i,i+=4096));return r}(i)}e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=s(),c.poolSize=8192,c._augment=function(t){return t.__proto__=c.prototype,t},c.from=function(t,e,r){return u(null,t,e,r)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(t,e,r){return function(t,e,r,i){return f(e),e<=0?a(t,e):void 0!==r?"string"==typeof i?a(t,e).fill(r,i):a(t,e).fill(r):a(t,e)}(null,t,e,r)},c.allocUnsafe=function(t){return h(null,t)},c.allocUnsafeSlow=function(t){return h(null,t)},c.isBuffer=function(t){return!(null==t||!t._isBuffer)},c.compare=function(t,e){if(!c.isBuffer(t)||!c.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,i=e.length,n=0,o=Math.min(r,i);n<o;++n)if(t[n]!==e[n]){r=t[n],i=e[n];break}return r<i?-1:i<r?1:0},c.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}},c.concat=function(t,e){if(!o(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return c.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var i=c.allocUnsafe(e),n=0;for(r=0;r<t.length;++r){var s=t[r];if(!c.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(i,n),n+=s.length}return i},c.byteLength=l,c.prototype._isBuffer=!0,c.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)m(this,e,e+1);return this},c.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)m(this,e,e+3),m(this,e+1,e+2);return this},c.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)m(this,e,e+7),m(this,e+1,e+6),m(this,e+2,e+5),m(this,e+3,e+4);return this},c.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?A(this,0,t):g.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},c.prototype.compare=function(t,e,r,i,n){if(!c.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===i&&(i=0),void 0===n&&(n=this.length),e<0||r>t.length||i<0||n>this.length)throw new RangeError("out of range index");if(i>=n&&e>=r)return 0;if(i>=n)return-1;if(e>=r)return 1;if(this===t)return 0;for(var o=(n>>>=0)-(i>>>=0),s=(r>>>=0)-(e>>>=0),a=Math.min(o,s),u=this.slice(i,n),f=t.slice(e,r),h=0;h<a;++h)if(u[h]!==f[h]){o=u[h],s=f[h];break}return o<s?-1:s<o?1:0},c.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},c.prototype.indexOf=function(t,e,r){return b(this,t,e,r,!0)},c.prototype.lastIndexOf=function(t,e,r){return b(this,t,e,r,!1)},c.prototype.write=function(t,e,r,i){if(void 0===e)i="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)i=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===i&&(i="utf8")):(i=r,r=void 0)}var n=this.length-e;if((void 0===r||r>n)&&(r=n),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return S(this,t,e,r);case"ascii":return _(this,t,e,r);case"latin1":case"binary":return w(this,t,e,r);case"base64":return I(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function E(t,e,r){var i="";r=Math.min(t.length,r);for(var n=e;n<r;++n)i+=String.fromCharCode(127&t[n]);return i}function k(t,e,r){var i="";r=Math.min(t.length,r);for(var n=e;n<r;++n)i+=String.fromCharCode(t[n]);return i}function x(t,e,r){var i=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>i)&&(r=i);for(var n="",o=e;o<r;++o)n+=F(t[o]);return n}function T(t,e,r){for(var i=t.slice(e,r),n="",o=0;o<i.length;o+=2)n+=String.fromCharCode(i[o]+256*i[o+1]);return n}function R(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function M(t,e,r,i,n,o){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>n||e<o)throw new RangeError('"value" argument is out of bounds');if(r+i>t.length)throw new RangeError("Index out of range")}function N(t,e,r,i){e<0&&(e=65535+e+1);for(var n=0,o=Math.min(t.length-r,2);n<o;++n)t[r+n]=(e&255<<8*(i?n:1-n))>>>8*(i?n:1-n)}function B(t,e,r,i){e<0&&(e=4294967295+e+1);for(var n=0,o=Math.min(t.length-r,4);n<o;++n)t[r+n]=e>>>8*(i?n:3-n)&255}function C(t,e,r,i,n,o){if(r+i>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function H(t,e,r,i,o){return o||C(t,0,r,4),n.write(t,e,r,i,23,4),r+4}function U(t,e,r,i,o){return o||C(t,0,r,8),n.write(t,e,r,i,52,8),r+8}c.prototype.slice=function(t,e){var r,i=this.length;if((t=~~t)<0?(t+=i)<0&&(t=0):t>i&&(t=i),(e=void 0===e?i:~~e)<0?(e+=i)<0&&(e=0):e>i&&(e=i),e<t&&(e=t),c.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=c.prototype;else{var n=e-t;r=new c(n,void 0);for(var o=0;o<n;++o)r[o]=this[o+t]}return r},c.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||R(t,e,this.length);for(var i=this[t],n=1,o=0;++o<e&&(n*=256);)i+=this[t+o]*n;return i},c.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||R(t,e,this.length);for(var i=this[t+--e],n=1;e>0&&(n*=256);)i+=this[t+--e]*n;return i},c.prototype.readUInt8=function(t,e){return e||R(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,e){return e||R(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,e){return e||R(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,e){return e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,e){return e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||R(t,e,this.length);for(var i=this[t],n=1,o=0;++o<e&&(n*=256);)i+=this[t+o]*n;return i>=(n*=128)&&(i-=Math.pow(2,8*e)),i},c.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||R(t,e,this.length);for(var i=e,n=1,o=this[t+--i];i>0&&(n*=256);)o+=this[t+--i]*n;return o>=(n*=128)&&(o-=Math.pow(2,8*e)),o},c.prototype.readInt8=function(t,e){return e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){e||R(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(t,e){e||R(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(t,e){return e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,e){return e||R(t,4,this.length),n.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return e||R(t,4,this.length),n.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return e||R(t,8,this.length),n.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return e||R(t,8,this.length),n.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,e,r,i){(t=+t,e|=0,r|=0,i)||M(this,t,e,r,Math.pow(2,8*r)-1,0);var n=1,o=0;for(this[e]=255&t;++o<r&&(n*=256);)this[e+o]=t/n&255;return e+r},c.prototype.writeUIntBE=function(t,e,r,i){(t=+t,e|=0,r|=0,i)||M(this,t,e,r,Math.pow(2,8*r)-1,0);var n=r-1,o=1;for(this[e+n]=255&t;--n>=0&&(o*=256);)this[e+n]=t/o&255;return e+r},c.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||M(this,t,e,1,255,0),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},c.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||M(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},c.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||M(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},c.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||M(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):B(this,t,e,!0),e+4},c.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||M(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):B(this,t,e,!1),e+4},c.prototype.writeIntLE=function(t,e,r,i){if(t=+t,e|=0,!i){var n=Math.pow(2,8*r-1);M(this,t,e,r,n-1,-n)}var o=0,s=1,a=0;for(this[e]=255&t;++o<r&&(s*=256);)t<0&&0===a&&0!==this[e+o-1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r},c.prototype.writeIntBE=function(t,e,r,i){if(t=+t,e|=0,!i){var n=Math.pow(2,8*r-1);M(this,t,e,r,n-1,-n)}var o=r-1,s=1,a=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r},c.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||M(this,t,e,1,127,-128),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||M(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},c.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||M(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},c.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||M(this,t,e,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):B(this,t,e,!0),e+4},c.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||M(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):B(this,t,e,!1),e+4},c.prototype.writeFloatLE=function(t,e,r){return H(this,t,e,!0,r)},c.prototype.writeFloatBE=function(t,e,r){return H(this,t,e,!1,r)},c.prototype.writeDoubleLE=function(t,e,r){return U(this,t,e,!0,r)},c.prototype.writeDoubleBE=function(t,e,r){return U(this,t,e,!1,r)},c.prototype.copy=function(t,e,r,i){if(r||(r=0),i||0===i||(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<r&&(i=r),i===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("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-r&&(i=t.length-e+r);var n,o=i-r;if(this===t&&r<e&&e<i)for(n=o-1;n>=0;--n)t[n+e]=this[n+r];else if(o<1e3||!c.TYPED_ARRAY_SUPPORT)for(n=0;n<o;++n)t[n+e]=this[n+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+o),e);return o},c.prototype.fill=function(t,e,r,i){if("string"==typeof t){if("string"==typeof e?(i=e,e=0,r=this.length):"string"==typeof r&&(i=r,r=this.length),1===t.length){var n=t.charCodeAt(0);n<256&&(t=n)}if(void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!c.isEncoding(i))throw new TypeError("Unknown encoding: "+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 s=c.isBuffer(t)?t:D(new c(t,i).toString()),a=s.length;for(o=0;o<r-e;++o)this[o+e]=s[o%a]}return this};var L=/[^+\/0-9A-Za-z-_]/g;function F(t){return t<16?"0"+t.toString(16):t.toString(16)}function D(t,e){var r;e=e||1/0;for(var i=t.length,n=null,o=[],s=0;s<i;++s){if((r=t.charCodeAt(s))>55295&&r<57344){if(!n){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===i){(e-=3)>-1&&o.push(239,191,189);continue}n=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&(e-=3)>-1&&o.push(239,191,189);if(n=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 K(t){return i.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function z(t,e,r,i){for(var n=0;n<i&&!(n+r>=e.length||n>=t.length);++n)e[n+r]=t[n];return n}}).call(this,r(40))},function(t,e,r){"use strict";var i={isArray:t=>Array.isArray(t),isNumber:t=>"number"==typeof t,isObject:t=>t&&"object"==typeof t,isString:t=>"string"==typeof t,isUndefined:t=>void 0===t,isFunction:t=>"function"==typeof t,isNull:t=>null===t,isDate:t=>t instanceof Date,extend:(t,e)=>Object.assign(t,e),noop:()=>{},every:(t,e)=>t.every(e||(t=>t)),map:(t,e)=>Array.from(t).map(e||(t=>t)),includes:(t,e)=>t.includes(e),each:(t,e)=>t.forEach(e),clone:t=>Object.assign({},t),pick:(t,e)=>{const r={};return e.forEach(e=>{void 0!==t[e]&&(r[e]=t[e])}),r},values:t=>Object.values(t),filter:(t,e)=>t.filter(e),reduce:(t,e,r)=>t.reduce(e,r),without:(t,e)=>t.filter(t=>t!==e),shuffle:t=>{const e=t.slice(0);for(let t=e.length-1;t>0;t--){const r=Math.floor(Math.random()*(t+1));[e[t],e[r]]=[e[r],e[t]]}return e},difference:(t,e)=>t.filter(t=>!e.includes(t)),findIndex:(t,e)=>t.findIndex(e),some:(t,e)=>t.some(e),range:t=>[...Array(t).keys()]};t.exports=i},function(t,e,r){"use strict";var i=r(10),n=r(1);t.exports={checkState:function(t,e){if(!t)throw new i.InvalidState(e)},checkArgument:function(t,e,r,n){if(!t)throw new i.InvalidArgument(e,r,n)},checkArgumentType:function(t,e,o){if(o=o||"(unknown name)",n.isString(e)){if("Buffer"===e){if(!r(0).Buffer.isBuffer(t))throw new i.InvalidArgumentType(t,e,o)}else if(typeof t!==e)throw new i.InvalidArgumentType(t,e,o)}else if(!(t instanceof e))throw new i.InvalidArgumentType(t,e.name,o)}}},function(t,e,r){"use strict";(function(e){var i=r(9),n=r(2),o=r(1),s=function(t){for(var r=e.alloc(t.length),i=0;i<t.length;i++)r[i]=t[t.length-1-i];return r};i.Zero=new i(0),i.One=new i(1),i.Minus1=new i(-1),i.fromNumber=function(t){return n.checkArgument(o.isNumber(t)),new i(t)},i.fromString=function(t,e){return n.checkArgument(o.isString(t)),new i(t,e)},i.fromBuffer=function(t,e){void 0!==e&&"little"===e.endian&&(t=s(t));var r=t.toString("hex");return new i(r,16)},i.fromSM=function(t,r){var n;if(0===t.length)return i.fromBuffer(e.from([0]));var o="big";return r&&(o=r.endian),"little"===o&&(t=s(t)),128&t[0]?(t[0]=127&t[0],(n=i.fromBuffer(t)).neg().copy(n)):n=i.fromBuffer(t),n},i.prototype.toNumber=function(){return parseInt(this.toString(10),10)},i.prototype.toBuffer=function(t){var r,n;if(t&&t.size){var o=(n=this.toString(16,2)).length/2;r=e.from(n,"hex"),o===t.size||(o>t.size?r=i.trim(r,o):o<t.size&&(r=i.pad(r,o,t.size)))}else n=this.toString(16,2),r=e.from(n,"hex");return void 0!==t&&"little"===t.endian&&(r=s(r)),r},i.prototype.toSMBigEndian=function(){var t;return-1===this.cmp(i.Zero)?128&(t=this.neg().toBuffer())[0]?t=e.concat([e.from([128]),t]):t[0]=128|t[0]:128&(t=this.toBuffer())[0]&&(t=e.concat([e.from([0]),t])),1===t.length&0===t[0]&&(t=e.from([])),t},i.prototype.toSM=function(t){var e=t?t.endian:"big",r=this.toSMBigEndian();return"little"===e&&(r=s(r)),r},i.fromScriptNumBuffer=function(t,e,r){var o=r||4;if(n.checkArgument(t.length<=o,new Error("script number overflow")),e&&t.length>0&&0==(127&t[t.length-1])&&(t.length<=1||0==(128&t[t.length-2])))throw new Error("non-minimally encoded script number");return i.fromSM(t,{endian:"little"})},i.prototype.toScriptNumBuffer=function(){return this.toSM({endian:"little"})},i.trim=function(t,e){return t.slice(e-t.length,t.length)},i.pad=function(t,r,i){for(var n=e.alloc(i),o=0;o<t.length;o++)n[n.length-1-o]=t[t.length-1-o];for(o=0;o<i-r;o++)n[o]=0;return n},i.prototype.toHex=function(...t){return this.toBuffer(...t).toString("hex")},i.fromHex=function(t,...r){return i.fromBuffer(e.from(t,"hex"),...r)},t.exports=i}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(3),n=r(1),o=r(2),s=r(5),a=function t(e,r){if(!(this instanceof t))return new t(e,r);if(e instanceof i)this.set({r:e,s:r});else if(e){var n=e;this.set(n)}};a.prototype.set=function(t){return this.r=t.r||this.r||void 0,this.s=t.s||this.s||void 0,this.i=void 0!==t.i?t.i:this.i,this.compressed=void 0!==t.compressed?t.compressed:this.compressed,this.nhashtype=t.nhashtype||this.nhashtype||void 0,this},a.fromCompact=function(t){o.checkArgument(e.isBuffer(t),"Argument is expected to be a Buffer");var r=new a,n=!0,s=t.slice(0,1)[0]-27-4;s<0&&(n=!1,s+=4);var c=t.slice(1,33),u=t.slice(33,65);return o.checkArgument(0===s||1===s||2===s||3===s,new Error("i must be 0, 1, 2, or 3")),o.checkArgument(32===c.length,new Error("r must be 32 bytes")),o.checkArgument(32===u.length,new Error("s must be 32 bytes")),r.compressed=n,r.i=s,r.r=i.fromBuffer(c),r.s=i.fromBuffer(u),r},a.fromDER=a.fromBuffer=function(t,e){var r=a.parseDER(t,e),i=new a;return i.r=r.r,i.s=r.s,i},a.fromTxFormat=function(t){var e=t.readUInt8(t.length-1),r=t.slice(0,t.length-1),i=a.fromDER(r,!1);return i.nhashtype=e,i},a.fromString=function(t){var r=e.from(t,"hex");return a.fromDER(r)},a.parseDER=function(t,r){o.checkArgument(e.isBuffer(t),new Error("DER formatted signature should be a buffer")),n.isUndefined(r)&&(r=!0);var s=t[0];o.checkArgument(48===s,new Error("Header byte should be 0x30"));var a=t[1],c=t.slice(2).length;o.checkArgument(!r||a===c,new Error("Length byte should length of what follows")),a=a<c?a:c;var u=t[2];o.checkArgument(2===u,new Error("Integer byte for r should be 0x02"));var f=t[3],h=t.slice(4,4+f),d=i.fromBuffer(h),p=0===t[4];o.checkArgument(f===h.length,new Error("Length of r incorrect"));var l=t[4+f+0];o.checkArgument(2===l,new Error("Integer byte for s should be 0x02"));var g=t[4+f+1],m=t.slice(4+f+2,4+f+2+g),b=i.fromBuffer(m),y=0===t[4+f+2+2];o.checkArgument(g===m.length,new Error("Length of s incorrect"));var v=4+f+2+g;return o.checkArgument(a===v-2,new Error("Length of signature incorrect")),{header:s,length:a,rheader:u,rlength:f,rneg:p,rbuf:h,r:d,sheader:l,slength:g,sneg:y,sbuf:m,s:b}},a.prototype.toCompact=function(t,r){if(t="number"==typeof t?t:this.i,r="boolean"==typeof r?r:this.compressed,0!==t&&1!==t&&2!==t&&3!==t)throw new Error("i must be equal to 0, 1, 2, or 3");var i=t+27+4;!1===r&&(i-=4);var n=e.from([i]),o=this.r.toBuffer({size:32}),s=this.s.toBuffer({size:32});return e.concat([n,o,s])},a.prototype.toBuffer=a.prototype.toDER=function(){var t=this.r.toBuffer(),r=this.s.toBuffer(),i=!!(128&t[0]),n=!!(128&r[0]),o=i?e.concat([e.from([0]),t]):t,s=n?e.concat([e.from([0]),r]):r,a=o.length,c=s.length,u=2+a+2+c;return e.concat([e.from([48,u,2,a]),o,e.from([2,c]),s])},a.prototype.toString=function(){return this.toDER().toString("hex")},a.isTxDER=function(t){if(t.length<9)return!1;if(t.length>73)return!1;if(48!==t[0])return!1;if(t[1]!==t.length-3)return!1;var e=t[3];if(5+e>=t.length)return!1;var r=t[5+e];if(e+r+7!==t.length)return!1;var i=t.slice(4);if(2!==t[2])return!1;if(0===e)return!1;if(128&i[0])return!1;if(e>1&&0===i[0]&&!(128&i[1]))return!1;var n=t.slice(6+e);return 2===t[6+e-2]&&(0!==r&&(!(128&n[0])&&!(r>1&&0===n[0]&&!(128&n[1]))))},a.prototype.hasLowS=function(){return!this.s.lt(new i(1))&&!this.s.gt(new i("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex"))},a.prototype.hasDefinedHashtype=function(){if(!s.isNaturalNumber(this.nhashtype))return!1;var t=31&this.nhashtype;return!(t<a.SIGHASH_ALL||t>a.SIGHASH_SINGLE)},a.prototype.toTxFormat=function(){var t=this.toDER(),r=e.alloc(1);return r.writeUInt8(this.nhashtype,0),e.concat([t,r])},a.SIGHASH_ALL=1,a.SIGHASH_NONE=2,a.SIGHASH_SINGLE=3,a.SIGHASH_FORKID=64,a.SIGHASH_ANYONECANPAY=128,a.prototype.isCanonical=function(){var t=r(11).getN().shrn(1);return this.s.lte(t)},a.prototype.toCanonical=function(){if(this.isCanonical())return new a({r:this.r,s:this.s,i:this.i,compressed:this.compressed,nhashtype:this.nhashtype});var t=r(11).getN().sub(this.s);return new a({r:this.r,s:t,i:this.i,compressed:this.compressed,nhashtype:this.nhashtype})},a.prototype.validate=function(){if(!this.r||!this.s)throw new Error("Signature missing r or s component");if(this.r.isZero())throw new Error("Signature r component is zero");if(this.s.isZero())throw new Error("Signature s component is zero");var t=r(11).getN();if(this.r.gte(t))throw new Error("Signature r component >= curve order");if(this.s.gte(t))throw new Error("Signature s component >= curve order");if(this.r.isNeg())throw new Error("Signature r component is negative");if(this.s.isNeg())throw new Error("Signature s component is negative");return!0},a.prototype.isValid=function(){try{return this.validate(),!0}catch(t){return!1}},a.prototype.applySecurityPatches=function(){var t=r(11).getN(),e=t.shrn(1);if(this.r.isZero()||this.s.isZero())throw new Error("Invalid signature: zero r or s");if(this.r.gte(t)||this.s.gte(t))throw new Error("Invalid signature: out of range");return this.s.gt(e)&&(this.s=t.sub(this.s)),this},t.exports=a}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(1),n=r(2),o=function(t){return!!i.isString(t)&&/^[0-9a-fA-F]+$/.test(t)};t.exports={isValidJSON:function(t){var e;if(!i.isString(t))return!1;try{e=JSON.parse(t)}catch(t){return!1}return"object"==typeof e},isHexa:o,isHexaString:o,defineImmutable:function(t,e){return Object.keys(e).forEach((function(r){Object.defineProperty(t,r,{configurable:!1,enumerable:!0,value:e[r]})})),t},isNaturalNumber:function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t&&t>=0},integerAsBuffer:function(t){n.checkArgumentType(t,"number","integer");const r=e.allocUnsafe(4);return r.writeUInt32BE(t,0),r}}}).call(this,r(0).Buffer)},function(t,e,r){(function(e){e.browser?t.exports=r(105):t.exports=r(106)}).call(this,r(24))},function(t,e,r){"use strict";(function(e,i){var n=t.exports;n.deps=n.deps||{};try{n.deps.bnjs=r(9),n.deps.bs58=r(54),n.deps.Buffer=void 0!==e?e:null,n.deps.elliptic=r(41),n.deps._=r(1)}catch(t){console.warn("Some dependencies may not be available in browser environment:",t.message)}if(n.version="v"+r(103).version,n.versionGuard=function(t){if(void 0!==t){console.warn("\n More than one instance of bsv found.\n Please make sure to require bsv and check that submodules do\n not also include their own bsv dependency.")}},n.versionGuard(i._bsv),i._bsv=n.version,n.isHardened=!0,n.hardenedBy="SmartLedger",n.baseVersion="v1.5.6",n.securityFeatures=["canonical-signatures","malleability-protection","enhanced-validation","elliptic-patches"],n.crypto={},n.crypto.BN=r(3),n.crypto.ECDSA=r(44),n.crypto.Hash=r(6),n.crypto.Random=r(38),n.crypto.Point=r(11),n.crypto.Signature=r(4),n.crypto.SmartVerify=r(51),n.crypto.EllipticFixed=r(52),n.encoding={},n.encoding.Base58=r(35),n.encoding.Base58Check=r(27),n.encoding.BufferReader=r(18),n.encoding.BufferWriter=r(16),n.encoding.Varint=r(28),n.util={},n.util.js=r(5),n.util.preconditions=r(2),n.errors=r(10),n.Address=r(25),n.Block=r(146),n.MerkleBlock=r(73),n.BlockHeader=r(39),n.HDPrivateKey=r(74),n.HDPublicKey=r(75),n.Networks=r(23),n.Opcode=r(48),n.PrivateKey=r(34),n.PublicKey=r(14),n.Script=r(12),n.Transaction=r(37),n.Message=r(148),n.Signature=r(4),n.SmartLedger={version:n.version,hardenedBy:n.hardenedBy,baseVersion:n.baseVersion,securityFeatures:n.securityFeatures,SmartVerify:r(51),EllipticFixed:r(52)},n.SmartVerify=r(51),n.EllipticFixed=r(52),"undefined"==typeof window)try{n.SmartUTXO=r(150),n.SmartMiner=r(152),n.CustomScriptHelper=r(153),n.SmartContract=r(154)}catch(t){}n.Transaction.sighash=r(19)}).call(this,r(0).Buffer,r(40))},function(t,e,r){"use strict";var i=e,n=r(9),o=r(21),s=r(55);i.assert=o,i.toArray=s.toArray,i.zero2=s.zero2,i.toHex=s.toHex,i.encode=s.encode,i.getNAF=function(t,e,r){var i,n=new Array(Math.max(t.bitLength(),r)+1);for(i=0;i<n.length;i+=1)n[i]=0;var o=1<<e+1,s=t.clone();for(i=0;i<n.length;i++){var a,c=s.andln(o-1);s.isOdd()?(a=c>(o>>1)-1?(o>>1)-c:c,s.isubn(a)):a=0,n[i]=a,s.iushrn(1)}return n},i.getJSF=function(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var i,n=0,o=0;t.cmpn(-n)>0||e.cmpn(-o)>0;){var s,a,c=t.andln(3)+n&3,u=e.andln(3)+o&3;3===c&&(c=-1),3===u&&(u=-1),s=0==(1&c)?0:3!==(i=t.andln(7)+n&7)&&5!==i||2!==u?c:-c,r[0].push(s),a=0==(1&u)?0:3!==(i=e.andln(7)+o&7)&&5!==i||2!==c?u:-u,r[1].push(a),2*n===s+1&&(n=1-n),2*o===a+1&&(o=1-o),t.iushrn(1),e.iushrn(1)}return r},i.cachedProperty=function(t,e,r){var i="_"+e;t.prototype[e]=function(){return void 0!==this[i]?this[i]:this[i]=r.call(this)}},i.parseBytes=function(t){return"string"==typeof t?i.toArray(t,"hex"):t},i.intFromLE=function(t){return new n(t,"hex","le")}},function(t,e,r){(function(t){!function(t,e){"use strict";function i(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function o(t,e,r){if(o.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var s;"object"==typeof t?t.exports=o:e.BN=o,o.BN=o,o.wordSize=26;try{s=r(81).Buffer}catch(t){}function a(t,e,r){for(var i=0,n=Math.min(t.length,r),o=e;o<n;o++){var s=t.charCodeAt(o)-48;i<<=4,i|=s>=49&&s<=54?s-49+10:s>=17&&s<=22?s-17+10:15&s}return i}function c(t,e,r,i){for(var n=0,o=Math.min(t.length,r),s=e;s<o;s++){var a=t.charCodeAt(s)-48;n*=i,n+=a>=49?a-49+10:a>=17?a-17+10:a}return n}o.isBN=function(t){return t instanceof o||null!==t&&"object"==typeof t&&t.constructor.wordSize===o.wordSize&&Array.isArray(t.words)},o.max=function(t,e){return t.cmp(e)>0?t:e},o.min=function(t,e){return t.cmp(e)<0?t:e},o.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),i(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&n++,16===e?this._parseHex(t,n):this._parseBase(t,e,n),"-"===t[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),e,r)},o.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(i(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},o.prototype._initArray=function(t,e,r){if(i("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var o,s,a=0;if("be"===r)for(n=t.length-1,o=0;n>=0;n-=3)s=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(n=0,o=0;n<t.length;n+=3)s=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},o.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var i,n,o=0;for(r=t.length-6,i=0;r>=e;r-=6)n=a(t,r,r+6),this.words[i]|=n<<o&67108863,this.words[i+1]|=n>>>26-o&4194303,(o+=24)>=26&&(o-=26,i++);r+6!==e&&(n=a(t,e,r+6),this.words[i]|=n<<o&67108863,this.words[i+1]|=n>>>26-o&4194303),this.strip()},o.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var o=t.length-r,s=o%i,a=Math.min(o,o-s)+r,u=0,f=r;f<a;f+=i)u=c(t,f,f+i,e),this.imuln(n),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==s){var h=1;for(u=c(t,f,t.length,e),f=0;f<s;f++)h*=e;this.imuln(h),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}},o.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},o.prototype.clone=function(){var t=new o(null);return this.copy(t),t},o.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},o.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function d(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],o=0|e.words[0],s=n*o,a=67108863&s,c=s/67108864|0;r.words[0]=a;for(var u=1;u<i;u++){for(var f=c>>>26,h=67108863&c,d=Math.min(u,e.length-1),p=Math.max(0,u-t.length+1);p<=d;p++){var l=u-p|0;f+=(s=(n=0|t.words[l])*(o=0|e.words[p])+h)/67108864|0,h=67108863&s}r.words[u]=0|h,c=0|f}return 0!==c?r.words[u]=0|c:r.length--,r.strip()}o.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var n=0,o=0,s=0;s<this.length;s++){var a=this.words[s],c=(16777215&(a<<n|o)).toString(16);r=0!==(o=a>>>24-n&16777215)||s!==this.length-1?u[6-c.length]+c+r:c+r,(n+=2)>=26&&(n-=26,s--)}for(0!==o&&(r=o.toString(16)+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var d=f[t],p=h[t];r="";var l=this.clone();for(l.negative=0;!l.isZero();){var g=l.modn(p).toString(t);r=(l=l.idivn(p)).isZero()?g+r:u[d-g.length]+g+r}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}i(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(t,e){return i(void 0!==s),this.toArrayLike(s,t,e)},o.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},o.prototype.toArrayLike=function(t,e,r){var n=this.byteLength(),o=r||Math.max(1,n);i(n<=o,"byte array longer than desired length"),i(o>0,"Requested array length <= 0"),this.strip();var s,a,c="le"===e,u=new t(o),f=this.clone();if(c){for(a=0;!f.isZero();a++)s=f.andln(255),f.iushrn(8),u[a]=s;for(;a<o;a++)u[a]=0}else{for(a=0;a<o-n;a++)u[a]=0;for(a=0;!f.isZero();a++)s=f.andln(255),f.iushrn(8),u[o-a-1]=s}return u},Math.clz32?o.prototype._countBits=function(t){return 32-Math.clz32(t)}:o.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},o.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},o.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},o.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return 0!==this.negative},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this.strip()},o.prototype.ior=function(t){return i(0==(this.negative|t.negative)),this.iuor(t)},o.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},o.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},o.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this.strip()},o.prototype.iand=function(t){return i(0==(this.negative|t.negative)),this.iuand(t)},o.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},o.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},o.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this.strip()},o.prototype.ixor=function(t){return i(0==(this.negative|t.negative)),this.iuxor(t)},o.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},o.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},o.prototype.inotn=function(t){i("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var n=0;n<e;n++)this.words[n]=67108863&~this.words[n];return r>0&&(this.words[n]=~this.words[n]&67108863>>26-r),this.strip()},o.prototype.notn=function(t){return this.clone().inotn(t)},o.prototype.setn=function(t,e){i("number"==typeof t&&t>=0);var r=t/26|0,n=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<<n:this.words[r]&~(1<<n),this.strip()},o.prototype.iadd=function(t){var e,r,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var n=0,o=0;o<i.length;o++)e=(0|r.words[o])+(0|i.words[o])+n,this.words[o]=67108863&e,n=e>>>26;for(;0!==n&&o<r.length;o++)e=(0|r.words[o])+n,this.words[o]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},o.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},o.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var o=0,s=0;s<i.length;s++)o=(e=(0|r.words[s])-(0|i.words[s])+o)>>26,this.words[s]=67108863&e;for(;0!==o&&s<r.length;s++)o=(e=(0|r.words[s])+o)>>26,this.words[s]=67108863&e;if(0===o&&s<r.length&&r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this.length=Math.max(this.length,s),r!==this&&(this.negative=1),this.strip()},o.prototype.sub=function(t){return this.clone().isub(t)};var p=function(t,e,r){var i,n,o,s=t.words,a=e.words,c=r.words,u=0,f=0|s[0],h=8191&f,d=f>>>13,p=0|s[1],l=8191&p,g=p>>>13,m=0|s[2],b=8191&m,y=m>>>13,v=0|s[3],S=8191&v,_=v>>>13,w=0|s[4],I=8191&w,O=w>>>13,P=0|s[5],A=8191&P,E=P>>>13,k=0|s[6],x=8191&k,T=k>>>13,R=0|s[7],M=8191&R,N=R>>>13,B=0|s[8],C=8191&B,H=B>>>13,U=0|s[9],L=8191&U,F=U>>>13,D=0|a[0],K=8191&D,z=D>>>13,j=0|a[1],V=8191&j,G=j>>>13,q=0|a[2],Y=8191&q,X=q>>>13,W=0|a[3],Z=8191&W,$=W>>>13,Q=0|a[4],J=8191&Q,tt=Q>>>13,et=0|a[5],rt=8191&et,it=et>>>13,nt=0|a[6],ot=8191&nt,st=nt>>>13,at=0|a[7],ct=8191&at,ut=at>>>13,ft=0|a[8],ht=8191&ft,dt=ft>>>13,pt=0|a[9],lt=8191&pt,gt=pt>>>13;r.negative=t.negative^e.negative,r.length=19;var mt=(u+(i=Math.imul(h,K))|0)+((8191&(n=(n=Math.imul(h,z))+Math.imul(d,K)|0))<<13)|0;u=((o=Math.imul(d,z))+(n>>>13)|0)+(mt>>>26)|0,mt&=67108863,i=Math.imul(l,K),n=(n=Math.imul(l,z))+Math.imul(g,K)|0,o=Math.imul(g,z);var bt=(u+(i=i+Math.imul(h,V)|0)|0)+((8191&(n=(n=n+Math.imul(h,G)|0)+Math.imul(d,V)|0))<<13)|0;u=((o=o+Math.imul(d,G)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(b,K),n=(n=Math.imul(b,z))+Math.imul(y,K)|0,o=Math.imul(y,z),i=i+Math.imul(l,V)|0,n=(n=n+Math.imul(l,G)|0)+Math.imul(g,V)|0,o=o+Math.imul(g,G)|0;var yt=(u+(i=i+Math.imul(h,Y)|0)|0)+((8191&(n=(n=n+Math.imul(h,X)|0)+Math.imul(d,Y)|0))<<13)|0;u=((o=o+Math.imul(d,X)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(S,K),n=(n=Math.imul(S,z))+Math.imul(_,K)|0,o=Math.imul(_,z),i=i+Math.imul(b,V)|0,n=(n=n+Math.imul(b,G)|0)+Math.imul(y,V)|0,o=o+Math.imul(y,G)|0,i=i+Math.imul(l,Y)|0,n=(n=n+Math.imul(l,X)|0)+Math.imul(g,Y)|0,o=o+Math.imul(g,X)|0;var vt=(u+(i=i+Math.imul(h,Z)|0)|0)+((8191&(n=(n=n+Math.imul(h,$)|0)+Math.imul(d,Z)|0))<<13)|0;u=((o=o+Math.imul(d,$)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(I,K),n=(n=Math.imul(I,z))+Math.imul(O,K)|0,o=Math.imul(O,z),i=i+Math.imul(S,V)|0,n=(n=n+Math.imul(S,G)|0)+Math.imul(_,V)|0,o=o+Math.imul(_,G)|0,i=i+Math.imul(b,Y)|0,n=(n=n+Math.imul(b,X)|0)+Math.imul(y,Y)|0,o=o+Math.imul(y,X)|0,i=i+Math.imul(l,Z)|0,n=(n=n+Math.imul(l,$)|0)+Math.imul(g,Z)|0,o=o+Math.imul(g,$)|0;var St=(u+(i=i+Math.imul(h,J)|0)|0)+((8191&(n=(n=n+Math.imul(h,tt)|0)+Math.imul(d,J)|0))<<13)|0;u=((o=o+Math.imul(d,tt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(A,K),n=(n=Math.imul(A,z))+Math.imul(E,K)|0,o=Math.imul(E,z),i=i+Math.imul(I,V)|0,n=(n=n+Math.imul(I,G)|0)+Math.imul(O,V)|0,o=o+Math.imul(O,G)|0,i=i+Math.imul(S,Y)|0,n=(n=n+Math.imul(S,X)|0)+Math.imul(_,Y)|0,o=o+Math.imul(_,X)|0,i=i+Math.imul(b,Z)|0,n=(n=n+Math.imul(b,$)|0)+Math.imul(y,Z)|0,o=o+Math.imul(y,$)|0,i=i+Math.imul(l,J)|0,n=(n=n+Math.imul(l,tt)|0)+Math.imul(g,J)|0,o=o+Math.imul(g,tt)|0;var _t=(u+(i=i+Math.imul(h,rt)|0)|0)+((8191&(n=(n=n+Math.imul(h,it)|0)+Math.imul(d,rt)|0))<<13)|0;u=((o=o+Math.imul(d,it)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(x,K),n=(n=Math.imul(x,z))+Math.imul(T,K)|0,o=Math.imul(T,z),i=i+Math.imul(A,V)|0,n=(n=n+Math.imul(A,G)|0)+Math.imul(E,V)|0,o=o+Math.imul(E,G)|0,i=i+Math.imul(I,Y)|0,n=(n=n+Math.imul(I,X)|0)+Math.imul(O,Y)|0,o=o+Math.imul(O,X)|0,i=i+Math.imul(S,Z)|0,n=(n=n+Math.imul(S,$)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,$)|0,i=i+Math.imul(b,J)|0,n=(n=n+Math.imul(b,tt)|0)+Math.imul(y,J)|0,o=o+Math.imul(y,tt)|0,i=i+Math.imul(l,rt)|0,n=(n=n+Math.imul(l,it)|0)+Math.imul(g,rt)|0,o=o+Math.imul(g,it)|0;var wt=(u+(i=i+Math.imul(h,ot)|0)|0)+((8191&(n=(n=n+Math.imul(h,st)|0)+Math.imul(d,ot)|0))<<13)|0;u=((o=o+Math.imul(d,st)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(M,K),n=(n=Math.imul(M,z))+Math.imul(N,K)|0,o=Math.imul(N,z),i=i+Math.imul(x,V)|0,n=(n=n+Math.imul(x,G)|0)+Math.imul(T,V)|0,o=o+Math.imul(T,G)|0,i=i+Math.imul(A,Y)|0,n=(n=n+Math.imul(A,X)|0)+Math.imul(E,Y)|0,o=o+Math.imul(E,X)|0,i=i+Math.imul(I,Z)|0,n=(n=n+Math.imul(I,$)|0)+Math.imul(O,Z)|0,o=o+Math.imul(O,$)|0,i=i+Math.imul(S,J)|0,n=(n=n+Math.imul(S,tt)|0)+Math.imul(_,J)|0,o=o+Math.imul(_,tt)|0,i=i+Math.imul(b,rt)|0,n=(n=n+Math.imul(b,it)|0)+Math.imul(y,rt)|0,o=o+Math.imul(y,it)|0,i=i+Math.imul(l,ot)|0,n=(n=n+Math.imul(l,st)|0)+Math.imul(g,ot)|0,o=o+Math.imul(g,st)|0;var It=(u+(i=i+Math.imul(h,ct)|0)|0)+((8191&(n=(n=n+Math.imul(h,ut)|0)+Math.imul(d,ct)|0))<<13)|0;u=((o=o+Math.imul(d,ut)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(C,K),n=(n=Math.imul(C,z))+Math.imul(H,K)|0,o=Math.imul(H,z),i=i+Math.imul(M,V)|0,n=(n=n+Math.imul(M,G)|0)+Math.imul(N,V)|0,o=o+Math.imul(N,G)|0,i=i+Math.imul(x,Y)|0,n=(n=n+Math.imul(x,X)|0)+Math.imul(T,Y)|0,o=o+Math.imul(T,X)|0,i=i+Math.imul(A,Z)|0,n=(n=n+Math.imul(A,$)|0)+Math.imul(E,Z)|0,o=o+Math.imul(E,$)|0,i=i+Math.imul(I,J)|0,n=(n=n+Math.imul(I,tt)|0)+Math.imul(O,J)|0,o=o+Math.imul(O,tt)|0,i=i+Math.imul(S,rt)|0,n=(n=n+Math.imul(S,it)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,it)|0,i=i+Math.imul(b,ot)|0,n=(n=n+Math.imul(b,st)|0)+Math.imul(y,ot)|0,o=o+Math.imul(y,st)|0,i=i+Math.imul(l,ct)|0,n=(n=n+Math.imul(l,ut)|0)+Math.imul(g,ct)|0,o=o+Math.imul(g,ut)|0;var Ot=(u+(i=i+Math.imul(h,ht)|0)|0)+((8191&(n=(n=n+Math.imul(h,dt)|0)+Math.imul(d,ht)|0))<<13)|0;u=((o=o+Math.imul(d,dt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,i=Math.imul(L,K),n=(n=Math.imul(L,z))+Math.imul(F,K)|0,o=Math.imul(F,z),i=i+Math.imul(C,V)|0,n=(n=n+Math.imul(C,G)|0)+Math.imul(H,V)|0,o=o+Math.imul(H,G)|0,i=i+Math.imul(M,Y)|0,n=(n=n+Math.imul(M,X)|0)+Math.imul(N,Y)|0,o=o+Math.imul(N,X)|0,i=i+Math.imul(x,Z)|0,n=(n=n+Math.imul(x,$)|0)+Math.imul(T,Z)|0,o=o+Math.imul(T,$)|0,i=i+Math.imul(A,J)|0,n=(n=n+Math.imul(A,tt)|0)+Math.imul(E,J)|0,o=o+Math.imul(E,tt)|0,i=i+Math.imul(I,rt)|0,n=(n=n+Math.imul(I,it)|0)+Math.imul(O,rt)|0,o=o+Math.imul(O,it)|0,i=i+Math.imul(S,ot)|0,n=(n=n+Math.imul(S,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,i=i+Math.imul(b,ct)|0,n=(n=n+Math.imul(b,ut)|0)+Math.imul(y,ct)|0,o=o+Math.imul(y,ut)|0,i=i+Math.imul(l,ht)|0,n=(n=n+Math.imul(l,dt)|0)+Math.imul(g,ht)|0,o=o+Math.imul(g,dt)|0;var Pt=(u+(i=i+Math.imul(h,lt)|0)|0)+((8191&(n=(n=n+Math.imul(h,gt)|0)+Math.imul(d,lt)|0))<<13)|0;u=((o=o+Math.imul(d,gt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,i=Math.imul(L,V),n=(n=Math.imul(L,G))+Math.imul(F,V)|0,o=Math.imul(F,G),i=i+Math.imul(C,Y)|0,n=(n=n+Math.imul(C,X)|0)+Math.imul(H,Y)|0,o=o+Math.imul(H,X)|0,i=i+Math.imul(M,Z)|0,n=(n=n+Math.imul(M,$)|0)+Math.imul(N,Z)|0,o=o+Math.imul(N,$)|0,i=i+Math.imul(x,J)|0,n=(n=n+Math.imul(x,tt)|0)+Math.imul(T,J)|0,o=o+Math.imul(T,tt)|0,i=i+Math.imul(A,rt)|0,n=(n=n+Math.imul(A,it)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,it)|0,i=i+Math.imul(I,ot)|0,n=(n=n+Math.imul(I,st)|0)+Math.imul(O,ot)|0,o=o+Math.imul(O,st)|0,i=i+Math.imul(S,ct)|0,n=(n=n+Math.imul(S,ut)|0)+Math.imul(_,ct)|0,o=o+Math.imul(_,ut)|0,i=i+Math.imul(b,ht)|0,n=(n=n+Math.imul(b,dt)|0)+Math.imul(y,ht)|0,o=o+Math.imul(y,dt)|0;var At=(u+(i=i+Math.imul(l,lt)|0)|0)+((8191&(n=(n=n+Math.imul(l,gt)|0)+Math.imul(g,lt)|0))<<13)|0;u=((o=o+Math.imul(g,gt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(L,Y),n=(n=Math.imul(L,X))+Math.imul(F,Y)|0,o=Math.imul(F,X),i=i+Math.imul(C,Z)|0,n=(n=n+Math.imul(C,$)|0)+Math.imul(H,Z)|0,o=o+Math.imul(H,$)|0,i=i+Math.imul(M,J)|0,n=(n=n+Math.imul(M,tt)|0)+Math.imul(N,J)|0,o=o+Math.imul(N,tt)|0,i=i+Math.imul(x,rt)|0,n=(n=n+Math.imul(x,it)|0)+Math.imul(T,rt)|0,o=o+Math.imul(T,it)|0,i=i+Math.imul(A,ot)|0,n=(n=n+Math.imul(A,st)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,st)|0,i=i+Math.imul(I,ct)|0,n=(n=n+Math.imul(I,ut)|0)+Math.imul(O,ct)|0,o=o+Math.imul(O,ut)|0,i=i+Math.imul(S,ht)|0,n=(n=n+Math.imul(S,dt)|0)+Math.imul(_,ht)|0,o=o+Math.imul(_,dt)|0;var Et=(u+(i=i+Math.imul(b,lt)|0)|0)+((8191&(n=(n=n+Math.imul(b,gt)|0)+Math.imul(y,lt)|0))<<13)|0;u=((o=o+Math.imul(y,gt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(L,Z),n=(n=Math.imul(L,$))+Math.imul(F,Z)|0,o=Math.imul(F,$),i=i+Math.imul(C,J)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(H,J)|0,o=o+Math.imul(H,tt)|0,i=i+Math.imul(M,rt)|0,n=(n=n+Math.imul(M,it)|0)+Math.imul(N,rt)|0,o=o+Math.imul(N,it)|0,i=i+Math.imul(x,ot)|0,n=(n=n+Math.imul(x,st)|0)+Math.imul(T,ot)|0,o=o+Math.imul(T,st)|0,i=i+Math.imul(A,ct)|0,n=(n=n+Math.imul(A,ut)|0)+Math.imul(E,ct)|0,o=o+Math.imul(E,ut)|0,i=i+Math.imul(I,ht)|0,n=(n=n+Math.imul(I,dt)|0)+Math.imul(O,ht)|0,o=o+Math.imul(O,dt)|0;var kt=(u+(i=i+Math.imul(S,lt)|0)|0)+((8191&(n=(n=n+Math.imul(S,gt)|0)+Math.imul(_,lt)|0))<<13)|0;u=((o=o+Math.imul(_,gt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(L,J),n=(n=Math.imul(L,tt))+Math.imul(F,J)|0,o=Math.imul(F,tt),i=i+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,it)|0)+Math.imul(H,rt)|0,o=o+Math.imul(H,it)|0,i=i+Math.imul(M,ot)|0,n=(n=n+Math.imul(M,st)|0)+Math.imul(N,ot)|0,o=o+Math.imul(N,st)|0,i=i+Math.imul(x,ct)|0,n=(n=n+Math.imul(x,ut)|0)+Math.imul(T,ct)|0,o=o+Math.imul(T,ut)|0,i=i+Math.imul(A,ht)|0,n=(n=n+Math.imul(A,dt)|0)+Math.imul(E,ht)|0,o=o+Math.imul(E,dt)|0;var xt=(u+(i=i+Math.imul(I,lt)|0)|0)+((8191&(n=(n=n+Math.imul(I,gt)|0)+Math.imul(O,lt)|0))<<13)|0;u=((o=o+Math.imul(O,gt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(L,rt),n=(n=Math.imul(L,it))+Math.imul(F,rt)|0,o=Math.imul(F,it),i=i+Math.imul(C,ot)|0,n=(n=n+Math.imul(C,st)|0)+Math.imul(H,ot)|0,o=o+Math.imul(H,st)|0,i=i+Math.imul(M,ct)|0,n=(n=n+Math.imul(M,ut)|0)+Math.imul(N,ct)|0,o=o+Math.imul(N,ut)|0,i=i+Math.imul(x,ht)|0,n=(n=n+Math.imul(x,dt)|0)+Math.imul(T,ht)|0,o=o+Math.imul(T,dt)|0;var Tt=(u+(i=i+Math.imul(A,lt)|0)|0)+((8191&(n=(n=n+Math.imul(A,gt)|0)+Math.imul(E,lt)|0))<<13)|0;u=((o=o+Math.imul(E,gt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(L,ot),n=(n=Math.imul(L,st))+Math.imul(F,ot)|0,o=Math.imul(F,st),i=i+Math.imul(C,ct)|0,n=(n=n+Math.imul(C,ut)|0)+Math.imul(H,ct)|0,o=o+Math.imul(H,ut)|0,i=i+Math.imul(M,ht)|0,n=(n=n+Math.imul(M,dt)|0)+Math.imul(N,ht)|0,o=o+Math.imul(N,dt)|0;var Rt=(u+(i=i+Math.imul(x,lt)|0)|0)+((8191&(n=(n=n+Math.imul(x,gt)|0)+Math.imul(T,lt)|0))<<13)|0;u=((o=o+Math.imul(T,gt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(L,ct),n=(n=Math.imul(L,ut))+Math.imul(F,ct)|0,o=Math.imul(F,ut),i=i+Math.imul(C,ht)|0,n=(n=n+Math.imul(C,dt)|0)+Math.imul(H,ht)|0,o=o+Math.imul(H,dt)|0;var Mt=(u+(i=i+Math.imul(M,lt)|0)|0)+((8191&(n=(n=n+Math.imul(M,gt)|0)+Math.imul(N,lt)|0))<<13)|0;u=((o=o+Math.imul(N,gt)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(L,ht),n=(n=Math.imul(L,dt))+Math.imul(F,ht)|0,o=Math.imul(F,dt);var Nt=(u+(i=i+Math.imul(C,lt)|0)|0)+((8191&(n=(n=n+Math.imul(C,gt)|0)+Math.imul(H,lt)|0))<<13)|0;u=((o=o+Math.imul(H,gt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863;var Bt=(u+(i=Math.imul(L,lt))|0)+((8191&(n=(n=Math.imul(L,gt))+Math.imul(F,lt)|0))<<13)|0;return u=((o=Math.imul(F,gt))+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,c[0]=mt,c[1]=bt,c[2]=yt,c[3]=vt,c[4]=St,c[5]=_t,c[6]=wt,c[7]=It,c[8]=Ot,c[9]=Pt,c[10]=At,c[11]=Et,c[12]=kt,c[13]=xt,c[14]=Tt,c[15]=Rt,c[16]=Mt,c[17]=Nt,c[18]=Bt,0!==u&&(c[19]=u,r.length++),r};function l(t,e,r){return(new g).mulp(t,e,r)}function g(t,e){this.x=t,this.y=e}Math.imul||(p=d),o.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?p(this,t,e):r<63?d(this,t,e):r<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,o=0;o<r.length-1;o++){var s=n;n=0;for(var a=67108863&i,c=Math.min(o,e.length-1),u=Math.max(0,o-t.length+1);u<=c;u++){var f=o-u,h=(0|t.words[f])*(0|e.words[u]),d=67108863&h;a=67108863&(d=d+a|0),n+=(s=(s=s+(h/67108864|0)|0)+(d>>>26)|0)>>>26,s&=67108863}r.words[o]=a,i=s,s=n}return 0!==i?r.words[o]=i:r.length--,r.strip()}(this,t,e):l(this,t,e)},g.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,i=0;i<t;i++)e[i]=this.revBin(i,r,t);return e},g.prototype.revBin=function(t,e,r){if(0===t||t===r-1)return t;for(var i=0,n=0;n<e;n++)i|=(1&t)<<e-n-1,t>>=1;return i},g.prototype.permute=function(t,e,r,i,n,o){for(var s=0;s<o;s++)i[s]=e[t[s]],n[s]=r[t[s]]},g.prototype.transform=function(t,e,r,i,n,o){this.permute(o,t,e,r,i,n);for(var s=1;s<n;s<<=1)for(var a=s<<1,c=Math.cos(2*Math.PI/a),u=Math.sin(2*Math.PI/a),f=0;f<n;f+=a)for(var h=c,d=u,p=0;p<s;p++){var l=r[f+p],g=i[f+p],m=r[f+p+s],b=i[f+p+s],y=h*m-d*b;b=h*b+d*m,m=y,r[f+p]=l+m,i[f+p]=g+b,r[f+p+s]=l-m,i[f+p+s]=g-b,p!==a&&(y=c*h-u*d,d=c*d+u*h,h=y)}},g.prototype.guessLen13b=function(t,e){var r=1|Math.max(e,t),i=1&r,n=0;for(r=r/2|0;r;r>>>=1)n++;return 1<<n+1+i},g.prototype.conjugate=function(t,e,r){if(!(r<=1))for(var i=0;i<r/2;i++){var n=t[i];t[i]=t[r-i-1],t[r-i-1]=n,n=e[i],e[i]=-e[r-i-1],e[r-i-1]=-n}},g.prototype.normalize13b=function(t,e){for(var r=0,i=0;i<e/2;i++){var n=8192*Math.round(t[2*i+1]/e)+Math.round(t[2*i]/e)+r;t[i]=67108863&n,r=n<67108864?0:n/67108864|0}return t},g.prototype.convert13b=function(t,e,r,n){for(var o=0,s=0;s<e;s++)o+=0|t[s],r[2*s]=8191&o,o>>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*e;s<n;++s)r[s]=0;i(0===o),i(0==(-8192&o))},g.prototype.stub=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=0;return e},g.prototype.mulp=function(t,e,r){var i=2*this.guessLen13b(t.length,e.length),n=this.makeRBT(i),o=this.stub(i),s=new Array(i),a=new Array(i),c=new Array(i),u=new Array(i),f=new Array(i),h=new Array(i),d=r.words;d.length=i,this.convert13b(t.words,t.length,s,i),this.convert13b(e.words,e.length,u,i),this.transform(s,o,a,c,i,n),this.transform(u,o,f,h,i,n);for(var p=0;p<i;p++){var l=a[p]*f[p]-c[p]*h[p];c[p]=a[p]*h[p]+c[p]*f[p],a[p]=l}return this.conjugate(a,c,i),this.transform(a,c,d,o,i,n),this.conjugate(d,o,i),this.normalize13b(d,i),r.negative=t.negative^e.negative,r.length=t.length+e.length,r.strip()},o.prototype.mul=function(t){var e=new o(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},o.prototype.mulf=function(t){var e=new o(null);return e.words=new Array(this.length+t.length),l(this,t,e)},o.prototype.imul=function(t){return this.clone().mulTo(t,this)},o.prototype.imuln=function(t){i("number"==typeof t),i(t<67108864);for(var e=0,r=0;r<this.length;r++){var n=(0|this.words[r])*t,o=(67108863&n)+(67108863&e);e>>=26,e+=n/67108864|0,e+=o>>>26,this.words[r]=67108863&o}return 0!==e&&(this.words[r]=e,this.length++),this},o.prototype.muln=function(t){return this.clone().imuln(t)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=(t.words[i]&1<<n)>>>n}return e}(t);if(0===e.length)return new o(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var n=r.sqr();i<e.length;i++,n=n.sqr())0!==e[i]&&(r=r.mul(n));return r},o.prototype.iushln=function(t){i("number"==typeof t&&t>=0);var e,r=t%26,n=(t-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var s=0;for(e=0;e<this.length;e++){var a=this.words[e]&o,c=(0|this.words[e])-a<<r;this.words[e]=c|s,s=a>>>26-r}s&&(this.words[e]=s,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e<n;e++)this.words[e]=0;this.length+=n}return this.strip()},o.prototype.ishln=function(t){return i(0===this.negative),this.iushln(t)},o.prototype.iushrn=function(t,e,r){var n;i("number"==typeof t&&t>=0),n=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<<o,c=r;if(n-=s,n=Math.max(0,n),c){for(var u=0;u<s;u++)c.words[u]=this.words[u];c.length=s}if(0===s);else if(this.length>s)for(this.length-=s,u=0;u<this.length;u++)this.words[u]=this.words[u+s];else this.words[0]=0,this.length=1;var f=0;for(u=this.length-1;u>=0&&(0!==f||u>=n);u--){var h=0|this.words[u];this.words[u]=f<<26-o|h>>>o,f=h&a}return c&&0!==f&&(c.words[c.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(t,e,r){return i(0===this.negative),this.iushrn(t,e,r)},o.prototype.shln=function(t){return this.clone().ishln(t)},o.prototype.ushln=function(t){return this.clone().iushln(t)},o.prototype.shrn=function(t){return this.clone().ishrn(t)},o.prototype.ushrn=function(t){return this.clone().iushrn(t)},o.prototype.testn=function(t){i("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,n=1<<e;return!(this.length<=r)&&!!(this.words[r]&n)},o.prototype.imaskn=function(t){i("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26;if(i(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var n=67108863^67108863>>>e<<e;this.words[this.length-1]&=n}return this.strip()},o.prototype.maskn=function(t){return this.clone().imaskn(t)},o.prototype.iaddn=function(t){return i("number"==typeof t),i(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},o.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},o.prototype.isubn=function(t){if(i("number"==typeof t),i(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this.strip()},o.prototype.addn=function(t){return this.clone().iaddn(t)},o.prototype.subn=function(t){return this.clone().isubn(t)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(t,e,r){var n,o,s=t.length+r;this._expand(s);var a=0;for(n=0;n<t.length;n++){o=(0|this.words[n+r])+a;var c=(0|t.words[n])*e;a=((o-=67108863&c)>>26)-(c/67108864|0),this.words[n+r]=67108863&o}for(;n<this.length-r;n++)a=(o=(0|this.words[n+r])+a)>>26,this.words[n+r]=67108863&o;if(0===a)return this.strip();for(i(-1===a),a=0,n=0;n<this.length;n++)a=(o=-(0|this.words[n])+a)>>26,this.words[n]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),n=t,s=0|n.words[n.length-1];0!==(r=26-this._countBits(s))&&(n=n.ushln(r),i.iushln(r),s=0|n.words[n.length-1]);var a,c=i.length-n.length;if("mod"!==e){(a=new o(null)).length=c+1,a.words=new Array(a.length);for(var u=0;u<a.length;u++)a.words[u]=0}var f=i.clone()._ishlnsubmul(n,1,c);0===f.negative&&(i=f,a&&(a.words[c]=1));for(var h=c-1;h>=0;h--){var d=67108864*(0|i.words[n.length+h])+(0|i.words[n.length+h-1]);for(d=Math.min(d/s|0,67108863),i._ishlnsubmul(n,d,h);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(n,1,h),i.isZero()||(i.negative^=1);a&&(a.words[h]=d)}return a&&a.strip(),i.strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:a||null,mod:i}},o.prototype.divmod=function(t,e,r){return i(!t.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(n=a.div.neg()),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(t)),{div:n,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(n=a.div.neg()),{div:n,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new o(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new o(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new o(this.modn(t.words[0]))}:this._wordDiv(t,e);var n,s,a},o.prototype.div=function(t){return this.divmod(t,"div",!1).div},o.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},o.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},o.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),o=r.cmp(i);return o<0||1===n&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},o.prototype.modn=function(t){i(t<=67108863);for(var e=(1<<26)%t,r=0,n=this.length-1;n>=0;n--)r=(e*r+(0|this.words[n]))%t;return r},o.prototype.idivn=function(t){i(t<=67108863);for(var e=0,r=this.length-1;r>=0;r--){var n=(0|this.words[r])+67108864*e;this.words[r]=n/t|0,e=n%t}return this.strip()},o.prototype.divn=function(t){return this.clone().idivn(t)},o.prototype.egcd=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n=new o(1),s=new o(0),a=new o(0),c=new o(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var f=r.clone(),h=e.clone();!e.isZero();){for(var d=0,p=1;0==(e.words[0]&p)&&d<26;++d,p<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(n.isOdd()||s.isOdd())&&(n.iadd(f),s.isub(h)),n.iushrn(1),s.iushrn(1);for(var l=0,g=1;0==(r.words[0]&g)&&l<26;++l,g<<=1);if(l>0)for(r.iushrn(l);l-- >0;)(a.isOdd()||c.isOdd())&&(a.iadd(f),c.isub(h)),a.iushrn(1),c.iushrn(1);e.cmp(r)>=0?(e.isub(r),n.isub(a),s.isub(c)):(r.isub(e),a.isub(n),c.isub(s))}return{a:a,b:c,gcd:r.iushln(u)}},o.prototype._invmp=function(t){i(0===t.negative),i(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var n,s=new o(1),a=new o(0),c=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,f=1;0==(e.words[0]&f)&&u<26;++u,f<<=1);if(u>0)for(e.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(c),s.iushrn(1);for(var h=0,d=1;0==(r.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(r.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),s.isub(a)):(r.isub(e),a.isub(s))}return(n=0===e.cmpn(1)?s:a).cmpn(0)<0&&n.iadd(t),n},o.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var o=e;e=r,r=o}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},o.prototype.invm=function(t){return this.egcd(t).a.umod(t)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(t){return this.words[0]&t},o.prototype.bincn=function(t){i("number"==typeof t);var e=t%26,r=(t-e)/26,n=1<<e;if(this.length<=r)return this._expand(r+1),this.words[r]|=n,this;for(var o=n,s=r;0!==o&&s<this.length;s++){var a=0|this.words[s];o=(a+=o)>>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)e=1;else{r&&(t=-t),i(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:n<t?-1:1}return 0!==this.negative?0|-e:e},o.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},o.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:i>n&&(e=1);break}}return e},o.prototype.gtn=function(t){return 1===this.cmpn(t)},o.prototype.gt=function(t){return 1===this.cmp(t)},o.prototype.gten=function(t){return this.cmpn(t)>=0},o.prototype.gte=function(t){return this.cmp(t)>=0},o.prototype.ltn=function(t){return-1===this.cmpn(t)},o.prototype.lt=function(t){return-1===this.cmp(t)},o.prototype.lten=function(t){return this.cmpn(t)<=0},o.prototype.lte=function(t){return this.cmp(t)<=0},o.prototype.eqn=function(t){return 0===this.cmpn(t)},o.prototype.eq=function(t){return 0===this.cmp(t)},o.red=function(t){return new w(t)},o.prototype.toRed=function(t){return i(!this.red,"Already a number in reduction context"),i(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},o.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(t){return this.red=t,this},o.prototype.forceRed=function(t){return i(!this.red,"Already a number in reduction context"),this._forceRed(t)},o.prototype.redAdd=function(t){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return i(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var m={k256:null,p224:null,p192:null,p25519:null};function b(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function y(){b.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function v(){b.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function S(){b.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){b.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function w(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else i(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function I(t){w.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}b.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},b.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},b.prototype.split=function(t,e){t.iushrn(this.n,0,e)},b.prototype.imulK=function(t){return t.imul(this.k)},n(y,b),y.prototype.split=function(t,e){for(var r=Math.min(t.length,9),i=0;i<r;i++)e.words[i]=t.words[i];if(e.length=r,t.length<=9)return t.words[0]=0,void(t.length=1);var n=t.words[9];for(e.words[e.length++]=4194303&n,i=10;i<t.length;i++){var o=0|t.words[i];t.words[i-10]=(4194303&o)<<4|n>>>22,n=o}n>>>=22,t.words[i-10]=n,0===n&&t.length>10?t.length-=10:t.length-=9},y.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(v,b),n(S,b),n(_,b),_.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(m[t])return m[t];var e;if("k256"===t)e=new y;else if("p224"===t)e=new v;else if("p192"===t)e=new S;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return m[t]=e,e},w.prototype._verify1=function(t){i(0===t.negative,"red works only with positives"),i(t.red,"red works only with red numbers")},w.prototype._verify2=function(t,e){i(0==(t.negative|e.negative),"red works only with positives"),i(t.red&&t.red===e.red,"red works only with red numbers")},w.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},w.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},w.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},w.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},w.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},w.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},w.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},w.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},w.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},w.prototype.isqr=function(t){return this.imul(t,t.clone())},w.prototype.sqr=function(t){return this.mul(t,t)},w.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(i(e%2==1),3===e){var r=this.m.add(new o(1)).iushrn(2);return this.pow(t,r)}for(var n=this.m.subn(1),s=0;!n.isZero()&&0===n.andln(1);)s++,n.iushrn(1);i(!n.isZero());var a=new o(1).toRed(this),c=a.redNeg(),u=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,u).cmp(c);)f.redIAdd(c);for(var h=this.pow(f,n),d=this.pow(t,n.addn(1).iushrn(1)),p=this.pow(t,n),l=s;0!==p.cmp(a);){for(var g=p,m=0;0!==g.cmp(a);m++)g=g.redSqr();i(m<l);var b=this.pow(h,new o(1).iushln(l-m-1));d=d.redMul(b),h=b.redSqr(),p=p.redMul(h),l=m}return d},w.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},w.prototype.pow=function(t,e){if(e.isZero())return new o(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new o(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var n=r[0],s=0,a=0,c=e.bitLength()%26;for(0===c&&(c=26),i=e.length-1;i>=0;i--){for(var u=e.words[i],f=c-1;f>=0;f--){var h=u>>f&1;n!==r[0]&&(n=this.sqr(n)),0!==h||0!==s?(s<<=1,s|=h,(4===++a||0===i&&0===f)&&(n=this.mul(n,r[s]),a=0,s=0)):a=0}c=26}return n},w.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},w.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new I(t)},n(I,w),I.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},I.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},I.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},I.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},I.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,this)}).call(this,r(31)(t))},function(t,e,r){"use strict";var i=r(1);function n(t,e){return t.replace("{0}",e[0]).replace("{1}",e[1]).replace("{2}",e[2])}var o=function(t,e){var r=function(){if(i.isString(e.message))this.message=n(e.message,arguments);else{if(!i.isFunction(e.message))throw new Error("Invalid error definition for "+e.name);this.message=e.message.apply(null,arguments)}this.stack=this.message+"\n"+(new Error).stack};return(r.prototype=Object.create(t.prototype)).name=t.prototype.name+e.name,t[e.name]=r,e.errors&&s(r,e.errors),r},s=function(t,e){i.each(e,(function(e){o(t,e)}))},a={Error:function(){this.message="Internal error",this.stack=this.message+"\n"+(new Error).stack}};a.Error.prototype=Object.create(Error.prototype),a.Error.prototype.name="bsv.Error";var c,u=r(104);c=a.Error,s(c,u),t.exports=a.Error,t.exports.extend=function(t){return o(a.Error,t)}},function(t,e,r){"use strict";(function(e){var i=r(3),n=new(0,r(41).ec)("secp256k1"),o=n.curve.point.bind(n.curve),s=n.curve.pointFromX.bind(n.curve),a=function(t,e,r){try{var i=o(t,e,r)}catch(t){throw new Error("Invalid Point")}return i.validate(),i};a.prototype=Object.getPrototypeOf(n.curve.point()),a.fromX=function(t,e){try{var r=s(e,t)}catch(t){throw new Error("Invalid X")}return r.validate(),r},a.getG=function(){return n.curve.g},a.getN=function(){return new i(n.curve.n.toArray())},a.prototype._getX||(a.prototype._getX=a.prototype.getX),a.prototype.getX=function(){return new i(this._getX().toArray())},a.prototype._getY||(a.prototype._getY=a.prototype.getY),a.prototype.getY=function(){return new i(this._getY().toArray())},a.prototype.validate=function(){if(this.isInfinity())throw new Error("Point cannot be equal to Infinity");var t;try{t=s(this.getX(),this.getY().isOdd())}catch(t){throw new Error("Point does not lie on the curve")}if(0!==t.y.cmp(this.y))throw new Error("Invalid y value for curve.");if(!this.mul(a.getN()).isInfinity())throw new Error("Point times N must be infinity");return this},a.pointToCompressed=function(t){var r,i=t.getX().toBuffer({size:32}),n=t.getY().toBuffer({size:32});return r=n[n.length-1]%2?e.from([3]):e.from([2]),e.concat([r,i])},a.pointFromCompressed=function(t){if(33!==t.length)throw new Error("invalid buffer length");let e,r=t[0];if(3===r)e=!0;else{if(2!==r)throw new Error("invalid value of compressed prefix");e=!1}let n=t.slice(1,33),o=i.fromBuffer(n);return a.fromX(e,o)},a.prototype.toBuffer=function(){return a.pointToCompressed(this)},a.prototype.toHex=function(){return this.toBuffer().toString("hex")},a.fromBuffer=function(t){return a.pointFromCompressed(t)},a.fromHex=function(t){return a.fromBuffer(e.from(t,"hex"))},t.exports=a}).call(this,r(0).Buffer)},function(t,e,r){t.exports=r(61),t.exports.Interpreter=r(49)},function(t,e,r){"use strict";var i=r(21),n=r(22);function o(t,e){return 55296==(64512&t.charCodeAt(e))&&(!(e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1)))}function s(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function a(t){return 1===t.length?"0"+t:t}function c(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}e.inherits=n,e.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),n=0;n<t.length;n+=2)r.push(parseInt(t[n]+t[n+1],16))}else for(var i=0,n=0;n<t.length;n++){var s=t.charCodeAt(n);s<128?r[i++]=s:s<2048?(r[i++]=s>>6|192,r[i++]=63&s|128):o(t,n)?(s=65536+((1023&s)<<10)+(1023&t.charCodeAt(++n)),r[i++]=s>>18|240,r[i++]=s>>12&63|128,r[i++]=s>>6&63|128,r[i++]=63&s|128):(r[i++]=s>>12|224,r[i++]=s>>6&63|128,r[i++]=63&s|128)}else for(n=0;n<t.length;n++)r[n]=0|t[n];return r},e.toHex=function(t){for(var e="",r=0;r<t.length;r++)e+=a(t[r].toString(16));return e},e.htonl=s,e.toHex32=function(t,e){for(var r="",i=0;i<t.length;i++){var n=t[i];"little"===e&&(n=s(n)),r+=c(n.toString(16))}return r},e.zero2=a,e.zero8=c,e.join32=function(t,e,r,n){var o=r-e;i(o%4==0);for(var s=new Array(o/4),a=0,c=e;a<s.length;a++,c+=4){var u;u="big"===n?t[c]<<24|t[c+1]<<16|t[c+2]<<8|t[c+3]:t[c+3]<<24|t[c+2]<<16|t[c+1]<<8|t[c],s[a]=u>>>0}return s},e.split32=function(t,e){for(var r=new Array(4*t.length),i=0,n=0;i<t.length;i++,n+=4){var o=t[i];"big"===e?(r[n]=o>>>24,r[n+1]=o>>>16&255,r[n+2]=o>>>8&255,r[n+3]=255&o):(r[n+3]=o>>>24,r[n+2]=o>>>16&255,r[n+1]=o>>>8&255,r[n]=255&o)}return r},e.rotr32=function(t,e){return t>>>e|t<<32-e},e.rotl32=function(t,e){return t<<e|t>>>32-e},e.sum32=function(t,e){return t+e>>>0},e.sum32_3=function(t,e,r){return t+e+r>>>0},e.sum32_4=function(t,e,r,i){return t+e+r+i>>>0},e.sum32_5=function(t,e,r,i,n){return t+e+r+i+n>>>0},e.sum64=function(t,e,r,i){var n=t[e],o=i+t[e+1]>>>0,s=(o<i?1:0)+r+n;t[e]=s>>>0,t[e+1]=o},e.sum64_hi=function(t,e,r,i){return(e+i>>>0<e?1:0)+t+r>>>0},e.sum64_lo=function(t,e,r,i){return e+i>>>0},e.sum64_4_hi=function(t,e,r,i,n,o,s,a){var c=0,u=e;return c+=(u=u+i>>>0)<e?1:0,c+=(u=u+o>>>0)<o?1:0,t+r+n+s+(c+=(u=u+a>>>0)<a?1:0)>>>0},e.sum64_4_lo=function(t,e,r,i,n,o,s,a){return e+i+o+a>>>0},e.sum64_5_hi=function(t,e,r,i,n,o,s,a,c,u){var f=0,h=e;return f+=(h=h+i>>>0)<e?1:0,f+=(h=h+o>>>0)<o?1:0,f+=(h=h+a>>>0)<a?1:0,t+r+n+s+c+(f+=(h=h+u>>>0)<u?1:0)>>>0},e.sum64_5_lo=function(t,e,r,i,n,o,s,a,c,u){return e+i+o+a+u>>>0},e.rotr64_hi=function(t,e,r){return(e<<32-r|t>>>r)>>>0},e.rotr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0},e.shr64_hi=function(t,e,r){return t>>>r},e.shr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0}},function(t,e,r){"use strict";(function(e){var i=r(3),n=r(11),o=r(6),s=r(5),a=r(23),c=r(1),u=r(2);function f(t,e){if(!(this instanceof f))return new f(t,e);if(u.checkArgument(t,"First argument is required, please include public key data."),t instanceof f)return t;e=e||{};var r=this._classifyArgs(t,e);return r.point.validate(),s.defineImmutable(this,{point:r.point,compressed:r.compressed,network:r.network||a.defaultNetwork}),this}f.prototype._classifyArgs=function(t,r){var i={compressed:c.isUndefined(r.compressed)||r.compressed};if(t instanceof n)i.point=t;else if(t.x&&t.y)i=f._transformObject(t);else if("string"==typeof t)i=f._transformDER(e.from(t,"hex"));else if(f._isBuffer(t))i=f._transformDER(t);else{if(!f._isPrivateKey(t))throw new TypeError("First argument is an unrecognized data format.");i=f._transformPrivateKey(t)}return i.network||(i.network=c.isUndefined(r.network)?void 0:a.get(r.network)),i},f._isPrivateKey=function(t){return t instanceof r(34)},f._isBuffer=function(t){return t instanceof e||t instanceof Uint8Array},f._transformPrivateKey=function(t){u.checkArgument(f._isPrivateKey(t),"Must be an instance of PrivateKey");var e={};return e.point=n.getG().mul(t.bn),e.compressed=t.compressed,e.network=t.network,e},f._transformDER=function(t,e){u.checkArgument(f._isBuffer(t),"Must be a buffer of DER encoded public key");var r,o,s,a,h={};if(e=!!c.isUndefined(e)||e,4!==t[0]&&(e||6!==t[0]&&7!==t[0]))if(3===t[0])s=t.slice(1),r=new i(s),(h=f._transformX(!0,r)).compressed=!0;else{if(2!==t[0])throw new TypeError("Invalid DER format public key");s=t.slice(1),r=new i(s),(h=f._transformX(!1,r)).compressed=!0}else{if(s=t.slice(1,33),a=t.slice(33,65),32!==s.length||32!==a.length||65!==t.length)throw new TypeError("Length of x and y must be 32 bytes");r=new i(s),o=new i(a),h.point=new n(r,o),h.compressed=!1}return h},f._transformX=function(t,e){u.checkArgument("boolean"==typeof t,"Must specify whether y is odd or not (true or false)");var r={};return r.point=n.fromX(t,e),r},f._transformObject=function(t){var e=new i(t.x,"hex"),r=new i(t.y,"hex");return new f(new n(e,r),{compressed:t.compressed})},f.fromPrivateKey=function(t){u.checkArgument(f._isPrivateKey(t),"Must be an instance of PrivateKey");var e=f._transformPrivateKey(t);return new f(e.point,{compressed:e.compressed,network:e.network})},f.fromDER=f.fromBuffer=function(t,e){u.checkArgument(f._isBuffer(t),"Must be a buffer of DER encoded public key");var r=f._transformDER(t,e);return new f(r.point,{compressed:r.compressed})},f.fromPoint=function(t,e){return u.checkArgument(t instanceof n,"First argument must be an instance of Point."),new f(t,{compressed:e})},f.fromHex=f.fromString=function(t,r){var i=e.from(t,r||"hex"),n=f._transformDER(i);return new f(n.point,{compressed:n.compressed})},f.fromX=function(t,e){var r=f._transformX(t,e);return new f(r.point,{compressed:r.compressed})},f.getValidationError=function(t){var e;try{new f(t)}catch(t){e=t}return e},f.isValid=function(t){return!f.getValidationError(t)},f.prototype.toObject=f.prototype.toJSON=function(){return{x:this.point.getX().toString("hex",2),y:this.point.getY().toString("hex",2),compressed:this.compressed}},f.prototype.toBuffer=f.prototype.toDER=function(){var t,r=this.point.getX(),i=this.point.getY(),n=r.toBuffer({size:32}),o=i.toBuffer({size:32});return this.compressed?(t=o[o.length-1]%2?e.from([3]):e.from([2]),e.concat([t,n])):(t=e.from([4]),e.concat([t,n,o]))},f.prototype._getID=function(){return o.sha256ripemd160(this.toBuffer())},f.prototype.toAddress=function(t){return r(25).fromPublicKey(this,t||this.network)},f.prototype.toString=f.prototype.toHex=function(){return this.toDER().toString("hex")},f.prototype.inspect=function(){return"<PublicKey: "+this.toHex()+(this.compressed?"":", uncompressed")+">"},t.exports=f}).call(this,r(0).Buffer)},function(t,e){},function(t,e,r){"use strict";(function(e){var i=r(45),n=function t(e){if(!(this instanceof t))return new t(e);this.bufLen=0,e?this.set(e):this.bufs=[]};n.prototype.set=function(t){return this.bufs=t.bufs||this.bufs||[],this.bufLen=this.bufs.reduce((function(t,e){return t+e.length}),0),this},n.prototype.toBuffer=function(){return this.concat()},n.prototype.concat=function(){return e.concat(this.bufs,this.bufLen)},n.prototype.write=function(t){return i(e.isBuffer(t)),this.bufs.push(t),this.bufLen+=t.length,this},n.prototype.writeReverse=function(t){return i(e.isBuffer(t)),this.bufs.push(e.from(t).reverse()),this.bufLen+=t.length,this},n.prototype.writeUInt8=function(t){var r=e.alloc(1);return r.writeUInt8(t,0),this.write(r),this},n.prototype.writeUInt16BE=function(t){var r=e.alloc(2);return r.writeUInt16BE(t,0),this.write(r),this},n.prototype.writeUInt16LE=function(t){var r=e.alloc(2);return r.writeUInt16LE(t,0),this.write(r),this},n.prototype.writeUInt32BE=function(t){var r=e.alloc(4);return r.writeUInt32BE(t,0),this.write(r),this},n.prototype.writeInt32LE=function(t){var r=e.alloc(4);return r.writeInt32LE(t,0),this.write(r),this},n.prototype.writeUInt32LE=function(t){var r=e.alloc(4);return r.writeUInt32LE(t,0),this.write(r),this},n.prototype.writeUInt64BEBN=function(t){var e=t.toBuffer({size:8});return this.write(e),this},n.prototype.writeUInt64LEBN=function(t){var e=t.toBuffer({size:8});return this.writeReverse(e),this},n.prototype.writeVarintNum=function(t){var e=n.varintBufNum(t);return this.write(e),this},n.prototype.writeVarintBN=function(t){var e=n.varintBufBN(t);return this.write(e),this},n.varintBufNum=function(t){var r;return t<253?(r=e.alloc(1)).writeUInt8(t,0):t<65536?((r=e.alloc(3)).writeUInt8(253,0),r.writeUInt16LE(t,1)):t<4294967296?((r=e.alloc(5)).writeUInt8(254,0),r.writeUInt32LE(t,1)):((r=e.alloc(9)).writeUInt8(255,0),r.writeInt32LE(-1&t,1),r.writeUInt32LE(Math.floor(t/4294967296),5)),r},n.varintBufBN=function(t){var r,i=t.toNumber();if(i<253)(r=e.alloc(1)).writeUInt8(i,0);else if(i<65536)(r=e.alloc(3)).writeUInt8(253,0),r.writeUInt16LE(i,1);else if(i<4294967296)(r=e.alloc(5)).writeUInt8(254,0),r.writeUInt32LE(i,1);else{var o=new n;o.writeUInt8(255),o.writeUInt64LEBN(t),r=o.concat()}return r},t.exports=n}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(7);r(15);function n(t,r){if(!(this instanceof n))return new n(t,r);this.preimage=e.isBuffer(t)?t:e.from(t,"hex"),this.options=r||{},this.strategy=this.options.strategy||"DYNAMIC",this.fields=null,this.sighashInfo=null,this.options.deferExtraction||this._extractFields()}n.prototype.extract=function(t){return this.strategy=t||this.strategy,this._extractFields(),this.fields},n.prototype.getSighashInfo=function(){return this.fields||this._extractFields(),this.sighashInfo},n.prototype.getField=function(t){return this.fields||this._extractFields(),this.fields[t]},n.prototype.extractField=function(t,e){e=e||{},this.fields||this._extractFields();var r=this._parsePreimageStructure(),i=this._generateBidirectionalASM(t,r,e.includeComments),n=this._extractSpecificField(t,r),o=this._interpretField(t,n,r);return{field:t,value:n?n.toString("hex"):null,buffer:n,asm:i,interpretation:o,strategy:this._getExtractionStrategy(t),structure:r._structure}},n.prototype.generateASM=function(t,e){var r=this._parsePreimageStructure();return this._generateBidirectionalASM(t,r,e)},n.prototype.extractFields=function(t){var e={};return t.forEach(function(t){e[t]=this.extractField(t)}.bind(this)),e},n.prototype.validate=function(){this.fields||this._extractFields();var t=[],e=[];return["version","hashPrevouts","hashSequence","outpoint","scriptCode","amount","sequence","hashOutputs","locktime","sighash"].forEach(function(e){this.fields[e]||t.push("Missing required field: "+e)}.bind(this)),this.sighashInfo.hasZeroHashes&&e.push("Zero hashes detected - check SIGHASH flags: "+this.sighashInfo.zeroFields.join(", ")),this.preimage.length<104&&t.push("Preimage too short: "+this.preimage.length+" bytes (minimum 104)"),{valid:0===t.length,errors:t,warnings:e,sighashInfo:this.sighashInfo}},n.prototype.toObject=function(){return this.fields||this._extractFields(),{preimage:this.preimage.toString("hex"),length:this.preimage.length,strategy:this.strategy,fields:{version:this.fields.version?this.fields.version.toString("hex"):null,hashPrevouts:this.fields.hashPrevouts?this.fields.hashPrevouts.toString("hex"):null,hashSequence:this.fields.hashSequence?this.fields.hashSequence.toString("hex"):null,outpoint:this.fields.outpoint?this.fields.outpoint.toString("hex"):null,scriptCode:this.fields.scriptCode?this.fields.scriptCode.toString("hex"):null,scriptCodeLength:this.fields.scriptCodeLength,amount:this.fields.amount?this.fields.amount.toString("hex"):null,sequence:this.fields.sequence?this.fields.sequence.toString("hex"):null,hashOutputs:this.fields.hashOutputs?this.fields.hashOutputs.toString("hex"):null,locktime:this.fields.locktime?this.fields.locktime.toString("hex"):null,sighash:this.fields.sighash?this.fields.sighash.toString("hex"):null},sighashInfo:this.sighashInfo,validation:this.validate()}},n.prototype._extractFields=function(){this.fields={},this.sighashInfo={flag:null,hasZeroHashes:!1,zeroFields:[],warnings:[]};try{"LEFT"===this.strategy||"DYNAMIC"===this.strategy?this._extractFromLeft():"RIGHT"===this.strategy&&this._extractFromRight(),this._analyzeSighash()}catch(t){if("DYNAMIC"!==this.strategy)throw t;try{this.strategy="RIGHT",this._extractFromRight(),this._analyzeSighash()}catch(e){throw new Error("Failed to extract preimage fields with any strategy: "+t.message)}}},n.prototype._extractFromLeft=function(){var t=0;this.fields.version=this.preimage.slice(t,t+4),t+=4,this.fields.hashPrevouts=this.preimage.slice(t,t+32),t+=32,this.fields.hashSequence=this.preimage.slice(t,t+32),t+=32,this.fields.outpoint=this.preimage.slice(t,t+36),t+=36;var e=n.decodeCompactSize(this.preimage,t);this.fields.scriptCodeLength=e.value,t=e.nextOffset,this.fields.scriptCode=this.preimage.slice(t,t+this.fields.scriptCodeLength),t+=this.fields.scriptCodeLength,this.fields.amount=this.preimage.slice(t,t+8),t+=8,this.fields.sequence=this.preimage.slice(t,t+4),t+=4,this.fields.hashOutputs=this.preimage.slice(t,t+32),t+=32,this.fields.locktime=this.preimage.slice(t,t+4),t+=4,this.fields.sighash=this.preimage.slice(t,t+4)},n.prototype._extractFromRight=function(){var t=this.preimage.length;t-=4,this.fields.sighash=this.preimage.slice(t,t+4),t-=4,this.fields.locktime=this.preimage.slice(t,t+4),t-=32,this.fields.hashOutputs=this.preimage.slice(t,t+32),t-=4,this.fields.sequence=this.preimage.slice(t,t+4),t-=8,this.fields.amount=this.preimage.slice(t,t+8);var e=n.decodeCompactSize(this.preimage,104);this.fields.scriptCodeLength=e.value,this.fields.scriptCode=this.preimage.slice(e.nextOffset,e.nextOffset+this.fields.scriptCodeLength),this.fields.version=this.preimage.slice(0,4),this.fields.hashPrevouts=this.preimage.slice(4,36),this.fields.hashSequence=this.preimage.slice(36,68),this.fields.outpoint=this.preimage.slice(68,104)},n.prototype._analyzeSighash=function(){if(this.fields.sighash){var t=this.fields.sighash.readUInt32LE(0);this.sighashInfo.flag=t;var r=31&t,i=0!=(128&t),n=0!=(64&t),o=e.alloc(32);i&&this.fields.hashPrevouts.equals(o)&&(this.sighashInfo.hasZeroHashes=!0,this.sighashInfo.zeroFields.push("hashPrevouts"),this.sighashInfo.warnings.push("ANYONECANPAY flag detected - hashPrevouts is zero")),2===r&&this.fields.hashSequence.equals(o)&&(this.sighashInfo.hasZeroHashes=!0,this.sighashInfo.zeroFields.push("hashSequence"),this.sighashInfo.warnings.push("SIGHASH_NONE flag detected - hashSequence is zero")),2!==r&&3!==r||!this.fields.hashOutputs.equals(o)||(this.sighashInfo.hasZeroHashes=!0,this.sighashInfo.zeroFields.push("hashOutputs"),this.sighashInfo.warnings.push("SIGHASH_NONE/SINGLE flag detected - hashOutputs is zero"));var s=[];1===r?s.push("ALL"):2===r?s.push("NONE"):3===r&&s.push("SINGLE"),i&&s.push("ANYONECANPAY"),n&&s.push("FORKID"),this.sighashInfo.flagName=s.join(" | ")}},n.prototype._parsePreimageStructure=function(){for(var t=this.preimage,e=0,r={},i=[{name:"nVersion",len:4},{name:"hashPrevouts",len:32},{name:"hashSequence",len:32},{name:"outpoint_txid",len:32},{name:"outpoint_vout",len:4}],o=[{name:"value",len:8},{name:"nSequence",len:4},{name:"hashOutputs",len:32},{name:"nLocktime",len:4},{name:"sighashType",len:4}],s=0;s<i.length;s++){var a=i[s];r[a.name]=t.slice(e,e+a.len).toString("hex"),e+=a.len}var c=n.decodeCompactSize(t,e);r.scriptLen=c.value,r.scriptLenSize=c.bytes,r.scriptLenRaw=t.slice(e,e+c.bytes).toString("hex"),e+=c.bytes,r.scriptCode=t.slice(e,e+r.scriptLen).toString("hex"),e+=r.scriptLen;for(var u=0;u<o.length;u++){var f=o[u];r[f.name]=t.slice(e,e+f.len).toString("hex"),e+=f.len}var h=i.reduce((function(t,e){return t+e.len}),0),d=o.reduce((function(t,e){return t+e.len}),0);return r._structure={leftFixed:h,scriptLenVarint:c.bytes,scriptCode:r.scriptLen,rightFixed:d,totalCalculated:h+c.bytes+r.scriptLen+d,totalActual:t.length},r},n.prototype._generateBidirectionalASM=function(t,e,r){if(["value","nSequence","hashOutputs","nLocktime","sighashType"].includes(t))return this._generateRightExtractionASM(t,r);if(["nVersion","hashPrevouts","hashSequence","outpoint_txid","outpoint_vout"].includes(t))return this._generateLeftExtractionASM(t,r);if("scriptCode"===t)return this._generateDynamicExtractionASM(e,r);if("scriptLen"===t)return this._generateScriptLenExtractionASM(e,r);throw new Error("Unknown field: "+t)},n.prototype._generateRightExtractionASM=function(t,e){for(var r=[{name:"value",len:8},{name:"nSequence",len:4},{name:"hashOutputs",len:32},{name:"nLocktime",len:4},{name:"sighashType",len:4}],i=0,n=0,o=!1,s=0;s<r.length;s++){var a=r[s];if(a.name===t){n=a.len,o=!0;break}i+=a.len}if(!o)throw new Error("Field not found in RIGHT fields: "+t);var c=52-i,u=[];return e?(u.push("# 🔄 Extract "+t+" from RIGHT side (bidirectional strategy)"),u.push("OP_SIZE # Push preimage size: [preimage, size]")):u.push("OP_SIZE"),(u=e?u.concat([c+" OP_SUB # Calculate split point: [preimage, split_point]","OP_SPLIT # Split: [left_part, right_part]","OP_DROP # Drop left: [right_part]",n+" OP_SPLIT # Extract field: [remaining, "+t+"]","OP_DROP # Clean up: ["+t+"]","# ✅ Result: "+t+" is now on top of stack"]):u.concat([c+" OP_SUB","OP_SPLIT","OP_DROP",n+" OP_SPLIT","OP_DROP"])).join("\n")},n.prototype._generateLeftExtractionASM=function(t,e){var r=[{name:"nVersion",len:4,offset:0},{name:"hashPrevouts",len:32,offset:4},{name:"hashSequence",len:32,offset:36},{name:"outpoint_txid",len:32,offset:68},{name:"outpoint_vout",len:4,offset:100}].find((function(e){return e.name===t}));if(!r)throw new Error("Field not found in LEFT fields: "+t);return(e?["# 🔄 Extract "+t+" from LEFT side (bidirectional strategy)",r.offset+" OP_SPLIT # Skip to field: [prefix, remainder]","OP_DROP # Drop prefix: [remainder]",r.len+" OP_SPLIT # Extract field: ["+t+", suffix]","OP_DROP # Clean up: ["+t+"]","# ✅ Result: "+t+" is now on top of stack"]:[r.offset+" OP_SPLIT","OP_DROP",r.len+" OP_SPLIT","OP_DROP"]).join("\n")},n.prototype._generateDynamicExtractionASM=function(t,e){return["# 🎯 Extract scriptCode DYNAMICALLY with CompactSize varint support",104+t.scriptLenSize+" OP_SPLIT # Skip left zone + scriptLen varint: [left_zone, remainder]","OP_DROP # Drop left: [remainder]",t.scriptLen+" OP_SPLIT # Extract scriptCode: [scriptCode, right_zone]","OP_DROP # Clean up: [scriptCode]","# ✅ Result: scriptCode extracted with "+t.scriptLenSize+"-byte varint awareness"].join("\n")},n.prototype._generateScriptLenExtractionASM=function(t,e){return["# 🎯 Extract scriptLen CompactSize varint ("+t.scriptLenSize+" bytes)","104 OP_SPLIT # Skip left fixed fields: [left_zone, remainder]","OP_DROP # Drop left: [remainder]",t.scriptLenSize+" OP_SPLIT # Extract varint: [scriptLen_varint, suffix]","OP_DROP # Clean up: [scriptLen_varint]","# ✅ Result: CompactSize varint (decode off-chain to get "+t.scriptLen+")"].join("\n")},n.prototype._extractSpecificField=function(t,r){var i=r[t];return i?e.from(i,"hex"):null},n.prototype._interpretField=function(t,r,i){if(!r)return null;var n={raw:r.toString("hex"),bytes:r.length};try{switch(t){case"nVersion":n.value=r.readUInt32LE(0),n.description="Transaction version "+n.value;break;case"value":8===r.length&&(n.satoshis=r.readBigUInt64LE(0).toString(),n.description=n.satoshis+" satoshis");break;case"sighashType":var o=r.readUInt32LE(0);n.value=o,n.description={1:"SIGHASH_ALL",65:"SIGHASH_ALL | FORKID",2:"SIGHASH_NONE",66:"SIGHASH_NONE | FORKID",3:"SIGHASH_SINGLE",67:"SIGHASH_SINGLE | FORKID"}[o]||"Custom ("+o+")";break;case"outpoint_vout":n.value=r.readUInt32LE(0),n.description="Output index "+n.value;break;case"scriptLen":n.varintSize=i.scriptLenSize,n.scriptLength=i.scriptLen,n.description=i.scriptLen+" bytes encoded as "+i.scriptLenSize+"-byte varint";break;case"scriptCode":25===r.length&&118===r[0]&&169===r[1]?(n.description="Standard P2PKH script (25 bytes)",n.type="P2PKH"):r.length>0&&106===r[0]?(n.description="OP_RETURN data script ("+r.length+" bytes)",n.type="OP_RETURN"):(n.description="Custom script ("+r.length+" bytes)",n.type="CUSTOM");break;default:if(["hashPrevouts","hashSequence","hashOutputs"].includes(t)){var s=e.alloc(32);r.equals(s)?(n.isZero=!0,n.description="Zero hash (check SIGHASH flags)"):n.description="32-byte hash"}}}catch(t){n.error=t.message}return n},n.prototype._getExtractionStrategy=function(t){return["value","nSequence","hashOutputs","nLocktime","sighashType"].includes(t)?"RIGHT":["nVersion","hashPrevouts","hashSequence","outpoint_txid","outpoint_vout"].includes(t)?"LEFT":"scriptCode"===t?"DYNAMIC":"scriptLen"===t?"VARINT":"UNKNOWN"},n.decodeCompactSize=function(t,e){var r=t[e];if(r<253)return{value:r,nextOffset:e+1,bytes:1};if(253===r)return{value:t.readUInt16LE(e+1),nextOffset:e+3,bytes:3};if(254===r)return{value:t.readUInt32LE(e+1),nextOffset:e+5,bytes:5};console.warn("Encountered 8-byte CompactSize - this is very unusual for script lengths");try{return{value:t.readUInt32LE(e+1),nextOffset:e+9,bytes:9}}catch(t){throw new Error("Invalid 8-byte CompactSize encoding in preimage")}},n.fromTransaction=function(t,e,r,o,s){return new n(i.Transaction.sighash.sighashPreimage(t,s,e,r,new i.crypto.BN(o)),{transaction:t,inputIndex:e,subscript:r,satoshis:o,sighashType:s})},n.createExample=function(t){var e=i.PrivateKey.fromRandom().toAddress(),r={txId:"0".repeat(64),outputIndex:0,script:i.Script.buildPublicKeyHashOut(e).toHex(),satoshis:1e5},o=(new i.Transaction).from(r).to(e,99e3),s=i.Script.fromHex(r.script);return n.fromTransaction(o,0,s,r.satoshis,t)},n.extractFromHex=function(t,e,r){return new n(t,{deferExtraction:!0}).extractField(e,r)},n.generateASMFromHex=function(t,e,r){return new n(t,{deferExtraction:!0}).generateASM(e,r)},n.extractMultipleFromHex=function(t,e){return new n(t,{deferExtraction:!0}).extractFields(e)},n.validateFromHex=function(t){return new n(t).validate()},n.analyzeFromHex=function(t){var e=new n(t),r=e._parsePreimageStructure(),i=e.validate();return{hex:t,length:t.length/2,structure:r._structure,fields:r,validation:i,sighashInfo:e.getSighashInfo(),extractField:function(t){return e.extractField(t)},generateASM:function(t){return e.generateASM(t)},getSummary:function(){return{totalBytes:r._structure.totalActual,scriptLength:r.scriptLen,scriptVarintSize:r.scriptLenSize,sighashType:r.sighashType,valid:i.valid,warnings:i.warnings}}}},t.exports=n}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(1),n=r(2),o=r(3),s=function t(r){if(!(this instanceof t))return new t(r);if(!i.isUndefined(r))if(e.isBuffer(r))this.set({buf:r});else if(i.isString(r)){var n=e.from(r,"hex");if(2*n.length!==r.length)throw new TypeError("Invalid hex string");this.set({buf:n})}else{if(!i.isObject(r))throw new TypeError("Unrecognized argument for BufferReader");var o=r;this.set(o)}};s.prototype.set=function(t){return this.buf=t.buf||this.buf||void 0,this.pos=t.pos||this.pos||0,this},s.prototype.eof=function(){return this.pos>=this.buf.length},s.prototype.finished=s.prototype.eof,s.prototype.read=function(t){n.checkArgument(!i.isUndefined(t),"Must specify a length");var e=this.buf.slice(this.pos,this.pos+t);return this.pos=this.pos+t,e},s.prototype.readAll=function(){var t=this.buf.slice(this.pos,this.buf.length);return this.pos=this.buf.length,t},s.prototype.readUInt8=function(){var t=this.buf.readUInt8(this.pos);return this.pos=this.pos+1,t},s.prototype.readUInt16BE=function(){var t=this.buf.readUInt16BE(this.pos);return this.pos=this.pos+2,t},s.prototype.readUInt16LE=function(){var t=this.buf.readUInt16LE(this.pos);return this.pos=this.pos+2,t},s.prototype.readUInt32BE=function(){var t=this.buf.readUInt32BE(this.pos);return this.pos=this.pos+4,t},s.prototype.readUInt32LE=function(){var t=this.buf.readUInt32LE(this.pos);return this.pos=this.pos+4,t},s.prototype.readInt32LE=function(){var t=this.buf.readInt32LE(this.pos);return this.pos=this.pos+4,t},s.prototype.readUInt64BEBN=function(){var t=this.buf.slice(this.pos,this.pos+8),e=o.fromBuffer(t);return this.pos=this.pos+8,e},s.prototype.readUInt64LEBN=function(){var t,e=this.buf.readUInt32LE(this.pos),r=4294967296*this.buf.readUInt32LE(this.pos+4)+e;if(r<=9007199254740991)t=new o(r);else{var i=Array.prototype.slice.call(this.buf,this.pos,this.pos+8);t=new o(i,10,"le")}return this.pos=this.pos+8,t},s.prototype.readVarintNum=function(){var t=this.readUInt8();switch(t){case 253:return this.readUInt16LE();case 254:return this.readUInt32LE();case 255:var e=this.readUInt64LEBN().toNumber();if(e<=Math.pow(2,53))return e;throw new Error("number too large to retain precision - use readVarintBN");default:return t}},s.prototype.readVarLengthBuffer=function(){var t=this.readVarintNum(),e=this.read(t);return n.checkState(e.length===t,"Invalid length while reading varlength buffer. Expected to read: "+t+" and read "+e.length),e},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 t=this.readUInt8();switch(t){case 253:return new o(this.readUInt16LE());case 254:return new o(this.readUInt32LE());case 255:return this.readUInt64LEBN();default:return new o(t)}},s.prototype.reverse=function(){for(var t=e.alloc(this.buf.length),r=0;r<t.length;r++)t[r]=this.buf[this.buf.length-1-r];return this.buf=t,this},s.prototype.readReverse=function(t){i.isUndefined(t)&&(t=this.buf.length);var r=this.buf.slice(this.pos,this.pos+t);return this.pos=this.pos+t,e.from(r).reverse()},t.exports=s}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(0),n=r(4),o=r(12),s=r(20),a=r(18),c=r(16),u=r(3),f=r(6),h=r(44),d=r(2),p=r(49),l=r(1),g=e.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),m=p.SCRIPT_ENABLE_SIGHASH_FORKID,b=function(t,a,h,b,y,v){var S=r(71),_=r(50);l.isUndefined(v)&&(v=m);var w,I=S.shallowCopy(t);(b=new o(b),v&p.SCRIPT_ENABLE_REPLAY_PROTECTION)&&(a=(16711680|57005^a>>8)<<8|255&a);if(a&n.SIGHASH_FORKID&&v&p.SCRIPT_ENABLE_SIGHASH_FORKID)return function(t,r,i,o,s){var a=t.inputs[i];function h(t,e){var r=new c;l.isUndefined(e)?l.each(t.outputs,(function(t){t.toBufferWriter(r)})):t.outputs[e].toBufferWriter(r);var i=r.toBuffer();return f.sha256sha256(i)}d.checkArgument(s instanceof u,"For ForkId=0 signatures, satoshis or complete input must be provided");var p=e.alloc(32),g=e.alloc(32),m=e.alloc(32);r&n.SIGHASH_ANYONECANPAY||(p=function(t){var e=new c;l.each(t.inputs,(function(t){e.writeReverse(t.prevTxId),e.writeUInt32LE(t.outputIndex)}));var r=e.toBuffer();return f.sha256sha256(r)}(t)),r&n.SIGHASH_ANYONECANPAY||(31&r)===n.SIGHASH_SINGLE||(31&r)===n.SIGHASH_NONE||(g=function(t){var e=new c;l.each(t.inputs,(function(t){e.writeUInt32LE(t.sequenceNumber)}));var r=e.toBuffer();return f.sha256sha256(r)}(t)),(31&r)!==n.SIGHASH_SINGLE&&(31&r)!==n.SIGHASH_NONE?m=h(t):(31&r)===n.SIGHASH_SINGLE&&i<t.outputs.length&&(m=h(t,i));var b=new c;b.writeInt32LE(t.version),b.write(p),b.write(g),b.writeReverse(a.prevTxId),b.writeUInt32LE(a.outputIndex),b.writeVarintNum(o.toBuffer().length),b.write(o.toBuffer()),b.writeUInt64LEBN(s);var y=a.sequenceNumber;return b.writeUInt32LE(y),b.write(m),b.writeUInt32LE(t.nLockTime),b.writeUInt32LE(r>>>0),b.toBuffer()}(I,a,h,b,y);for(b.removeCodeseparators(),w=0;w<I.inputs.length;w++)I.inputs[w]=new _(I.inputs[w]).setScript(o.empty());if(I.inputs[h]=new _(I.inputs[h]).setScript(b),(31&a)===n.SIGHASH_NONE||(31&a)===n.SIGHASH_SINGLE)for(w=0;w<I.inputs.length;w++)w!==h&&(I.inputs[w].sequenceNumber=0);if((31&a)===n.SIGHASH_NONE)I.outputs=[];else if((31&a)===n.SIGHASH_SINGLE){if(h>=I.outputs.length)return g;for(I.outputs.length=h+1,w=0;w<h;w++)I.outputs[w]=new s({satoshis:u.fromBuffer(i.Buffer.from("ffffffffffffffff","hex")),script:o.empty()})}return a&n.SIGHASH_ANYONECANPAY&&(I.inputs=[I.inputs[h]]),(new c).write(I.toBuffer()).writeInt32LE(a).toBuffer()},y=function(t,e,r,i,n,o){var s=b(t,e,r,i,n,o);if(0===s.compare(g))return s;var c=f.sha256sha256(s);return c=new a(c).readReverse()};t.exports={sighashPreimage:b,sighash:y,sign:function(t,e,r,i,n,o,s){var a=y(t,r,i,n,o,s);return h.sign(a,e,"little").set({nhashtype:r})},verify:function(t,e,r,i,n,o,s){d.checkArgument(!l.isUndefined(t)),d.checkArgument(!l.isUndefined(e)&&!l.isUndefined(e.nhashtype));var a=y(t,e.nhashtype,i,n,o,s);return h.verify(a,e,r,"little")}}}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(1),n=r(3),o=r(0),s=r(5),a=r(16),c=r(28),u=r(12),f=r(2),h=r(10);function d(t){if(!(this instanceof d))return new d(t);if(!i.isObject(t))throw new TypeError("Unrecognized argument for Output");var r;this.satoshis=t.satoshis,e.isBuffer(t.script)?this._scriptBuffer=t.script:(r=i.isString(t.script)&&s.isHexa(t.script)?o.Buffer.from(t.script,"hex"):t.script,this.setScript(r))}Object.defineProperty(d.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this._script||this.setScriptFromBuffer(this._scriptBuffer),this._script}}),Object.defineProperty(d.prototype,"satoshis",{configurable:!1,enumerable:!0,get:function(){return this._satoshis},set:function(t){t instanceof n?(this._satoshisBN=t,this._satoshis=t.toNumber()):i.isString(t)?(this._satoshis=parseInt(t),this._satoshisBN=n.fromNumber(this._satoshis)):(f.checkArgument(s.isNaturalNumber(t),"Output satoshis is not a natural number"),this._satoshisBN=n.fromNumber(t),this._satoshis=t),f.checkState(s.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}}),d.prototype.invalidSatoshis=function(){return this._satoshis>9007199254740991?"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"},Object.defineProperty(d.prototype,"satoshisBN",{configurable:!1,enumerable:!0,get:function(){return this._satoshisBN},set:function(t){this._satoshisBN=t,this._satoshis=t.toNumber(),f.checkState(s.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}}),d.prototype.toObject=d.prototype.toJSON=function(){var t={satoshis:this.satoshis};return t.script=this._scriptBuffer.toString("hex"),t},d.fromObject=function(t){return new d(t)},d.prototype.setScriptFromBuffer=function(t){this._scriptBuffer=t;try{this._script=u.fromBuffer(this._scriptBuffer),this._script._isOutput=!0}catch(t){if(!(t instanceof h.Script.InvalidBuffer))throw t;this._script=null}},d.prototype.setScript=function(t){if(t instanceof u)this._scriptBuffer=t.toBuffer(),this._script=t,this._script._isOutput=!0;else if(i.isString(t))this._script=u.fromString(t),this._scriptBuffer=this._script.toBuffer(),this._script._isOutput=!0;else{if(!e.isBuffer(t))throw new TypeError("Invalid argument type: script");this.setScriptFromBuffer(t)}return this},d.prototype.inspect=function(){var t;return t=this.script?this.script.inspect():this._scriptBuffer.toString("hex"),"<Output ("+this.satoshis+" sats) "+t+">"},d.fromBufferReader=function(t){var e={};e.satoshis=t.readUInt64LEBN();var r=t.readVarintNum();return e.script=0!==r?t.read(r):o.Buffer.from([]),new d(e)},d.prototype.toBufferWriter=function(t){t||(t=new a),t.writeUInt64LEBN(this._satoshisBN);var e=this._scriptBuffer;return t.writeVarintNum(e.length),t.write(e),t},d.prototype.getSize=function(){var t=this.script.toBuffer().length;return 8+c(t).toBuffer().length+t},t.exports=d}).call(this,r(0).Buffer)},function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}t.exports=r,r.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)}},function(t,e){"function"==typeof Object.create?t.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},function(t,e,r){"use strict";var i=r(1),n=r(5),o=[],s={};function a(){}function c(t,e){if(~o.indexOf(t))return t;if(!e)return s[t];i.isArray(e)||(e=[e]);for(var r=0;r<o.length;r++){var n=o[r],a=i.pick(n,e);if(~i.values(a).indexOf(t))return n}}function u(t){for(var e=[],r=0;r<t.length;r++)e.push(31&t.charCodeAt(r));return e}function f(t){var e=new a;n.defineImmutable(e,{name:t.name,alias:t.alias,pubkeyhash:t.pubkeyhash,privatekey:t.privatekey,scripthash:t.scripthash,xpubkey:t.xpubkey,xprivkey:t.xprivkey});var r=t.indexBy||Object.keys(t);return t.cashAddrPrefix&&i.extend(e,{cashAddrPrefix:t.cashAddrPrefix,cashAddrPrefixArray:u(t.cashAddrPrefix)}),t.networkMagic&&i.extend(e,{networkMagic:n.integerAsBuffer(t.networkMagic)}),t.port&&i.extend(e,{port:t.port}),t.dnsSeeds&&i.extend(e,{dnsSeeds:t.dnsSeeds}),o.push(e),function(t,e){for(var r=0;r<e.length;r++){var n=e[r],o=t[n];i.isUndefined(o)||i.isObject(o)||(s[o]=t)}}(e,r),e}a.prototype.toString=function(){return this.name};var h=["seed.bitcoinsv.org","seed.bitcoinunlimited.info"],d={PORT:18333,NETWORK_MAGIC:4108710900,DNS_SEEDS:h,PREFIX:"testnet",CASHADDRPREFIX:"bchtest"},p={PORT:18444,NETWORK_MAGIC:3669344250,DNS_SEEDS:[],PREFIX:"regtest",CASHADDRPREFIX:"bchreg"},l={PORT:9333,NETWORK_MAGIC:4224632057,DNS_SEEDS:["stn-seed.bitcoinsv.io"],PREFIX:"stn",CASHADDRPREFIX:"bsvstn"},g={name:"livenet",alias:"mainnet",prefix:"bitcoin",cashAddrPrefix:"bitcoincash",pubkeyhash:0,privatekey:128,scripthash:5,xpubkey:76067358,xprivkey:76066276,networkMagic:3823236072,port:8333,dnsSeeds:h},m={name:"testnet",prefix:d.PREFIX,cashAddrPrefix:d.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:d.NETWORK_MAGIC},b={name:"regtest",prefix:p.PREFIX,cashAddrPrefix:p.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:p.NETWORK_MAGIC,port:p.PORT,dnsSeeds:[],indexBy:["port","name","cashAddrPrefix","networkMagic"]},y={name:"stn",prefix:l.PREFIX,cashAddrPrefix:l.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:l.NETWORK_MAGIC,indexBy:["port","name","cashAddrPrefix","networkMagic"]};f(m),f(y),f(b),f(g);var v=c("livenet"),S=c("regtest"),_=c("testnet"),w=c("stn");Object.defineProperty(_,"port",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?p.PORT:this.stnEnabled?l.PORT:d.PORT}}),Object.defineProperty(_,"networkMagic",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?n.integerAsBuffer(p.NETWORK_MAGIC):this.stnEnabled?n.integerAsBuffer(l.NETWORK_MAGIC):n.integerAsBuffer(d.NETWORK_MAGIC)}}),Object.defineProperty(_,"dnsSeeds",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?p.DNS_SEEDS:this.stnEnabled?l.DNS_SEEDS:d.DNS_SEEDS}}),Object.defineProperty(_,"cashAddrPrefix",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?p.CASHADDRPREFIX:this.stnEnabled?l.CASHADDRPREFIX:d.CASHADDRPREFIX}}),Object.defineProperty(_,"cashAddrPrefixArray",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?u(p.CASHADDRPREFIX):this.stnEnabled?l.cashAddrPrefixToArray(l.CASHADDRPREFIX):u(d.CASHADDRPREFIX)}}),t.exports={add:f,remove:function(t){for(var e=0;e<o.length;e++)o[e]===t&&o.splice(e,1);!function(t,e){for(var r=0;r<e.length;r++){var i=e[r];s[i]===t&&delete s[i]}}(t,Object.keys(s))},defaultNetwork:v,livenet:v,mainnet:v,testnet:_,regtest:S,stn:w,get:c,enableRegtest:function(){_.regtestEnabled=!0},disableRegtest:function(){_.regtestEnabled=!1},enableStn:function(){_.stnEnabled=!0},disableStn:function(){_.stnEnabled=!1}}},function(t,e){var r,i,n=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(t){if(r===setTimeout)return setTimeout(t,0);if((r===o||!r)&&setTimeout)return r=setTimeout,setTimeout(t,0);try{return r(t,0)}catch(e){try{return r.call(null,t,0)}catch(e){return r.call(this,t,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:o}catch(t){r=o}try{i="function"==typeof clearTimeout?clearTimeout:s}catch(t){i=s}}();var c,u=[],f=!1,h=-1;function d(){f&&c&&(f=!1,c.length?u=c.concat(u):h=-1,u.length&&p())}function p(){if(!f){var t=a(d);f=!0;for(var e=u.length;e;){for(c=u,u=[];++h<e;)c&&c[h].run();h=-1,e=u.length}c=null,f=!1,function(t){if(i===clearTimeout)return clearTimeout(t);if((i===s||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(t);try{i(t)}catch(e){try{return i.call(null,t)}catch(e){return i.call(this,t)}}}(t)}}function l(t,e){this.fun=t,this.array=e}function g(){}n.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];u.push(new l(t,e)),1!==u.length||f||a(p)},l.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=g,n.addListener=g,n.once=g,n.off=g,n.removeListener=g,n.removeAllListeners=g,n.emit=g,n.prependListener=g,n.prependOnceListener=g,n.listeners=function(t){return[]},n.binding=function(t){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(t){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},function(t,e,r){"use strict";(function(e){var i=r(1),n=r(2),o=r(10),s=r(27),a=r(23),c=r(6),u=r(5),f=r(14);function h(t,e,r){if(!(this instanceof h))return new h(t,e,r);if(i.isArray(t)&&i.isNumber(e))return h.createMultisig(t,e,r);if(t instanceof h)return t;if(n.checkArgument(t,"First argument is required, please include address data.","guide/address.html"),e&&!a.get(e))throw new TypeError('Second argument must be "livenet", "testnet", or "regtest".');if(r&&r!==h.PayToPublicKeyHash&&r!==h.PayToScriptHash)throw new TypeError('Third argument must be "pubkeyhash" or "scripthash".');var o=this._classifyArguments(t,e,r);return o.network=o.network||a.get(e)||a.defaultNetwork,o.type=o.type||r||h.PayToPublicKeyHash,u.defineImmutable(this,{hashBuffer:o.hashBuffer,network:o.network,type:o.type}),this}h.prototype._classifyArguments=function(t,r,n){if((t instanceof e||t instanceof Uint8Array)&&20===t.length)return h._transformHash(t);if((t instanceof e||t instanceof Uint8Array)&&21===t.length)return h._transformBuffer(t,r,n);if(t instanceof f)return h._transformPublicKey(t);if(t instanceof d)return h._transformScript(t,r);if("string"==typeof t)return h._transformString(t,r,n);if(i.isObject(t))return h._transformObject(t);throw new TypeError("First argument is an unrecognized data format.")},h.PayToPublicKeyHash="pubkeyhash",h.PayToScriptHash="scripthash",h._transformHash=function(t){var r={};if(!(t instanceof e||t instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(20!==t.length)throw new TypeError("Address hashbuffers must be exactly 20 bytes.");return r.hashBuffer=t,r},h._transformObject=function(t){return n.checkArgument(t.hash||t.hashBuffer,"Must provide a `hash` or `hashBuffer` property"),n.checkArgument(t.type,"Must provide a `type` property"),{hashBuffer:t.hash?e.from(t.hash,"hex"):t.hashBuffer,network:a.get(t.network)||a.defaultNetwork,type:t.type}},h._classifyFromVersion=function(t){var e={},r=a.get(t[0],"pubkeyhash"),i=a.get(t[0],"scripthash");return r?(e.network=r,e.type=h.PayToPublicKeyHash):i&&(e.network=i,e.type=h.PayToScriptHash),e},h._transformBuffer=function(t,r,i){var n={};if(!(t instanceof e||t instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(21!==t.length)throw new TypeError("Address buffers must be exactly 21 bytes.");var o=a.get(r),s=h._classifyFromVersion(t);if(r&&!o)throw new TypeError("Unknown network");if(!s.network||o&&o!==s.network)throw new TypeError("Address has mismatched network type.");if(!s.type||i&&i!==s.type)throw new TypeError("Address has mismatched type.");return n.hashBuffer=t.slice(1),n.network=s.network,n.type=s.type,n},h._transformPublicKey=function(t){var e={};if(!(t instanceof f))throw new TypeError("Address must be an instance of PublicKey.");return e.hashBuffer=c.sha256ripemd160(t.toBuffer()),e.type=h.PayToPublicKeyHash,e},h._transformScript=function(t,e){n.checkArgument(t instanceof d,"script must be a Script instance");var r=t.getAddressInfo(e);if(!r)throw new o.Script.CantDeriveAddress(t);return r},h.createMultisig=function(t,e,r){return r=r||t[0].network||a.defaultNetwork,h.payingTo(d.buildMultisigOut(t,e),r)},h._transformString=function(t,e,r){if("string"!=typeof t)throw new TypeError("data parameter supplied is not a string.");if(t.length<27)throw new Error("Invalid Address string provided");t=t.trim();var i=a.get(e);if(e&&!i)throw new TypeError("Unknown network");var n=s.decode(t);return h._transformBuffer(n,e,r)},h.fromPublicKey=function(t,e){var r=h._transformPublicKey(t);return e=e||a.defaultNetwork,new h(r.hashBuffer,e,r.type)},h.fromPrivateKey=function(t,e){let r=f.fromPrivateKey(t);return e=e||t.network||a.defaultNetwork,h.fromPublicKey(r,e)},h.fromPublicKeyHash=function(t,e){var r=h._transformHash(t);return new h(r.hashBuffer,e,h.PayToPublicKeyHash)},h.fromScriptHash=function(t,e){n.checkArgument(t,"hash parameter is required");var r=h._transformHash(t);return new h(r.hashBuffer,e,h.PayToScriptHash)},h.payingTo=function(t,e){return n.checkArgument(t,"script is required"),n.checkArgument(t instanceof d,"script must be instance of Script"),h.fromScriptHash(c.sha256ripemd160(t.toBuffer()),e)},h.fromScript=function(t,e){n.checkArgument(t instanceof d,"script must be a Script instance");var r=h._transformScript(t,e);return new h(r.hashBuffer,e,r.type)},h.fromBuffer=function(t,e,r){var i=h._transformBuffer(t,e,r);return new h(i.hashBuffer,i.network,i.type)},h.fromHex=function(t,r,i){return h.fromBuffer(e.from(t,"hex"),r,i)},h.fromString=function(t,e,r){var i=h._transformString(t,e,r);return new h(i.hashBuffer,i.network,i.type)},h.fromObject=function(t){return n.checkState(u.isHexa(t.hash),'Unexpected hash property, "'+t.hash+'", expected to be hex.'),new h(e.from(t.hash,"hex"),t.network,t.type)},h.getValidationError=function(t,e,r){var i;try{new h(t,e,r)}catch(t){i=t}return i},h.isValid=function(t,e,r){return!h.getValidationError(t,e,r)},h.prototype.isPayToPublicKeyHash=function(){return this.type===h.PayToPublicKeyHash},h.prototype.isPayToScriptHash=function(){return this.type===h.PayToScriptHash},h.prototype.toBuffer=function(){var t=e.from([this.network[this.type]]);return e.concat([t,this.hashBuffer])},h.prototype.toHex=function(){return this.toBuffer().toString("hex")},h.prototype.toObject=h.prototype.toJSON=function(){return{hash:this.hashBuffer.toString("hex"),type:this.type,network:this.network.toString()}},h.prototype.inspect=function(){return"<Address: "+this.toString()+", type: "+this.type+", network: "+this.network+">"},h.prototype.toString=function(){return s.encode(this.toBuffer())},t.exports=h;var d=r(12)}).call(this,r(0).Buffer)},function(t,e,r){"use strict";var i=r(13),n=r(21);function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}e.BlockHash=o,o.prototype.update=function(t,e){if(t=i.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=i.join32(t,0,t.length-r,this.endian);for(var n=0;n<t.length;n+=this._delta32)this._update(t,n,n+this._delta32)}return this},o.prototype.digest=function(t){return this.update(this._pad()),n(null===this.pending),this._digest(t)},o.prototype._pad=function(){var t=this.pendingTotal,e=this._delta8,r=e-(t+this.padLength)%e,i=new Array(r+this.padLength);i[0]=128;for(var n=1;n<r;n++)i[n]=0;if(t<<=3,"big"===this.endian){for(var o=8;o<this.padLength;o++)i[n++]=0;i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=t>>>24&255,i[n++]=t>>>16&255,i[n++]=t>>>8&255,i[n++]=255&t}else for(i[n++]=255&t,i[n++]=t>>>8&255,i[n++]=t>>>16&255,i[n++]=t>>>24&255,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,o=8;o<this.padLength;o++)i[n++]=0;return i}},function(t,e,r){"use strict";(function(e){var i=r(1),n=r(35),o=r(0),s=r(6).sha256sha256,a=function t(r){if(!(this instanceof t))return new t(r);if(e.isBuffer(r)){var i=r;this.fromBuffer(i)}else if("string"==typeof r){var n=r;this.fromString(n)}};a.prototype.set=function(t){return this.buf=t.buf||this.buf||void 0,this},a.validChecksum=function(t,e){return i.isString(t)&&(t=o.Buffer.from(n.decode(t))),i.isString(e)&&(e=o.Buffer.from(n.decode(e))),e||(e=t.slice(-4),t=t.slice(0,-4)),a.checksum(t).toString("hex")===e.toString("hex")},a.decode=function(t){if("string"!=typeof t)throw new Error("Input must be a string");var r=e.from(n.decode(t));if(r.length<4)throw new Error("Input string too short");var i=r.slice(0,-4),o=r.slice(-4),a=s(i).slice(0,4);if(o.toString("hex")!==a.toString("hex"))throw new Error("Checksum mismatch");return i},a.checksum=function(t){return s(t).slice(0,4)},a.encode=function(t){if(!e.isBuffer(t))throw new Error("Input must be a buffer");var r=e.alloc(t.length+4),i=a.checksum(t);return t.copy(r),i.copy(r,t.length),n.encode(r)},a.prototype.fromBuffer=function(t){return this.buf=t,this},a.fromBuffer=function(t){return(new a).fromBuffer(t)},a.fromHex=function(t){return a.fromBuffer(e.from(t,"hex"))},a.prototype.fromString=function(t){var e=a.decode(t);return this.buf=e,this},a.fromString=function(t){var e=a.decode(t);return new n(e)},a.prototype.toBuffer=function(){return this.buf},a.prototype.toHex=function(){return this.toBuffer().toString("hex")},a.prototype.toString=function(){return a.encode(this.buf)},t.exports=a}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(16),n=r(18),o=r(3),s=function t(r){if(!(this instanceof t))return new t(r);if(e.isBuffer(r))this.buf=r;else if("number"==typeof r){var i=r;this.fromNumber(i)}else if(r instanceof o){var n=r;this.fromBN(n)}else if(r){var s=r;this.set(s)}};s.prototype.set=function(t){return this.buf=t.buf||this.buf,this},s.prototype.fromString=function(t){return this.set({buf:e.from(t,"hex")}),this},s.prototype.toString=function(){return this.buf.toString("hex")},s.prototype.fromBuffer=function(t){return this.buf=t,this},s.prototype.fromBufferReader=function(t){return this.buf=t.readVarintBuf(),this},s.prototype.fromBN=function(t){return this.buf=i().writeVarintBN(t).concat(),this},s.prototype.fromNumber=function(t){return this.buf=i().writeVarintNum(t).concat(),this},s.prototype.toBuffer=function(){return this.buf},s.prototype.toBN=function(){return n(this.buf).readVarintBN()},s.prototype.toNumber=function(){return n(this.buf).readVarintNum()},t.exports=s}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(1),n=r(2),o=r(10),s=r(16),a=r(0),c=r(5),u=r(12),f=r(19),h=r(20);function d(t){return this instanceof d?t?this._fromObject(t):void 0:new d(t)}d.MAXINT=4294967295,d.DEFAULT_SEQNUMBER=4294967295,d.DEFAULT_LOCKTIME_SEQNUMBER=4294967294,d.DEFAULT_RBF_SEQNUMBER=4294967293,d.BASE_SIZE=40,Object.defineProperty(d.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this.isNull()?null:(this._script||(this._script=new u(this._scriptBuffer),this._script._isInput=!0),this._script)}}),d.fromObject=function(t){return n.checkArgument(i.isObject(t)),(new d)._fromObject(t)},d.prototype._fromObject=function(t){var e;if(e=i.isString(t.prevTxId)&&c.isHexa(t.prevTxId)?a.Buffer.from(t.prevTxId,"hex"):t.prevTxId,this.output=t.output?t.output instanceof h?t.output:new h(t.output):void 0,this.prevTxId=e||t.txidbuf,this.outputIndex=i.isUndefined(t.outputIndex)?t.txoutnum:t.outputIndex,this.sequenceNumber=i.isUndefined(t.sequenceNumber)?i.isUndefined(t.seqnum)?4294967295:t.seqnum:t.sequenceNumber,i.isUndefined(t.script)&&i.isUndefined(t.scriptBuffer))throw new o.Transaction.Input.MissingScript;return this.setScript(t.scriptBuffer||t.script),this},d.prototype.toObject=d.prototype.toJSON=function(){var t={prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,sequenceNumber:this.sequenceNumber,script:this._scriptBuffer.toString("hex")};return this.script&&(t.scriptString=this.script.toString()),this.output&&(t.output=this.output.toObject()),t},d.fromBufferReader=function(t){var e=new d;return e.prevTxId=t.readReverse(32),e.outputIndex=t.readUInt32LE(),e._scriptBuffer=t.readVarLengthBuffer(),e.sequenceNumber=t.readUInt32LE(),e},d.prototype.toBufferWriter=function(t){t||(t=new s),t.writeReverse(this.prevTxId),t.writeUInt32LE(this.outputIndex);var e=this._scriptBuffer;return t.writeVarintNum(e.length),t.write(e),t.writeUInt32LE(this.sequenceNumber),t},d.prototype.setScript=function(t){if(this._script=null,t instanceof u)this._script=t,this._script._isInput=!0,this._scriptBuffer=t.toBuffer();else if(null===t)this._script=u.empty(),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else if(c.isHexa(t))this._scriptBuffer=a.Buffer.from(t,"hex");else if(i.isString(t))this._script=new u(t),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else{if(!e.isBuffer(t))throw new TypeError("Invalid argument type: script");this._scriptBuffer=a.Buffer.from(t)}return this},d.prototype.getSignatures=function(){throw new o.AbstractMethodInvoked("Trying to sign unsupported output type (only P2PKH and P2SH multisig inputs are supported) for input: "+JSON.stringify(this))},d.prototype.isFullySigned=function(){throw new o.AbstractMethodInvoked("Input#isFullySigned")},d.prototype.isFinal=function(){return this.sequenceNumber===d.MAXINT},d.prototype.addSignature=function(){throw new o.AbstractMethodInvoked("Input#addSignature")},d.prototype.clearSignatures=function(){throw new o.AbstractMethodInvoked("Input#clearSignatures")},d.prototype.isValidSignature=function(t,e){return e.signature.nhashtype=e.sigtype,f.verify(t,e.signature,e.publicKey,e.inputIndex,this.output.script,this.output.satoshisBN)},d.prototype.isNull=function(){return"0000000000000000000000000000000000000000000000000000000000000000"===this.prevTxId.toString("hex")&&4294967295===this.outputIndex},d.prototype._estimateSize=function(){return this.toBufferWriter().toBuffer().length},t.exports=d}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(1),n=r(2),o=r(22),s=r(5),a=r(14),c=r(10),u=r(4);function f(t){if(!(this instanceof f))return new f(t);if(t instanceof f)return t;if(i.isObject(t))return this._fromObject(t);throw new c.InvalidArgument("TransactionSignatures must be instantiated from an object")}o(f,u),f.prototype._fromObject=function(t){return this._checkObjectArgs(t),this.publicKey=new a(t.publicKey),this.prevTxId=e.isBuffer(t.prevTxId)?t.prevTxId:e.from(t.prevTxId,"hex"),this.outputIndex=t.outputIndex,this.inputIndex=t.inputIndex,this.signature=t.signature instanceof u?t.signature:e.isBuffer(t.signature)?u.fromBuffer(t.signature):u.fromString(t.signature),this.sigtype=t.sigtype,this},f.prototype._checkObjectArgs=function(t){n.checkArgument(a(t.publicKey),"publicKey"),n.checkArgument(!i.isUndefined(t.inputIndex),"inputIndex"),n.checkArgument(!i.isUndefined(t.outputIndex),"outputIndex"),n.checkState(i.isNumber(t.inputIndex),"inputIndex must be a number"),n.checkState(i.isNumber(t.outputIndex),"outputIndex must be a number"),n.checkArgument(t.signature,"signature"),n.checkArgument(t.prevTxId,"prevTxId"),n.checkState(t.signature instanceof u||e.isBuffer(t.signature)||s.isHexa(t.signature),"signature must be a buffer or hexa value"),n.checkState(e.isBuffer(t.prevTxId)||s.isHexa(t.prevTxId),"prevTxId must be a buffer or hexa value"),n.checkArgument(t.sigtype,"sigtype"),n.checkState(i.isNumber(t.sigtype),"sigtype must be a number")},f.prototype.toObject=f.prototype.toJSON=function(){return{publicKey:this.publicKey.toString(),prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,inputIndex:this.inputIndex,signature:this.signature.toString(),sigtype:this.sigtype}},f.fromObject=function(t){return n.checkArgument(t),new f(t)},t.exports=f}).call(this,r(0).Buffer)},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,r){"use strict";var i=r(9),n=r(8),o=n.getNAF,s=n.getJSF,a=n.assert;function c(t,e){this.type=t,this.p=new i(e.p,16),this.red=e.prime?i.red(e.prime):i.mont(this.p),this.zero=new i(0).toRed(this.red),this.one=new i(1).toRed(this.red),this.two=new i(2).toRed(this.red),this.n=e.n&&new i(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function u(t,e){this.curve=t,this.type=e,this.precomputed=null}t.exports=c,c.prototype.point=function(){throw new Error("Not implemented")},c.prototype.validate=function(){throw new Error("Not implemented")},c.prototype._fixedNafMul=function(t,e){a(t.precomputed);var r=t._getDoubles(),i=o(e,1,this._bitLength),n=(1<<r.step+1)-(r.step%2==0?2:1);n/=3;var s,c,u=[];for(s=0;s<i.length;s+=r.step){c=0;for(var f=s+r.step-1;f>=s;f--)c=(c<<1)+i[f];u.push(c)}for(var h=this.jpoint(null,null,null),d=this.jpoint(null,null,null),p=n;p>0;p--){for(s=0;s<u.length;s++)(c=u[s])===p?d=d.mixedAdd(r.points[s]):c===-p&&(d=d.mixedAdd(r.points[s].neg()));h=h.add(d)}return h.toP()},c.prototype._wnafMul=function(t,e){var r=4,i=t._getNAFPoints(r);r=i.wnd;for(var n=i.points,s=o(e,r,this._bitLength),c=this.jpoint(null,null,null),u=s.length-1;u>=0;u--){for(var f=0;u>=0&&0===s[u];u--)f++;if(u>=0&&f++,c=c.dblp(f),u<0)break;var h=s[u];a(0!==h),c="affine"===t.type?h>0?c.mixedAdd(n[h-1>>1]):c.mixedAdd(n[-h-1>>1].neg()):h>0?c.add(n[h-1>>1]):c.add(n[-h-1>>1].neg())}return"affine"===t.type?c.toP():c},c.prototype._wnafMulAdd=function(t,e,r,i,n){var a,c,u,f=this._wnafT1,h=this._wnafT2,d=this._wnafT3,p=0;for(a=0;a<i;a++){var l=(u=e[a])._getNAFPoints(t);f[a]=l.wnd,h[a]=l.points}for(a=i-1;a>=1;a-=2){var g=a-1,m=a;if(1===f[g]&&1===f[m]){var b=[e[g],null,null,e[m]];0===e[g].y.cmp(e[m].y)?(b[1]=e[g].add(e[m]),b[2]=e[g].toJ().mixedAdd(e[m].neg())):0===e[g].y.cmp(e[m].y.redNeg())?(b[1]=e[g].toJ().mixedAdd(e[m]),b[2]=e[g].add(e[m].neg())):(b[1]=e[g].toJ().mixedAdd(e[m]),b[2]=e[g].toJ().mixedAdd(e[m].neg()));var y=[-3,-1,-5,-7,0,7,5,1,3],v=s(r[g],r[m]);for(p=Math.max(v[0].length,p),d[g]=new Array(p),d[m]=new Array(p),c=0;c<p;c++){var S=0|v[0][c],_=0|v[1][c];d[g][c]=y[3*(S+1)+(_+1)],d[m][c]=0,h[g]=b}}else d[g]=o(r[g],f[g],this._bitLength),d[m]=o(r[m],f[m],this._bitLength),p=Math.max(d[g].length,p),p=Math.max(d[m].length,p)}var w=this.jpoint(null,null,null),I=this._wnafT4;for(a=p;a>=0;a--){for(var O=0;a>=0;){var P=!0;for(c=0;c<i;c++)I[c]=0|d[c][a],0!==I[c]&&(P=!1);if(!P)break;O++,a--}if(a>=0&&O++,w=w.dblp(O),a<0)break;for(c=0;c<i;c++){var A=I[c];0!==A&&(A>0?u=h[c][A-1>>1]:A<0&&(u=h[c][-A-1>>1].neg()),w="affine"===u.type?w.mixedAdd(u):w.add(u))}}for(a=0;a<i;a++)h[a]=null;return n?w:w.toP()},c.BasePoint=u,u.prototype.eq=function(){throw new Error("Not implemented")},u.prototype.validate=function(){return this.curve.validate(this)},c.prototype.decodePoint=function(t,e){t=n.toArray(t,e);var r=this.p.byteLength();if((4===t[0]||6===t[0]||7===t[0])&&t.length-1==2*r)return 6===t[0]?a(t[t.length-1]%2==0):7===t[0]&&a(t[t.length-1]%2==1),this.point(t.slice(1,1+r),t.slice(1+r,1+2*r));if((2===t[0]||3===t[0])&&t.length-1===r)return this.pointFromX(t.slice(1,1+r),3===t[0]);throw new Error("Unknown point format")},u.prototype.encodeCompressed=function(t){return this.encode(t,!0)},u.prototype._encode=function(t){var e=this.curve.p.byteLength(),r=this.getX().toArray("be",e);return t?[this.getY().isEven()?2:3].concat(r):[4].concat(r,this.getY().toArray("be",e))},u.prototype.encode=function(t,e){return n.encode(this._encode(e),t)},u.prototype.precompute=function(t){if(this.precomputed)return this;var e={doubles:null,naf:null,beta:null};return e.naf=this._getNAFPoints(8),e.doubles=this._getDoubles(4,t),e.beta=this._getBeta(),this.precomputed=e,this},u.prototype._hasDoubles=function(t){if(!this.precomputed)return!1;var e=this.precomputed.doubles;return!!e&&e.points.length>=Math.ceil((t.bitLength()+1)/e.step)},u.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],i=this,n=0;n<e;n+=t){for(var o=0;o<t;o++)i=i.dbl();r.push(i)}return{step:t,points:r}},u.prototype._getNAFPoints=function(t){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var e=[this],r=(1<<t)-1,i=1===r?null:this.dbl(),n=1;n<r;n++)e[n]=e[n-1].add(i);return{wnd:t,points:e}},u.prototype._getBeta=function(){return null},u.prototype.dblp=function(t){for(var e=this,r=0;r<t;r++)e=e.dbl();return e}},function(t,e,r){var i=e;i.utils=r(13),i.common=r(26),i.sha=r(89),i.ripemd=r(93),i.hmac=r(94),i.sha1=i.sha.sha1,i.sha256=i.sha.sha256,i.sha224=i.sha.sha224,i.sha384=i.sha.sha384,i.sha512=i.sha.sha512,i.ripemd160=i.ripemd.ripemd160},function(t,e,r){"use strict";(function(e){var i=r(1),n=r(25),o=r(27),s=r(3),a=r(5),c=r(23),u=r(11),f=r(14),h=r(38),d=r(2);function p(t,e){if(!(this instanceof p))return new p(t,e);if(t instanceof p)return t;var r=this._classifyArguments(t,e);if(!r.bn||0===r.bn.cmp(new s(0)))throw new TypeError("Number can not be equal to zero, undefined, null or false");if(!r.bn.lt(u.getN()))throw new TypeError("Number must be less than N");if(void 0===r.network)throw new TypeError('Must specify the network ("livenet" or "testnet")');return a.defineImmutable(this,{bn:r.bn,compressed:r.compressed,network:r.network}),Object.defineProperty(this,"publicKey",{configurable:!1,enumerable:!0,get:this.toPublicKey.bind(this)}),this}p.prototype._classifyArguments=function(t,r){var n={compressed:!0,network:r?c.get(r):c.defaultNetwork};if(i.isUndefined(t)||i.isNull(t))n.bn=p._getRandomBN();else if(t instanceof s)n.bn=t;else if(t instanceof e||t instanceof Uint8Array)n=p._transformBuffer(t,r);else if(t.bn&&t.network)n=p._transformObject(t);else if(!r&&c.get(t))n.bn=p._getRandomBN(),n.network=c.get(t);else{if("string"!=typeof t)throw new TypeError("First argument is an unrecognized data type.");a.isHexa(t)?n.bn=new s(e.from(t,"hex")):n=p._transformWIF(t,r)}return n},p._getRandomBN=function(){var t,e;do{var r=h.getRandomBuffer(32);t=(e=s.fromBuffer(r)).lt(u.getN())}while(!t);return e},p._transformBuffer=function(t,e){var r={};if(32===t.length)return p._transformBNBuffer(t,e);if(r.network=c.get(t[0],"privatekey"),!r.network)throw new Error("Invalid network");if(e&&r.network!==c.get(e))throw new TypeError("Private key network mismatch");if(34===t.length&&1===t[33])r.compressed=!0;else{if(33!==t.length)throw new Error("Length of buffer must be 33 (uncompressed) or 34 (compressed)");r.compressed=!1}return r.bn=s.fromBuffer(t.slice(1,33)),r},p._transformBNBuffer=function(t,e){var r={};return r.network=c.get(e)||c.defaultNetwork,r.bn=s.fromBuffer(t),r.compressed=!1,r},p._transformWIF=function(t,e){return p._transformBuffer(o.decode(t),e)},p.fromBuffer=function(t,e){return new p(t,e)},p.fromHex=function(t,r){return p.fromBuffer(e.from(t,"hex"),r)},p._transformObject=function(t){return{bn:new s(t.bn,"hex"),network:c.get(t.network),compressed:t.compressed}},p.fromString=p.fromWIF=function(t){return d.checkArgument(i.isString(t),"First argument is expected to be a string."),new p(t)},p.fromObject=p.fromJSON=function(t){return d.checkArgument(i.isObject(t),"First argument is expected to be an object."),new p(t)},p.fromRandom=function(t){var e=p._getRandomBN();return new p(e,t)},p.getValidationError=function(t,e){var r;try{new p(t,e)}catch(t){r=t}return r},p.isValid=function(t,e){return!!t&&!p.getValidationError(t,e)},p.prototype.toString=function(){return this.toWIF()},p.prototype.toWIF=function(){var t,r=this.network;return t=this.compressed?e.concat([e.from([r.privatekey]),this.bn.toBuffer({size:32}),e.from([1])]):e.concat([e.from([r.privatekey]),this.bn.toBuffer({size:32})]),o.encode(t)},p.prototype.toBigNumber=function(){return this.bn},p.prototype.toBuffer=function(){return this.bn.toBuffer({size:32})},p.prototype.toHex=function(){return this.toBuffer().toString("hex")},p.prototype.toPublicKey=function(){return this._pubkey||(this._pubkey=f.fromPrivateKey(this)),this._pubkey},p.prototype.toAddress=function(t){var e=this.toPublicKey();return n.fromPublicKey(e,t||this.network)},p.prototype.toObject=p.prototype.toJSON=function(){return{bn:this.bn.toString("hex"),compressed:this.compressed,network:this.network.toString()}},p.prototype.inspect=function(){var t=this.compressed?"":", uncompressed";return"<PrivateKey: "+this.toHex()+", network: "+this.network+t+">"},t.exports=p}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(1),n=r(54),o=r(0),s="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".split(""),a=function t(r){if(!(this instanceof t))return new t(r);if(e.isBuffer(r)){var i=r;this.fromBuffer(i)}else if("string"==typeof r){var n=r;this.fromString(n)}};a.validCharacters=function(t){return o.Buffer.isBuffer(t)&&(t=t.toString()),i.every(i.map(t,(function(t){return i.includes(s,t)})))},a.prototype.set=function(t){return this.buf=t.buf||this.buf||void 0,this},a.encode=function(t){if(!o.Buffer.isBuffer(t))throw new Error("Input should be a buffer");return n.encode(t)},a.decode=function(t){if("string"!=typeof t)throw new Error("Input should be a string");return e.from(n.decode(t))},a.prototype.fromBuffer=function(t){return this.buf=t,this},a.fromBuffer=function(t){return(new a).fromBuffer(t)},a.fromHex=function(t){return a.fromBuffer(e.from(t,"hex"))},a.prototype.fromString=function(t){var e=a.decode(t);return this.buf=e,this},a.fromString=function(t){return(new a).fromString(t)},a.prototype.toBuffer=function(){return this.buf},a.prototype.toHex=function(){return this.toBuffer().toString("hex")},a.prototype.toString=function(){return a.encode(this.buf)},t.exports=a}).call(this,r(0).Buffer)},function(t,e,r){"use strict";var i=r(132);t.exports=Function.prototype.bind||i},function(t,e,r){t.exports=r(71),t.exports.Input=r(50),t.exports.Output=r(20),t.exports.UnspentOutput=r(72),t.exports.Signature=r(30),t.exports.Sighash=r(19)},function(t,e,r){"use strict";(function(e,i){function n(){}n.getRandomBuffer=function(t){return e.browser?n.getRandomBufferBrowser(t):n.getRandomBufferNode(t)},n.getRandomBufferNode=function(t){return r(15).randomBytes(t)},n.getRandomBufferBrowser=function(t){if(!window.crypto&&!window.msCrypto)throw new Error("window.crypto not available");var e;if(window.crypto&&window.crypto.getRandomValues)e=window.crypto;else{if(!window.msCrypto||!window.msCrypto.getRandomValues)throw new Error("window.crypto.getRandomValues not available");e=window.msCrypto}var r=new Uint8Array(t);return e.getRandomValues(r),i.from(r)},t.exports=n}).call(this,r(24),r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(1),n=r(3),o=r(18),s=r(16),a=r(6),c=r(2),u=function t(e){if(!(this instanceof t))return new t(e);var r=t._from(e);return this.version=r.version,this.prevHash=r.prevHash,this.merkleRoot=r.merkleRoot,this.time=r.time,this.timestamp=r.time,this.bits=r.bits,this.nonce=r.nonce,r.hash&&c.checkState(this.hash===r.hash,"Argument object hash property does not match block hash."),this};u._from=function(t){var r={};if(e.isBuffer(t))r=u._fromBufferReader(o(t));else{if(!i.isObject(t))throw new TypeError("Unrecognized argument for BlockHeader");r=u._fromObject(t)}return r},u._fromObject=function(t){c.checkArgument(t,"data is required");var r=t.prevHash,n=t.merkleRoot;return i.isString(t.prevHash)&&(r=e.from(t.prevHash,"hex").reverse()),i.isString(t.merkleRoot)&&(n=e.from(t.merkleRoot,"hex").reverse()),{hash:t.hash,version:t.version,prevHash:r,merkleRoot:n,time:t.time,timestamp:t.time,bits:t.bits,nonce:t.nonce}},u.fromObject=function(t){var e=u._fromObject(t);return new u(e)},u.fromRawBlock=function(t){e.isBuffer(t)||(t=e.from(t,"binary"));var r=o(t);r.pos=u.Constants.START_OF_HEADER;var i=u._fromBufferReader(r);return new u(i)},u.fromBuffer=function(t){var e=u._fromBufferReader(o(t));return new u(e)},u.fromString=function(t){var r=e.from(t,"hex");return u.fromBuffer(r)},u._fromBufferReader=function(t){var e={};return e.version=t.readInt32LE(),e.prevHash=t.read(32),e.merkleRoot=t.read(32),e.time=t.readUInt32LE(),e.bits=t.readUInt32LE(),e.nonce=t.readUInt32LE(),e},u.fromBufferReader=function(t){var e=u._fromBufferReader(t);return new u(e)},u.prototype.toObject=u.prototype.toJSON=function(){return{hash:this.hash,version:this.version,prevHash:e.from(this.prevHash).reverse().toString("hex"),merkleRoot:e.from(this.merkleRoot).reverse().toString("hex"),time:this.time,bits:this.bits,nonce:this.nonce}},u.prototype.toBuffer=function(){return this.toBufferWriter().concat()},u.prototype.toString=function(){return this.toBuffer().toString("hex")},u.prototype.toBufferWriter=function(t){return t||(t=new s),t.writeInt32LE(this.version),t.write(this.prevHash),t.write(this.merkleRoot),t.writeUInt32LE(this.time),t.writeUInt32LE(this.bits),t.writeUInt32LE(this.nonce),t},u.prototype.getTargetDifficulty=function(t){t=t||this.bits;for(var e=new n(16777215&t),r=8*((t>>>24)-3);r-- >0;)e=e.mul(new n(2));return e},u.prototype.getDifficulty=function(){var t=this.getTargetDifficulty(486604799).mul(new n(Math.pow(10,8))),e=this.getTargetDifficulty(),r=t.div(e).toString(10),i=r.length-8;return r=r.slice(0,i)+"."+r.slice(i),parseFloat(r)},u.prototype._getHash=function(){var t=this.toBuffer();return a.sha256sha256(t)};var f={configurable:!1,enumerable:!0,get:function(){return this._id||(this._id=o(this._getHash()).readReverse().toString("hex")),this._id},set:i.noop};Object.defineProperty(u.prototype,"id",f),Object.defineProperty(u.prototype,"hash",f),u.prototype.validTimestamp=function(){var t=Math.round((new Date).getTime()/1e3);return!(this.time>t+u.Constants.MAX_TIME_OFFSET)},u.prototype.validProofOfWork=function(){var t=new n(this.id,"hex"),e=this.getTargetDifficulty();return!(t.cmp(e)>0)},u.prototype.inspect=function(){return"<BlockHeader "+this.id+">"},u.Constants={START_OF_HEADER:8,MAX_TIME_OFFSET:7200,LARGEST_HASH:new n("10000000000000000000000000000000000000000000000000000000000000000","hex")},t.exports=u}).call(this,r(0).Buffer)},function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e,r){"use strict";var i=e;i.version=r(84).version,i.utils=r(8),i.rand=r(56),i.curve=r(57),i.curves=r(43),i.ec=r(96),i.eddsa=r(100)},function(t,e){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},function(t,e,r){"use strict";var i,n=e,o=r(33),s=r(57),a=r(8).assert;function c(t){"short"===t.type?this.curve=new s.short(t):"edwards"===t.type?this.curve=new s.edwards(t):this.curve=new s.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,a(this.g.validate(),"Invalid curve"),a(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function u(t,e){Object.defineProperty(n,t,{configurable:!0,enumerable:!0,get:function(){var r=new c(e);return Object.defineProperty(n,t,{configurable:!0,enumerable:!0,value:r}),r}})}n.PresetCurve=c,u("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),u("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),u("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),u("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),u("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),u("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),u("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{i=r(95)}catch(t){i=void 0}u("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",i]})},function(t,e,r){"use strict";(function(e){var i=r(3),n=r(11),o=r(4),s=r(14),a=r(38),c=r(6),u=r(1),f=r(2),h=function t(e){if(!(this instanceof t))return new t(e);e&&this.set(e)};h.prototype.set=function(t){if(this.hashbuf=t.hashbuf||this.hashbuf,this.endian=t.endian||this.endian,this.privkey=t.privkey||this.privkey,this.pubkey=t.pubkey||(this.privkey?this.privkey.publicKey:this.pubkey),t.sig)if(e.isBuffer(t.sig)){var i=r(4);this.sig=i.fromDER(t.sig)}else this.sig=t.sig;else this.sig=this.sig;return this.k=t.k||this.k,this.verified=t.verified||this.verified,this},h.prototype.privkey2pubkey=function(){this.pubkey=this.privkey.toPublicKey()},h.prototype.calci=function(){for(var t=0;t<4;t++){var e;this.sig.i=t;try{e=this.toPublicKey()}catch(t){console.error(t);continue}if(e.point.eq(this.pubkey.point))return this.sig.compressed=this.pubkey.compressed,this}throw this.sig.i=void 0,new Error("Unable to find valid recovery factor")},h.fromString=function(t){var e=JSON.parse(t);return new h(e)},h.prototype.randomK=function(){var t,e=n.getN();do{t=i.fromBuffer(a.getRandomBuffer(32))}while(!t.lt(e)||!t.gt(i.Zero));return this.k=t,this},h.prototype.deterministicK=function(t){u.isUndefined(t)&&(t=0);var r=e.alloc(32);r.fill(1);var o=e.alloc(32);o.fill(0);var s=this.privkey.bn.toBuffer({size:32}),a="little"===this.endian?e.from(this.hashbuf).reverse():this.hashbuf;o=c.sha256hmac(e.concat([r,e.from([0]),s,a]),o),r=c.sha256hmac(r,o),o=c.sha256hmac(e.concat([r,e.from([1]),s,a]),o),r=c.sha256hmac(r,o),r=c.sha256hmac(r,o);for(var f=i.fromBuffer(r),h=n.getN(),d=0;d<t||!f.lt(h)||!f.gt(i.Zero);d++)o=c.sha256hmac(e.concat([r,e.from([0])]),o),r=c.sha256hmac(r,o),r=c.sha256hmac(r,o),f=i.fromBuffer(r);return this.k=f,this},h.prototype.toPublicKey=function(){var t=this.sig.i;f.checkArgument(0===t||1===t||2===t||3===t,new Error("i must be equal to 0, 1, 2, or 3"));var e=i.fromBuffer(this.hashbuf),r=this.sig.r,o=this.sig.s,a=1&t,c=t>>1,u=n.getN(),h=n.getG(),d=c?r.add(u):r,p=n.fromX(a,d);if(!p.mul(u).isInfinity())throw new Error("nR is not a valid curve point");var l=e.neg().umod(u),g=r.invm(u),m=p.mul(o).add(h.mul(l)).mul(g);return s.fromPoint(m,this.sig.compressed)},h.prototype.sigError=function(){if(!e.isBuffer(this.hashbuf)||32!==this.hashbuf.length)return"hashbuf must be a 32 byte buffer";var t=this.sig.r,r=this.sig.s,o=n.getN();try{if(t.isZero()||r.isZero()||t.gte(o)||r.gte(o))return"r and s not in range";var s=o.shrn(1),a=r.gt(s)?o.sub(r):r,c=i.fromBuffer(this.hashbuf,this.endian?{endian:this.endian}:void 0),u=a.invm(o),f=u.mul(c).umod(o),h=u.mul(t).umod(o),d=n.getG().mulAdd(f,this.pubkey.point,h);if(d.isInfinity())return"p is infinity";if(0!==d.getX().umod(o).cmp(t)){if(r.lte(s))if(f=(u=o.sub(r).invm(o)).mul(c).umod(o),h=u.mul(t).umod(o),!(d=n.getG().mulAdd(f,this.pubkey.point,h)).isInfinity()&&0===d.getX().umod(o).cmp(t))return!1;return"Invalid signature"}return!1}catch(t){return"Signature security validation failed: "+t.message}},h.toLowS=function(t){return t.gt(i.fromBuffer(e.from("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))&&(t=n.getN().sub(t)),t},h.prototype._findSignature=function(t,e){var r,o,s,a=n.getN(),c=n.getG(),u=0;do{(!this.k||u>0)&&this.deterministicK(u),u++,r=this.k,o=c.mul(r).x.umod(a),s=r.invm(a).mul(e.add(t.mul(o))).umod(a)}while(o.cmp(i.Zero)<=0||s.cmp(i.Zero)<=0);return{s:s=h.toLowS(s),r:o}},h.prototype.sign=function(){var t=this.hashbuf,r=this.privkey,n=r.bn;f.checkState(t&&r&&n,new Error("invalid parameters")),f.checkState(e.isBuffer(t)&&32===t.length,new Error("hashbuf must be a 32 byte buffer"));var s=i.fromBuffer(t,this.endian?{endian:this.endian}:void 0),a=this._findSignature(n,s);return a.compressed=this.pubkey.compressed,this.sig=new o(a),this},h.prototype.signRandomK=function(){return this.randomK(),this.sign()},h.prototype.toString=function(){var t={};return this.hashbuf&&(t.hashbuf=this.hashbuf.toString("hex")),this.privkey&&(t.privkey=this.privkey.toString()),this.pubkey&&(t.pubkey=this.pubkey.toString()),this.sig&&(t.sig=this.sig.toString()),this.k&&(t.k=this.k.toString()),JSON.stringify(t)},h.prototype.verify=function(){return this.sigError()?this.verified=!1:this.verified=!0,this},h.sign=function(t,e,r){return h().set({hashbuf:t,endian:r,privkey:e}).sign().sig},h.signWithCalcI=function(t,e,r){return h().set({hashbuf:t,endian:r,privkey:e}).sign().calci().sig},h.signRandomK=function(t,e,r){return h().set({hashbuf:t,endian:r,privkey:e}).signRandomK().sig},h.verify=function(t,e,r,i){return h().set({hashbuf:t,endian:i,sig:e,pubkey:r}).verify().verified},t.exports=h}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(107)();
8
+ var n=r(79),i=r(80),o=r(81);function s(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(s()<e)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=c.prototype:(null===t&&(t=new c(e)),t.length=e),t}function c(t,e,r){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(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 h(this,t)}return u(this,t,e,r)}function u(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n);c.TYPED_ARRAY_SUPPORT?(t=e).__proto__=c.prototype:t=d(t,e);return t}(t,e,r,n):"string"==typeof e?function(t,e,r){"string"==typeof r&&""!==r||(r="utf8");if(!c.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|l(e,r),i=(t=a(t,n)).write(e,r);i!==n&&(t=t.slice(0,i));return t}(t,e,r):function(t,e){if(c.isBuffer(e)){var r=0|p(e.length);return 0===(t=a(t,r)).length||e.copy(t,0,0,r),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(n=e.length)!=n?a(t,0):d(t,e);if("Buffer"===e.type&&o(e.data))return d(t,e.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function f(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function h(t,e){if(f(e),t=a(t,e<0?0:0|p(e)),!c.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function d(t,e){var r=e.length<0?0:0|p(e.length);t=a(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function p(t){if(t>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|t}function l(t,e){if(c.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))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 D(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return K(t).length;default:if(n)return D(t).length;e=(""+e).toLowerCase(),n=!0}}function g(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 A(this,e,r);case"ascii":return E(this,e,r);case"latin1":case"binary":return k(this,e,r);case"base64":return P(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function b(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(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=c.from(e,n)),c.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,i);if("number"==typeof e)return e&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,i){var o,s=1,a=t.length,c=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,c/=2,r/=2}function u(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){var f=-1;for(o=r;o<a;o++)if(u(t,o)===u(e,-1===f?0:o-f)){if(-1===f&&(f=o),o-f+1===c)return f*s}else-1!==f&&(o-=o-f),f=-1}else for(r+c>a&&(r=a-c),o=r;o>=0;o--){for(var h=!0,d=0;d<c;d++)if(u(t,o+d)!==u(e,d)){h=!1;break}if(h)return o}return-1}function v(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s<n;++s){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))return s;t[r+s]=a}return s}function S(t,e,r,n){return z(D(e,t.length-r),t,r,n)}function _(t,e,r,n){return z(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,n){return _(t,e,r,n)}function I(t,e,r,n){return z(K(e),t,r,n)}function O(t,e,r,n){return z(function(t,e){for(var r,n,i,o=[],s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function P(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function A(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i<r;){var o,s,a,c,u=t[i],f=null,h=u>239?4:u>223?3:u>191?2:1;if(i+h<=r)switch(h){case 1:u<128&&(f=u);break;case 2:128==(192&(o=t[i+1]))&&(c=(31&u)<<6|63&o)>127&&(f=c);break;case 3:o=t[i+1],s=t[i+2],128==(192&o)&&128==(192&s)&&(c=(15&u)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(f=c);break;case 4:o=t[i+1],s=t[i+2],a=t[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(f=c)}null===f?(f=65533,h=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=h}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);var r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=4096));return r}(n)}e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=s(),c.poolSize=8192,c._augment=function(t){return t.__proto__=c.prototype,t},c.from=function(t,e,r){return u(null,t,e,r)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(t,e,r){return function(t,e,r,n){return f(e),e<=0?a(t,e):void 0!==r?"string"==typeof n?a(t,e).fill(r,n):a(t,e).fill(r):a(t,e)}(null,t,e,r)},c.allocUnsafe=function(t){return h(null,t)},c.allocUnsafeSlow=function(t){return h(null,t)},c.isBuffer=function(t){return!(null==t||!t._isBuffer)},c.compare=function(t,e){if(!c.isBuffer(t)||!c.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},c.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}},c.concat=function(t,e){if(!o(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return c.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=c.allocUnsafe(e),i=0;for(r=0;r<t.length;++r){var s=t[r];if(!c.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,i),i+=s.length}return n},c.byteLength=l,c.prototype._isBuffer=!0,c.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)m(this,e,e+1);return this},c.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)m(this,e,e+3),m(this,e+1,e+2);return this},c.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)m(this,e,e+7),m(this,e+1,e+6),m(this,e+2,e+5),m(this,e+3,e+4);return this},c.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?A(this,0,t):g.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},c.prototype.compare=function(t,e,r,n,i){if(!c.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(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),a=Math.min(o,s),u=this.slice(n,i),f=t.slice(e,r),h=0;h<a;++h)if(u[h]!==f[h]){o=u[h],s=f[h];break}return o<s?-1:s<o?1:0},c.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},c.prototype.indexOf=function(t,e,r){return b(this,t,e,r,!0)},c.prototype.lastIndexOf=function(t,e,r){return b(this,t,e,r,!1)},c.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||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return S(this,t,e,r);case"ascii":return _(this,t,e,r);case"latin1":case"binary":return w(this,t,e,r);case"base64":return I(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function E(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 k(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||r>n)&&(r=n);for(var i="",o=e;o<r;++o)i+=F(t[o]);return i}function T(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 R(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function M(t,e,r,n,i,o){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function N(t,e,r,n){e<0&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-r,2);i<o;++i)t[r+i]=(e&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function B(t,e,r,n){e<0&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-r,4);i<o;++i)t[r+i]=e>>>8*(n?i:3-i)&255}function C(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function H(t,e,r,n,o){return o||C(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function U(t,e,r,n,o){return o||C(t,0,r,8),i.write(t,e,r,n,52,8),r+8}c.prototype.slice=function(t,e){var r,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t),c.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=c.prototype;else{var i=e-t;r=new c(i,void 0);for(var o=0;o<i;++o)r[o]=this[o+t]}return r},c.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||R(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return n},c.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||R(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},c.prototype.readUInt8=function(t,e){return e||R(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,e){return e||R(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,e){return e||R(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,e){return e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,e){return e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||R(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*e)),n},c.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||R(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},c.prototype.readInt8=function(t,e){return e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){e||R(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(t,e){e||R(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(t,e){return e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,e){return e||R(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return e||R(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return e||R(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return e||R(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||M(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},c.prototype.writeUIntBE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||M(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},c.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||M(this,t,e,1,255,0),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},c.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||M(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},c.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||M(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},c.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||M(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):B(this,t,e,!0),e+4},c.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||M(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):B(this,t,e,!1),e+4},c.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);M(this,t,e,r,i-1,-i)}var o=0,s=1,a=0;for(this[e]=255&t;++o<r&&(s*=256);)t<0&&0===a&&0!==this[e+o-1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r},c.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);M(this,t,e,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r},c.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||M(this,t,e,1,127,-128),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||M(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},c.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||M(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},c.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||M(this,t,e,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):B(this,t,e,!0),e+4},c.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||M(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):B(this,t,e,!1),e+4},c.prototype.writeFloatLE=function(t,e,r){return H(this,t,e,!0,r)},c.prototype.writeFloatBE=function(t,e,r){return H(this,t,e,!1,r)},c.prototype.writeDoubleLE=function(t,e,r){return U(this,t,e,!0,r)},c.prototype.writeDoubleBE=function(t,e,r){return U(this,t,e,!1,r)},c.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&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("sourceStart out of bounds");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,o=n-r;if(this===t&&r<e&&e<n)for(i=o-1;i>=0;--i)t[i+e]=this[i+r];else if(o<1e3||!c.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+o),e);return o},c.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),1===t.length){var i=t.charCodeAt(0);i<256&&(t=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!c.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}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 s=c.isBuffer(t)?t:D(new c(t,n).toString()),a=s.length;for(o=0;o<r-e;++o)this[o+e]=s[o%a]}return this};var L=/[^+\/0-9A-Za-z-_]/g;function F(t){return t<16?"0"+t.toString(16):t.toString(16)}function D(t,e){var r;e=e||1/0;for(var n=t.length,i=null,o=[],s=0;s<n;++s){if((r=t.charCodeAt(s))>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function K(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(L,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function z(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}}).call(this,r(40))},function(t,e,r){"use strict";var n={isArray:t=>Array.isArray(t),isNumber:t=>"number"==typeof t,isObject:t=>t&&"object"==typeof t,isString:t=>"string"==typeof t,isUndefined:t=>void 0===t,isFunction:t=>"function"==typeof t,isNull:t=>null===t,isDate:t=>t instanceof Date,extend:(t,e)=>Object.assign(t,e),noop:()=>{},every:(t,e)=>t.every(e||(t=>t)),map:(t,e)=>Array.from(t).map(e||(t=>t)),includes:(t,e)=>t.includes(e),each:(t,e)=>t.forEach(e),clone:t=>Object.assign({},t),pick:(t,e)=>{const r={};return e.forEach(e=>{void 0!==t[e]&&(r[e]=t[e])}),r},values:t=>Object.values(t),filter:(t,e)=>t.filter(e),reduce:(t,e,r)=>t.reduce(e,r),without:(t,e)=>t.filter(t=>t!==e),shuffle:t=>{const e=t.slice(0);for(let t=e.length-1;t>0;t--){const r=Math.floor(Math.random()*(t+1));[e[t],e[r]]=[e[r],e[t]]}return e},difference:(t,e)=>t.filter(t=>!e.includes(t)),findIndex:(t,e)=>t.findIndex(e),some:(t,e)=>t.some(e),range:t=>[...Array(t).keys()]};t.exports=n},function(t,e,r){"use strict";var n=r(10),i=r(1);t.exports={checkState:function(t,e){if(!t)throw new n.InvalidState(e)},checkArgument:function(t,e,r,i){if(!t)throw new n.InvalidArgument(e,r,i)},checkArgumentType:function(t,e,o){if(o=o||"(unknown name)",i.isString(e)){if("Buffer"===e){if(!r(0).Buffer.isBuffer(t))throw new n.InvalidArgumentType(t,e,o)}else if(typeof t!==e)throw new n.InvalidArgumentType(t,e,o)}else if(!(t instanceof e))throw new n.InvalidArgumentType(t,e.name,o)}}},function(t,e,r){"use strict";(function(e){var n=r(9),i=r(2),o=r(1),s=function(t){for(var r=e.alloc(t.length),n=0;n<t.length;n++)r[n]=t[t.length-1-n];return r};n.Zero=new n(0),n.One=new n(1),n.Minus1=new n(-1),n.fromNumber=function(t){return i.checkArgument(o.isNumber(t)),new n(t)},n.fromString=function(t,e){return i.checkArgument(o.isString(t)),new n(t,e)},n.fromBuffer=function(t,e){void 0!==e&&"little"===e.endian&&(t=s(t));var r=t.toString("hex");return new n(r,16)},n.fromSM=function(t,r){var i;if(0===t.length)return n.fromBuffer(e.from([0]));var o="big";return r&&(o=r.endian),"little"===o&&(t=s(t)),128&t[0]?(t[0]=127&t[0],(i=n.fromBuffer(t)).neg().copy(i)):i=n.fromBuffer(t),i},n.prototype.toNumber=function(){return parseInt(this.toString(10),10)},n.prototype.toBuffer=function(t){var r,i;if(t&&t.size){var o=(i=this.toString(16,2)).length/2;r=e.from(i,"hex"),o===t.size||(o>t.size?r=n.trim(r,o):o<t.size&&(r=n.pad(r,o,t.size)))}else i=this.toString(16,2),r=e.from(i,"hex");return void 0!==t&&"little"===t.endian&&(r=s(r)),r},n.prototype.toSMBigEndian=function(){var t;return-1===this.cmp(n.Zero)?128&(t=this.neg().toBuffer())[0]?t=e.concat([e.from([128]),t]):t[0]=128|t[0]:128&(t=this.toBuffer())[0]&&(t=e.concat([e.from([0]),t])),1===t.length&0===t[0]&&(t=e.from([])),t},n.prototype.toSM=function(t){var e=t?t.endian:"big",r=this.toSMBigEndian();return"little"===e&&(r=s(r)),r},n.fromScriptNumBuffer=function(t,e,r){var o=r||4;if(i.checkArgument(t.length<=o,new Error("script number overflow")),e&&t.length>0&&0==(127&t[t.length-1])&&(t.length<=1||0==(128&t[t.length-2])))throw new Error("non-minimally encoded script number");return n.fromSM(t,{endian:"little"})},n.prototype.toScriptNumBuffer=function(){return this.toSM({endian:"little"})},n.trim=function(t,e){return t.slice(e-t.length,t.length)},n.pad=function(t,r,n){for(var i=e.alloc(n),o=0;o<t.length;o++)i[i.length-1-o]=t[t.length-1-o];for(o=0;o<n-r;o++)i[o]=0;return i},n.prototype.toHex=function(...t){return this.toBuffer(...t).toString("hex")},n.fromHex=function(t,...r){return n.fromBuffer(e.from(t,"hex"),...r)},t.exports=n}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e,n){var i=t.exports;i.deps=i.deps||{};try{i.deps.bnjs=r(9),i.deps.bs58=r(54),i.deps.Buffer=void 0!==e?e:null,i.deps.elliptic=r(41),i.deps._=r(1)}catch(t){console.warn("Some dependencies may not be available in browser environment:",t.message)}if(i.version="v"+r(104).version,i.versionGuard=function(t){if(void 0!==t){console.warn("\n More than one instance of bsv found.\n Please make sure to require bsv and check that submodules do\n not also include their own bsv dependency.")}},i.versionGuard(n._bsv),n._bsv=i.version,i.isHardened=!0,i.hardenedBy="SmartLedger",i.baseVersion="v1.5.6",i.securityFeatures=["canonical-signatures","malleability-protection","enhanced-validation","elliptic-patches"],i.crypto={},i.crypto.BN=r(3),i.crypto.ECDSA=r(44),i.crypto.Hash=r(7),i.crypto.Random=r(38),i.crypto.Point=r(11),i.crypto.Signature=r(5),i.crypto.SmartVerify=r(51),i.crypto.EllipticFixed=r(52),i.encoding={},i.encoding.Base58=r(35),i.encoding.Base58Check=r(28),i.encoding.BufferReader=r(19),i.encoding.BufferWriter=r(16),i.encoding.Varint=r(29),i.util={},i.util.js=r(6),i.util.preconditions=r(2),i.errors=r(10),i.Address=r(26),i.Block=r(146),i.MerkleBlock=r(74),i.BlockHeader=r(39),i.HDPrivateKey=r(75),i.HDPublicKey=r(76),i.Networks=r(24),i.Opcode=r(48),i.PrivateKey=r(34),i.PublicKey=r(14),i.Script=r(12),i.Transaction=r(37),i.Message=r(148),i.Signature=r(5),i.SmartLedger={version:i.version,hardenedBy:i.hardenedBy,baseVersion:i.baseVersion,securityFeatures:i.securityFeatures,SmartVerify:r(51),EllipticFixed:r(52)},i.SmartVerify=r(51),i.EllipticFixed=r(52),"undefined"==typeof window)try{i.SmartUTXO=r(150),i.SmartMiner=r(152),i.CustomScriptHelper=r(153),i.SmartContract=r(154)}catch(t){}i.Transaction.sighash=r(20)}).call(this,r(0).Buffer,r(40))},function(t,e,r){"use strict";(function(e){var n=r(3),i=r(1),o=r(2),s=r(6),a=function t(e,r){if(!(this instanceof t))return new t(e,r);if(e instanceof n)this.set({r:e,s:r});else if(e){var i=e;this.set(i)}};a.prototype.set=function(t){return this.r=t.r||this.r||void 0,this.s=t.s||this.s||void 0,this.i=void 0!==t.i?t.i:this.i,this.compressed=void 0!==t.compressed?t.compressed:this.compressed,this.nhashtype=t.nhashtype||this.nhashtype||void 0,this},a.fromCompact=function(t){o.checkArgument(e.isBuffer(t),"Argument is expected to be a Buffer");var r=new a,i=!0,s=t.slice(0,1)[0]-27-4;s<0&&(i=!1,s+=4);var c=t.slice(1,33),u=t.slice(33,65);return o.checkArgument(0===s||1===s||2===s||3===s,new Error("i must be 0, 1, 2, or 3")),o.checkArgument(32===c.length,new Error("r must be 32 bytes")),o.checkArgument(32===u.length,new Error("s must be 32 bytes")),r.compressed=i,r.i=s,r.r=n.fromBuffer(c),r.s=n.fromBuffer(u),r},a.fromDER=a.fromBuffer=function(t,e){var r=a.parseDER(t,e),n=new a;return n.r=r.r,n.s=r.s,n},a.fromTxFormat=function(t){var e=t.readUInt8(t.length-1),r=t.slice(0,t.length-1),n=a.fromDER(r,!1);return n.nhashtype=e,n},a.fromString=function(t){var r=e.from(t,"hex");return a.fromDER(r)},a.parseDER=function(t,r){o.checkArgument(e.isBuffer(t),new Error("DER formatted signature should be a buffer")),i.isUndefined(r)&&(r=!0);var s=t[0];o.checkArgument(48===s,new Error("Header byte should be 0x30"));var a=t[1],c=t.slice(2).length;o.checkArgument(!r||a===c,new Error("Length byte should length of what follows")),a=a<c?a:c;var u=t[2];o.checkArgument(2===u,new Error("Integer byte for r should be 0x02"));var f=t[3],h=t.slice(4,4+f),d=n.fromBuffer(h),p=0===t[4];o.checkArgument(f===h.length,new Error("Length of r incorrect"));var l=t[4+f+0];o.checkArgument(2===l,new Error("Integer byte for s should be 0x02"));var g=t[4+f+1],m=t.slice(4+f+2,4+f+2+g),b=n.fromBuffer(m),y=0===t[4+f+2+2];o.checkArgument(g===m.length,new Error("Length of s incorrect"));var v=4+f+2+g;return o.checkArgument(a===v-2,new Error("Length of signature incorrect")),{header:s,length:a,rheader:u,rlength:f,rneg:p,rbuf:h,r:d,sheader:l,slength:g,sneg:y,sbuf:m,s:b}},a.prototype.toCompact=function(t,r){if(t="number"==typeof t?t:this.i,r="boolean"==typeof r?r:this.compressed,0!==t&&1!==t&&2!==t&&3!==t)throw new Error("i must be equal to 0, 1, 2, or 3");var n=t+27+4;!1===r&&(n-=4);var i=e.from([n]),o=this.r.toBuffer({size:32}),s=this.s.toBuffer({size:32});return e.concat([i,o,s])},a.prototype.toBuffer=a.prototype.toDER=function(){var t=this.r.toBuffer(),r=this.s.toBuffer(),n=!!(128&t[0]),i=!!(128&r[0]),o=n?e.concat([e.from([0]),t]):t,s=i?e.concat([e.from([0]),r]):r,a=o.length,c=s.length,u=2+a+2+c;return e.concat([e.from([48,u,2,a]),o,e.from([2,c]),s])},a.prototype.toString=function(){return this.toDER().toString("hex")},a.isTxDER=function(t){if(t.length<9)return!1;if(t.length>73)return!1;if(48!==t[0])return!1;if(t[1]!==t.length-3)return!1;var e=t[3];if(5+e>=t.length)return!1;var r=t[5+e];if(e+r+7!==t.length)return!1;var n=t.slice(4);if(2!==t[2])return!1;if(0===e)return!1;if(128&n[0])return!1;if(e>1&&0===n[0]&&!(128&n[1]))return!1;var i=t.slice(6+e);return 2===t[6+e-2]&&(0!==r&&(!(128&i[0])&&!(r>1&&0===i[0]&&!(128&i[1]))))},a.prototype.hasLowS=function(){return!this.s.lt(new n(1))&&!this.s.gt(new n("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex"))},a.prototype.hasDefinedHashtype=function(){if(!s.isNaturalNumber(this.nhashtype))return!1;var t=31&this.nhashtype;return!(t<a.SIGHASH_ALL||t>a.SIGHASH_SINGLE)},a.prototype.toTxFormat=function(){var t=this.toDER(),r=e.alloc(1);return r.writeUInt8(this.nhashtype,0),e.concat([t,r])},a.SIGHASH_ALL=1,a.SIGHASH_NONE=2,a.SIGHASH_SINGLE=3,a.SIGHASH_FORKID=64,a.SIGHASH_ANYONECANPAY=128,a.prototype.isCanonical=function(){var t=r(11).getN().shrn(1);return this.s.lte(t)},a.prototype.toCanonical=function(){if(this.isCanonical())return new a({r:this.r,s:this.s,i:this.i,compressed:this.compressed,nhashtype:this.nhashtype});var t=r(11).getN().sub(this.s);return new a({r:this.r,s:t,i:this.i,compressed:this.compressed,nhashtype:this.nhashtype})},a.prototype.validate=function(){if(!this.r||!this.s)throw new Error("Signature missing r or s component");if(this.r.isZero())throw new Error("Signature r component is zero");if(this.s.isZero())throw new Error("Signature s component is zero");var t=r(11).getN();if(this.r.gte(t))throw new Error("Signature r component >= curve order");if(this.s.gte(t))throw new Error("Signature s component >= curve order");if(this.r.isNeg())throw new Error("Signature r component is negative");if(this.s.isNeg())throw new Error("Signature s component is negative");return!0},a.prototype.isValid=function(){try{return this.validate(),!0}catch(t){return!1}},a.prototype.applySecurityPatches=function(){var t=r(11).getN(),e=t.shrn(1);if(this.r.isZero()||this.s.isZero())throw new Error("Invalid signature: zero r or s");if(this.r.gte(t)||this.s.gte(t))throw new Error("Invalid signature: out of range");return this.s.gt(e)&&(this.s=t.sub(this.s)),this},t.exports=a}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var n=r(1),i=r(2),o=function(t){return!!n.isString(t)&&/^[0-9a-fA-F]+$/.test(t)};t.exports={isValidJSON:function(t){var e;if(!n.isString(t))return!1;try{e=JSON.parse(t)}catch(t){return!1}return"object"==typeof e},isHexa:o,isHexaString:o,defineImmutable:function(t,e){return Object.keys(e).forEach((function(r){Object.defineProperty(t,r,{configurable:!1,enumerable:!0,value:e[r]})})),t},isNaturalNumber:function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t&&t>=0},integerAsBuffer:function(t){i.checkArgumentType(t,"number","integer");const r=e.allocUnsafe(4);return r.writeUInt32BE(t,0),r}}}).call(this,r(0).Buffer)},function(t,e,r){(function(e){e.browser?t.exports=r(106):t.exports=r(107)}).call(this,r(18))},function(t,e,r){"use strict";var n=e,i=r(9),o=r(22),s=r(55);n.assert=o,n.toArray=s.toArray,n.zero2=s.zero2,n.toHex=s.toHex,n.encode=s.encode,n.getNAF=function(t,e,r){var n,i=new Array(Math.max(t.bitLength(),r)+1);for(n=0;n<i.length;n+=1)i[n]=0;var o=1<<e+1,s=t.clone();for(n=0;n<i.length;n++){var a,c=s.andln(o-1);s.isOdd()?(a=c>(o>>1)-1?(o>>1)-c:c,s.isubn(a)):a=0,i[n]=a,s.iushrn(1)}return i},n.getJSF=function(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var n,i=0,o=0;t.cmpn(-i)>0||e.cmpn(-o)>0;){var s,a,c=t.andln(3)+i&3,u=e.andln(3)+o&3;3===c&&(c=-1),3===u&&(u=-1),s=0==(1&c)?0:3!==(n=t.andln(7)+i&7)&&5!==n||2!==u?c:-c,r[0].push(s),a=0==(1&u)?0:3!==(n=e.andln(7)+o&7)&&5!==n||2!==c?u:-u,r[1].push(a),2*i===s+1&&(i=1-i),2*o===a+1&&(o=1-o),t.iushrn(1),e.iushrn(1)}return r},n.cachedProperty=function(t,e,r){var n="_"+e;t.prototype[e]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(t){return"string"==typeof t?n.toArray(t,"hex"):t},n.intFromLE=function(t){return new i(t,"hex","le")}},function(t,e,r){(function(t){!function(t,e){"use strict";function n(t,e){if(!t)throw new Error(e||"Assertion failed")}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function o(t,e,r){if(o.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var s;"object"==typeof t?t.exports=o:e.BN=o,o.BN=o,o.wordSize=26;try{s=r(82).Buffer}catch(t){}function a(t,e,r){for(var n=0,i=Math.min(t.length,r),o=e;o<i;o++){var s=t.charCodeAt(o)-48;n<<=4,n|=s>=49&&s<=54?s-49+10:s>=17&&s<=22?s-17+10:15&s}return n}function c(t,e,r,n){for(var i=0,o=Math.min(t.length,r),s=e;s<o;s++){var a=t.charCodeAt(s)-48;i*=n,i+=a>=49?a-49+10:a>=17?a-17+10:a}return i}o.isBN=function(t){return t instanceof o||null!==t&&"object"==typeof t&&t.constructor.wordSize===o.wordSize&&Array.isArray(t.words)},o.max=function(t,e){return t.cmp(e)>0?t:e},o.min=function(t,e){return t.cmp(e)<0?t:e},o.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),n(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&i++,16===e?this._parseHex(t,i):this._parseBase(t,e,i),"-"===t[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),e,r)},o.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(n(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},o.prototype._initArray=function(t,e,r){if(n("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var o,s,a=0;if("be"===r)for(i=t.length-1,o=0;i>=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(i=0,o=0;i<t.length;i+=3)s=t[i]|t[i+1]<<8|t[i+2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},o.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var n,i,o=0;for(r=t.length-6,n=0;r>=e;r-=6)i=a(t,r,r+6),this.words[n]|=i<<o&67108863,this.words[n+1]|=i>>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==e&&(i=a(t,e,r+6),this.words[n]|=i<<o&67108863,this.words[n+1]|=i>>>26-o&4194303),this.strip()},o.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var o=t.length-r,s=o%n,a=Math.min(o,o-s)+r,u=0,f=r;f<a;f+=n)u=c(t,f,f+n,e),this.imuln(i),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==s){var h=1;for(u=c(t,f,t.length,e),f=0;f<s;f++)h*=e;this.imuln(h),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}},o.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},o.prototype.clone=function(){var t=new o(null);return this.copy(t),t},o.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},o.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],f=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function d(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],o=0|e.words[0],s=i*o,a=67108863&s,c=s/67108864|0;r.words[0]=a;for(var u=1;u<n;u++){for(var f=c>>>26,h=67108863&c,d=Math.min(u,e.length-1),p=Math.max(0,u-t.length+1);p<=d;p++){var l=u-p|0;f+=(s=(i=0|t.words[l])*(o=0|e.words[p])+h)/67108864|0,h=67108863&s}r.words[u]=0|h,c=0|f}return 0!==c?r.words[u]=0|c:r.length--,r.strip()}o.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var i=0,o=0,s=0;s<this.length;s++){var a=this.words[s],c=(16777215&(a<<i|o)).toString(16);r=0!==(o=a>>>24-i&16777215)||s!==this.length-1?u[6-c.length]+c+r:c+r,(i+=2)>=26&&(i-=26,s--)}for(0!==o&&(r=o.toString(16)+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var d=f[t],p=h[t];r="";var l=this.clone();for(l.negative=0;!l.isZero();){var g=l.modn(p).toString(t);r=(l=l.idivn(p)).isZero()?g+r:u[d-g.length]+g+r}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(t,e){return n(void 0!==s),this.toArrayLike(s,t,e)},o.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},o.prototype.toArrayLike=function(t,e,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var s,a,c="le"===e,u=new t(o),f=this.clone();if(c){for(a=0;!f.isZero();a++)s=f.andln(255),f.iushrn(8),u[a]=s;for(;a<o;a++)u[a]=0}else{for(a=0;a<o-i;a++)u[a]=0;for(a=0;!f.isZero();a++)s=f.andln(255),f.iushrn(8),u[o-a-1]=s}return u},Math.clz32?o.prototype._countBits=function(t){return 32-Math.clz32(t)}:o.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},o.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},o.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},o.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return 0!==this.negative},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this.strip()},o.prototype.ior=function(t){return n(0==(this.negative|t.negative)),this.iuor(t)},o.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},o.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},o.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this.strip()},o.prototype.iand=function(t){return n(0==(this.negative|t.negative)),this.iuand(t)},o.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},o.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},o.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;n<r.length;n++)this.words[n]=e.words[n]^r.words[n];if(this!==e)for(;n<e.length;n++)this.words[n]=e.words[n];return this.length=e.length,this.strip()},o.prototype.ixor=function(t){return n(0==(this.negative|t.negative)),this.iuxor(t)},o.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},o.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},o.prototype.inotn=function(t){n("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),r>0&&e--;for(var i=0;i<e;i++)this.words[i]=67108863&~this.words[i];return r>0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(t){return this.clone().inotn(t)},o.prototype.setn=function(t,e){n("number"==typeof t&&t>=0);var r=t/26|0,i=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<<i:this.words[r]&~(1<<i),this.strip()},o.prototype.iadd=function(t){var e,r,n;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o<n.length;o++)e=(0|r.words[o])+(0|n.words[o])+i,this.words[o]=67108863&e,i=e>>>26;for(;0!==i&&o<r.length;o++)e=(0|r.words[o])+i,this.words[o]=67108863&e,i=e>>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},o.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},o.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var o=0,s=0;s<n.length;s++)o=(e=(0|r.words[s])-(0|n.words[s])+o)>>26,this.words[s]=67108863&e;for(;0!==o&&s<r.length;s++)o=(e=(0|r.words[s])+o)>>26,this.words[s]=67108863&e;if(0===o&&s<r.length&&r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this.length=Math.max(this.length,s),r!==this&&(this.negative=1),this.strip()},o.prototype.sub=function(t){return this.clone().isub(t)};var p=function(t,e,r){var n,i,o,s=t.words,a=e.words,c=r.words,u=0,f=0|s[0],h=8191&f,d=f>>>13,p=0|s[1],l=8191&p,g=p>>>13,m=0|s[2],b=8191&m,y=m>>>13,v=0|s[3],S=8191&v,_=v>>>13,w=0|s[4],I=8191&w,O=w>>>13,P=0|s[5],A=8191&P,E=P>>>13,k=0|s[6],x=8191&k,T=k>>>13,R=0|s[7],M=8191&R,N=R>>>13,B=0|s[8],C=8191&B,H=B>>>13,U=0|s[9],L=8191&U,F=U>>>13,D=0|a[0],K=8191&D,z=D>>>13,j=0|a[1],V=8191&j,G=j>>>13,q=0|a[2],Y=8191&q,X=q>>>13,W=0|a[3],Z=8191&W,$=W>>>13,Q=0|a[4],J=8191&Q,tt=Q>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ct=8191&at,ut=at>>>13,ft=0|a[8],ht=8191&ft,dt=ft>>>13,pt=0|a[9],lt=8191&pt,gt=pt>>>13;r.negative=t.negative^e.negative,r.length=19;var mt=(u+(n=Math.imul(h,K))|0)+((8191&(i=(i=Math.imul(h,z))+Math.imul(d,K)|0))<<13)|0;u=((o=Math.imul(d,z))+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,n=Math.imul(l,K),i=(i=Math.imul(l,z))+Math.imul(g,K)|0,o=Math.imul(g,z);var bt=(u+(n=n+Math.imul(h,V)|0)|0)+((8191&(i=(i=i+Math.imul(h,G)|0)+Math.imul(d,V)|0))<<13)|0;u=((o=o+Math.imul(d,G)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(b,K),i=(i=Math.imul(b,z))+Math.imul(y,K)|0,o=Math.imul(y,z),n=n+Math.imul(l,V)|0,i=(i=i+Math.imul(l,G)|0)+Math.imul(g,V)|0,o=o+Math.imul(g,G)|0;var yt=(u+(n=n+Math.imul(h,Y)|0)|0)+((8191&(i=(i=i+Math.imul(h,X)|0)+Math.imul(d,Y)|0))<<13)|0;u=((o=o+Math.imul(d,X)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(S,K),i=(i=Math.imul(S,z))+Math.imul(_,K)|0,o=Math.imul(_,z),n=n+Math.imul(b,V)|0,i=(i=i+Math.imul(b,G)|0)+Math.imul(y,V)|0,o=o+Math.imul(y,G)|0,n=n+Math.imul(l,Y)|0,i=(i=i+Math.imul(l,X)|0)+Math.imul(g,Y)|0,o=o+Math.imul(g,X)|0;var vt=(u+(n=n+Math.imul(h,Z)|0)|0)+((8191&(i=(i=i+Math.imul(h,$)|0)+Math.imul(d,Z)|0))<<13)|0;u=((o=o+Math.imul(d,$)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(I,K),i=(i=Math.imul(I,z))+Math.imul(O,K)|0,o=Math.imul(O,z),n=n+Math.imul(S,V)|0,i=(i=i+Math.imul(S,G)|0)+Math.imul(_,V)|0,o=o+Math.imul(_,G)|0,n=n+Math.imul(b,Y)|0,i=(i=i+Math.imul(b,X)|0)+Math.imul(y,Y)|0,o=o+Math.imul(y,X)|0,n=n+Math.imul(l,Z)|0,i=(i=i+Math.imul(l,$)|0)+Math.imul(g,Z)|0,o=o+Math.imul(g,$)|0;var St=(u+(n=n+Math.imul(h,J)|0)|0)+((8191&(i=(i=i+Math.imul(h,tt)|0)+Math.imul(d,J)|0))<<13)|0;u=((o=o+Math.imul(d,tt)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(A,K),i=(i=Math.imul(A,z))+Math.imul(E,K)|0,o=Math.imul(E,z),n=n+Math.imul(I,V)|0,i=(i=i+Math.imul(I,G)|0)+Math.imul(O,V)|0,o=o+Math.imul(O,G)|0,n=n+Math.imul(S,Y)|0,i=(i=i+Math.imul(S,X)|0)+Math.imul(_,Y)|0,o=o+Math.imul(_,X)|0,n=n+Math.imul(b,Z)|0,i=(i=i+Math.imul(b,$)|0)+Math.imul(y,Z)|0,o=o+Math.imul(y,$)|0,n=n+Math.imul(l,J)|0,i=(i=i+Math.imul(l,tt)|0)+Math.imul(g,J)|0,o=o+Math.imul(g,tt)|0;var _t=(u+(n=n+Math.imul(h,rt)|0)|0)+((8191&(i=(i=i+Math.imul(h,nt)|0)+Math.imul(d,rt)|0))<<13)|0;u=((o=o+Math.imul(d,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(x,K),i=(i=Math.imul(x,z))+Math.imul(T,K)|0,o=Math.imul(T,z),n=n+Math.imul(A,V)|0,i=(i=i+Math.imul(A,G)|0)+Math.imul(E,V)|0,o=o+Math.imul(E,G)|0,n=n+Math.imul(I,Y)|0,i=(i=i+Math.imul(I,X)|0)+Math.imul(O,Y)|0,o=o+Math.imul(O,X)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,$)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,$)|0,n=n+Math.imul(b,J)|0,i=(i=i+Math.imul(b,tt)|0)+Math.imul(y,J)|0,o=o+Math.imul(y,tt)|0,n=n+Math.imul(l,rt)|0,i=(i=i+Math.imul(l,nt)|0)+Math.imul(g,rt)|0,o=o+Math.imul(g,nt)|0;var wt=(u+(n=n+Math.imul(h,ot)|0)|0)+((8191&(i=(i=i+Math.imul(h,st)|0)+Math.imul(d,ot)|0))<<13)|0;u=((o=o+Math.imul(d,st)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(M,K),i=(i=Math.imul(M,z))+Math.imul(N,K)|0,o=Math.imul(N,z),n=n+Math.imul(x,V)|0,i=(i=i+Math.imul(x,G)|0)+Math.imul(T,V)|0,o=o+Math.imul(T,G)|0,n=n+Math.imul(A,Y)|0,i=(i=i+Math.imul(A,X)|0)+Math.imul(E,Y)|0,o=o+Math.imul(E,X)|0,n=n+Math.imul(I,Z)|0,i=(i=i+Math.imul(I,$)|0)+Math.imul(O,Z)|0,o=o+Math.imul(O,$)|0,n=n+Math.imul(S,J)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(_,J)|0,o=o+Math.imul(_,tt)|0,n=n+Math.imul(b,rt)|0,i=(i=i+Math.imul(b,nt)|0)+Math.imul(y,rt)|0,o=o+Math.imul(y,nt)|0,n=n+Math.imul(l,ot)|0,i=(i=i+Math.imul(l,st)|0)+Math.imul(g,ot)|0,o=o+Math.imul(g,st)|0;var It=(u+(n=n+Math.imul(h,ct)|0)|0)+((8191&(i=(i=i+Math.imul(h,ut)|0)+Math.imul(d,ct)|0))<<13)|0;u=((o=o+Math.imul(d,ut)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(C,K),i=(i=Math.imul(C,z))+Math.imul(H,K)|0,o=Math.imul(H,z),n=n+Math.imul(M,V)|0,i=(i=i+Math.imul(M,G)|0)+Math.imul(N,V)|0,o=o+Math.imul(N,G)|0,n=n+Math.imul(x,Y)|0,i=(i=i+Math.imul(x,X)|0)+Math.imul(T,Y)|0,o=o+Math.imul(T,X)|0,n=n+Math.imul(A,Z)|0,i=(i=i+Math.imul(A,$)|0)+Math.imul(E,Z)|0,o=o+Math.imul(E,$)|0,n=n+Math.imul(I,J)|0,i=(i=i+Math.imul(I,tt)|0)+Math.imul(O,J)|0,o=o+Math.imul(O,tt)|0,n=n+Math.imul(S,rt)|0,i=(i=i+Math.imul(S,nt)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,nt)|0,n=n+Math.imul(b,ot)|0,i=(i=i+Math.imul(b,st)|0)+Math.imul(y,ot)|0,o=o+Math.imul(y,st)|0,n=n+Math.imul(l,ct)|0,i=(i=i+Math.imul(l,ut)|0)+Math.imul(g,ct)|0,o=o+Math.imul(g,ut)|0;var Ot=(u+(n=n+Math.imul(h,ht)|0)|0)+((8191&(i=(i=i+Math.imul(h,dt)|0)+Math.imul(d,ht)|0))<<13)|0;u=((o=o+Math.imul(d,dt)|0)+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,n=Math.imul(L,K),i=(i=Math.imul(L,z))+Math.imul(F,K)|0,o=Math.imul(F,z),n=n+Math.imul(C,V)|0,i=(i=i+Math.imul(C,G)|0)+Math.imul(H,V)|0,o=o+Math.imul(H,G)|0,n=n+Math.imul(M,Y)|0,i=(i=i+Math.imul(M,X)|0)+Math.imul(N,Y)|0,o=o+Math.imul(N,X)|0,n=n+Math.imul(x,Z)|0,i=(i=i+Math.imul(x,$)|0)+Math.imul(T,Z)|0,o=o+Math.imul(T,$)|0,n=n+Math.imul(A,J)|0,i=(i=i+Math.imul(A,tt)|0)+Math.imul(E,J)|0,o=o+Math.imul(E,tt)|0,n=n+Math.imul(I,rt)|0,i=(i=i+Math.imul(I,nt)|0)+Math.imul(O,rt)|0,o=o+Math.imul(O,nt)|0,n=n+Math.imul(S,ot)|0,i=(i=i+Math.imul(S,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,n=n+Math.imul(b,ct)|0,i=(i=i+Math.imul(b,ut)|0)+Math.imul(y,ct)|0,o=o+Math.imul(y,ut)|0,n=n+Math.imul(l,ht)|0,i=(i=i+Math.imul(l,dt)|0)+Math.imul(g,ht)|0,o=o+Math.imul(g,dt)|0;var Pt=(u+(n=n+Math.imul(h,lt)|0)|0)+((8191&(i=(i=i+Math.imul(h,gt)|0)+Math.imul(d,lt)|0))<<13)|0;u=((o=o+Math.imul(d,gt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(L,V),i=(i=Math.imul(L,G))+Math.imul(F,V)|0,o=Math.imul(F,G),n=n+Math.imul(C,Y)|0,i=(i=i+Math.imul(C,X)|0)+Math.imul(H,Y)|0,o=o+Math.imul(H,X)|0,n=n+Math.imul(M,Z)|0,i=(i=i+Math.imul(M,$)|0)+Math.imul(N,Z)|0,o=o+Math.imul(N,$)|0,n=n+Math.imul(x,J)|0,i=(i=i+Math.imul(x,tt)|0)+Math.imul(T,J)|0,o=o+Math.imul(T,tt)|0,n=n+Math.imul(A,rt)|0,i=(i=i+Math.imul(A,nt)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,nt)|0,n=n+Math.imul(I,ot)|0,i=(i=i+Math.imul(I,st)|0)+Math.imul(O,ot)|0,o=o+Math.imul(O,st)|0,n=n+Math.imul(S,ct)|0,i=(i=i+Math.imul(S,ut)|0)+Math.imul(_,ct)|0,o=o+Math.imul(_,ut)|0,n=n+Math.imul(b,ht)|0,i=(i=i+Math.imul(b,dt)|0)+Math.imul(y,ht)|0,o=o+Math.imul(y,dt)|0;var At=(u+(n=n+Math.imul(l,lt)|0)|0)+((8191&(i=(i=i+Math.imul(l,gt)|0)+Math.imul(g,lt)|0))<<13)|0;u=((o=o+Math.imul(g,gt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(L,Y),i=(i=Math.imul(L,X))+Math.imul(F,Y)|0,o=Math.imul(F,X),n=n+Math.imul(C,Z)|0,i=(i=i+Math.imul(C,$)|0)+Math.imul(H,Z)|0,o=o+Math.imul(H,$)|0,n=n+Math.imul(M,J)|0,i=(i=i+Math.imul(M,tt)|0)+Math.imul(N,J)|0,o=o+Math.imul(N,tt)|0,n=n+Math.imul(x,rt)|0,i=(i=i+Math.imul(x,nt)|0)+Math.imul(T,rt)|0,o=o+Math.imul(T,nt)|0,n=n+Math.imul(A,ot)|0,i=(i=i+Math.imul(A,st)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,st)|0,n=n+Math.imul(I,ct)|0,i=(i=i+Math.imul(I,ut)|0)+Math.imul(O,ct)|0,o=o+Math.imul(O,ut)|0,n=n+Math.imul(S,ht)|0,i=(i=i+Math.imul(S,dt)|0)+Math.imul(_,ht)|0,o=o+Math.imul(_,dt)|0;var Et=(u+(n=n+Math.imul(b,lt)|0)|0)+((8191&(i=(i=i+Math.imul(b,gt)|0)+Math.imul(y,lt)|0))<<13)|0;u=((o=o+Math.imul(y,gt)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(L,Z),i=(i=Math.imul(L,$))+Math.imul(F,Z)|0,o=Math.imul(F,$),n=n+Math.imul(C,J)|0,i=(i=i+Math.imul(C,tt)|0)+Math.imul(H,J)|0,o=o+Math.imul(H,tt)|0,n=n+Math.imul(M,rt)|0,i=(i=i+Math.imul(M,nt)|0)+Math.imul(N,rt)|0,o=o+Math.imul(N,nt)|0,n=n+Math.imul(x,ot)|0,i=(i=i+Math.imul(x,st)|0)+Math.imul(T,ot)|0,o=o+Math.imul(T,st)|0,n=n+Math.imul(A,ct)|0,i=(i=i+Math.imul(A,ut)|0)+Math.imul(E,ct)|0,o=o+Math.imul(E,ut)|0,n=n+Math.imul(I,ht)|0,i=(i=i+Math.imul(I,dt)|0)+Math.imul(O,ht)|0,o=o+Math.imul(O,dt)|0;var kt=(u+(n=n+Math.imul(S,lt)|0)|0)+((8191&(i=(i=i+Math.imul(S,gt)|0)+Math.imul(_,lt)|0))<<13)|0;u=((o=o+Math.imul(_,gt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(L,J),i=(i=Math.imul(L,tt))+Math.imul(F,J)|0,o=Math.imul(F,tt),n=n+Math.imul(C,rt)|0,i=(i=i+Math.imul(C,nt)|0)+Math.imul(H,rt)|0,o=o+Math.imul(H,nt)|0,n=n+Math.imul(M,ot)|0,i=(i=i+Math.imul(M,st)|0)+Math.imul(N,ot)|0,o=o+Math.imul(N,st)|0,n=n+Math.imul(x,ct)|0,i=(i=i+Math.imul(x,ut)|0)+Math.imul(T,ct)|0,o=o+Math.imul(T,ut)|0,n=n+Math.imul(A,ht)|0,i=(i=i+Math.imul(A,dt)|0)+Math.imul(E,ht)|0,o=o+Math.imul(E,dt)|0;var xt=(u+(n=n+Math.imul(I,lt)|0)|0)+((8191&(i=(i=i+Math.imul(I,gt)|0)+Math.imul(O,lt)|0))<<13)|0;u=((o=o+Math.imul(O,gt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(L,rt),i=(i=Math.imul(L,nt))+Math.imul(F,rt)|0,o=Math.imul(F,nt),n=n+Math.imul(C,ot)|0,i=(i=i+Math.imul(C,st)|0)+Math.imul(H,ot)|0,o=o+Math.imul(H,st)|0,n=n+Math.imul(M,ct)|0,i=(i=i+Math.imul(M,ut)|0)+Math.imul(N,ct)|0,o=o+Math.imul(N,ut)|0,n=n+Math.imul(x,ht)|0,i=(i=i+Math.imul(x,dt)|0)+Math.imul(T,ht)|0,o=o+Math.imul(T,dt)|0;var Tt=(u+(n=n+Math.imul(A,lt)|0)|0)+((8191&(i=(i=i+Math.imul(A,gt)|0)+Math.imul(E,lt)|0))<<13)|0;u=((o=o+Math.imul(E,gt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(L,ot),i=(i=Math.imul(L,st))+Math.imul(F,ot)|0,o=Math.imul(F,st),n=n+Math.imul(C,ct)|0,i=(i=i+Math.imul(C,ut)|0)+Math.imul(H,ct)|0,o=o+Math.imul(H,ut)|0,n=n+Math.imul(M,ht)|0,i=(i=i+Math.imul(M,dt)|0)+Math.imul(N,ht)|0,o=o+Math.imul(N,dt)|0;var Rt=(u+(n=n+Math.imul(x,lt)|0)|0)+((8191&(i=(i=i+Math.imul(x,gt)|0)+Math.imul(T,lt)|0))<<13)|0;u=((o=o+Math.imul(T,gt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(L,ct),i=(i=Math.imul(L,ut))+Math.imul(F,ct)|0,o=Math.imul(F,ut),n=n+Math.imul(C,ht)|0,i=(i=i+Math.imul(C,dt)|0)+Math.imul(H,ht)|0,o=o+Math.imul(H,dt)|0;var Mt=(u+(n=n+Math.imul(M,lt)|0)|0)+((8191&(i=(i=i+Math.imul(M,gt)|0)+Math.imul(N,lt)|0))<<13)|0;u=((o=o+Math.imul(N,gt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(L,ht),i=(i=Math.imul(L,dt))+Math.imul(F,ht)|0,o=Math.imul(F,dt);var Nt=(u+(n=n+Math.imul(C,lt)|0)|0)+((8191&(i=(i=i+Math.imul(C,gt)|0)+Math.imul(H,lt)|0))<<13)|0;u=((o=o+Math.imul(H,gt)|0)+(i>>>13)|0)+(Nt>>>26)|0,Nt&=67108863;var Bt=(u+(n=Math.imul(L,lt))|0)+((8191&(i=(i=Math.imul(L,gt))+Math.imul(F,lt)|0))<<13)|0;return u=((o=Math.imul(F,gt))+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,c[0]=mt,c[1]=bt,c[2]=yt,c[3]=vt,c[4]=St,c[5]=_t,c[6]=wt,c[7]=It,c[8]=Ot,c[9]=Pt,c[10]=At,c[11]=Et,c[12]=kt,c[13]=xt,c[14]=Tt,c[15]=Rt,c[16]=Mt,c[17]=Nt,c[18]=Bt,0!==u&&(c[19]=u,r.length++),r};function l(t,e,r){return(new g).mulp(t,e,r)}function g(t,e){this.x=t,this.y=e}Math.imul||(p=d),o.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?p(this,t,e):r<63?d(this,t,e):r<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o<r.length-1;o++){var s=i;i=0;for(var a=67108863&n,c=Math.min(o,e.length-1),u=Math.max(0,o-t.length+1);u<=c;u++){var f=o-u,h=(0|t.words[f])*(0|e.words[u]),d=67108863&h;a=67108863&(d=d+a|0),i+=(s=(s=s+(h/67108864|0)|0)+(d>>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,t,e):l(this,t,e)},g.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,n=0;n<t;n++)e[n]=this.revBin(n,r,t);return e},g.prototype.revBin=function(t,e,r){if(0===t||t===r-1)return t;for(var n=0,i=0;i<e;i++)n|=(1&t)<<e-i-1,t>>=1;return n},g.prototype.permute=function(t,e,r,n,i,o){for(var s=0;s<o;s++)n[s]=e[t[s]],i[s]=r[t[s]]},g.prototype.transform=function(t,e,r,n,i,o){this.permute(o,t,e,r,n,i);for(var s=1;s<i;s<<=1)for(var a=s<<1,c=Math.cos(2*Math.PI/a),u=Math.sin(2*Math.PI/a),f=0;f<i;f+=a)for(var h=c,d=u,p=0;p<s;p++){var l=r[f+p],g=n[f+p],m=r[f+p+s],b=n[f+p+s],y=h*m-d*b;b=h*b+d*m,m=y,r[f+p]=l+m,n[f+p]=g+b,r[f+p+s]=l-m,n[f+p+s]=g-b,p!==a&&(y=c*h-u*d,d=c*d+u*h,h=y)}},g.prototype.guessLen13b=function(t,e){var r=1|Math.max(e,t),n=1&r,i=0;for(r=r/2|0;r;r>>>=1)i++;return 1<<i+1+n},g.prototype.conjugate=function(t,e,r){if(!(r<=1))for(var n=0;n<r/2;n++){var i=t[n];t[n]=t[r-n-1],t[r-n-1]=i,i=e[n],e[n]=-e[r-n-1],e[r-n-1]=-i}},g.prototype.normalize13b=function(t,e){for(var r=0,n=0;n<e/2;n++){var i=8192*Math.round(t[2*n+1]/e)+Math.round(t[2*n]/e)+r;t[n]=67108863&i,r=i<67108864?0:i/67108864|0}return t},g.prototype.convert13b=function(t,e,r,i){for(var o=0,s=0;s<e;s++)o+=0|t[s],r[2*s]=8191&o,o>>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*e;s<i;++s)r[s]=0;n(0===o),n(0==(-8192&o))},g.prototype.stub=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=0;return e},g.prototype.mulp=function(t,e,r){var n=2*this.guessLen13b(t.length,e.length),i=this.makeRBT(n),o=this.stub(n),s=new Array(n),a=new Array(n),c=new Array(n),u=new Array(n),f=new Array(n),h=new Array(n),d=r.words;d.length=n,this.convert13b(t.words,t.length,s,n),this.convert13b(e.words,e.length,u,n),this.transform(s,o,a,c,n,i),this.transform(u,o,f,h,n,i);for(var p=0;p<n;p++){var l=a[p]*f[p]-c[p]*h[p];c[p]=a[p]*h[p]+c[p]*f[p],a[p]=l}return this.conjugate(a,c,n),this.transform(a,c,d,o,n,i),this.conjugate(d,o,n),this.normalize13b(d,n),r.negative=t.negative^e.negative,r.length=t.length+e.length,r.strip()},o.prototype.mul=function(t){var e=new o(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},o.prototype.mulf=function(t){var e=new o(null);return e.words=new Array(this.length+t.length),l(this,t,e)},o.prototype.imul=function(t){return this.clone().mulTo(t,this)},o.prototype.imuln=function(t){n("number"==typeof t),n(t<67108864);for(var e=0,r=0;r<this.length;r++){var i=(0|this.words[r])*t,o=(67108863&i)+(67108863&e);e>>=26,e+=i/67108864|0,e+=o>>>26,this.words[r]=67108863&o}return 0!==e&&(this.words[r]=e,this.length++),this},o.prototype.muln=function(t){return this.clone().imuln(t)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var n=r/26|0,i=r%26;e[r]=(t.words[n]&1<<i)>>>i}return e}(t);if(0===e.length)return new o(1);for(var r=this,n=0;n<e.length&&0===e[n];n++,r=r.sqr());if(++n<e.length)for(var i=r.sqr();n<e.length;n++,i=i.sqr())0!==e[n]&&(r=r.mul(i));return r},o.prototype.iushln=function(t){n("number"==typeof t&&t>=0);var e,r=t%26,i=(t-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var s=0;for(e=0;e<this.length;e++){var a=this.words[e]&o,c=(0|this.words[e])-a<<r;this.words[e]=c|s,s=a>>>26-r}s&&(this.words[e]=s,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e<i;e++)this.words[e]=0;this.length+=i}return this.strip()},o.prototype.ishln=function(t){return n(0===this.negative),this.iushln(t)},o.prototype.iushrn=function(t,e,r){var i;n("number"==typeof t&&t>=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<<o,c=r;if(i-=s,i=Math.max(0,i),c){for(var u=0;u<s;u++)c.words[u]=this.words[u];c.length=s}if(0===s);else if(this.length>s)for(this.length-=s,u=0;u<this.length;u++)this.words[u]=this.words[u+s];else this.words[0]=0,this.length=1;var f=0;for(u=this.length-1;u>=0&&(0!==f||u>=i);u--){var h=0|this.words[u];this.words[u]=f<<26-o|h>>>o,f=h&a}return c&&0!==f&&(c.words[c.length++]=f),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(t,e,r){return n(0===this.negative),this.iushrn(t,e,r)},o.prototype.shln=function(t){return this.clone().ishln(t)},o.prototype.ushln=function(t){return this.clone().iushln(t)},o.prototype.shrn=function(t){return this.clone().ishrn(t)},o.prototype.ushrn=function(t){return this.clone().iushrn(t)},o.prototype.testn=function(t){n("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26,i=1<<e;return!(this.length<=r)&&!!(this.words[r]&i)},o.prototype.imaskn=function(t){n("number"==typeof t&&t>=0);var e=t%26,r=(t-e)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var i=67108863^67108863>>>e<<e;this.words[this.length-1]&=i}return this.strip()},o.prototype.maskn=function(t){return this.clone().imaskn(t)},o.prototype.iaddn=function(t){return n("number"==typeof t),n(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},o.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},o.prototype.isubn=function(t){if(n("number"==typeof t),n(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this.strip()},o.prototype.addn=function(t){return this.clone().iaddn(t)},o.prototype.subn=function(t){return this.clone().isubn(t)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(t,e,r){var i,o,s=t.length+r;this._expand(s);var a=0;for(i=0;i<t.length;i++){o=(0|this.words[i+r])+a;var c=(0|t.words[i])*e;a=((o-=67108863&c)>>26)-(c/67108864|0),this.words[i+r]=67108863&o}for(;i<this.length-r;i++)a=(o=(0|this.words[i+r])+a)>>26,this.words[i+r]=67108863&o;if(0===a)return this.strip();for(n(-1===a),a=0,i=0;i<this.length;i++)a=(o=-(0|this.words[i])+a)>>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),i=t,s=0|i.words[i.length-1];0!==(r=26-this._countBits(s))&&(i=i.ushln(r),n.iushln(r),s=0|i.words[i.length-1]);var a,c=n.length-i.length;if("mod"!==e){(a=new o(null)).length=c+1,a.words=new Array(a.length);for(var u=0;u<a.length;u++)a.words[u]=0}var f=n.clone()._ishlnsubmul(i,1,c);0===f.negative&&(n=f,a&&(a.words[c]=1));for(var h=c-1;h>=0;h--){var d=67108864*(0|n.words[i.length+h])+(0|n.words[i.length+h-1]);for(d=Math.min(d/s|0,67108863),n._ishlnsubmul(i,d,h);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(i,1,h),n.isZero()||(n.negative^=1);a&&(a.words[h]=d)}return a&&a.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},o.prototype.divmod=function(t,e,r){return n(!t.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(t)),{div:i,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new o(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new o(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new o(this.modn(t.words[0]))}:this._wordDiv(t,e);var i,s,a},o.prototype.div=function(t){return this.divmod(t,"div",!1).div},o.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},o.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},o.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},o.prototype.modn=function(t){n(t<=67108863);for(var e=(1<<26)%t,r=0,i=this.length-1;i>=0;i--)r=(e*r+(0|this.words[i]))%t;return r},o.prototype.idivn=function(t){n(t<=67108863);for(var e=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*e;this.words[r]=i/t|0,e=i%t}return this.strip()},o.prototype.divn=function(t){return this.clone().idivn(t)},o.prototype.egcd=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i=new o(1),s=new o(0),a=new o(0),c=new o(1),u=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++u;for(var f=r.clone(),h=e.clone();!e.isZero();){for(var d=0,p=1;0==(e.words[0]&p)&&d<26;++d,p<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(i.isOdd()||s.isOdd())&&(i.iadd(f),s.isub(h)),i.iushrn(1),s.iushrn(1);for(var l=0,g=1;0==(r.words[0]&g)&&l<26;++l,g<<=1);if(l>0)for(r.iushrn(l);l-- >0;)(a.isOdd()||c.isOdd())&&(a.iadd(f),c.isub(h)),a.iushrn(1),c.iushrn(1);e.cmp(r)>=0?(e.isub(r),i.isub(a),s.isub(c)):(r.isub(e),a.isub(i),c.isub(s))}return{a:a,b:c,gcd:r.iushln(u)}},o.prototype._invmp=function(t){n(0===t.negative),n(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i,s=new o(1),a=new o(0),c=r.clone();e.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,f=1;0==(e.words[0]&f)&&u<26;++u,f<<=1);if(u>0)for(e.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(c),s.iushrn(1);for(var h=0,d=1;0==(r.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(r.iushrn(h);h-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);e.cmp(r)>=0?(e.isub(r),s.isub(a)):(r.isub(e),a.isub(s))}return(i=0===e.cmpn(1)?s:a).cmpn(0)<0&&i.iadd(t),i},o.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var o=e;e=r,r=o}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},o.prototype.invm=function(t){return this.egcd(t).a.umod(t)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(t){return this.words[0]&t},o.prototype.bincn=function(t){n("number"==typeof t);var e=t%26,r=(t-e)/26,i=1<<e;if(this.length<=r)return this._expand(r+1),this.words[r]|=i,this;for(var o=i,s=r;0!==o&&s<this.length;s++){var a=0|this.words[s];o=(a+=o)>>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)e=1;else{r&&(t=-t),n(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:i<t?-1:1}return 0!==this.negative?0|-e:e},o.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},o.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){n<i?e=-1:n>i&&(e=1);break}}return e},o.prototype.gtn=function(t){return 1===this.cmpn(t)},o.prototype.gt=function(t){return 1===this.cmp(t)},o.prototype.gten=function(t){return this.cmpn(t)>=0},o.prototype.gte=function(t){return this.cmp(t)>=0},o.prototype.ltn=function(t){return-1===this.cmpn(t)},o.prototype.lt=function(t){return-1===this.cmp(t)},o.prototype.lten=function(t){return this.cmpn(t)<=0},o.prototype.lte=function(t){return this.cmp(t)<=0},o.prototype.eqn=function(t){return 0===this.cmpn(t)},o.prototype.eq=function(t){return 0===this.cmp(t)},o.red=function(t){return new w(t)},o.prototype.toRed=function(t){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(t){return this.red=t,this},o.prototype.forceRed=function(t){return n(!this.red,"Already a number in reduction context"),this._forceRed(t)},o.prototype.redAdd=function(t){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return n(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var m={k256:null,p224:null,p192:null,p25519:null};function b(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function y(){b.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function v(){b.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function S(){b.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){b.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function w(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else n(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function I(t){w.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}b.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},b.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e<this.n?-1:r.ucmp(this.p);return 0===n?(r.words[0]=0,r.length=1):n>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},b.prototype.split=function(t,e){t.iushrn(this.n,0,e)},b.prototype.imulK=function(t){return t.imul(this.k)},i(y,b),y.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n<r;n++)e.words[n]=t.words[n];if(e.length=r,t.length<=9)return t.words[0]=0,void(t.length=1);var i=t.words[9];for(e.words[e.length++]=4194303&i,n=10;n<t.length;n++){var o=0|t.words[n];t.words[n-10]=(4194303&o)<<4|i>>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},y.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var n=0|t.words[r];e+=977*n,t.words[r]=67108863&e,e=64*n+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},i(v,b),i(S,b),i(_,b),_.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var n=19*(0|t.words[r])+e,i=67108863&n;n>>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(m[t])return m[t];var e;if("k256"===t)e=new y;else if("p224"===t)e=new v;else if("p192"===t)e=new S;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return m[t]=e,e},w.prototype._verify1=function(t){n(0===t.negative,"red works only with positives"),n(t.red,"red works only with red numbers")},w.prototype._verify2=function(t,e){n(0==(t.negative|e.negative),"red works only with positives"),n(t.red&&t.red===e.red,"red works only with red numbers")},w.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},w.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},w.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},w.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},w.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},w.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},w.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},w.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},w.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},w.prototype.isqr=function(t){return this.imul(t,t.clone())},w.prototype.sqr=function(t){return this.mul(t,t)},w.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(n(e%2==1),3===e){var r=this.m.add(new o(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);n(!i.isZero());var a=new o(1).toRed(this),c=a.redNeg(),u=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);0!==this.pow(f,u).cmp(c);)f.redIAdd(c);for(var h=this.pow(f,i),d=this.pow(t,i.addn(1).iushrn(1)),p=this.pow(t,i),l=s;0!==p.cmp(a);){for(var g=p,m=0;0!==g.cmp(a);m++)g=g.redSqr();n(m<l);var b=this.pow(h,new o(1).iushln(l-m-1));d=d.redMul(b),h=b.redSqr(),p=p.redMul(h),l=m}return d},w.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},w.prototype.pow=function(t,e){if(e.isZero())return new o(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new o(1).toRed(this),r[1]=t;for(var n=2;n<r.length;n++)r[n]=this.mul(r[n-1],t);var i=r[0],s=0,a=0,c=e.bitLength()%26;for(0===c&&(c=26),n=e.length-1;n>=0;n--){for(var u=e.words[n],f=c-1;f>=0;f--){var h=u>>f&1;i!==r[0]&&(i=this.sqr(i)),0!==h||0!==s?(s<<=1,s|=h,(4===++a||0===n&&0===f)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}c=26}return i},w.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},w.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new I(t)},i(I,w),I.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},I.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},I.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},I.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},I.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,this)}).call(this,r(25)(t))},function(t,e,r){"use strict";var n=r(1);function i(t,e){return t.replace("{0}",e[0]).replace("{1}",e[1]).replace("{2}",e[2])}var o=function(t,e){var r=function(){if(n.isString(e.message))this.message=i(e.message,arguments);else{if(!n.isFunction(e.message))throw new Error("Invalid error definition for "+e.name);this.message=e.message.apply(null,arguments)}this.stack=this.message+"\n"+(new Error).stack};return(r.prototype=Object.create(t.prototype)).name=t.prototype.name+e.name,t[e.name]=r,e.errors&&s(r,e.errors),r},s=function(t,e){n.each(e,(function(e){o(t,e)}))},a={Error:function(){this.message="Internal error",this.stack=this.message+"\n"+(new Error).stack}};a.Error.prototype=Object.create(Error.prototype),a.Error.prototype.name="bsv.Error";var c,u=r(105);c=a.Error,s(c,u),t.exports=a.Error,t.exports.extend=function(t){return o(a.Error,t)}},function(t,e,r){"use strict";(function(e){var n=r(3),i=new(0,r(41).ec)("secp256k1"),o=i.curve.point.bind(i.curve),s=i.curve.pointFromX.bind(i.curve),a=function(t,e,r){try{var n=o(t,e,r)}catch(t){throw new Error("Invalid Point")}return n.validate(),n};a.prototype=Object.getPrototypeOf(i.curve.point()),a.fromX=function(t,e){try{var r=s(e,t)}catch(t){throw new Error("Invalid X")}return r.validate(),r},a.getG=function(){return i.curve.g},a.getN=function(){return new n(i.curve.n.toArray())},a.prototype._getX||(a.prototype._getX=a.prototype.getX),a.prototype.getX=function(){return new n(this._getX().toArray())},a.prototype._getY||(a.prototype._getY=a.prototype.getY),a.prototype.getY=function(){return new n(this._getY().toArray())},a.prototype.validate=function(){if(this.isInfinity())throw new Error("Point cannot be equal to Infinity");var t;try{t=s(this.getX(),this.getY().isOdd())}catch(t){throw new Error("Point does not lie on the curve")}if(0!==t.y.cmp(this.y))throw new Error("Invalid y value for curve.");if(!this.mul(a.getN()).isInfinity())throw new Error("Point times N must be infinity");return this},a.pointToCompressed=function(t){var r,n=t.getX().toBuffer({size:32}),i=t.getY().toBuffer({size:32});return r=i[i.length-1]%2?e.from([3]):e.from([2]),e.concat([r,n])},a.pointFromCompressed=function(t){if(33!==t.length)throw new Error("invalid buffer length");let e,r=t[0];if(3===r)e=!0;else{if(2!==r)throw new Error("invalid value of compressed prefix");e=!1}let i=t.slice(1,33),o=n.fromBuffer(i);return a.fromX(e,o)},a.prototype.toBuffer=function(){return a.pointToCompressed(this)},a.prototype.toHex=function(){return this.toBuffer().toString("hex")},a.fromBuffer=function(t){return a.pointFromCompressed(t)},a.fromHex=function(t){return a.fromBuffer(e.from(t,"hex"))},t.exports=a}).call(this,r(0).Buffer)},function(t,e,r){t.exports=r(61),t.exports.Interpreter=r(49)},function(t,e,r){"use strict";var n=r(22),i=r(23);function o(t,e){return 55296==(64512&t.charCodeAt(e))&&(!(e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1)))}function s(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function a(t){return 1===t.length?"0"+t:t}function c(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}e.inherits=i,e.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),i=0;i<t.length;i+=2)r.push(parseInt(t[i]+t[i+1],16))}else for(var n=0,i=0;i<t.length;i++){var s=t.charCodeAt(i);s<128?r[n++]=s:s<2048?(r[n++]=s>>6|192,r[n++]=63&s|128):o(t,i)?(s=65536+((1023&s)<<10)+(1023&t.charCodeAt(++i)),r[n++]=s>>18|240,r[n++]=s>>12&63|128,r[n++]=s>>6&63|128,r[n++]=63&s|128):(r[n++]=s>>12|224,r[n++]=s>>6&63|128,r[n++]=63&s|128)}else for(i=0;i<t.length;i++)r[i]=0|t[i];return r},e.toHex=function(t){for(var e="",r=0;r<t.length;r++)e+=a(t[r].toString(16));return e},e.htonl=s,e.toHex32=function(t,e){for(var r="",n=0;n<t.length;n++){var i=t[n];"little"===e&&(i=s(i)),r+=c(i.toString(16))}return r},e.zero2=a,e.zero8=c,e.join32=function(t,e,r,i){var o=r-e;n(o%4==0);for(var s=new Array(o/4),a=0,c=e;a<s.length;a++,c+=4){var u;u="big"===i?t[c]<<24|t[c+1]<<16|t[c+2]<<8|t[c+3]:t[c+3]<<24|t[c+2]<<16|t[c+1]<<8|t[c],s[a]=u>>>0}return s},e.split32=function(t,e){for(var r=new Array(4*t.length),n=0,i=0;n<t.length;n++,i+=4){var o=t[n];"big"===e?(r[i]=o>>>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},e.rotr32=function(t,e){return t>>>e|t<<32-e},e.rotl32=function(t,e){return t<<e|t>>>32-e},e.sum32=function(t,e){return t+e>>>0},e.sum32_3=function(t,e,r){return t+e+r>>>0},e.sum32_4=function(t,e,r,n){return t+e+r+n>>>0},e.sum32_5=function(t,e,r,n,i){return t+e+r+n+i>>>0},e.sum64=function(t,e,r,n){var i=t[e],o=n+t[e+1]>>>0,s=(o<n?1:0)+r+i;t[e]=s>>>0,t[e+1]=o},e.sum64_hi=function(t,e,r,n){return(e+n>>>0<e?1:0)+t+r>>>0},e.sum64_lo=function(t,e,r,n){return e+n>>>0},e.sum64_4_hi=function(t,e,r,n,i,o,s,a){var c=0,u=e;return c+=(u=u+n>>>0)<e?1:0,c+=(u=u+o>>>0)<o?1:0,t+r+i+s+(c+=(u=u+a>>>0)<a?1:0)>>>0},e.sum64_4_lo=function(t,e,r,n,i,o,s,a){return e+n+o+a>>>0},e.sum64_5_hi=function(t,e,r,n,i,o,s,a,c,u){var f=0,h=e;return f+=(h=h+n>>>0)<e?1:0,f+=(h=h+o>>>0)<o?1:0,f+=(h=h+a>>>0)<a?1:0,t+r+i+s+c+(f+=(h=h+u>>>0)<u?1:0)>>>0},e.sum64_5_lo=function(t,e,r,n,i,o,s,a,c,u){return e+n+o+a+u>>>0},e.rotr64_hi=function(t,e,r){return(e<<32-r|t>>>r)>>>0},e.rotr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0},e.shr64_hi=function(t,e,r){return t>>>r},e.shr64_lo=function(t,e,r){return(t<<32-r|e>>>r)>>>0}},function(t,e,r){"use strict";(function(e){var n=r(3),i=r(11),o=r(7),s=r(6),a=r(24),c=r(1),u=r(2);function f(t,e){if(!(this instanceof f))return new f(t,e);if(u.checkArgument(t,"First argument is required, please include public key data."),t instanceof f)return t;e=e||{};var r=this._classifyArgs(t,e);return r.point.validate(),s.defineImmutable(this,{point:r.point,compressed:r.compressed,network:r.network||a.defaultNetwork}),this}f.prototype._classifyArgs=function(t,r){var n={compressed:c.isUndefined(r.compressed)||r.compressed};if(t instanceof i)n.point=t;else if(t.x&&t.y)n=f._transformObject(t);else if("string"==typeof t)n=f._transformDER(e.from(t,"hex"));else if(f._isBuffer(t))n=f._transformDER(t);else{if(!f._isPrivateKey(t))throw new TypeError("First argument is an unrecognized data format.");n=f._transformPrivateKey(t)}return n.network||(n.network=c.isUndefined(r.network)?void 0:a.get(r.network)),n},f._isPrivateKey=function(t){return t instanceof r(34)},f._isBuffer=function(t){return t instanceof e||t instanceof Uint8Array},f._transformPrivateKey=function(t){u.checkArgument(f._isPrivateKey(t),"Must be an instance of PrivateKey");var e={};return e.point=i.getG().mul(t.bn),e.compressed=t.compressed,e.network=t.network,e},f._transformDER=function(t,e){u.checkArgument(f._isBuffer(t),"Must be a buffer of DER encoded public key");var r,o,s,a,h={};if(e=!!c.isUndefined(e)||e,4!==t[0]&&(e||6!==t[0]&&7!==t[0]))if(3===t[0])s=t.slice(1),r=new n(s),(h=f._transformX(!0,r)).compressed=!0;else{if(2!==t[0])throw new TypeError("Invalid DER format public key");s=t.slice(1),r=new n(s),(h=f._transformX(!1,r)).compressed=!0}else{if(s=t.slice(1,33),a=t.slice(33,65),32!==s.length||32!==a.length||65!==t.length)throw new TypeError("Length of x and y must be 32 bytes");r=new n(s),o=new n(a),h.point=new i(r,o),h.compressed=!1}return h},f._transformX=function(t,e){u.checkArgument("boolean"==typeof t,"Must specify whether y is odd or not (true or false)");var r={};return r.point=i.fromX(t,e),r},f._transformObject=function(t){var e=new n(t.x,"hex"),r=new n(t.y,"hex");return new f(new i(e,r),{compressed:t.compressed})},f.fromPrivateKey=function(t){u.checkArgument(f._isPrivateKey(t),"Must be an instance of PrivateKey");var e=f._transformPrivateKey(t);return new f(e.point,{compressed:e.compressed,network:e.network})},f.fromDER=f.fromBuffer=function(t,e){u.checkArgument(f._isBuffer(t),"Must be a buffer of DER encoded public key");var r=f._transformDER(t,e);return new f(r.point,{compressed:r.compressed})},f.fromPoint=function(t,e){return u.checkArgument(t instanceof i,"First argument must be an instance of Point."),new f(t,{compressed:e})},f.fromHex=f.fromString=function(t,r){var n=e.from(t,r||"hex"),i=f._transformDER(n);return new f(i.point,{compressed:i.compressed})},f.fromX=function(t,e){var r=f._transformX(t,e);return new f(r.point,{compressed:r.compressed})},f.getValidationError=function(t){var e;try{new f(t)}catch(t){e=t}return e},f.isValid=function(t){return!f.getValidationError(t)},f.prototype.toObject=f.prototype.toJSON=function(){return{x:this.point.getX().toString("hex",2),y:this.point.getY().toString("hex",2),compressed:this.compressed}},f.prototype.toBuffer=f.prototype.toDER=function(){var t,r=this.point.getX(),n=this.point.getY(),i=r.toBuffer({size:32}),o=n.toBuffer({size:32});return this.compressed?(t=o[o.length-1]%2?e.from([3]):e.from([2]),e.concat([t,i])):(t=e.from([4]),e.concat([t,i,o]))},f.prototype._getID=function(){return o.sha256ripemd160(this.toBuffer())},f.prototype.toAddress=function(t){return r(26).fromPublicKey(this,t||this.network)},f.prototype.toString=f.prototype.toHex=function(){return this.toDER().toString("hex")},f.prototype.inspect=function(){return"<PublicKey: "+this.toHex()+(this.compressed?"":", uncompressed")+">"},t.exports=f}).call(this,r(0).Buffer)},function(t,e){},function(t,e,r){"use strict";(function(e){var n=r(45),i=function t(e){if(!(this instanceof t))return new t(e);this.bufLen=0,e?this.set(e):this.bufs=[]};i.prototype.set=function(t){return this.bufs=t.bufs||this.bufs||[],this.bufLen=this.bufs.reduce((function(t,e){return t+e.length}),0),this},i.prototype.toBuffer=function(){return this.concat()},i.prototype.concat=function(){return e.concat(this.bufs,this.bufLen)},i.prototype.write=function(t){return n(e.isBuffer(t)),this.bufs.push(t),this.bufLen+=t.length,this},i.prototype.writeReverse=function(t){return n(e.isBuffer(t)),this.bufs.push(e.from(t).reverse()),this.bufLen+=t.length,this},i.prototype.writeUInt8=function(t){var r=e.alloc(1);return r.writeUInt8(t,0),this.write(r),this},i.prototype.writeUInt16BE=function(t){var r=e.alloc(2);return r.writeUInt16BE(t,0),this.write(r),this},i.prototype.writeUInt16LE=function(t){var r=e.alloc(2);return r.writeUInt16LE(t,0),this.write(r),this},i.prototype.writeUInt32BE=function(t){var r=e.alloc(4);return r.writeUInt32BE(t,0),this.write(r),this},i.prototype.writeInt32LE=function(t){var r=e.alloc(4);return r.writeInt32LE(t,0),this.write(r),this},i.prototype.writeUInt32LE=function(t){var r=e.alloc(4);return r.writeUInt32LE(t,0),this.write(r),this},i.prototype.writeUInt64BEBN=function(t){var e=t.toBuffer({size:8});return this.write(e),this},i.prototype.writeUInt64LEBN=function(t){var e=t.toBuffer({size:8});return this.writeReverse(e),this},i.prototype.writeVarintNum=function(t){var e=i.varintBufNum(t);return this.write(e),this},i.prototype.writeVarintBN=function(t){var e=i.varintBufBN(t);return this.write(e),this},i.varintBufNum=function(t){var r;return t<253?(r=e.alloc(1)).writeUInt8(t,0):t<65536?((r=e.alloc(3)).writeUInt8(253,0),r.writeUInt16LE(t,1)):t<4294967296?((r=e.alloc(5)).writeUInt8(254,0),r.writeUInt32LE(t,1)):((r=e.alloc(9)).writeUInt8(255,0),r.writeInt32LE(-1&t,1),r.writeUInt32LE(Math.floor(t/4294967296),5)),r},i.varintBufBN=function(t){var r,n=t.toNumber();if(n<253)(r=e.alloc(1)).writeUInt8(n,0);else if(n<65536)(r=e.alloc(3)).writeUInt8(253,0),r.writeUInt16LE(n,1);else if(n<4294967296)(r=e.alloc(5)).writeUInt8(254,0),r.writeUInt32LE(n,1);else{var o=new i;o.writeUInt8(255),o.writeUInt64LEBN(t),r=o.concat()}return r},t.exports=i}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var n=r(4);r(15);function i(t,r){if(!(this instanceof i))return new i(t,r);this.preimage=e.isBuffer(t)?t:e.from(t,"hex"),this.options=r||{},this.strategy=this.options.strategy||"DYNAMIC",this.fields=null,this.sighashInfo=null,this.options.deferExtraction||this._extractFields()}i.prototype.extract=function(t){return this.strategy=t||this.strategy,this._extractFields(),this.fields},i.prototype.getSighashInfo=function(){return this.fields||this._extractFields(),this.sighashInfo},i.prototype.getField=function(t){return this.fields||this._extractFields(),this.fields[t]},i.prototype.extractField=function(t,e){e=e||{},this.fields||this._extractFields();var r=this._parsePreimageStructure(),n=this._generateBidirectionalASM(t,r,e.includeComments),i=this._extractSpecificField(t,r),o=this._interpretField(t,i,r);return{field:t,value:i?i.toString("hex"):null,buffer:i,asm:n,interpretation:o,strategy:this._getExtractionStrategy(t),structure:r._structure}},i.prototype.generateASM=function(t,e){var r=this._parsePreimageStructure();return this._generateBidirectionalASM(t,r,e)},i.prototype.extractFields=function(t){var e={};return t.forEach(function(t){e[t]=this.extractField(t)}.bind(this)),e},i.prototype.validate=function(){this.fields||this._extractFields();var t=[],e=[];return["version","hashPrevouts","hashSequence","outpoint","scriptCode","amount","sequence","hashOutputs","locktime","sighash"].forEach(function(e){this.fields[e]||t.push("Missing required field: "+e)}.bind(this)),this.sighashInfo.hasZeroHashes&&e.push("Zero hashes detected - check SIGHASH flags: "+this.sighashInfo.zeroFields.join(", ")),this.preimage.length<104&&t.push("Preimage too short: "+this.preimage.length+" bytes (minimum 104)"),{valid:0===t.length,errors:t,warnings:e,sighashInfo:this.sighashInfo}},i.prototype.toObject=function(){return this.fields||this._extractFields(),{preimage:this.preimage.toString("hex"),length:this.preimage.length,strategy:this.strategy,fields:{version:this.fields.version?this.fields.version.toString("hex"):null,hashPrevouts:this.fields.hashPrevouts?this.fields.hashPrevouts.toString("hex"):null,hashSequence:this.fields.hashSequence?this.fields.hashSequence.toString("hex"):null,outpoint:this.fields.outpoint?this.fields.outpoint.toString("hex"):null,scriptCode:this.fields.scriptCode?this.fields.scriptCode.toString("hex"):null,scriptCodeLength:this.fields.scriptCodeLength,amount:this.fields.amount?this.fields.amount.toString("hex"):null,sequence:this.fields.sequence?this.fields.sequence.toString("hex"):null,hashOutputs:this.fields.hashOutputs?this.fields.hashOutputs.toString("hex"):null,locktime:this.fields.locktime?this.fields.locktime.toString("hex"):null,sighash:this.fields.sighash?this.fields.sighash.toString("hex"):null},sighashInfo:this.sighashInfo,validation:this.validate()}},i.prototype._extractFields=function(){this.fields={},this.sighashInfo={flag:null,hasZeroHashes:!1,zeroFields:[],warnings:[]};try{"LEFT"===this.strategy||"DYNAMIC"===this.strategy?this._extractFromLeft():"RIGHT"===this.strategy&&this._extractFromRight(),this._analyzeSighash()}catch(t){if("DYNAMIC"!==this.strategy)throw t;try{this.strategy="RIGHT",this._extractFromRight(),this._analyzeSighash()}catch(e){throw new Error("Failed to extract preimage fields with any strategy: "+t.message)}}},i.prototype._extractFromLeft=function(){var t=0;this.fields.version=this.preimage.slice(t,t+4),t+=4,this.fields.hashPrevouts=this.preimage.slice(t,t+32),t+=32,this.fields.hashSequence=this.preimage.slice(t,t+32),t+=32,this.fields.outpoint=this.preimage.slice(t,t+36),t+=36;var e=i.decodeCompactSize(this.preimage,t);this.fields.scriptCodeLength=e.value,t=e.nextOffset,this.fields.scriptCode=this.preimage.slice(t,t+this.fields.scriptCodeLength),t+=this.fields.scriptCodeLength,this.fields.amount=this.preimage.slice(t,t+8),t+=8,this.fields.sequence=this.preimage.slice(t,t+4),t+=4,this.fields.hashOutputs=this.preimage.slice(t,t+32),t+=32,this.fields.locktime=this.preimage.slice(t,t+4),t+=4,this.fields.sighash=this.preimage.slice(t,t+4)},i.prototype._extractFromRight=function(){var t=this.preimage.length;t-=4,this.fields.sighash=this.preimage.slice(t,t+4),t-=4,this.fields.locktime=this.preimage.slice(t,t+4),t-=32,this.fields.hashOutputs=this.preimage.slice(t,t+32),t-=4,this.fields.sequence=this.preimage.slice(t,t+4),t-=8,this.fields.amount=this.preimage.slice(t,t+8);var e=i.decodeCompactSize(this.preimage,104);this.fields.scriptCodeLength=e.value,this.fields.scriptCode=this.preimage.slice(e.nextOffset,e.nextOffset+this.fields.scriptCodeLength),this.fields.version=this.preimage.slice(0,4),this.fields.hashPrevouts=this.preimage.slice(4,36),this.fields.hashSequence=this.preimage.slice(36,68),this.fields.outpoint=this.preimage.slice(68,104)},i.prototype._analyzeSighash=function(){if(this.fields.sighash){var t=this.fields.sighash.readUInt32LE(0);this.sighashInfo.flag=t;var r=31&t,n=0!=(128&t),i=0!=(64&t),o=e.alloc(32);n&&this.fields.hashPrevouts.equals(o)&&(this.sighashInfo.hasZeroHashes=!0,this.sighashInfo.zeroFields.push("hashPrevouts"),this.sighashInfo.warnings.push("ANYONECANPAY flag detected - hashPrevouts is zero")),2===r&&this.fields.hashSequence.equals(o)&&(this.sighashInfo.hasZeroHashes=!0,this.sighashInfo.zeroFields.push("hashSequence"),this.sighashInfo.warnings.push("SIGHASH_NONE flag detected - hashSequence is zero")),2!==r&&3!==r||!this.fields.hashOutputs.equals(o)||(this.sighashInfo.hasZeroHashes=!0,this.sighashInfo.zeroFields.push("hashOutputs"),this.sighashInfo.warnings.push("SIGHASH_NONE/SINGLE flag detected - hashOutputs is zero"));var s=[];1===r?s.push("ALL"):2===r?s.push("NONE"):3===r&&s.push("SINGLE"),n&&s.push("ANYONECANPAY"),i&&s.push("FORKID"),this.sighashInfo.flagName=s.join(" | ")}},i.prototype._parsePreimageStructure=function(){for(var t=this.preimage,e=0,r={},n=[{name:"nVersion",len:4},{name:"hashPrevouts",len:32},{name:"hashSequence",len:32},{name:"outpoint_txid",len:32},{name:"outpoint_vout",len:4}],o=[{name:"value",len:8},{name:"nSequence",len:4},{name:"hashOutputs",len:32},{name:"nLocktime",len:4},{name:"sighashType",len:4}],s=0;s<n.length;s++){var a=n[s];r[a.name]=t.slice(e,e+a.len).toString("hex"),e+=a.len}var c=i.decodeCompactSize(t,e);r.scriptLen=c.value,r.scriptLenSize=c.bytes,r.scriptLenRaw=t.slice(e,e+c.bytes).toString("hex"),e+=c.bytes,r.scriptCode=t.slice(e,e+r.scriptLen).toString("hex"),e+=r.scriptLen;for(var u=0;u<o.length;u++){var f=o[u];r[f.name]=t.slice(e,e+f.len).toString("hex"),e+=f.len}var h=n.reduce((function(t,e){return t+e.len}),0),d=o.reduce((function(t,e){return t+e.len}),0);return r._structure={leftFixed:h,scriptLenVarint:c.bytes,scriptCode:r.scriptLen,rightFixed:d,totalCalculated:h+c.bytes+r.scriptLen+d,totalActual:t.length},r},i.prototype._generateBidirectionalASM=function(t,e,r){if(["value","nSequence","hashOutputs","nLocktime","sighashType"].includes(t))return this._generateRightExtractionASM(t,r);if(["nVersion","hashPrevouts","hashSequence","outpoint_txid","outpoint_vout"].includes(t))return this._generateLeftExtractionASM(t,r);if("scriptCode"===t)return this._generateDynamicExtractionASM(e,r);if("scriptLen"===t)return this._generateScriptLenExtractionASM(e,r);throw new Error("Unknown field: "+t)},i.prototype._generateRightExtractionASM=function(t,e){for(var r=[{name:"value",len:8},{name:"nSequence",len:4},{name:"hashOutputs",len:32},{name:"nLocktime",len:4},{name:"sighashType",len:4}],n=0,i=0,o=!1,s=0;s<r.length;s++){var a=r[s];if(a.name===t){i=a.len,o=!0;break}n+=a.len}if(!o)throw new Error("Field not found in RIGHT fields: "+t);var c=52-n,u=[];return e?(u.push("# 🔄 Extract "+t+" from RIGHT side (bidirectional strategy)"),u.push("OP_SIZE # Push preimage size: [preimage, size]")):u.push("OP_SIZE"),(u=e?u.concat([c+" OP_SUB # Calculate split point: [preimage, split_point]","OP_SPLIT # Split: [left_part, right_part]","OP_DROP # Drop left: [right_part]",i+" OP_SPLIT # Extract field: [remaining, "+t+"]","OP_DROP # Clean up: ["+t+"]","# ✅ Result: "+t+" is now on top of stack"]):u.concat([c+" OP_SUB","OP_SPLIT","OP_DROP",i+" OP_SPLIT","OP_DROP"])).join("\n")},i.prototype._generateLeftExtractionASM=function(t,e){var r=[{name:"nVersion",len:4,offset:0},{name:"hashPrevouts",len:32,offset:4},{name:"hashSequence",len:32,offset:36},{name:"outpoint_txid",len:32,offset:68},{name:"outpoint_vout",len:4,offset:100}].find((function(e){return e.name===t}));if(!r)throw new Error("Field not found in LEFT fields: "+t);return(e?["# 🔄 Extract "+t+" from LEFT side (bidirectional strategy)",r.offset+" OP_SPLIT # Skip to field: [prefix, remainder]","OP_DROP # Drop prefix: [remainder]",r.len+" OP_SPLIT # Extract field: ["+t+", suffix]","OP_DROP # Clean up: ["+t+"]","# ✅ Result: "+t+" is now on top of stack"]:[r.offset+" OP_SPLIT","OP_DROP",r.len+" OP_SPLIT","OP_DROP"]).join("\n")},i.prototype._generateDynamicExtractionASM=function(t,e){return["# 🎯 Extract scriptCode DYNAMICALLY with CompactSize varint support",104+t.scriptLenSize+" OP_SPLIT # Skip left zone + scriptLen varint: [left_zone, remainder]","OP_DROP # Drop left: [remainder]",t.scriptLen+" OP_SPLIT # Extract scriptCode: [scriptCode, right_zone]","OP_DROP # Clean up: [scriptCode]","# ✅ Result: scriptCode extracted with "+t.scriptLenSize+"-byte varint awareness"].join("\n")},i.prototype._generateScriptLenExtractionASM=function(t,e){return["# 🎯 Extract scriptLen CompactSize varint ("+t.scriptLenSize+" bytes)","104 OP_SPLIT # Skip left fixed fields: [left_zone, remainder]","OP_DROP # Drop left: [remainder]",t.scriptLenSize+" OP_SPLIT # Extract varint: [scriptLen_varint, suffix]","OP_DROP # Clean up: [scriptLen_varint]","# ✅ Result: CompactSize varint (decode off-chain to get "+t.scriptLen+")"].join("\n")},i.prototype._extractSpecificField=function(t,r){var n=r[t];return n?e.from(n,"hex"):null},i.prototype._interpretField=function(t,r,n){if(!r)return null;var i={raw:r.toString("hex"),bytes:r.length};try{switch(t){case"nVersion":i.value=r.readUInt32LE(0),i.description="Transaction version "+i.value;break;case"value":8===r.length&&(i.satoshis=r.readBigUInt64LE(0).toString(),i.description=i.satoshis+" satoshis");break;case"sighashType":var o=r.readUInt32LE(0);i.value=o,i.description={1:"SIGHASH_ALL",65:"SIGHASH_ALL | FORKID",2:"SIGHASH_NONE",66:"SIGHASH_NONE | FORKID",3:"SIGHASH_SINGLE",67:"SIGHASH_SINGLE | FORKID"}[o]||"Custom ("+o+")";break;case"outpoint_vout":i.value=r.readUInt32LE(0),i.description="Output index "+i.value;break;case"scriptLen":i.varintSize=n.scriptLenSize,i.scriptLength=n.scriptLen,i.description=n.scriptLen+" bytes encoded as "+n.scriptLenSize+"-byte varint";break;case"scriptCode":25===r.length&&118===r[0]&&169===r[1]?(i.description="Standard P2PKH script (25 bytes)",i.type="P2PKH"):r.length>0&&106===r[0]?(i.description="OP_RETURN data script ("+r.length+" bytes)",i.type="OP_RETURN"):(i.description="Custom script ("+r.length+" bytes)",i.type="CUSTOM");break;default:if(["hashPrevouts","hashSequence","hashOutputs"].includes(t)){var s=e.alloc(32);r.equals(s)?(i.isZero=!0,i.description="Zero hash (check SIGHASH flags)"):i.description="32-byte hash"}}}catch(t){i.error=t.message}return i},i.prototype._getExtractionStrategy=function(t){return["value","nSequence","hashOutputs","nLocktime","sighashType"].includes(t)?"RIGHT":["nVersion","hashPrevouts","hashSequence","outpoint_txid","outpoint_vout"].includes(t)?"LEFT":"scriptCode"===t?"DYNAMIC":"scriptLen"===t?"VARINT":"UNKNOWN"},i.decodeCompactSize=function(t,e){var r=t[e];if(r<253)return{value:r,nextOffset:e+1,bytes:1};if(253===r)return{value:t.readUInt16LE(e+1),nextOffset:e+3,bytes:3};if(254===r)return{value:t.readUInt32LE(e+1),nextOffset:e+5,bytes:5};console.warn("Encountered 8-byte CompactSize - this is very unusual for script lengths");try{return{value:t.readUInt32LE(e+1),nextOffset:e+9,bytes:9}}catch(t){throw new Error("Invalid 8-byte CompactSize encoding in preimage")}},i.fromTransaction=function(t,e,r,o,s){return new i(n.Transaction.sighash.sighashPreimage(t,s,e,r,new n.crypto.BN(o)),{transaction:t,inputIndex:e,subscript:r,satoshis:o,sighashType:s})},i.createExample=function(t){var e=n.PrivateKey.fromRandom().toAddress(),r={txId:"0".repeat(64),outputIndex:0,script:n.Script.buildPublicKeyHashOut(e).toHex(),satoshis:1e5},o=(new n.Transaction).from(r).to(e,99e3),s=n.Script.fromHex(r.script);return i.fromTransaction(o,0,s,r.satoshis,t)},i.extractFromHex=function(t,e,r){return new i(t,{deferExtraction:!0}).extractField(e,r)},i.generateASMFromHex=function(t,e,r){return new i(t,{deferExtraction:!0}).generateASM(e,r)},i.extractMultipleFromHex=function(t,e){return new i(t,{deferExtraction:!0}).extractFields(e)},i.validateFromHex=function(t){return new i(t).validate()},i.analyzeFromHex=function(t){var e=new i(t),r=e._parsePreimageStructure(),n=e.validate();return{hex:t,length:t.length/2,structure:r._structure,fields:r,validation:n,sighashInfo:e.getSighashInfo(),extractField:function(t){return e.extractField(t)},generateASM:function(t){return e.generateASM(t)},getSummary:function(){return{totalBytes:r._structure.totalActual,scriptLength:r.scriptLen,scriptVarintSize:r.scriptLenSize,sighashType:r.sighashType,valid:n.valid,warnings:n.warnings}}}},t.exports=i}).call(this,r(0).Buffer)},function(t,e){var r,n,i=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(t){if(r===setTimeout)return setTimeout(t,0);if((r===o||!r)&&setTimeout)return r=setTimeout,setTimeout(t,0);try{return r(t,0)}catch(e){try{return r.call(null,t,0)}catch(e){return r.call(this,t,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:o}catch(t){r=o}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(t){n=s}}();var c,u=[],f=!1,h=-1;function d(){f&&c&&(f=!1,c.length?u=c.concat(u):h=-1,u.length&&p())}function p(){if(!f){var t=a(d);f=!0;for(var e=u.length;e;){for(c=u,u=[];++h<e;)c&&c[h].run();h=-1,e=u.length}c=null,f=!1,function(t){if(n===clearTimeout)return clearTimeout(t);if((n===s||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(t);try{n(t)}catch(e){try{return n.call(null,t)}catch(e){return n.call(this,t)}}}(t)}}function l(t,e){this.fun=t,this.array=e}function g(){}i.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];u.push(new l(t,e)),1!==u.length||f||a(p)},l.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=g,i.addListener=g,i.once=g,i.off=g,i.removeListener=g,i.removeAllListeners=g,i.emit=g,i.prependListener=g,i.prependOnceListener=g,i.listeners=function(t){return[]},i.binding=function(t){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(t){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(t,e,r){"use strict";(function(e){var n=r(1),i=r(2),o=r(3),s=function t(r){if(!(this instanceof t))return new t(r);if(!n.isUndefined(r))if(e.isBuffer(r))this.set({buf:r});else if(n.isString(r)){var i=e.from(r,"hex");if(2*i.length!==r.length)throw new TypeError("Invalid hex string");this.set({buf:i})}else{if(!n.isObject(r))throw new TypeError("Unrecognized argument for BufferReader");var o=r;this.set(o)}};s.prototype.set=function(t){return this.buf=t.buf||this.buf||void 0,this.pos=t.pos||this.pos||0,this},s.prototype.eof=function(){return this.pos>=this.buf.length},s.prototype.finished=s.prototype.eof,s.prototype.read=function(t){i.checkArgument(!n.isUndefined(t),"Must specify a length");var e=this.buf.slice(this.pos,this.pos+t);return this.pos=this.pos+t,e},s.prototype.readAll=function(){var t=this.buf.slice(this.pos,this.buf.length);return this.pos=this.buf.length,t},s.prototype.readUInt8=function(){var t=this.buf.readUInt8(this.pos);return this.pos=this.pos+1,t},s.prototype.readUInt16BE=function(){var t=this.buf.readUInt16BE(this.pos);return this.pos=this.pos+2,t},s.prototype.readUInt16LE=function(){var t=this.buf.readUInt16LE(this.pos);return this.pos=this.pos+2,t},s.prototype.readUInt32BE=function(){var t=this.buf.readUInt32BE(this.pos);return this.pos=this.pos+4,t},s.prototype.readUInt32LE=function(){var t=this.buf.readUInt32LE(this.pos);return this.pos=this.pos+4,t},s.prototype.readInt32LE=function(){var t=this.buf.readInt32LE(this.pos);return this.pos=this.pos+4,t},s.prototype.readUInt64BEBN=function(){var t=this.buf.slice(this.pos,this.pos+8),e=o.fromBuffer(t);return this.pos=this.pos+8,e},s.prototype.readUInt64LEBN=function(){var t,e=this.buf.readUInt32LE(this.pos),r=4294967296*this.buf.readUInt32LE(this.pos+4)+e;if(r<=9007199254740991)t=new o(r);else{var n=Array.prototype.slice.call(this.buf,this.pos,this.pos+8);t=new o(n,10,"le")}return this.pos=this.pos+8,t},s.prototype.readVarintNum=function(){var t=this.readUInt8();switch(t){case 253:return this.readUInt16LE();case 254:return this.readUInt32LE();case 255:var e=this.readUInt64LEBN().toNumber();if(e<=Math.pow(2,53))return e;throw new Error("number too large to retain precision - use readVarintBN");default:return t}},s.prototype.readVarLengthBuffer=function(){var t=this.readVarintNum(),e=this.read(t);return i.checkState(e.length===t,"Invalid length while reading varlength buffer. Expected to read: "+t+" and read "+e.length),e},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 t=this.readUInt8();switch(t){case 253:return new o(this.readUInt16LE());case 254:return new o(this.readUInt32LE());case 255:return this.readUInt64LEBN();default:return new o(t)}},s.prototype.reverse=function(){for(var t=e.alloc(this.buf.length),r=0;r<t.length;r++)t[r]=this.buf[this.buf.length-1-r];return this.buf=t,this},s.prototype.readReverse=function(t){n.isUndefined(t)&&(t=this.buf.length);var r=this.buf.slice(this.pos,this.pos+t);return this.pos=this.pos+t,e.from(r).reverse()},t.exports=s}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var n=r(0),i=r(5),o=r(12),s=r(21),a=r(19),c=r(16),u=r(3),f=r(7),h=r(44),d=r(2),p=r(49),l=r(1),g=e.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),m=p.SCRIPT_ENABLE_SIGHASH_FORKID,b=function(t,a,h,b,y,v){var S=r(72),_=r(50);l.isUndefined(v)&&(v=m);var w,I=S.shallowCopy(t);(b=new o(b),v&p.SCRIPT_ENABLE_REPLAY_PROTECTION)&&(a=(16711680|57005^a>>8)<<8|255&a);if(a&i.SIGHASH_FORKID&&v&p.SCRIPT_ENABLE_SIGHASH_FORKID)return function(t,r,n,o,s){var a=t.inputs[n];function h(t,e){var r=new c;l.isUndefined(e)?l.each(t.outputs,(function(t){t.toBufferWriter(r)})):t.outputs[e].toBufferWriter(r);var n=r.toBuffer();return f.sha256sha256(n)}d.checkArgument(s instanceof u,"For ForkId=0 signatures, satoshis or complete input must be provided");var p=e.alloc(32),g=e.alloc(32),m=e.alloc(32);r&i.SIGHASH_ANYONECANPAY||(p=function(t){var e=new c;l.each(t.inputs,(function(t){e.writeReverse(t.prevTxId),e.writeUInt32LE(t.outputIndex)}));var r=e.toBuffer();return f.sha256sha256(r)}(t)),r&i.SIGHASH_ANYONECANPAY||(31&r)===i.SIGHASH_SINGLE||(31&r)===i.SIGHASH_NONE||(g=function(t){var e=new c;l.each(t.inputs,(function(t){e.writeUInt32LE(t.sequenceNumber)}));var r=e.toBuffer();return f.sha256sha256(r)}(t)),(31&r)!==i.SIGHASH_SINGLE&&(31&r)!==i.SIGHASH_NONE?m=h(t):(31&r)===i.SIGHASH_SINGLE&&n<t.outputs.length&&(m=h(t,n));var b=new c;b.writeInt32LE(t.version),b.write(p),b.write(g),b.writeReverse(a.prevTxId),b.writeUInt32LE(a.outputIndex),b.writeVarintNum(o.toBuffer().length),b.write(o.toBuffer()),b.writeUInt64LEBN(s);var y=a.sequenceNumber;return b.writeUInt32LE(y),b.write(m),b.writeUInt32LE(t.nLockTime),b.writeUInt32LE(r>>>0),b.toBuffer()}(I,a,h,b,y);for(b.removeCodeseparators(),w=0;w<I.inputs.length;w++)I.inputs[w]=new _(I.inputs[w]).setScript(o.empty());if(I.inputs[h]=new _(I.inputs[h]).setScript(b),(31&a)===i.SIGHASH_NONE||(31&a)===i.SIGHASH_SINGLE)for(w=0;w<I.inputs.length;w++)w!==h&&(I.inputs[w].sequenceNumber=0);if((31&a)===i.SIGHASH_NONE)I.outputs=[];else if((31&a)===i.SIGHASH_SINGLE){if(h>=I.outputs.length)return g;for(I.outputs.length=h+1,w=0;w<h;w++)I.outputs[w]=new s({satoshis:u.fromBuffer(n.Buffer.from("ffffffffffffffff","hex")),script:o.empty()})}return a&i.SIGHASH_ANYONECANPAY&&(I.inputs=[I.inputs[h]]),(new c).write(I.toBuffer()).writeInt32LE(a).toBuffer()},y=function(t,e,r,n,i,o){var s=b(t,e,r,n,i,o);if(0===s.compare(g))return s;var c=f.sha256sha256(s);return c=new a(c).readReverse()};t.exports={sighashPreimage:b,sighash:y,sign:function(t,e,r,n,i,o,s){var a=y(t,r,n,i,o,s);return h.sign(a,e,"little").set({nhashtype:r})},verify:function(t,e,r,n,i,o,s){d.checkArgument(!l.isUndefined(t)),d.checkArgument(!l.isUndefined(e)&&!l.isUndefined(e.nhashtype));var a=y(t,e.nhashtype,n,i,o,s);return h.verify(a,e,r,"little")}}}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var n=r(1),i=r(3),o=r(0),s=r(6),a=r(16),c=r(29),u=r(12),f=r(2),h=r(10);function d(t){if(!(this instanceof d))return new d(t);if(!n.isObject(t))throw new TypeError("Unrecognized argument for Output");var r;this.satoshis=t.satoshis,e.isBuffer(t.script)?this._scriptBuffer=t.script:(r=n.isString(t.script)&&s.isHexa(t.script)?o.Buffer.from(t.script,"hex"):t.script,this.setScript(r))}Object.defineProperty(d.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this._script||this.setScriptFromBuffer(this._scriptBuffer),this._script}}),Object.defineProperty(d.prototype,"satoshis",{configurable:!1,enumerable:!0,get:function(){return this._satoshis},set:function(t){t instanceof i?(this._satoshisBN=t,this._satoshis=t.toNumber()):n.isString(t)?(this._satoshis=parseInt(t),this._satoshisBN=i.fromNumber(this._satoshis)):(f.checkArgument(s.isNaturalNumber(t),"Output satoshis is not a natural number"),this._satoshisBN=i.fromNumber(t),this._satoshis=t),f.checkState(s.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}}),d.prototype.invalidSatoshis=function(){return this._satoshis>9007199254740991?"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"},Object.defineProperty(d.prototype,"satoshisBN",{configurable:!1,enumerable:!0,get:function(){return this._satoshisBN},set:function(t){this._satoshisBN=t,this._satoshis=t.toNumber(),f.checkState(s.isNaturalNumber(this._satoshis),"Output satoshis is not a natural number")}}),d.prototype.toObject=d.prototype.toJSON=function(){var t={satoshis:this.satoshis};return t.script=this._scriptBuffer.toString("hex"),t},d.fromObject=function(t){return new d(t)},d.prototype.setScriptFromBuffer=function(t){this._scriptBuffer=t;try{this._script=u.fromBuffer(this._scriptBuffer),this._script._isOutput=!0}catch(t){if(!(t instanceof h.Script.InvalidBuffer))throw t;this._script=null}},d.prototype.setScript=function(t){if(t instanceof u)this._scriptBuffer=t.toBuffer(),this._script=t,this._script._isOutput=!0;else if(n.isString(t))this._script=u.fromString(t),this._scriptBuffer=this._script.toBuffer(),this._script._isOutput=!0;else{if(!e.isBuffer(t))throw new TypeError("Invalid argument type: script");this.setScriptFromBuffer(t)}return this},d.prototype.inspect=function(){var t;return t=this.script?this.script.inspect():this._scriptBuffer.toString("hex"),"<Output ("+this.satoshis+" sats) "+t+">"},d.fromBufferReader=function(t){var e={};e.satoshis=t.readUInt64LEBN();var r=t.readVarintNum();return e.script=0!==r?t.read(r):o.Buffer.from([]),new d(e)},d.prototype.toBufferWriter=function(t){t||(t=new a),t.writeUInt64LEBN(this._satoshisBN);var e=this._scriptBuffer;return t.writeVarintNum(e.length),t.write(e),t},d.prototype.getSize=function(){var t=this.script.toBuffer().length;return 8+c(t).toBuffer().length+t},t.exports=d}).call(this,r(0).Buffer)},function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}t.exports=r,r.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)}},function(t,e){"function"==typeof Object.create?t.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},function(t,e,r){"use strict";var n=r(1),i=r(6),o=[],s={};function a(){}function c(t,e){if(~o.indexOf(t))return t;if(!e)return s[t];n.isArray(e)||(e=[e]);for(var r=0;r<o.length;r++){var i=o[r],a=n.pick(i,e);if(~n.values(a).indexOf(t))return i}}function u(t){for(var e=[],r=0;r<t.length;r++)e.push(31&t.charCodeAt(r));return e}function f(t){var e=new a;i.defineImmutable(e,{name:t.name,alias:t.alias,pubkeyhash:t.pubkeyhash,privatekey:t.privatekey,scripthash:t.scripthash,xpubkey:t.xpubkey,xprivkey:t.xprivkey});var r=t.indexBy||Object.keys(t);return t.cashAddrPrefix&&n.extend(e,{cashAddrPrefix:t.cashAddrPrefix,cashAddrPrefixArray:u(t.cashAddrPrefix)}),t.networkMagic&&n.extend(e,{networkMagic:i.integerAsBuffer(t.networkMagic)}),t.port&&n.extend(e,{port:t.port}),t.dnsSeeds&&n.extend(e,{dnsSeeds:t.dnsSeeds}),o.push(e),function(t,e){for(var r=0;r<e.length;r++){var i=e[r],o=t[i];n.isUndefined(o)||n.isObject(o)||(s[o]=t)}}(e,r),e}a.prototype.toString=function(){return this.name};var h=["seed.bitcoinsv.org","seed.bitcoinunlimited.info"],d={PORT:18333,NETWORK_MAGIC:4108710900,DNS_SEEDS:h,PREFIX:"testnet",CASHADDRPREFIX:"bchtest"},p={PORT:18444,NETWORK_MAGIC:3669344250,DNS_SEEDS:[],PREFIX:"regtest",CASHADDRPREFIX:"bchreg"},l={PORT:9333,NETWORK_MAGIC:4224632057,DNS_SEEDS:["stn-seed.bitcoinsv.io"],PREFIX:"stn",CASHADDRPREFIX:"bsvstn"},g={name:"livenet",alias:"mainnet",prefix:"bitcoin",cashAddrPrefix:"bitcoincash",pubkeyhash:0,privatekey:128,scripthash:5,xpubkey:76067358,xprivkey:76066276,networkMagic:3823236072,port:8333,dnsSeeds:h},m={name:"testnet",prefix:d.PREFIX,cashAddrPrefix:d.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:d.NETWORK_MAGIC},b={name:"regtest",prefix:p.PREFIX,cashAddrPrefix:p.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:p.NETWORK_MAGIC,port:p.PORT,dnsSeeds:[],indexBy:["port","name","cashAddrPrefix","networkMagic"]},y={name:"stn",prefix:l.PREFIX,cashAddrPrefix:l.CASHADDRPREFIX,pubkeyhash:111,privatekey:239,scripthash:196,xpubkey:70617039,xprivkey:70615956,networkMagic:l.NETWORK_MAGIC,indexBy:["port","name","cashAddrPrefix","networkMagic"]};f(m),f(y),f(b),f(g);var v=c("livenet"),S=c("regtest"),_=c("testnet"),w=c("stn");Object.defineProperty(_,"port",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?p.PORT:this.stnEnabled?l.PORT:d.PORT}}),Object.defineProperty(_,"networkMagic",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?i.integerAsBuffer(p.NETWORK_MAGIC):this.stnEnabled?i.integerAsBuffer(l.NETWORK_MAGIC):i.integerAsBuffer(d.NETWORK_MAGIC)}}),Object.defineProperty(_,"dnsSeeds",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?p.DNS_SEEDS:this.stnEnabled?l.DNS_SEEDS:d.DNS_SEEDS}}),Object.defineProperty(_,"cashAddrPrefix",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?p.CASHADDRPREFIX:this.stnEnabled?l.CASHADDRPREFIX:d.CASHADDRPREFIX}}),Object.defineProperty(_,"cashAddrPrefixArray",{enumerable:!0,configurable:!1,get:function(){return this.regtestEnabled?u(p.CASHADDRPREFIX):this.stnEnabled?l.cashAddrPrefixToArray(l.CASHADDRPREFIX):u(d.CASHADDRPREFIX)}}),t.exports={add:f,remove:function(t){for(var e=0;e<o.length;e++)o[e]===t&&o.splice(e,1);!function(t,e){for(var r=0;r<e.length;r++){var n=e[r];s[n]===t&&delete s[n]}}(t,Object.keys(s))},defaultNetwork:v,livenet:v,mainnet:v,testnet:_,regtest:S,stn:w,get:c,enableRegtest:function(){_.regtestEnabled=!0},disableRegtest:function(){_.regtestEnabled=!1},enableStn:function(){_.stnEnabled=!0},disableStn:function(){_.stnEnabled=!1}}},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,r){"use strict";(function(e){var n=r(1),i=r(2),o=r(10),s=r(28),a=r(24),c=r(7),u=r(6),f=r(14);function h(t,e,r){if(!(this instanceof h))return new h(t,e,r);if(n.isArray(t)&&n.isNumber(e))return h.createMultisig(t,e,r);if(t instanceof h)return t;if(i.checkArgument(t,"First argument is required, please include address data.","guide/address.html"),e&&!a.get(e))throw new TypeError('Second argument must be "livenet", "testnet", or "regtest".');if(r&&r!==h.PayToPublicKeyHash&&r!==h.PayToScriptHash)throw new TypeError('Third argument must be "pubkeyhash" or "scripthash".');var o=this._classifyArguments(t,e,r);return o.network=o.network||a.get(e)||a.defaultNetwork,o.type=o.type||r||h.PayToPublicKeyHash,u.defineImmutable(this,{hashBuffer:o.hashBuffer,network:o.network,type:o.type}),this}h.prototype._classifyArguments=function(t,r,i){if((t instanceof e||t instanceof Uint8Array)&&20===t.length)return h._transformHash(t);if((t instanceof e||t instanceof Uint8Array)&&21===t.length)return h._transformBuffer(t,r,i);if(t instanceof f)return h._transformPublicKey(t);if(t instanceof d)return h._transformScript(t,r);if("string"==typeof t)return h._transformString(t,r,i);if(n.isObject(t))return h._transformObject(t);throw new TypeError("First argument is an unrecognized data format.")},h.PayToPublicKeyHash="pubkeyhash",h.PayToScriptHash="scripthash",h._transformHash=function(t){var r={};if(!(t instanceof e||t instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(20!==t.length)throw new TypeError("Address hashbuffers must be exactly 20 bytes.");return r.hashBuffer=t,r},h._transformObject=function(t){return i.checkArgument(t.hash||t.hashBuffer,"Must provide a `hash` or `hashBuffer` property"),i.checkArgument(t.type,"Must provide a `type` property"),{hashBuffer:t.hash?e.from(t.hash,"hex"):t.hashBuffer,network:a.get(t.network)||a.defaultNetwork,type:t.type}},h._classifyFromVersion=function(t){var e={},r=a.get(t[0],"pubkeyhash"),n=a.get(t[0],"scripthash");return r?(e.network=r,e.type=h.PayToPublicKeyHash):n&&(e.network=n,e.type=h.PayToScriptHash),e},h._transformBuffer=function(t,r,n){var i={};if(!(t instanceof e||t instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(21!==t.length)throw new TypeError("Address buffers must be exactly 21 bytes.");var o=a.get(r),s=h._classifyFromVersion(t);if(r&&!o)throw new TypeError("Unknown network");if(!s.network||o&&o!==s.network)throw new TypeError("Address has mismatched network type.");if(!s.type||n&&n!==s.type)throw new TypeError("Address has mismatched type.");return i.hashBuffer=t.slice(1),i.network=s.network,i.type=s.type,i},h._transformPublicKey=function(t){var e={};if(!(t instanceof f))throw new TypeError("Address must be an instance of PublicKey.");return e.hashBuffer=c.sha256ripemd160(t.toBuffer()),e.type=h.PayToPublicKeyHash,e},h._transformScript=function(t,e){i.checkArgument(t instanceof d,"script must be a Script instance");var r=t.getAddressInfo(e);if(!r)throw new o.Script.CantDeriveAddress(t);return r},h.createMultisig=function(t,e,r){return r=r||t[0].network||a.defaultNetwork,h.payingTo(d.buildMultisigOut(t,e),r)},h._transformString=function(t,e,r){if("string"!=typeof t)throw new TypeError("data parameter supplied is not a string.");if(t.length<27)throw new Error("Invalid Address string provided");t=t.trim();var n=a.get(e);if(e&&!n)throw new TypeError("Unknown network");var i=s.decode(t);return h._transformBuffer(i,e,r)},h.fromPublicKey=function(t,e){var r=h._transformPublicKey(t);return e=e||a.defaultNetwork,new h(r.hashBuffer,e,r.type)},h.fromPrivateKey=function(t,e){let r=f.fromPrivateKey(t);return e=e||t.network||a.defaultNetwork,h.fromPublicKey(r,e)},h.fromPublicKeyHash=function(t,e){var r=h._transformHash(t);return new h(r.hashBuffer,e,h.PayToPublicKeyHash)},h.fromScriptHash=function(t,e){i.checkArgument(t,"hash parameter is required");var r=h._transformHash(t);return new h(r.hashBuffer,e,h.PayToScriptHash)},h.payingTo=function(t,e){return i.checkArgument(t,"script is required"),i.checkArgument(t instanceof d,"script must be instance of Script"),h.fromScriptHash(c.sha256ripemd160(t.toBuffer()),e)},h.fromScript=function(t,e){i.checkArgument(t instanceof d,"script must be a Script instance");var r=h._transformScript(t,e);return new h(r.hashBuffer,e,r.type)},h.fromBuffer=function(t,e,r){var n=h._transformBuffer(t,e,r);return new h(n.hashBuffer,n.network,n.type)},h.fromHex=function(t,r,n){return h.fromBuffer(e.from(t,"hex"),r,n)},h.fromString=function(t,e,r){var n=h._transformString(t,e,r);return new h(n.hashBuffer,n.network,n.type)},h.fromObject=function(t){return i.checkState(u.isHexa(t.hash),'Unexpected hash property, "'+t.hash+'", expected to be hex.'),new h(e.from(t.hash,"hex"),t.network,t.type)},h.getValidationError=function(t,e,r){var n;try{new h(t,e,r)}catch(t){n=t}return n},h.isValid=function(t,e,r){return!h.getValidationError(t,e,r)},h.prototype.isPayToPublicKeyHash=function(){return this.type===h.PayToPublicKeyHash},h.prototype.isPayToScriptHash=function(){return this.type===h.PayToScriptHash},h.prototype.toBuffer=function(){var t=e.from([this.network[this.type]]);return e.concat([t,this.hashBuffer])},h.prototype.toHex=function(){return this.toBuffer().toString("hex")},h.prototype.toObject=h.prototype.toJSON=function(){return{hash:this.hashBuffer.toString("hex"),type:this.type,network:this.network.toString()}},h.prototype.inspect=function(){return"<Address: "+this.toString()+", type: "+this.type+", network: "+this.network+">"},h.prototype.toString=function(){return s.encode(this.toBuffer())},t.exports=h;var d=r(12)}).call(this,r(0).Buffer)},function(t,e,r){"use strict";var n=r(13),i=r(22);function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}e.BlockHash=o,o.prototype.update=function(t,e){if(t=n.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=n.join32(t,0,t.length-r,this.endian);for(var i=0;i<t.length;i+=this._delta32)this._update(t,i,i+this._delta32)}return this},o.prototype.digest=function(t){return this.update(this._pad()),i(null===this.pending),this._digest(t)},o.prototype._pad=function(){var t=this.pendingTotal,e=this._delta8,r=e-(t+this.padLength)%e,n=new Array(r+this.padLength);n[0]=128;for(var i=1;i<r;i++)n[i]=0;if(t<<=3,"big"===this.endian){for(var o=8;o<this.padLength;o++)n[i++]=0;n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=t>>>24&255,n[i++]=t>>>16&255,n[i++]=t>>>8&255,n[i++]=255&t}else for(n[i++]=255&t,n[i++]=t>>>8&255,n[i++]=t>>>16&255,n[i++]=t>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;o<this.padLength;o++)n[i++]=0;return n}},function(t,e,r){"use strict";(function(e){var n=r(1),i=r(35),o=r(0),s=r(7).sha256sha256,a=function t(r){if(!(this instanceof t))return new t(r);if(e.isBuffer(r)){var n=r;this.fromBuffer(n)}else if("string"==typeof r){var i=r;this.fromString(i)}};a.prototype.set=function(t){return this.buf=t.buf||this.buf||void 0,this},a.validChecksum=function(t,e){return n.isString(t)&&(t=o.Buffer.from(i.decode(t))),n.isString(e)&&(e=o.Buffer.from(i.decode(e))),e||(e=t.slice(-4),t=t.slice(0,-4)),a.checksum(t).toString("hex")===e.toString("hex")},a.decode=function(t){if("string"!=typeof t)throw new Error("Input must be a string");var r=e.from(i.decode(t));if(r.length<4)throw new Error("Input string too short");var n=r.slice(0,-4),o=r.slice(-4),a=s(n).slice(0,4);if(o.toString("hex")!==a.toString("hex"))throw new Error("Checksum mismatch");return n},a.checksum=function(t){return s(t).slice(0,4)},a.encode=function(t){if(!e.isBuffer(t))throw new Error("Input must be a buffer");var r=e.alloc(t.length+4),n=a.checksum(t);return t.copy(r),n.copy(r,t.length),i.encode(r)},a.prototype.fromBuffer=function(t){return this.buf=t,this},a.fromBuffer=function(t){return(new a).fromBuffer(t)},a.fromHex=function(t){return a.fromBuffer(e.from(t,"hex"))},a.prototype.fromString=function(t){var e=a.decode(t);return this.buf=e,this},a.fromString=function(t){var e=a.decode(t);return new i(e)},a.prototype.toBuffer=function(){return this.buf},a.prototype.toHex=function(){return this.toBuffer().toString("hex")},a.prototype.toString=function(){return a.encode(this.buf)},t.exports=a}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var n=r(16),i=r(19),o=r(3),s=function t(r){if(!(this instanceof t))return new t(r);if(e.isBuffer(r))this.buf=r;else if("number"==typeof r){var n=r;this.fromNumber(n)}else if(r instanceof o){var i=r;this.fromBN(i)}else if(r){var s=r;this.set(s)}};s.prototype.set=function(t){return this.buf=t.buf||this.buf,this},s.prototype.fromString=function(t){return this.set({buf:e.from(t,"hex")}),this},s.prototype.toString=function(){return this.buf.toString("hex")},s.prototype.fromBuffer=function(t){return this.buf=t,this},s.prototype.fromBufferReader=function(t){return this.buf=t.readVarintBuf(),this},s.prototype.fromBN=function(t){return this.buf=n().writeVarintBN(t).concat(),this},s.prototype.fromNumber=function(t){return this.buf=n().writeVarintNum(t).concat(),this},s.prototype.toBuffer=function(){return this.buf},s.prototype.toBN=function(){return i(this.buf).readVarintBN()},s.prototype.toNumber=function(){return i(this.buf).readVarintNum()},t.exports=s}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var n=r(1),i=r(2),o=r(10),s=r(16),a=r(0),c=r(6),u=r(12),f=r(20),h=r(21);function d(t){return this instanceof d?t?this._fromObject(t):void 0:new d(t)}d.MAXINT=4294967295,d.DEFAULT_SEQNUMBER=4294967295,d.DEFAULT_LOCKTIME_SEQNUMBER=4294967294,d.DEFAULT_RBF_SEQNUMBER=4294967293,d.BASE_SIZE=40,Object.defineProperty(d.prototype,"script",{configurable:!1,enumerable:!0,get:function(){return this.isNull()?null:(this._script||(this._script=new u(this._scriptBuffer),this._script._isInput=!0),this._script)}}),d.fromObject=function(t){return i.checkArgument(n.isObject(t)),(new d)._fromObject(t)},d.prototype._fromObject=function(t){var e;if(e=n.isString(t.prevTxId)&&c.isHexa(t.prevTxId)?a.Buffer.from(t.prevTxId,"hex"):t.prevTxId,this.output=t.output?t.output instanceof h?t.output:new h(t.output):void 0,this.prevTxId=e||t.txidbuf,this.outputIndex=n.isUndefined(t.outputIndex)?t.txoutnum:t.outputIndex,this.sequenceNumber=n.isUndefined(t.sequenceNumber)?n.isUndefined(t.seqnum)?4294967295:t.seqnum:t.sequenceNumber,n.isUndefined(t.script)&&n.isUndefined(t.scriptBuffer))throw new o.Transaction.Input.MissingScript;return this.setScript(t.scriptBuffer||t.script),this},d.prototype.toObject=d.prototype.toJSON=function(){var t={prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,sequenceNumber:this.sequenceNumber,script:this._scriptBuffer.toString("hex")};return this.script&&(t.scriptString=this.script.toString()),this.output&&(t.output=this.output.toObject()),t},d.fromBufferReader=function(t){var e=new d;return e.prevTxId=t.readReverse(32),e.outputIndex=t.readUInt32LE(),e._scriptBuffer=t.readVarLengthBuffer(),e.sequenceNumber=t.readUInt32LE(),e},d.prototype.toBufferWriter=function(t){t||(t=new s),t.writeReverse(this.prevTxId),t.writeUInt32LE(this.outputIndex);var e=this._scriptBuffer;return t.writeVarintNum(e.length),t.write(e),t.writeUInt32LE(this.sequenceNumber),t},d.prototype.setScript=function(t){if(this._script=null,t instanceof u)this._script=t,this._script._isInput=!0,this._scriptBuffer=t.toBuffer();else if(null===t)this._script=u.empty(),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else if(c.isHexa(t))this._scriptBuffer=a.Buffer.from(t,"hex");else if(n.isString(t))this._script=new u(t),this._script._isInput=!0,this._scriptBuffer=this._script.toBuffer();else{if(!e.isBuffer(t))throw new TypeError("Invalid argument type: script");this._scriptBuffer=a.Buffer.from(t)}return this},d.prototype.getSignatures=function(){throw new o.AbstractMethodInvoked("Trying to sign unsupported output type (only P2PKH and P2SH multisig inputs are supported) for input: "+JSON.stringify(this))},d.prototype.isFullySigned=function(){throw new o.AbstractMethodInvoked("Input#isFullySigned")},d.prototype.isFinal=function(){return this.sequenceNumber===d.MAXINT},d.prototype.addSignature=function(){throw new o.AbstractMethodInvoked("Input#addSignature")},d.prototype.clearSignatures=function(){throw new o.AbstractMethodInvoked("Input#clearSignatures")},d.prototype.isValidSignature=function(t,e){return e.signature.nhashtype=e.sigtype,f.verify(t,e.signature,e.publicKey,e.inputIndex,this.output.script,this.output.satoshisBN)},d.prototype.isNull=function(){return"0000000000000000000000000000000000000000000000000000000000000000"===this.prevTxId.toString("hex")&&4294967295===this.outputIndex},d.prototype._estimateSize=function(){return this.toBufferWriter().toBuffer().length},t.exports=d}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var n=r(1),i=r(2),o=r(23),s=r(6),a=r(14),c=r(10),u=r(5);function f(t){if(!(this instanceof f))return new f(t);if(t instanceof f)return t;if(n.isObject(t))return this._fromObject(t);throw new c.InvalidArgument("TransactionSignatures must be instantiated from an object")}o(f,u),f.prototype._fromObject=function(t){return this._checkObjectArgs(t),this.publicKey=new a(t.publicKey),this.prevTxId=e.isBuffer(t.prevTxId)?t.prevTxId:e.from(t.prevTxId,"hex"),this.outputIndex=t.outputIndex,this.inputIndex=t.inputIndex,this.signature=t.signature instanceof u?t.signature:e.isBuffer(t.signature)?u.fromBuffer(t.signature):u.fromString(t.signature),this.sigtype=t.sigtype,this},f.prototype._checkObjectArgs=function(t){i.checkArgument(a(t.publicKey),"publicKey"),i.checkArgument(!n.isUndefined(t.inputIndex),"inputIndex"),i.checkArgument(!n.isUndefined(t.outputIndex),"outputIndex"),i.checkState(n.isNumber(t.inputIndex),"inputIndex must be a number"),i.checkState(n.isNumber(t.outputIndex),"outputIndex must be a number"),i.checkArgument(t.signature,"signature"),i.checkArgument(t.prevTxId,"prevTxId"),i.checkState(t.signature instanceof u||e.isBuffer(t.signature)||s.isHexa(t.signature),"signature must be a buffer or hexa value"),i.checkState(e.isBuffer(t.prevTxId)||s.isHexa(t.prevTxId),"prevTxId must be a buffer or hexa value"),i.checkArgument(t.sigtype,"sigtype"),i.checkState(n.isNumber(t.sigtype),"sigtype must be a number")},f.prototype.toObject=f.prototype.toJSON=function(){return{publicKey:this.publicKey.toString(),prevTxId:this.prevTxId.toString("hex"),outputIndex:this.outputIndex,inputIndex:this.inputIndex,signature:this.signature.toString(),sigtype:this.sigtype}},f.fromObject=function(t){return i.checkArgument(t),new f(t)},t.exports=f}).call(this,r(0).Buffer)},function(t,e,r){"use strict";var n=r(9),i=r(8),o=i.getNAF,s=i.getJSF,a=i.assert;function c(t,e){this.type=t,this.p=new n(e.p,16),this.red=e.prime?n.red(e.prime):n.mont(this.p),this.zero=new n(0).toRed(this.red),this.one=new n(1).toRed(this.red),this.two=new n(2).toRed(this.red),this.n=e.n&&new n(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function u(t,e){this.curve=t,this.type=e,this.precomputed=null}t.exports=c,c.prototype.point=function(){throw new Error("Not implemented")},c.prototype.validate=function(){throw new Error("Not implemented")},c.prototype._fixedNafMul=function(t,e){a(t.precomputed);var r=t._getDoubles(),n=o(e,1,this._bitLength),i=(1<<r.step+1)-(r.step%2==0?2:1);i/=3;var s,c,u=[];for(s=0;s<n.length;s+=r.step){c=0;for(var f=s+r.step-1;f>=s;f--)c=(c<<1)+n[f];u.push(c)}for(var h=this.jpoint(null,null,null),d=this.jpoint(null,null,null),p=i;p>0;p--){for(s=0;s<u.length;s++)(c=u[s])===p?d=d.mixedAdd(r.points[s]):c===-p&&(d=d.mixedAdd(r.points[s].neg()));h=h.add(d)}return h.toP()},c.prototype._wnafMul=function(t,e){var r=4,n=t._getNAFPoints(r);r=n.wnd;for(var i=n.points,s=o(e,r,this._bitLength),c=this.jpoint(null,null,null),u=s.length-1;u>=0;u--){for(var f=0;u>=0&&0===s[u];u--)f++;if(u>=0&&f++,c=c.dblp(f),u<0)break;var h=s[u];a(0!==h),c="affine"===t.type?h>0?c.mixedAdd(i[h-1>>1]):c.mixedAdd(i[-h-1>>1].neg()):h>0?c.add(i[h-1>>1]):c.add(i[-h-1>>1].neg())}return"affine"===t.type?c.toP():c},c.prototype._wnafMulAdd=function(t,e,r,n,i){var a,c,u,f=this._wnafT1,h=this._wnafT2,d=this._wnafT3,p=0;for(a=0;a<n;a++){var l=(u=e[a])._getNAFPoints(t);f[a]=l.wnd,h[a]=l.points}for(a=n-1;a>=1;a-=2){var g=a-1,m=a;if(1===f[g]&&1===f[m]){var b=[e[g],null,null,e[m]];0===e[g].y.cmp(e[m].y)?(b[1]=e[g].add(e[m]),b[2]=e[g].toJ().mixedAdd(e[m].neg())):0===e[g].y.cmp(e[m].y.redNeg())?(b[1]=e[g].toJ().mixedAdd(e[m]),b[2]=e[g].add(e[m].neg())):(b[1]=e[g].toJ().mixedAdd(e[m]),b[2]=e[g].toJ().mixedAdd(e[m].neg()));var y=[-3,-1,-5,-7,0,7,5,1,3],v=s(r[g],r[m]);for(p=Math.max(v[0].length,p),d[g]=new Array(p),d[m]=new Array(p),c=0;c<p;c++){var S=0|v[0][c],_=0|v[1][c];d[g][c]=y[3*(S+1)+(_+1)],d[m][c]=0,h[g]=b}}else d[g]=o(r[g],f[g],this._bitLength),d[m]=o(r[m],f[m],this._bitLength),p=Math.max(d[g].length,p),p=Math.max(d[m].length,p)}var w=this.jpoint(null,null,null),I=this._wnafT4;for(a=p;a>=0;a--){for(var O=0;a>=0;){var P=!0;for(c=0;c<n;c++)I[c]=0|d[c][a],0!==I[c]&&(P=!1);if(!P)break;O++,a--}if(a>=0&&O++,w=w.dblp(O),a<0)break;for(c=0;c<n;c++){var A=I[c];0!==A&&(A>0?u=h[c][A-1>>1]:A<0&&(u=h[c][-A-1>>1].neg()),w="affine"===u.type?w.mixedAdd(u):w.add(u))}}for(a=0;a<n;a++)h[a]=null;return i?w:w.toP()},c.BasePoint=u,u.prototype.eq=function(){throw new Error("Not implemented")},u.prototype.validate=function(){return this.curve.validate(this)},c.prototype.decodePoint=function(t,e){t=i.toArray(t,e);var r=this.p.byteLength();if((4===t[0]||6===t[0]||7===t[0])&&t.length-1==2*r)return 6===t[0]?a(t[t.length-1]%2==0):7===t[0]&&a(t[t.length-1]%2==1),this.point(t.slice(1,1+r),t.slice(1+r,1+2*r));if((2===t[0]||3===t[0])&&t.length-1===r)return this.pointFromX(t.slice(1,1+r),3===t[0]);throw new Error("Unknown point format")},u.prototype.encodeCompressed=function(t){return this.encode(t,!0)},u.prototype._encode=function(t){var e=this.curve.p.byteLength(),r=this.getX().toArray("be",e);return t?[this.getY().isEven()?2:3].concat(r):[4].concat(r,this.getY().toArray("be",e))},u.prototype.encode=function(t,e){return i.encode(this._encode(e),t)},u.prototype.precompute=function(t){if(this.precomputed)return this;var e={doubles:null,naf:null,beta:null};return e.naf=this._getNAFPoints(8),e.doubles=this._getDoubles(4,t),e.beta=this._getBeta(),this.precomputed=e,this},u.prototype._hasDoubles=function(t){if(!this.precomputed)return!1;var e=this.precomputed.doubles;return!!e&&e.points.length>=Math.ceil((t.bitLength()+1)/e.step)},u.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i<e;i+=t){for(var o=0;o<t;o++)n=n.dbl();r.push(n)}return{step:t,points:r}},u.prototype._getNAFPoints=function(t){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var e=[this],r=(1<<t)-1,n=1===r?null:this.dbl(),i=1;i<r;i++)e[i]=e[i-1].add(n);return{wnd:t,points:e}},u.prototype._getBeta=function(){return null},u.prototype.dblp=function(t){for(var e=this,r=0;r<t;r++)e=e.dbl();return e}},function(t,e,r){var n=e;n.utils=r(13),n.common=r(27),n.sha=r(90),n.ripemd=r(94),n.hmac=r(95),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},function(t,e,r){"use strict";(function(e){var n=r(1),i=r(26),o=r(28),s=r(3),a=r(6),c=r(24),u=r(11),f=r(14),h=r(38),d=r(2);function p(t,e){if(!(this instanceof p))return new p(t,e);if(t instanceof p)return t;var r=this._classifyArguments(t,e);if(!r.bn||0===r.bn.cmp(new s(0)))throw new TypeError("Number can not be equal to zero, undefined, null or false");if(!r.bn.lt(u.getN()))throw new TypeError("Number must be less than N");if(void 0===r.network)throw new TypeError('Must specify the network ("livenet" or "testnet")');return a.defineImmutable(this,{bn:r.bn,compressed:r.compressed,network:r.network}),Object.defineProperty(this,"publicKey",{configurable:!1,enumerable:!0,get:this.toPublicKey.bind(this)}),this}p.prototype._classifyArguments=function(t,r){var i={compressed:!0,network:r?c.get(r):c.defaultNetwork};if(n.isUndefined(t)||n.isNull(t))i.bn=p._getRandomBN();else if(t instanceof s)i.bn=t;else if(t instanceof e||t instanceof Uint8Array)i=p._transformBuffer(t,r);else if(t.bn&&t.network)i=p._transformObject(t);else if(!r&&c.get(t))i.bn=p._getRandomBN(),i.network=c.get(t);else{if("string"!=typeof t)throw new TypeError("First argument is an unrecognized data type.");a.isHexa(t)?i.bn=new s(e.from(t,"hex")):i=p._transformWIF(t,r)}return i},p._getRandomBN=function(){var t,e;do{var r=h.getRandomBuffer(32);t=(e=s.fromBuffer(r)).lt(u.getN())}while(!t);return e},p._transformBuffer=function(t,e){var r={};if(32===t.length)return p._transformBNBuffer(t,e);if(r.network=c.get(t[0],"privatekey"),!r.network)throw new Error("Invalid network");if(e&&r.network!==c.get(e))throw new TypeError("Private key network mismatch");if(34===t.length&&1===t[33])r.compressed=!0;else{if(33!==t.length)throw new Error("Length of buffer must be 33 (uncompressed) or 34 (compressed)");r.compressed=!1}return r.bn=s.fromBuffer(t.slice(1,33)),r},p._transformBNBuffer=function(t,e){var r={};return r.network=c.get(e)||c.defaultNetwork,r.bn=s.fromBuffer(t),r.compressed=!1,r},p._transformWIF=function(t,e){return p._transformBuffer(o.decode(t),e)},p.fromBuffer=function(t,e){return new p(t,e)},p.fromHex=function(t,r){return p.fromBuffer(e.from(t,"hex"),r)},p._transformObject=function(t){return{bn:new s(t.bn,"hex"),network:c.get(t.network),compressed:t.compressed}},p.fromString=p.fromWIF=function(t){return d.checkArgument(n.isString(t),"First argument is expected to be a string."),new p(t)},p.fromObject=p.fromJSON=function(t){return d.checkArgument(n.isObject(t),"First argument is expected to be an object."),new p(t)},p.fromRandom=function(t){var e=p._getRandomBN();return new p(e,t)},p.getValidationError=function(t,e){var r;try{new p(t,e)}catch(t){r=t}return r},p.isValid=function(t,e){return!!t&&!p.getValidationError(t,e)},p.prototype.toString=function(){return this.toWIF()},p.prototype.toWIF=function(){var t,r=this.network;return t=this.compressed?e.concat([e.from([r.privatekey]),this.bn.toBuffer({size:32}),e.from([1])]):e.concat([e.from([r.privatekey]),this.bn.toBuffer({size:32})]),o.encode(t)},p.prototype.toBigNumber=function(){return this.bn},p.prototype.toBuffer=function(){return this.bn.toBuffer({size:32})},p.prototype.toHex=function(){return this.toBuffer().toString("hex")},p.prototype.toPublicKey=function(){return this._pubkey||(this._pubkey=f.fromPrivateKey(this)),this._pubkey},p.prototype.toAddress=function(t){var e=this.toPublicKey();return i.fromPublicKey(e,t||this.network)},p.prototype.toObject=p.prototype.toJSON=function(){return{bn:this.bn.toString("hex"),compressed:this.compressed,network:this.network.toString()}},p.prototype.inspect=function(){var t=this.compressed?"":", uncompressed";return"<PrivateKey: "+this.toHex()+", network: "+this.network+t+">"},t.exports=p}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var n=r(1),i=r(54),o=r(0),s="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".split(""),a=function t(r){if(!(this instanceof t))return new t(r);if(e.isBuffer(r)){var n=r;this.fromBuffer(n)}else if("string"==typeof r){var i=r;this.fromString(i)}};a.validCharacters=function(t){return o.Buffer.isBuffer(t)&&(t=t.toString()),n.every(n.map(t,(function(t){return n.includes(s,t)})))},a.prototype.set=function(t){return this.buf=t.buf||this.buf||void 0,this},a.encode=function(t){if(!o.Buffer.isBuffer(t))throw new Error("Input should be a buffer");return i.encode(t)},a.decode=function(t){if("string"!=typeof t)throw new Error("Input should be a string");return e.from(i.decode(t))},a.prototype.fromBuffer=function(t){return this.buf=t,this},a.fromBuffer=function(t){return(new a).fromBuffer(t)},a.fromHex=function(t){return a.fromBuffer(e.from(t,"hex"))},a.prototype.fromString=function(t){var e=a.decode(t);return this.buf=e,this},a.fromString=function(t){return(new a).fromString(t)},a.prototype.toBuffer=function(){return this.buf},a.prototype.toHex=function(){return this.toBuffer().toString("hex")},a.prototype.toString=function(){return a.encode(this.buf)},t.exports=a}).call(this,r(0).Buffer)},function(t,e,r){"use strict";var n=r(133);t.exports=Function.prototype.bind||n},function(t,e,r){t.exports=r(72),t.exports.Input=r(50),t.exports.Output=r(21),t.exports.UnspentOutput=r(73),t.exports.Signature=r(31),t.exports.Sighash=r(20)},function(t,e,r){"use strict";(function(e,n){function i(){}i.getRandomBuffer=function(t){return e.browser?i.getRandomBufferBrowser(t):i.getRandomBufferNode(t)},i.getRandomBufferNode=function(t){return r(15).randomBytes(t)},i.getRandomBufferBrowser=function(t){if(!window.crypto&&!window.msCrypto)throw new Error("window.crypto not available");var e;if(window.crypto&&window.crypto.getRandomValues)e=window.crypto;else{if(!window.msCrypto||!window.msCrypto.getRandomValues)throw new Error("window.crypto.getRandomValues not available");e=window.msCrypto}var r=new Uint8Array(t);return e.getRandomValues(r),n.from(r)},t.exports=i}).call(this,r(18),r(0).Buffer)},function(t,e,r){"use strict";(function(e){var n=r(1),i=r(3),o=r(19),s=r(16),a=r(7),c=r(2),u=function t(e){if(!(this instanceof t))return new t(e);var r=t._from(e);return this.version=r.version,this.prevHash=r.prevHash,this.merkleRoot=r.merkleRoot,this.time=r.time,this.timestamp=r.time,this.bits=r.bits,this.nonce=r.nonce,r.hash&&c.checkState(this.hash===r.hash,"Argument object hash property does not match block hash."),this};u._from=function(t){var r={};if(e.isBuffer(t))r=u._fromBufferReader(o(t));else{if(!n.isObject(t))throw new TypeError("Unrecognized argument for BlockHeader");r=u._fromObject(t)}return r},u._fromObject=function(t){c.checkArgument(t,"data is required");var r=t.prevHash,i=t.merkleRoot;return n.isString(t.prevHash)&&(r=e.from(t.prevHash,"hex").reverse()),n.isString(t.merkleRoot)&&(i=e.from(t.merkleRoot,"hex").reverse()),{hash:t.hash,version:t.version,prevHash:r,merkleRoot:i,time:t.time,timestamp:t.time,bits:t.bits,nonce:t.nonce}},u.fromObject=function(t){var e=u._fromObject(t);return new u(e)},u.fromRawBlock=function(t){e.isBuffer(t)||(t=e.from(t,"binary"));var r=o(t);r.pos=u.Constants.START_OF_HEADER;var n=u._fromBufferReader(r);return new u(n)},u.fromBuffer=function(t){var e=u._fromBufferReader(o(t));return new u(e)},u.fromString=function(t){var r=e.from(t,"hex");return u.fromBuffer(r)},u._fromBufferReader=function(t){var e={};return e.version=t.readInt32LE(),e.prevHash=t.read(32),e.merkleRoot=t.read(32),e.time=t.readUInt32LE(),e.bits=t.readUInt32LE(),e.nonce=t.readUInt32LE(),e},u.fromBufferReader=function(t){var e=u._fromBufferReader(t);return new u(e)},u.prototype.toObject=u.prototype.toJSON=function(){return{hash:this.hash,version:this.version,prevHash:e.from(this.prevHash).reverse().toString("hex"),merkleRoot:e.from(this.merkleRoot).reverse().toString("hex"),time:this.time,bits:this.bits,nonce:this.nonce}},u.prototype.toBuffer=function(){return this.toBufferWriter().concat()},u.prototype.toString=function(){return this.toBuffer().toString("hex")},u.prototype.toBufferWriter=function(t){return t||(t=new s),t.writeInt32LE(this.version),t.write(this.prevHash),t.write(this.merkleRoot),t.writeUInt32LE(this.time),t.writeUInt32LE(this.bits),t.writeUInt32LE(this.nonce),t},u.prototype.getTargetDifficulty=function(t){t=t||this.bits;for(var e=new i(16777215&t),r=8*((t>>>24)-3);r-- >0;)e=e.mul(new i(2));return e},u.prototype.getDifficulty=function(){var t=this.getTargetDifficulty(486604799).mul(new i(Math.pow(10,8))),e=this.getTargetDifficulty(),r=t.div(e).toString(10),n=r.length-8;return r=r.slice(0,n)+"."+r.slice(n),parseFloat(r)},u.prototype._getHash=function(){var t=this.toBuffer();return a.sha256sha256(t)};var f={configurable:!1,enumerable:!0,get:function(){return this._id||(this._id=o(this._getHash()).readReverse().toString("hex")),this._id},set:n.noop};Object.defineProperty(u.prototype,"id",f),Object.defineProperty(u.prototype,"hash",f),u.prototype.validTimestamp=function(){var t=Math.round((new Date).getTime()/1e3);return!(this.time>t+u.Constants.MAX_TIME_OFFSET)},u.prototype.validProofOfWork=function(){var t=new i(this.id,"hex"),e=this.getTargetDifficulty();return!(t.cmp(e)>0)},u.prototype.inspect=function(){return"<BlockHeader "+this.id+">"},u.Constants={START_OF_HEADER:8,MAX_TIME_OFFSET:7200,LARGEST_HASH:new i("10000000000000000000000000000000000000000000000000000000000000000","hex")},t.exports=u}).call(this,r(0).Buffer)},function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e,r){"use strict";var n=e;n.version=r(85).version,n.utils=r(8),n.rand=r(56),n.curve=r(57),n.curves=r(43),n.ec=r(97),n.eddsa=r(101)},function(t,e){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},function(t,e,r){"use strict";var n,i=e,o=r(33),s=r(57),a=r(8).assert;function c(t){"short"===t.type?this.curve=new s.short(t):"edwards"===t.type?this.curve=new s.edwards(t):this.curve=new s.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,a(this.g.validate(),"Invalid curve"),a(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function u(t,e){Object.defineProperty(i,t,{configurable:!0,enumerable:!0,get:function(){var r=new c(e);return Object.defineProperty(i,t,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=c,u("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),u("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),u("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),u("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),u("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),u("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),u("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=r(96)}catch(t){n=void 0}u("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},function(t,e,r){"use strict";(function(e){var n=r(3),i=r(11),o=r(5),s=r(14),a=r(38),c=r(7),u=r(1),f=r(2),h=function t(e){if(!(this instanceof t))return new t(e);e&&this.set(e)};h.prototype.set=function(t){if(this.hashbuf=t.hashbuf||this.hashbuf,this.endian=t.endian||this.endian,this.privkey=t.privkey||this.privkey,this.pubkey=t.pubkey||(this.privkey?this.privkey.publicKey:this.pubkey),t.sig)if(e.isBuffer(t.sig)){var n=r(5);this.sig=n.fromDER(t.sig)}else this.sig=t.sig;else this.sig=this.sig;return this.k=t.k||this.k,this.verified=t.verified||this.verified,this},h.prototype.privkey2pubkey=function(){this.pubkey=this.privkey.toPublicKey()},h.prototype.calci=function(){for(var t=0;t<4;t++){var e;this.sig.i=t;try{e=this.toPublicKey()}catch(t){console.error(t);continue}if(e.point.eq(this.pubkey.point))return this.sig.compressed=this.pubkey.compressed,this}throw this.sig.i=void 0,new Error("Unable to find valid recovery factor")},h.fromString=function(t){var e=JSON.parse(t);return new h(e)},h.prototype.randomK=function(){var t,e=i.getN();do{t=n.fromBuffer(a.getRandomBuffer(32))}while(!t.lt(e)||!t.gt(n.Zero));return this.k=t,this},h.prototype.deterministicK=function(t){u.isUndefined(t)&&(t=0);var r=e.alloc(32);r.fill(1);var o=e.alloc(32);o.fill(0);var s=this.privkey.bn.toBuffer({size:32}),a="little"===this.endian?e.from(this.hashbuf).reverse():this.hashbuf;o=c.sha256hmac(e.concat([r,e.from([0]),s,a]),o),r=c.sha256hmac(r,o),o=c.sha256hmac(e.concat([r,e.from([1]),s,a]),o),r=c.sha256hmac(r,o),r=c.sha256hmac(r,o);for(var f=n.fromBuffer(r),h=i.getN(),d=0;d<t||!f.lt(h)||!f.gt(n.Zero);d++)o=c.sha256hmac(e.concat([r,e.from([0])]),o),r=c.sha256hmac(r,o),r=c.sha256hmac(r,o),f=n.fromBuffer(r);return this.k=f,this},h.prototype.toPublicKey=function(){var t=this.sig.i;f.checkArgument(0===t||1===t||2===t||3===t,new Error("i must be equal to 0, 1, 2, or 3"));var e=n.fromBuffer(this.hashbuf),r=this.sig.r,o=this.sig.s,a=1&t,c=t>>1,u=i.getN(),h=i.getG(),d=c?r.add(u):r,p=i.fromX(a,d);if(!p.mul(u).isInfinity())throw new Error("nR is not a valid curve point");var l=e.neg().umod(u),g=r.invm(u),m=p.mul(o).add(h.mul(l)).mul(g);return s.fromPoint(m,this.sig.compressed)},h.prototype.sigError=function(){if(!e.isBuffer(this.hashbuf)||32!==this.hashbuf.length)return"hashbuf must be a 32 byte buffer";var t=this.sig.r,r=this.sig.s,o=i.getN();try{if(t.isZero()||r.isZero()||t.gte(o)||r.gte(o))return"r and s not in range";var s=o.shrn(1),a=r.gt(s)?o.sub(r):r,c=n.fromBuffer(this.hashbuf,this.endian?{endian:this.endian}:void 0),u=a.invm(o),f=u.mul(c).umod(o),h=u.mul(t).umod(o),d=i.getG().mulAdd(f,this.pubkey.point,h);if(d.isInfinity())return"p is infinity";if(0!==d.getX().umod(o).cmp(t)){if(r.lte(s))if(f=(u=o.sub(r).invm(o)).mul(c).umod(o),h=u.mul(t).umod(o),!(d=i.getG().mulAdd(f,this.pubkey.point,h)).isInfinity()&&0===d.getX().umod(o).cmp(t))return!1;return"Invalid signature"}return!1}catch(t){return"Signature security validation failed: "+t.message}},h.toLowS=function(t){return t.gt(n.fromBuffer(e.from("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0","hex")))&&(t=i.getN().sub(t)),t},h.prototype._findSignature=function(t,e){var r,o,s,a=i.getN(),c=i.getG(),u=0;do{(!this.k||u>0)&&this.deterministicK(u),u++,r=this.k,o=c.mul(r).x.umod(a),s=r.invm(a).mul(e.add(t.mul(o))).umod(a)}while(o.cmp(n.Zero)<=0||s.cmp(n.Zero)<=0);return{s:s=h.toLowS(s),r:o}},h.prototype.sign=function(){var t=this.hashbuf,r=this.privkey,i=r.bn;f.checkState(t&&r&&i,new Error("invalid parameters")),f.checkState(e.isBuffer(t)&&32===t.length,new Error("hashbuf must be a 32 byte buffer"));var s=n.fromBuffer(t,this.endian?{endian:this.endian}:void 0),a=this._findSignature(i,s);return a.compressed=this.pubkey.compressed,this.sig=new o(a),this},h.prototype.signRandomK=function(){return this.randomK(),this.sign()},h.prototype.toString=function(){var t={};return this.hashbuf&&(t.hashbuf=this.hashbuf.toString("hex")),this.privkey&&(t.privkey=this.privkey.toString()),this.pubkey&&(t.pubkey=this.pubkey.toString()),this.sig&&(t.sig=this.sig.toString()),this.k&&(t.k=this.k.toString()),JSON.stringify(t)},h.prototype.verify=function(){return this.sigError()?this.verified=!1:this.verified=!0,this},h.sign=function(t,e,r){return h().set({hashbuf:t,endian:r,privkey:e}).sign().sig},h.signWithCalcI=function(t,e,r){return h().set({hashbuf:t,endian:r,privkey:e}).sign().calci().sig},h.signRandomK=function(t,e,r){return h().set({hashbuf:t,endian:r,privkey:e}).signRandomK().sig},h.verify=function(t,e,r,n){return h().set({hashbuf:t,endian:n,sig:e,pubkey:r}).verify().verified},t.exports=h}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var n=r(108)();
9
9
  /*!
10
10
  * The buffer module from node.js, for the browser.
11
11
  *
12
12
  * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
13
13
  * @license MIT
14
- */function n(t,e){if(t===e)return 0;for(var r=t.length,i=e.length,n=0,o=Math.min(r,i);n<o;++n)if(t[n]!==e[n]){r=t[n],i=e[n];break}return r<i?-1:i<r?1:0}function o(t){return e.Buffer&&"function"==typeof e.Buffer.isBuffer?e.Buffer.isBuffer(t):!(null==t||!t._isBuffer)}var s=r(136),a=Object.prototype.hasOwnProperty,c=Array.prototype.slice,u="foo"===function(){}.name;function f(t){return Object.prototype.toString.call(t)}function h(t){return!o(t)&&("function"==typeof e.ArrayBuffer&&("function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):!!t&&(t instanceof DataView||!!(t.buffer&&t.buffer instanceof ArrayBuffer))))}var d=t.exports=y,p=/\s*function\s+([^\(\s]*)\s*/;function l(t){if(s.isFunction(t)){if(u)return t.name;var e=t.toString().match(p);return e&&e[1]}}function g(t,e){return"string"==typeof t?t.length<e?t:t.slice(0,e):t}function m(t){if(u||!s.isFunction(t))return s.inspect(t);var e=l(t);return"[Function"+(e?": "+e:"")+"]"}function b(t,e,r,i,n){throw new d.AssertionError({message:r,actual:t,expected:e,operator:i,stackStartFunction:n})}function y(t,e){t||b(t,!0,e,"==",d.ok)}function v(t,e,r,i){if(t===e)return!0;if(o(t)&&o(e))return 0===n(t,e);if(s.isDate(t)&&s.isDate(e))return t.getTime()===e.getTime();if(s.isRegExp(t)&&s.isRegExp(e))return t.source===e.source&&t.global===e.global&&t.multiline===e.multiline&&t.lastIndex===e.lastIndex&&t.ignoreCase===e.ignoreCase;if(null!==t&&"object"==typeof t||null!==e&&"object"==typeof e){if(h(t)&&h(e)&&f(t)===f(e)&&!(t instanceof Float32Array||t instanceof Float64Array))return 0===n(new Uint8Array(t.buffer),new Uint8Array(e.buffer));if(o(t)!==o(e))return!1;var a=(i=i||{actual:[],expected:[]}).actual.indexOf(t);return-1!==a&&a===i.expected.indexOf(e)||(i.actual.push(t),i.expected.push(e),function(t,e,r,i){if(null==t||null==e)return!1;if(s.isPrimitive(t)||s.isPrimitive(e))return t===e;if(r&&Object.getPrototypeOf(t)!==Object.getPrototypeOf(e))return!1;var n=S(t),o=S(e);if(n&&!o||!n&&o)return!1;if(n)return t=c.call(t),e=c.call(e),v(t,e,r);var a,u,f=I(t),h=I(e);if(f.length!==h.length)return!1;for(f.sort(),h.sort(),u=f.length-1;u>=0;u--)if(f[u]!==h[u])return!1;for(u=f.length-1;u>=0;u--)if(a=f[u],!v(t[a],e[a],r,i))return!1;return!0}(t,e,r,i))}return r?t===e:t==e}function S(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function _(t,e){if(!t||!e)return!1;if("[object RegExp]"==Object.prototype.toString.call(e))return e.test(t);try{if(t instanceof e)return!0}catch(t){}return!Error.isPrototypeOf(e)&&!0===e.call({},t)}function w(t,e,r,i){var n;if("function"!=typeof e)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(i=r,r=null),n=function(t){var e;try{t()}catch(t){e=t}return e}(e),i=(r&&r.name?" ("+r.name+").":".")+(i?" "+i:"."),t&&!n&&b(n,r,"Missing expected exception"+i);var o="string"==typeof i,a=!t&&n&&!r;if((!t&&s.isError(n)&&o&&_(n,r)||a)&&b(n,r,"Got unwanted exception"+i),t&&n&&r&&!_(n,r)||!t&&n)throw n}d.AssertionError=function(t){this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=function(t){return g(m(t.actual),128)+" "+t.operator+" "+g(m(t.expected),128)}(this),this.generatedMessage=!0);var e=t.stackStartFunction||b;if(Error.captureStackTrace)Error.captureStackTrace(this,e);else{var r=new Error;if(r.stack){var i=r.stack,n=l(e),o=i.indexOf("\n"+n);if(o>=0){var s=i.indexOf("\n",o+1);i=i.substring(s+1)}this.stack=i}}},s.inherits(d.AssertionError,Error),d.fail=b,d.ok=y,d.equal=function(t,e,r){t!=e&&b(t,e,r,"==",d.equal)},d.notEqual=function(t,e,r){t==e&&b(t,e,r,"!=",d.notEqual)},d.deepEqual=function(t,e,r){v(t,e,!1)||b(t,e,r,"deepEqual",d.deepEqual)},d.deepStrictEqual=function(t,e,r){v(t,e,!0)||b(t,e,r,"deepStrictEqual",d.deepStrictEqual)},d.notDeepEqual=function(t,e,r){v(t,e,!1)&&b(t,e,r,"notDeepEqual",d.notDeepEqual)},d.notDeepStrictEqual=function t(e,r,i){v(e,r,!0)&&b(e,r,i,"notDeepStrictEqual",t)},d.strictEqual=function(t,e,r){t!==e&&b(t,e,r,"===",d.strictEqual)},d.notStrictEqual=function(t,e,r){t===e&&b(t,e,r,"!==",d.notStrictEqual)},d.throws=function(t,e,r){w(!0,t,e,r)},d.doesNotThrow=function(t,e,r){w(!1,t,e,r)},d.ifError=function(t){if(t)throw t},d.strict=i((function t(e,r){e||b(e,!0,r,"==",t)}),d,{equal:d.strictEqual,deepEqual:d.deepStrictEqual,notEqual:d.notStrictEqual,notDeepEqual:d.notDeepStrictEqual}),d.strict.strict=d.strict;var I=Object.keys||function(t){var e=[];for(var r in t)a.call(t,r)&&e.push(r);return e}}).call(this,r(40))},function(t,e,r){"use strict";t.exports=Object},function(t,e,r){"use strict";t.exports=Function.prototype.call},function(t,e,r){"use strict";(function(e){var i=r(1),n=r(2),o=r(5);function s(t){if(!(this instanceof s))return new s(t);var e;if(i.isNumber(t))e=t;else{if(!i.isString(t))throw new TypeError('Unrecognized num type: "'+typeof t+'" for Opcode');e=s.map[t]}return o.defineImmutable(this,{num:e}),this}for(var a in s.fromBuffer=function(t){return n.checkArgument(e.isBuffer(t)),new s(Number("0x"+t.toString("hex")))},s.fromNumber=function(t){return n.checkArgument(i.isNumber(t)),new s(t)},s.fromString=function(t){n.checkArgument(i.isString(t));var e=s.map[t];if(void 0===e)throw new TypeError("Invalid opcodestr");return new s(e)},s.prototype.toHex=function(){return this.num.toString(16)},s.prototype.toBuffer=function(){return e.from(this.toHex(),"hex")},s.prototype.toNumber=function(){return this.num},s.prototype.toString=function(){var t=s.reverseMap[this.num];if(void 0===t)throw new Error("Opcode does not have a string representation");return t},s.smallInt=function(t){return n.checkArgument(i.isNumber(t),"Invalid Argument: n should be number"),n.checkArgument(t>=0&&t<=16,"Invalid Argument: n must be between 0 and 16"),0===t?s("OP_0"):new s(s.map.OP_1+t-1)},s.map={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SPLIT:127,OP_NUM2BIN:128,OP_BIN2NUM:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_CHECKLOCKTIMEVERIFY:177,OP_CHECKSEQUENCEVERIFY:178,OP_NOP1:176,OP_NOP2:177,OP_NOP3:178,OP_SUBSTR:179,OP_LEFT:180,OP_RIGHT:181,OP_NOP4:182,OP_NOP5:183,OP_NOP6:184,OP_NOP7:185,OP_NOP8:186,OP_NOP9:187,OP_NOP10:188,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255},s.reverseMap=[],s.map)s.reverseMap[s.map[a]]=a;i.extend(s,s.map),s.isSmallIntOp=function(t){return t instanceof s&&(t=t.toNumber()),t===s.map.OP_0||t>=s.map.OP_1&&t<=s.map.OP_16},s.prototype.inspect=function(){return"<Opcode: "+this.toString()+", hex: "+this.toHex()+", decimal: "+this.num+">"},t.exports=s}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(1),n=r(61),o=r(48),s=r(3),a=r(6),c=r(4),u=r(14),f=r(138),h=function t(e){if(!(this instanceof t))return new t(e);e?(this.initialize(),this.set(e)):this.initialize()};h.prototype.verify=function(t,e,o,s,a,c){var u,f=r(37);if(i.isUndefined(o)&&(o=new f),i.isUndefined(s)&&(s=0),i.isUndefined(a)&&(a=0),a&h.SCRIPT_ENABLE_SIGHASH_FORKID&&(a|=h.SCRIPT_VERIFY_STRICTENC,!c))throw new Error("internal error - need satoshisBN to verify FORKID transactions");if(this.set({script:t,tx:o,nin:s,flags:a,satoshisBN:c}),0!=(a&h.SCRIPT_VERIFY_SIGPUSHONLY)&&!t.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(!this.evaluate())return!1;a&h.SCRIPT_VERIFY_P2SH&&(u=this.stack.slice());var d=this.stack;if(this.initialize(),this.set({script:e,stack:d,tx:o,nin:s,flags:a,satoshisBN:c}),!this.evaluate())return!1;if(0===this.stack.length)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_RESULT",!1;var p=this.stack[this.stack.length-1];if(!h.castToBool(p))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_STACK",!1;if(a&h.SCRIPT_VERIFY_P2SH&&e.isScriptHashOut()){if(!t.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(0===u.length)throw new Error("internal error - stack copy empty");var l=u[u.length-1],g=n.fromBuffer(l);if(u.pop(),this.initialize(),this.set({script:g,stack:u,tx:o,nin:s,flags:a,satoshisBN:c}),!this.evaluate())return!1;if(0===u.length)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_P2SH_STACK",!1;if(!h.castToBool(u[u.length-1]))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_P2SH_STACK",!1}if(0!=(a&h.SCRIPT_VERIFY_CLEANSTACK)){if(0==(a&h.SCRIPT_VERIFY_P2SH))throw new Error("internal error - CLEANSTACK without P2SH");if(1!==u.length)return this.errstr="SCRIPT_ERR_CLEANSTACK",!1}return!0},t.exports=h,h.prototype.initialize=function(t){this.stack=[],this.altstack=[],this.pc=0,this.pbegincodehash=0,this.nOpCount=0,this.vfExec=[],this.errstr="",this.flags=0},h.prototype.set=function(t){this.script=t.script||this.script,this.tx=t.tx||this.tx,this.nin=void 0!==t.nin?t.nin:this.nin,this.satoshisBN=t.satoshisBN||this.satoshisBN,this.stack=t.stack||this.stack,this.altstack=t.altstack||this.altstack,this.pc=void 0!==t.pc?t.pc:this.pc,this.pbegincodehash=void 0!==t.pbegincodehash?t.pbegincodehash:this.pbegincodehash,this.nOpCount=void 0!==t.nOpCount?t.nOpCount:this.nOpCount,this.vfExec=t.vfExec||this.vfExec,this.errstr=t.errstr||this.errstr,this.flags=void 0!==t.flags?t.flags:this.flags},h.true=e.from([1]),h.false=e.from([]),h.MAX_SCRIPT_ELEMENT_SIZE=520,h.MAXIMUM_ELEMENT_SIZE=4,h.LOCKTIME_THRESHOLD_BN=new s(h.LOCKTIME_THRESHOLD=5e8),h.SCRIPT_VERIFY_NONE=0,h.SCRIPT_VERIFY_P2SH=1,h.SCRIPT_VERIFY_STRICTENC=2,h.SCRIPT_VERIFY_DERSIG=4,h.SCRIPT_VERIFY_LOW_S=8,h.SCRIPT_VERIFY_NULLDUMMY=16,h.SCRIPT_VERIFY_SIGPUSHONLY=32,h.SCRIPT_VERIFY_MINIMALDATA=64,h.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS=128,h.SCRIPT_VERIFY_CLEANSTACK=256,h.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY=512,h.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY=1024,h.SCRIPT_VERIFY_MINIMALIF=8192,h.SCRIPT_VERIFY_NULLFAIL=16384,h.SCRIPT_VERIFY_COMPRESSED_PUBKEYTYPE=32768,h.SCRIPT_ENABLE_SIGHASH_FORKID=65536,h.SCRIPT_ENABLE_REPLAY_PROTECTION=1<<17,h.SCRIPT_ENABLE_MONOLITH_OPCODES=1<<18,h.SCRIPT_ENABLE_MAGNETIC_OPCODES=1<<19,h.SEQUENCE_LOCKTIME_DISABLE_FLAG=1<<31,h.SEQUENCE_LOCKTIME_TYPE_FLAG=1<<22,h.SEQUENCE_LOCKTIME_MASK=65535,h.castToBool=function(t){for(var e=0;e<t.length;e++)if(0!==t[e])return e!==t.length-1||128!==t[e];return!1},h.prototype.checkSignatureEncoding=function(t){var e;if(0===t.length)return!0;if(0!=(this.flags&(h.SCRIPT_VERIFY_DERSIG|h.SCRIPT_VERIFY_LOW_S|h.SCRIPT_VERIFY_STRICTENC))&&!c.isTxDER(t))return this.errstr="SCRIPT_ERR_SIG_DER_INVALID_FORMAT",!1;if(0!=(this.flags&h.SCRIPT_VERIFY_LOW_S)){if(!(e=c.fromTxFormat(t)).hasLowS())return this.errstr="SCRIPT_ERR_SIG_DER_HIGH_S",!1}else if(0!=(this.flags&h.SCRIPT_VERIFY_STRICTENC)){if(!(e=c.fromTxFormat(t)).hasDefinedHashtype())return this.errstr="SCRIPT_ERR_SIG_HASHTYPE",!1;if(!(this.flags&h.SCRIPT_ENABLE_SIGHASH_FORKID)&&e.nhashtype&c.SIGHASH_FORKID)return this.errstr="SCRIPT_ERR_ILLEGAL_FORKID",!1;if(this.flags&h.SCRIPT_ENABLE_SIGHASH_FORKID&&!(e.nhashtype&c.SIGHASH_FORKID))return this.errstr="SCRIPT_ERR_MUST_USE_FORKID",!1}return!0},h.prototype.checkPubkeyEncoding=function(t){return!(0!=(this.flags&h.SCRIPT_VERIFY_STRICTENC)&&!u.isValid(t))||(this.errstr="SCRIPT_ERR_PUBKEYTYPE",!1)},h._isMinimallyEncoded=function(t,e){return e=e||h.MAXIMUM_ELEMENT_SIZE,!(t.length>e)&&!(t.length>0&&0==(127&t[t.length-1])&&(t.length<=1||0==(128&t[t.length-2])))},h._minimallyEncode=function(t){if(0===t.length)return t;var r=t[t.length-1];if(127&r)return t;if(1===t.length)return e.from("");if(128&t[t.length-2])return t;for(var i=t.length-1;i>0;i--)if(0!==t[i-1])return 128&t[i-1]?t[i++]=r:t[i-1]|=r,t.slice(0,i);return e.from("")},h.prototype.evaluate=function(){if(this.script.toBuffer().length>1e4)return this.errstr="SCRIPT_ERR_SCRIPT_SIZE",!1;try{for(;this.pc<this.script.chunks.length;){let t={pc:this.pc,opcode:o.fromNumber(this.script.chunks[this.pc].opcodenum)};if(!this.step())return!1;this._callbackStep(t)}if(this.stack.length+this.altstack.length>1e3)return this.errstr="SCRIPT_ERR_STACK_SIZE",!1}catch(t){return this.errstr="SCRIPT_ERR_UNKNOWN_ERROR: "+t,!1}return!(this.vfExec.length>0)||(this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1)},h.prototype._callbackStep=function(t){if("function"==typeof this.stepListener)try{this.stepListener(t,f(this.stack,!0),f(this.altstack,!0))}catch(t){console.log("Error in Step callback:"+t)}},h.prototype.checkLockTime=function(t){return!!(this.tx.nLockTime<h.LOCKTIME_THRESHOLD&&t.lt(h.LOCKTIME_THRESHOLD_BN)||this.tx.nLockTime>=h.LOCKTIME_THRESHOLD&&t.gte(h.LOCKTIME_THRESHOLD_BN))&&(!t.gt(new s(this.tx.nLockTime))&&!this.tx.inputs[this.nin].isFinal())},h.prototype.checkSequence=function(t){var e=this.tx.inputs[this.nin].sequenceNumber;if(this.tx.version<2)return!1;if(e&h.SEQUENCE_LOCKTIME_DISABLE_FLAG)return!1;var r=h.SEQUENCE_LOCKTIME_TYPE_FLAG|h.SEQUENCE_LOCKTIME_MASK,i=new s(e&r),n=t.and(r),o=new s(h.SEQUENCE_LOCKTIME_TYPE_FLAG);return!!(i.lt(o)&&n.lt(o)||i.gte(o)&&n.gte(o))&&!n.gt(i)},h.prototype.step=function(){var t=this;function r(e){return t.stack[t.stack.length+e]}var f,d,p,l,g,m,b,y,v,S,_,w,I,O,P,A,E,k=0!=(this.flags&h.SCRIPT_VERIFY_MINIMALDATA),x=-1===this.vfExec.indexOf(!1),T=this.script.chunks[this.pc];this.pc++;var R=T.opcodenum;if(i.isUndefined(R))return this.errstr="SCRIPT_ERR_UNDEFINED_OPCODE",!1;if(T.buf&&T.buf.length>h.MAX_SCRIPT_ELEMENT_SIZE)return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;if(R>o.OP_16&&++this.nOpCount>201)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;if(function(e){switch(e){case o.OP_2MUL:case o.OP_2DIV:return!0;case o.OP_INVERT:case o.OP_MUL:case o.OP_LSHIFT:case o.OP_RSHIFT:if(0==(t.flags&h.SCRIPT_ENABLE_MAGNETIC_OPCODES))return!0;break;case o.OP_DIV:case o.OP_MOD:case o.OP_SPLIT:case o.OP_CAT:case o.OP_AND:case o.OP_OR:case o.OP_XOR:case o.OP_BIN2NUM:case o.OP_NUM2BIN:return!1}return!1}(R))return this.errstr="SCRIPT_ERR_DISABLED_OPCODE",!1;if(x&&R>=0&&R<=o.OP_PUSHDATA4){if(k&&!this.script.checkMinimalPush(this.pc-1))return this.errstr="SCRIPT_ERR_MINIMALDATA",!1;if(T.buf){if(T.len!==T.buf.length)throw new Error(`Length of push value not equal to length of data (${T.len},${T.buf.length})`);this.stack.push(T.buf)}else this.stack.push(h.false)}else if(x||o.OP_IF<=R&&R<=o.OP_ENDIF)switch(R){case o.OP_1NEGATE:case o.OP_1:case o.OP_2:case o.OP_3:case o.OP_4:case o.OP_5:case o.OP_6:case o.OP_7:case o.OP_8:case o.OP_9:case o.OP_10:case o.OP_11:case o.OP_12:case o.OP_13:case o.OP_14:case o.OP_15:case o.OP_16:g=R-(o.OP_1-1),f=new s(g).toScriptNumBuffer(),this.stack.push(f);break;case o.OP_NOP:break;case o.OP_NOP2:case o.OP_CHECKLOCKTIMEVERIFY:if(!(this.flags&h.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)){if(this.flags&h.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var M=s.fromScriptNumBuffer(this.stack[this.stack.length-1],k,5);if(M.lt(new s(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if(!this.checkLockTime(M))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case o.OP_NOP3:case o.OP_CHECKSEQUENCEVERIFY:if(!(this.flags&h.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY)){if(this.flags&h.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var N=s.fromScriptNumBuffer(r(-1),k,5);if(N.lt(new s(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if(0!=(N&h.SEQUENCE_LOCKTIME_DISABLE_FLAG))break;if(!this.checkSequence(N))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case o.OP_NOP1:case o.OP_NOP4:case o.OP_NOP5:case o.OP_NOP6:case o.OP_NOP7:case o.OP_NOP8:case o.OP_NOP9:case o.OP_NOP10:if(this.flags&h.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break;case o.OP_IF:case o.OP_NOTIF:if(A=!1,x){if(this.stack.length<1)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;if(f=r(-1),this.flags&h.SCRIPT_VERIFY_MINIMALIF){if(f.length>1)return this.errstr="SCRIPT_ERR_MINIMALIF",!1;if(1===f.length&&1!==f[0])return this.errstr="SCRIPT_ERR_MINIMALIF",!1}A=h.castToBool(f),R===o.OP_NOTIF&&(A=!A),this.stack.pop()}this.vfExec.push(A);break;case o.OP_ELSE:if(0===this.vfExec.length)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec[this.vfExec.length-1]=!this.vfExec[this.vfExec.length-1];break;case o.OP_ENDIF:if(0===this.vfExec.length)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec.pop();break;case o.OP_VERIFY:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(f=r(-1),!(A=h.castToBool(f)))return this.errstr="SCRIPT_ERR_VERIFY",!1;this.stack.pop();break;case o.OP_RETURN:return this.errstr="SCRIPT_ERR_OP_RETURN",!1;case o.OP_TOALTSTACK:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.altstack.push(this.stack.pop());break;case o.OP_FROMALTSTACK:if(this.altstack.length<1)return this.errstr="SCRIPT_ERR_INVALID_ALTSTACK_OPERATION",!1;this.stack.push(this.altstack.pop());break;case o.OP_2DROP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop(),this.stack.pop();break;case o.OP_2DUP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;d=r(-2),p=r(-1),this.stack.push(e.from(d)),this.stack.push(e.from(p));break;case o.OP_3DUP:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;d=r(-3),p=r(-2);var B=r(-1);this.stack.push(e.from(d)),this.stack.push(e.from(p)),this.stack.push(e.from(B));break;case o.OP_2OVER:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;d=r(-4),p=r(-3),this.stack.push(e.from(d)),this.stack.push(e.from(p));break;case o.OP_2ROT:if(this.stack.length<6)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;l=this.stack.splice(this.stack.length-6,2),this.stack.push(l[0]),this.stack.push(l[1]);break;case o.OP_2SWAP:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;l=this.stack.splice(this.stack.length-4,2),this.stack.push(l[0]),this.stack.push(l[1]);break;case o.OP_IFDUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;f=r(-1),(A=h.castToBool(f))&&this.stack.push(e.from(f));break;case o.OP_DEPTH:f=new s(this.stack.length).toScriptNumBuffer(),this.stack.push(f);break;case o.OP_DROP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop();break;case o.OP_DUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(e.from(r(-1)));break;case o.OP_NIP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,1);break;case o.OP_OVER:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(e.from(r(-2)));break;case o.OP_PICK:case o.OP_ROLL:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(f=r(-1),g=(y=s.fromScriptNumBuffer(f,k)).toNumber(),this.stack.pop(),g<0||g>=this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;f=r(-g-1),R===o.OP_ROLL&&this.stack.splice(this.stack.length-g-1,1),this.stack.push(e.from(f));break;case o.OP_ROT:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;m=r(-3),b=r(-2);var C=r(-1);this.stack[this.stack.length-3]=b,this.stack[this.stack.length-2]=C,this.stack[this.stack.length-1]=m;break;case o.OP_SWAP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;m=r(-2),b=r(-1),this.stack[this.stack.length-2]=b,this.stack[this.stack.length-1]=m;break;case o.OP_TUCK:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,0,e.from(r(-1)));break;case o.OP_SIZE:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;y=new s(r(-1).length),this.stack.push(y.toScriptNumBuffer());break;case o.OP_AND:case o.OP_OR:case o.OP_XOR:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(d=r(-2),p=r(-1),d.length!==p.length)return this.errstr="SCRIPT_ERR_INVALID_OPERAND_SIZE",!1;switch(R){case o.OP_AND:for(let t=0;t<d.length;t++)d[t]&=p[t];break;case o.OP_OR:for(let t=0;t<d.length;t++)d[t]|=p[t];break;case o.OP_XOR:for(let t=0;t<d.length;t++)d[t]^=p[t]}this.stack.pop();break;case o.OP_INVERT:this.stack.length<1&&(this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION"),f=r(-1);for(let t=0;t<f.length;t++)f[t]=~f[t];break;case o.OP_LSHIFT:case o.OP_RSHIFT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(0===(d=r(-2)).length)this.stack.pop();else{if(v=new s(d),(g=(S=s.fromScriptNumBuffer(r(-1),k)).toNumber())<0)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;let t;this.stack.pop(),this.stack.pop(),R===o.OP_LSHIFT&&(t=v.ushln(g)),R===o.OP_RSHIFT&&(t=v.ushrn(g));let i=function(t,r){let i=t;for(;i.length<r;)i=e.concat([e.from([0]),i]);return i}(e.from(t.toArray().slice(-1*d.length)),d.length);this.stack.push(i)}break;case o.OP_EQUAL:case o.OP_EQUALVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;d=r(-2),p=r(-1);var H=d.toString("hex")===p.toString("hex");if(this.stack.pop(),this.stack.pop(),this.stack.push(H?h.true:h.false),R===o.OP_EQUALVERIFY){if(!H)return this.errstr="SCRIPT_ERR_EQUALVERIFY",!1;this.stack.pop()}break;case o.OP_1ADD:case o.OP_1SUB:case o.OP_NEGATE:case o.OP_ABS:case o.OP_NOT:case o.OP_0NOTEQUAL:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(f=r(-1),y=s.fromScriptNumBuffer(f,k),R){case o.OP_1ADD:y=y.add(s.One);break;case o.OP_1SUB:y=y.sub(s.One);break;case o.OP_NEGATE:y=y.neg();break;case o.OP_ABS:y.cmp(s.Zero)<0&&(y=y.neg());break;case o.OP_NOT:y=new s((0===y.cmp(s.Zero))+0);break;case o.OP_0NOTEQUAL:y=new s((0!==y.cmp(s.Zero))+0)}this.stack.pop(),this.stack.push(y.toScriptNumBuffer());break;case o.OP_ADD:case o.OP_SUB:case o.OP_MUL:case o.OP_MOD:case o.OP_DIV:case o.OP_BOOLAND:case o.OP_BOOLOR:case o.OP_NUMEQUAL:case o.OP_NUMEQUALVERIFY:case o.OP_NUMNOTEQUAL:case o.OP_LESSTHAN:case o.OP_GREATERTHAN:case o.OP_LESSTHANOREQUAL:case o.OP_GREATERTHANOREQUAL:case o.OP_MIN:case o.OP_MAX:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(v=s.fromScriptNumBuffer(r(-2),k),S=s.fromScriptNumBuffer(r(-1),k),y=new s(0),R){case o.OP_ADD:y=v.add(S);break;case o.OP_SUB:y=v.sub(S);break;case o.OP_MUL:y=v.mul(S);break;case o.OP_DIV:if(0===S)return this.errstr="SCRIPT_ERR_DIV_BY_ZERO",!1;y=v.div(S);break;case o.OP_MOD:if(0===S)return this.errstr="SCRIPT_ERR_DIV_BY_ZERO",!1;y=v.mod(S);break;case o.OP_BOOLAND:y=new s((0!==v.cmp(s.Zero)&&0!==S.cmp(s.Zero))+0);break;case o.OP_BOOLOR:y=new s((0!==v.cmp(s.Zero)||0!==S.cmp(s.Zero))+0);break;case o.OP_NUMEQUAL:case o.OP_NUMEQUALVERIFY:y=new s((0===v.cmp(S))+0);break;case o.OP_NUMNOTEQUAL:y=new s((0!==v.cmp(S))+0);break;case o.OP_LESSTHAN:y=new s((v.cmp(S)<0)+0);break;case o.OP_GREATERTHAN:y=new s((v.cmp(S)>0)+0);break;case o.OP_LESSTHANOREQUAL:y=new s((v.cmp(S)<=0)+0);break;case o.OP_GREATERTHANOREQUAL:y=new s((v.cmp(S)>=0)+0);break;case o.OP_MIN:y=v.cmp(S)<0?v:S;break;case o.OP_MAX:y=v.cmp(S)>0?v:S}if(this.stack.pop(),this.stack.pop(),this.stack.push(y.toScriptNumBuffer()),R===o.OP_NUMEQUALVERIFY){if(!h.castToBool(r(-1)))return this.errstr="SCRIPT_ERR_NUMEQUALVERIFY",!1;this.stack.pop()}break;case o.OP_WITHIN:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;v=s.fromScriptNumBuffer(r(-3),k),S=s.fromScriptNumBuffer(r(-2),k);var U=s.fromScriptNumBuffer(r(-1),k);A=S.cmp(v)<=0&&v.cmp(U)<0,this.stack.pop(),this.stack.pop(),this.stack.pop(),this.stack.push(A?h.true:h.false);break;case o.OP_RIPEMD160:case o.OP_SHA1:case o.OP_SHA256:case o.OP_HASH160:case o.OP_HASH256:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var L;f=r(-1),R===o.OP_RIPEMD160?L=a.ripemd160(f):R===o.OP_SHA1?L=a.sha1(f):R===o.OP_SHA256?L=a.sha256(f):R===o.OP_HASH160?L=a.sha256ripemd160(f):R===o.OP_HASH256&&(L=a.sha256sha256(f)),this.stack.pop(),this.stack.push(L);break;case o.OP_CODESEPARATOR:this.pbegincodehash=this.pc;break;case o.OP_CHECKSIG:case o.OP_CHECKSIGVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(_=r(-2),w=r(-1),!this.checkSignatureEncoding(_)||!this.checkPubkeyEncoding(w))return!1;I=(new n).set({chunks:this.script.chunks.slice(this.pbegincodehash)});var F=(new n).add(_);I.findAndDelete(F);try{O=c.fromTxFormat(_),P=u.fromBuffer(w,!1),E=this.tx.verifySignature(O,P,this.nin,I,this.satoshisBN,this.flags)}catch(t){E=!1}if(!E&&this.flags&h.SCRIPT_VERIFY_NULLFAIL&&_.length)return this.errstr="SCRIPT_ERR_NULLFAIL",!1;if(this.stack.pop(),this.stack.pop(),this.stack.push(E?h.true:h.false),R===o.OP_CHECKSIGVERIFY){if(!E)return this.errstr="SCRIPT_ERR_CHECKSIGVERIFY",!1;this.stack.pop()}break;case o.OP_CHECKMULTISIG:case o.OP_CHECKMULTISIGVERIFY:var D=1;if(this.stack.length<D)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var K=s.fromScriptNumBuffer(r(-D),k).toNumber();if(K<0||K>20)return this.errstr="SCRIPT_ERR_PUBKEY_COUNT",!1;if(this.nOpCount+=K,this.nOpCount>201)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;var z=++D;D+=K;var j=K+2;if(this.stack.length<D)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var V=s.fromScriptNumBuffer(r(-D),k).toNumber();if(V<0||V>K)return this.errstr="SCRIPT_ERR_SIG_COUNT",!1;var G=++D;if(D+=V,this.stack.length<D)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;I=(new n).set({chunks:this.script.chunks.slice(this.pbegincodehash)});for(var q=0;q<V;q++)_=r(-G-q),I.findAndDelete((new n).add(_));for(E=!0;E&&V>0;){if(_=r(-G),w=r(-z),!this.checkSignatureEncoding(_)||!this.checkPubkeyEncoding(w))return!1;var Y;try{O=c.fromTxFormat(_),P=u.fromBuffer(w,!1),Y=this.tx.verifySignature(O,P,this.nin,I,this.satoshisBN,this.flags)}catch(t){Y=!1}Y&&(G++,V--),z++,V>--K&&(E=!1)}for(;D-- >1;){if(!E&&this.flags&h.SCRIPT_VERIFY_NULLFAIL&&!j&&r(-1).length)return this.errstr="SCRIPT_ERR_NULLFAIL",!1;j>0&&j--,this.stack.pop()}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(this.flags&h.SCRIPT_VERIFY_NULLDUMMY&&r(-1).length)return this.errstr="SCRIPT_ERR_SIG_NULLDUMMY",!1;if(this.stack.pop(),this.stack.push(E?h.true:h.false),R===o.OP_CHECKMULTISIGVERIFY){if(!E)return this.errstr="SCRIPT_ERR_CHECKMULTISIGVERIFY",!1;this.stack.pop()}break;case o.OP_CAT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(d=r(-2),p=r(-1),d.length+p.length>h.MAX_SCRIPT_ELEMENT_SIZE)return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;this.stack[this.stack.length-2]=e.concat([d,p]),this.stack.pop();break;case o.OP_SPLIT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;d=r(-2);var X=s.fromScriptNumBuffer(r(-1),k).toNumber();if(X<0||X>d.length)return this.errstr="SCRIPT_ERR_INVALID_SPLIT_RANGE",!1;var W=e.from(d);this.stack[this.stack.length-2]=W.slice(0,X),this.stack[this.stack.length-1]=W.slice(X);break;case o.OP_NUM2BIN:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var Z=s.fromScriptNumBuffer(r(-1),k).toNumber();if(Z>h.MAX_SCRIPT_ELEMENT_SIZE)return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;this.stack.pop();var $=r(-1);if(($=h._minimallyEncode($)).length>Z)return this.errstr="SCRIPT_ERR_IMPOSSIBLE_ENCODING",!1;if($.length===Z){this.stack[this.stack.length-1]=$;break}var Q=0;$.length>0&&(Q=128&$[$.length-1],$[$.length-1]&=127);var J=e.alloc(Z);$.copy(J,0);for(var tt=$.length-1;tt++<Z-2;)J[tt]=0;J[tt]=Q,this.stack[this.stack.length-1]=J;break;case o.OP_BIN2NUM:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(d=r(-1),p=h._minimallyEncode(d),this.stack[this.stack.length-1]=p,!h._isMinimallyEncoded(p))return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;break;default:return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1}return!0}}).call(this,r(0).Buffer)},function(t,e,r){t.exports=r(29),t.exports.PublicKey=r(142),t.exports.PublicKeyHash=r(143),t.exports.MultiSig=r(144),t.exports.MultiSigScriptHash=r(145)},function(t,e,r){"use strict";(function(e){const i=r(3),n=r(11),o=r(44),s=n.getN(),a=s.shrn(1);t.exports={smartVerify:function(t,n,c){if(!e.isBuffer(t)||32!==t.length)throw new Error("Invalid message hash: must be 32-byte buffer");if(!n)return!1;let u=n;if(e.isBuffer(n))try{u=r(4).fromDER(n)}catch(t){return!1}if(!u||!u.r||!u.s)return!1;const f=i.isBN(u.r)?u.r:new i(u.r),h=i.isBN(u.s)?u.s:new i(u.s);if(f.isZero()||h.isZero())return!1;if(f.gte(s)||h.gte(s))return!1;let d=h;h.gt(a)&&(d=s.sub(h));const p=new(r(4))({r:f,s:d});return o.verify(t,p,c)},isCanonical:function(t){if(!t)return!1;let n=t;if(e.isBuffer(t))try{n=r(4).fromDER(t)}catch(t){return!1}return!(!n||!n.s)&&(i.isBN(n.s)?n.s:new i(n.s)).lte(a)},canonicalize:function(t){if(!t||!t.r||!t.s)throw new Error("Invalid signature object");const e=i.isBN(t.r)?t.r:new i(t.r),r=i.isBN(t.s)?t.s:new i(t.s);let n=r;return r.gt(a)&&(n=s.sub(r)),{r:e,s:n}},constants:{n:s,nh:a}}}).call(this,r(0).Buffer)},function(t,e,r){"use strict";const{ec:i}=r(41),n=new i("secp256k1"),o=n.verify.bind(n);n.verify=function(t,e,r,i,n){if(!e||"object"!=typeof e)return!1;if(!e.r||!e.s)return!1;const s="function"==typeof e.r.cmp?e.r:this.curve.n.red?this.curve.n.fromRed(e.r):e.r,a="function"==typeof e.s.cmp?e.s:this.curve.n.red?this.curve.n.fromRed(e.s):e.s;return!(s&&s.cmp&&s.cmp(this.curve.n)>=0)&&(!(a&&a.cmp&&a.cmp(this.curve.n)>=0)&&(!(s&&s.isZero&&s.isZero())&&(!(a&&a.isZero&&a.isZero())&&o(t,e,r,i,n))))};const s=n.sign.bind(n);n.sign=function(t,e,r,i){const n=s(t,e,r,i);if(n.s&&n.s.cmp){const t=this.curve.n.shrn(1);n.s.cmp(t)>0&&(n.s=this.curve.n.sub(n.s))}return n},t.exports=n},function(t,e,r){(function(t){function r(t,e){for(var r=0,i=t.length-1;i>=0;i--){var n=t[i];"."===n?t.splice(i,1):".."===n?(t.splice(i,1),r++):r&&(t.splice(i,1),r--)}if(e)for(;r--;r)t.unshift("..");return t}function i(t,e){if(t.filter)return t.filter(e);for(var r=[],i=0;i<t.length;i++)e(t[i],i,t)&&r.push(t[i]);return r}e.resolve=function(){for(var e="",n=!1,o=arguments.length-1;o>=-1&&!n;o--){var s=o>=0?arguments[o]:t.cwd();if("string"!=typeof s)throw new TypeError("Arguments to path.resolve must be strings");s&&(e=s+"/"+e,n="/"===s.charAt(0))}return(n?"/":"")+(e=r(i(e.split("/"),(function(t){return!!t})),!n).join("/"))||"."},e.normalize=function(t){var o=e.isAbsolute(t),s="/"===n(t,-1);return(t=r(i(t.split("/"),(function(t){return!!t})),!o).join("/"))||o||(t="."),t&&s&&(t+="/"),(o?"/":"")+t},e.isAbsolute=function(t){return"/"===t.charAt(0)},e.join=function(){var t=Array.prototype.slice.call(arguments,0);return e.normalize(i(t,(function(t,e){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t})).join("/"))},e.relative=function(t,r){function i(t){for(var e=0;e<t.length&&""===t[e];e++);for(var r=t.length-1;r>=0&&""===t[r];r--);return e>r?[]:t.slice(e,r-e+1)}t=e.resolve(t).substr(1),r=e.resolve(r).substr(1);for(var n=i(t.split("/")),o=i(r.split("/")),s=Math.min(n.length,o.length),a=s,c=0;c<s;c++)if(n[c]!==o[c]){a=c;break}var u=[];for(c=a;c<n.length;c++)u.push("..");return(u=u.concat(o.slice(a))).join("/")},e.sep="/",e.delimiter=":",e.dirname=function(t){if("string"!=typeof t&&(t+=""),0===t.length)return".";for(var e=t.charCodeAt(0),r=47===e,i=-1,n=!0,o=t.length-1;o>=1;--o)if(47===(e=t.charCodeAt(o))){if(!n){i=o;break}}else n=!1;return-1===i?r?"/":".":r&&1===i?"/":t.slice(0,i)},e.basename=function(t,e){var r=function(t){"string"!=typeof t&&(t+="");var e,r=0,i=-1,n=!0;for(e=t.length-1;e>=0;--e)if(47===t.charCodeAt(e)){if(!n){r=e+1;break}}else-1===i&&(n=!1,i=e+1);return-1===i?"":t.slice(r,i)}(t);return e&&r.substr(-1*e.length)===e&&(r=r.substr(0,r.length-e.length)),r},e.extname=function(t){"string"!=typeof t&&(t+="");for(var e=-1,r=0,i=-1,n=!0,o=0,s=t.length-1;s>=0;--s){var a=t.charCodeAt(s);if(47!==a)-1===i&&(n=!1,i=s+1),46===a?-1===e?e=s:1!==o&&(o=1):-1!==e&&(o=-1);else if(!n){r=s+1;break}}return-1===e||-1===i||0===o||1===o&&e===i-1&&e===r+1?"":t.slice(e,i)};var n="b"==="ab".substr(-1)?function(t,e,r){return t.substr(e,r)}:function(t,e,r){return e<0&&(e=t.length+e),t.substr(e,r)}}).call(this,r(24))},function(t,e,r){var i=r(82);t.exports=i("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},function(t,e,r){"use strict";var i=e;function n(t){return 1===t.length?"0"+t:t}function o(t){for(var e="",r=0;r<t.length;r++)e+=n(t[r].toString(16));return e}i.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"!=typeof t){for(var i=0;i<t.length;i++)r[i]=0|t[i];return r}if("hex"===e){(t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t);for(i=0;i<t.length;i+=2)r.push(parseInt(t[i]+t[i+1],16))}else for(i=0;i<t.length;i++){var n=t.charCodeAt(i),o=n>>8,s=255&n;o?r.push(o,s):r.push(s)}return r},i.zero2=n,i.toHex=o,i.encode=function(t,e){return"hex"===e?o(t):t}},function(t,e,r){var i;function n(t){this.rand=t}if(t.exports=function(t){return i||(i=new n(null)),i.generate(t)},t.exports.Rand=n,n.prototype.generate=function(t){return this._rand(t)},n.prototype._rand=function(t){if(this.rand.getBytes)return this.rand.getBytes(t);for(var e=new Uint8Array(t),r=0;r<e.length;r++)e[r]=this.rand.getByte();return e},"object"==typeof self)self.crypto&&self.crypto.getRandomValues?n.prototype._rand=function(t){var e=new Uint8Array(t);return self.crypto.getRandomValues(e),e}:self.msCrypto&&self.msCrypto.getRandomValues?n.prototype._rand=function(t){var e=new Uint8Array(t);return self.msCrypto.getRandomValues(e),e}:"object"==typeof window&&(n.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var o=r(85);if("function"!=typeof o.randomBytes)throw new Error("Not supported");n.prototype._rand=function(t){return o.randomBytes(t)}}catch(t){}},function(t,e,r){"use strict";var i=e;i.base=r(32),i.short=r(86),i.mont=r(87),i.edwards=r(88)},function(t,e,r){"use strict";var i=r(13).rotr32;function n(t,e,r){return t&e^~t&r}function o(t,e,r){return t&e^t&r^e&r}function s(t,e,r){return t^e^r}e.ft_1=function(t,e,r,i){return 0===t?n(e,r,i):1===t||3===t?s(e,r,i):2===t?o(e,r,i):void 0},e.ch32=n,e.maj32=o,e.p32=s,e.s0_256=function(t){return i(t,2)^i(t,13)^i(t,22)},e.s1_256=function(t){return i(t,6)^i(t,11)^i(t,25)},e.g0_256=function(t){return i(t,7)^i(t,18)^t>>>3},e.g1_256=function(t){return i(t,17)^i(t,19)^t>>>10}},function(t,e,r){"use strict";var i=r(13),n=r(26),o=r(58),s=r(21),a=i.sum32,c=i.sum32_4,u=i.sum32_5,f=o.ch32,h=o.maj32,d=o.s0_256,p=o.s1_256,l=o.g0_256,g=o.g1_256,m=n.BlockHash,b=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function y(){if(!(this instanceof y))return new y;m.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=b,this.W=new Array(64)}i.inherits(y,m),t.exports=y,y.blockSize=512,y.outSize=256,y.hmacStrength=192,y.padLength=64,y.prototype._update=function(t,e){for(var r=this.W,i=0;i<16;i++)r[i]=t[e+i];for(;i<r.length;i++)r[i]=c(g(r[i-2]),r[i-7],l(r[i-15]),r[i-16]);var n=this.h[0],o=this.h[1],m=this.h[2],b=this.h[3],y=this.h[4],v=this.h[5],S=this.h[6],_=this.h[7];for(s(this.k.length===r.length),i=0;i<r.length;i++){var w=u(_,p(y),f(y,v,S),this.k[i],r[i]),I=a(d(n),h(n,o,m));_=S,S=v,v=y,y=a(b,w),b=m,m=o,o=n,n=a(w,I)}this.h[0]=a(this.h[0],n),this.h[1]=a(this.h[1],o),this.h[2]=a(this.h[2],m),this.h[3]=a(this.h[3],b),this.h[4]=a(this.h[4],y),this.h[5]=a(this.h[5],v),this.h[6]=a(this.h[6],S),this.h[7]=a(this.h[7],_)},y.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h,"big"):i.split32(this.h,"big")}},function(t,e,r){"use strict";var i=r(13),n=r(26),o=r(21),s=i.rotr64_hi,a=i.rotr64_lo,c=i.shr64_hi,u=i.shr64_lo,f=i.sum64,h=i.sum64_hi,d=i.sum64_lo,p=i.sum64_4_hi,l=i.sum64_4_lo,g=i.sum64_5_hi,m=i.sum64_5_lo,b=n.BlockHash,y=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function v(){if(!(this instanceof v))return new v;b.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=y,this.W=new Array(160)}function S(t,e,r,i,n){var o=t&r^~t&n;return o<0&&(o+=4294967296),o}function _(t,e,r,i,n,o){var s=e&i^~e&o;return s<0&&(s+=4294967296),s}function w(t,e,r,i,n){var o=t&r^t&n^r&n;return o<0&&(o+=4294967296),o}function I(t,e,r,i,n,o){var s=e&i^e&o^i&o;return s<0&&(s+=4294967296),s}function O(t,e){var r=s(t,e,28)^s(e,t,2)^s(e,t,7);return r<0&&(r+=4294967296),r}function P(t,e){var r=a(t,e,28)^a(e,t,2)^a(e,t,7);return r<0&&(r+=4294967296),r}function A(t,e){var r=s(t,e,14)^s(t,e,18)^s(e,t,9);return r<0&&(r+=4294967296),r}function E(t,e){var r=a(t,e,14)^a(t,e,18)^a(e,t,9);return r<0&&(r+=4294967296),r}function k(t,e){var r=s(t,e,1)^s(t,e,8)^c(t,e,7);return r<0&&(r+=4294967296),r}function x(t,e){var r=a(t,e,1)^a(t,e,8)^u(t,e,7);return r<0&&(r+=4294967296),r}function T(t,e){var r=s(t,e,19)^s(e,t,29)^c(t,e,6);return r<0&&(r+=4294967296),r}function R(t,e){var r=a(t,e,19)^a(e,t,29)^u(t,e,6);return r<0&&(r+=4294967296),r}i.inherits(v,b),t.exports=v,v.blockSize=1024,v.outSize=512,v.hmacStrength=192,v.padLength=128,v.prototype._prepareBlock=function(t,e){for(var r=this.W,i=0;i<32;i++)r[i]=t[e+i];for(;i<r.length;i+=2){var n=T(r[i-4],r[i-3]),o=R(r[i-4],r[i-3]),s=r[i-14],a=r[i-13],c=k(r[i-30],r[i-29]),u=x(r[i-30],r[i-29]),f=r[i-32],h=r[i-31];r[i]=p(n,o,s,a,c,u,f,h),r[i+1]=l(n,o,s,a,c,u,f,h)}},v.prototype._update=function(t,e){this._prepareBlock(t,e);var r=this.W,i=this.h[0],n=this.h[1],s=this.h[2],a=this.h[3],c=this.h[4],u=this.h[5],p=this.h[6],l=this.h[7],b=this.h[8],y=this.h[9],v=this.h[10],k=this.h[11],x=this.h[12],T=this.h[13],R=this.h[14],M=this.h[15];o(this.k.length===r.length);for(var N=0;N<r.length;N+=2){var B=R,C=M,H=A(b,y),U=E(b,y),L=S(b,y,v,k,x),F=_(b,y,v,k,x,T),D=this.k[N],K=this.k[N+1],z=r[N],j=r[N+1],V=g(B,C,H,U,L,F,D,K,z,j),G=m(B,C,H,U,L,F,D,K,z,j);B=O(i,n),C=P(i,n),H=w(i,n,s,a,c),U=I(i,n,s,a,c,u);var q=h(B,C,H,U),Y=d(B,C,H,U);R=x,M=T,x=v,T=k,v=b,k=y,b=h(p,l,V,G),y=d(l,l,V,G),p=c,l=u,c=s,u=a,s=i,a=n,i=h(V,G,q,Y),n=d(V,G,q,Y)}f(this.h,0,i,n),f(this.h,2,s,a),f(this.h,4,c,u),f(this.h,6,p,l),f(this.h,8,b,y),f(this.h,10,v,k),f(this.h,12,x,T),f(this.h,14,R,M)},v.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h,"big"):i.split32(this.h,"big")}},function(t,e,r){"use strict";(function(e){var i=r(25),n=r(18),o=r(16),s=r(6),a=r(48),c=r(14),u=r(4),f=r(23),h=r(2),d=r(1),p=r(10),l=r(0),g=r(5),m=function t(r){return this instanceof t?(this.chunks=[],e.isBuffer(r)?t.fromBuffer(r):r instanceof i?t.fromAddress(r):r instanceof t?t.fromBuffer(r.toBuffer()):d.isString(r)?t.fromString(r):void(d.isObject(r)&&d.isArray(r.chunks)&&this.set(r))):new t(r)};m.prototype.set=function(t){return h.checkArgument(d.isObject(t)),h.checkArgument(d.isArray(t.chunks)),this.chunks=t.chunks,this},m.fromBuffer=function(t){var e=new m;e.chunks=[];for(var r=new n(t);!r.finished();)try{var i,o,s=r.readUInt8();s>0&&s<a.OP_PUSHDATA1?(i=s,e.chunks.push({buf:r.read(i),len:i,opcodenum:s})):s===a.OP_PUSHDATA1?(i=r.readUInt8(),o=r.read(i),e.chunks.push({buf:o,len:i,opcodenum:s})):s===a.OP_PUSHDATA2?(i=r.readUInt16LE(),o=r.read(i),e.chunks.push({buf:o,len:i,opcodenum:s})):s===a.OP_PUSHDATA4?(i=r.readUInt32LE(),o=r.read(i),e.chunks.push({buf:o,len:i,opcodenum:s})):e.chunks.push({opcodenum:s})}catch(e){if(e instanceof RangeError)throw new p.Script.InvalidBuffer(t.toString("hex"));throw e}return e},m.prototype.toBuffer=function(){for(var t=new o,e=0;e<this.chunks.length;e++){var r=this.chunks[e],i=r.opcodenum;t.writeUInt8(r.opcodenum),r.buf&&(i<a.OP_PUSHDATA1?t.write(r.buf):i===a.OP_PUSHDATA1?(t.writeUInt8(r.len),t.write(r.buf)):i===a.OP_PUSHDATA2?(t.writeUInt16LE(r.len),t.write(r.buf)):i===a.OP_PUSHDATA4&&(t.writeUInt32LE(r.len),t.write(r.buf)))}return t.concat()},m.fromASM=function(t){var r=new m;r.chunks=[];for(var i=t.split(" "),n=0;n<i.length;){var o=i[n],s=a(o).toNumber();if("0"===o)s=0,r.chunks.push({opcodenum:s}),n+=1;else if("-1"===o)s=a.OP_1NEGATE,r.chunks.push({opcodenum:s}),n+=1;else if(d.isUndefined(s)){var c=e.from(i[n],"hex");if(c.toString("hex")!==i[n])throw new Error("invalid hex string in script");var u=c.length;u>=0&&u<a.OP_PUSHDATA1?s=u:u<Math.pow(2,8)?s=a.OP_PUSHDATA1:u<Math.pow(2,16)?s=a.OP_PUSHDATA2:u<Math.pow(2,32)&&(s=a.OP_PUSHDATA4),r.chunks.push({buf:c,len:c.length,opcodenum:s}),n+=1}else r.chunks.push({opcodenum:s}),n+=1}return r},m.fromHex=function(t){return new m(l.Buffer.from(t,"hex"))},m.fromString=function(t){if(g.isHexa(t)||0===t.length)return new m(l.Buffer.from(t,"hex"));var r=new m;r.chunks=[];for(var i=t.split(" "),n=0;n<i.length;){var o=i[n],s=a(o).toNumber();if(d.isUndefined(s)){if(!((s=parseInt(o))>0&&s<a.OP_PUSHDATA1))throw new Error("Invalid script: "+JSON.stringify(t));r.chunks.push({buf:e.from(i[n+1].slice(2),"hex"),len:s,opcodenum:s}),n+=2}else if(s===a.OP_PUSHDATA1||s===a.OP_PUSHDATA2||s===a.OP_PUSHDATA4){if("0x"!==i[n+2].slice(0,2))throw new Error("Pushdata data must start with 0x");r.chunks.push({buf:e.from(i[n+2].slice(2),"hex"),len:parseInt(i[n+1]),opcodenum:s}),n+=3}else r.chunks.push({opcodenum:s}),n+=1}return r},m.prototype._chunkToString=function(t,e){var r=t.opcodenum,i="asm"===e,n="";if(t.buf)i||r!==a.OP_PUSHDATA1&&r!==a.OP_PUSHDATA2&&r!==a.OP_PUSHDATA4||(n=n+" "+a(r).toString()),t.len>0&&(n=i?n+" "+t.buf.toString("hex"):n+" "+t.len+" 0x"+t.buf.toString("hex"));else if(void 0!==a.reverseMap[r])i?0===r?n+=" 0":79===r?n+=" -1":n=n+" "+a(r).toString():n=n+" "+a(r).toString();else{var o=r.toString(16);o.length%2!=0&&(o="0"+o),n=i?n+" "+o:n+" 0x"+o}return n},m.prototype.toASM=function(){for(var t="",e=0;e<this.chunks.length;e++){var r=this.chunks[e];t+=this._chunkToString(r,"asm")}return t.substr(1)},m.prototype.toString=function(){for(var t="",e=0;e<this.chunks.length;e++){var r=this.chunks[e];t+=this._chunkToString(r)}return t.substr(1)},m.prototype.toHex=function(){return this.toBuffer().toString("hex")},m.prototype.inspect=function(){return"<Script: "+this.toString()+">"},m.prototype.isPublicKeyHashOut=function(){return!(5!==this.chunks.length||this.chunks[0].opcodenum!==a.OP_DUP||this.chunks[1].opcodenum!==a.OP_HASH160||!this.chunks[2].buf||20!==this.chunks[2].buf.length||this.chunks[3].opcodenum!==a.OP_EQUALVERIFY||this.chunks[4].opcodenum!==a.OP_CHECKSIG)},m.prototype.isPublicKeyHashIn=function(){if(2===this.chunks.length){var t=this.chunks[0].buf,e=this.chunks[1].buf;if(t&&t.length&&48===t[0]&&e&&e.length){var r=e[0];if((4===r||6===r||7===r)&&65===e.length)return!0;if((3===r||2===r)&&33===e.length)return!0}}return!1},m.prototype.getPublicKey=function(){return h.checkState(this.isPublicKeyOut(),"Can't retrieve PublicKey from a non-PK output"),this.chunks[0].buf},m.prototype.getPublicKeyHash=function(){return h.checkState(this.isPublicKeyHashOut(),"Can't retrieve PublicKeyHash from a non-PKH output"),this.chunks[2].buf},m.prototype.isPublicKeyOut=function(){if(2===this.chunks.length&&this.chunks[0].buf&&this.chunks[0].buf.length&&this.chunks[1].opcodenum===a.OP_CHECKSIG){var t=this.chunks[0].buf,e=t[0],r=!1;if((4!==e&&6!==e&&7!==e||65!==t.length)&&(3!==e&&2!==e||33!==t.length)||(r=!0),r)return c.isValid(t)}return!1},m.prototype.isPublicKeyIn=function(){if(1===this.chunks.length){var t=this.chunks[0].buf;if(t&&t.length&&48===t[0])return!0}return!1},m.prototype.isScriptHashOut=function(){var t=this.toBuffer();return 23===t.length&&t[0]===a.OP_HASH160&&20===t[1]&&t[t.length-1]===a.OP_EQUAL},m.prototype.isScriptHashIn=function(){if(this.chunks.length<=1)return!1;var t,e=this.chunks[this.chunks.length-1].buf;if(!e)return!1;try{t=m.fromBuffer(e)}catch(t){if(t instanceof p.Script.InvalidBuffer)return!1;throw t}return t.classify()!==m.types.UNKNOWN},m.prototype.isMultisigOut=function(){return this.chunks.length>3&&a.isSmallIntOp(this.chunks[0].opcodenum)&&this.chunks.slice(1,this.chunks.length-2).every((function(t){return t.buf&&e.isBuffer(t.buf)}))&&a.isSmallIntOp(this.chunks[this.chunks.length-2].opcodenum)&&this.chunks[this.chunks.length-1].opcodenum===a.OP_CHECKMULTISIG},m.prototype.isMultisigIn=function(){return this.chunks.length>=2&&0===this.chunks[0].opcodenum&&this.chunks.slice(1,this.chunks.length).every((function(t){return t.buf&&e.isBuffer(t.buf)&&u.isTxDER(t.buf)}))},m.prototype.isDataOut=function(){if(!(this.chunks.length>=1&&this.chunks[0].opcodenum===a.OP_RETURN))return!1;var t=this.chunks.slice(1);return new m({chunks:t}).isPushOnly()},m.prototype.isSafeDataOut=function(){if(this.chunks.length<2)return!1;if(this.chunks[0].opcodenum!==a.OP_FALSE)return!1;var t=this.chunks.slice(1);return new m({chunks:t}).isDataOut()},m.prototype.getData=function(){if(this.isSafeDataOut())return this.chunks.slice(2).map(t=>t.buf);if(this.isDataOut()||this.isScriptHashOut())return d.isUndefined(this.chunks[1])?e.alloc(0):e.from(this.chunks[1].buf);if(this.isPublicKeyHashOut())return e.from(this.chunks[2].buf);throw new Error("Unrecognized script type to get data from")},m.prototype.isPushOnly=function(){return d.every(this.chunks,(function(t){return t.opcodenum<=a.OP_16||t.opcodenum===a.OP_PUSHDATA1||t.opcodenum===a.OP_PUSHDATA2||t.opcodenum===a.OP_PUSHDATA4}))},(m.types={}).UNKNOWN="Unknown",m.types.PUBKEY_OUT="Pay to public key",m.types.PUBKEY_IN="Spend from public key",m.types.PUBKEYHASH_OUT="Pay to public key hash",m.types.PUBKEYHASH_IN="Spend from public key hash",m.types.SCRIPTHASH_OUT="Pay to script hash",m.types.SCRIPTHASH_IN="Spend from script hash",m.types.MULTISIG_OUT="Pay to multisig",m.types.MULTISIG_IN="Spend from multisig",m.types.DATA_OUT="Data push",m.types.SAFE_DATA_OUT="Safe data push",m.OP_RETURN_STANDARD_SIZE=220,m.prototype.classify=function(){if(this._isInput)return this.classifyInput();if(this._isOutput)return this.classifyOutput();var t=this.classifyOutput();return t!==m.types.UNKNOWN?t:this.classifyInput()},(m.outputIdentifiers={}).PUBKEY_OUT=m.prototype.isPublicKeyOut,m.outputIdentifiers.PUBKEYHASH_OUT=m.prototype.isPublicKeyHashOut,m.outputIdentifiers.MULTISIG_OUT=m.prototype.isMultisigOut,m.outputIdentifiers.SCRIPTHASH_OUT=m.prototype.isScriptHashOut,m.outputIdentifiers.DATA_OUT=m.prototype.isDataOut,m.outputIdentifiers.SAFE_DATA_OUT=m.prototype.isSafeDataOut,m.prototype.classifyOutput=function(){for(var t in m.outputIdentifiers)if(m.outputIdentifiers[t].bind(this)())return m.types[t];return m.types.UNKNOWN},(m.inputIdentifiers={}).PUBKEY_IN=m.prototype.isPublicKeyIn,m.inputIdentifiers.PUBKEYHASH_IN=m.prototype.isPublicKeyHashIn,m.inputIdentifiers.MULTISIG_IN=m.prototype.isMultisigIn,m.inputIdentifiers.SCRIPTHASH_IN=m.prototype.isScriptHashIn,m.prototype.classifyInput=function(){for(var t in m.inputIdentifiers)if(m.inputIdentifiers[t].bind(this)())return m.types[t];return m.types.UNKNOWN},m.prototype.isStandard=function(){return this.classify()!==m.types.UNKNOWN},m.prototype.prepend=function(t){return this._addByType(t,!0),this},m.prototype.equals=function(t){if(h.checkState(t instanceof m,"Must provide another script"),this.chunks.length!==t.chunks.length)return!1;var r;for(r=0;r<this.chunks.length;r++){if(e.isBuffer(this.chunks[r].buf)&&!e.isBuffer(t.chunks[r].buf))return!1;if(e.isBuffer(this.chunks[r].buf)&&!this.chunks[r].buf.equals(t.chunks[r].buf))return!1;if(this.chunks[r].opcodenum!==t.chunks[r].opcodenum)return!1}return!0},m.prototype.add=function(t){return this._addByType(t,!1),this},m.prototype._addByType=function(t,r){if("string"==typeof t)this._addOpcode(t,r);else if("number"==typeof t)this._addOpcode(t,r);else if(t instanceof a)this._addOpcode(t,r);else if(e.isBuffer(t))this._addBuffer(t,r);else if(t instanceof m)this.chunks=this.chunks.concat(t.chunks);else{if("object"!=typeof t)throw new Error("Invalid script chunk");this._insertAtPosition(t,r)}},m.prototype._insertAtPosition=function(t,e){e?this.chunks.unshift(t):this.chunks.push(t)},m.prototype._addOpcode=function(t,e){var r;return r="number"==typeof t?t:t instanceof a?t.toNumber():a(t).toNumber(),this._insertAtPosition({opcodenum:r},e),this},m.prototype._addBuffer=function(t,e){var r,i=t.length;if(i>=0&&i<a.OP_PUSHDATA1)r=i;else if(i<Math.pow(2,8))r=a.OP_PUSHDATA1;else if(i<Math.pow(2,16))r=a.OP_PUSHDATA2;else{if(!(i<Math.pow(2,32)))throw new Error("You can't push that much data");r=a.OP_PUSHDATA4}return this._insertAtPosition({buf:t,len:i,opcodenum:r},e),this},m.prototype.removeCodeseparators=function(){for(var t=[],e=0;e<this.chunks.length;e++)this.chunks[e].opcodenum!==a.OP_CODESEPARATOR&&t.push(this.chunks[e]);return this.chunks=t,this},m.buildMultisigOut=function(t,e,r){h.checkArgument(e<=t.length,"Number of required signatures must be less than or equal to the number of public keys"),r=r||{};var i=new m;i.add(a.smallInt(e));var n=t=d.map(t,c);r.noSorting||(n=t.map(t=>t.toString("hex")).sort().map(t=>new c(t)));for(var o=0;o<n.length;o++){var s=n[o];i.add(s.toBuffer())}return i.add(a.smallInt(t.length)),i.add(a.OP_CHECKMULTISIG),i},m.buildMultisigIn=function(t,r,i,n){h.checkArgument(d.isArray(t)),h.checkArgument(d.isNumber(r)),h.checkArgument(d.isArray(i)),n=n||{};var o=new m;return o.add(a.OP_0),d.each(i,(function(t){h.checkArgument(e.isBuffer(t),"Signatures must be an array of Buffers"),o.add(t)})),o},m.buildP2SHMultisigIn=function(t,r,i,n){h.checkArgument(d.isArray(t)),h.checkArgument(d.isNumber(r)),h.checkArgument(d.isArray(i)),n=n||{};var o=new m;return o.add(a.OP_0),d.each(i,(function(t){h.checkArgument(e.isBuffer(t),"Signatures must be an array of Buffers"),o.add(t)})),o.add((n.cachedMultisig||m.buildMultisigOut(t,r,n)).toBuffer()),o},m.buildPublicKeyHashOut=function(t){h.checkArgument(!d.isUndefined(t)),h.checkArgument(t instanceof c||t instanceof i||d.isString(t)),t instanceof c?t=t.toAddress():d.isString(t)&&(t=new i(t));var e=new m;return e.add(a.OP_DUP).add(a.OP_HASH160).add(t.hashBuffer).add(a.OP_EQUALVERIFY).add(a.OP_CHECKSIG),e._network=t.network,e},m.buildPublicKeyOut=function(t){h.checkArgument(t instanceof c);var e=new m;return e.add(t.toBuffer()).add(a.OP_CHECKSIG),e},m.buildDataOut=function(t,r){h.checkArgument(d.isUndefined(t)||d.isString(t)||d.isArray(t)||e.isBuffer(t));var i=t;d.isArray(i)||(i=[t]);var n=new m;n.add(a.OP_RETURN);for(let t of i)h.checkArgument(d.isUndefined(t)||d.isString(t)||e.isBuffer(t)),d.isString(t)&&(t=e.from(t,r)),d.isUndefined(t)||n.add(t);return n},m.buildSafeDataOut=function(t,e){var r=m.buildDataOut(t,e),i=new m;return i.add(a.OP_FALSE),i.add(r),i},m.buildScriptHashOut=function(t){h.checkArgument(t instanceof m||t instanceof i&&t.isPayToScriptHash());var e=new m;return e.add(a.OP_HASH160).add(t instanceof i?t.hashBuffer:s.sha256ripemd160(t.toBuffer())).add(a.OP_EQUAL),e._network=t._network||t.network,e},m.buildPublicKeyIn=function(t,r){h.checkArgument(t instanceof u||e.isBuffer(t)),h.checkArgument(d.isUndefined(r)||d.isNumber(r)),t instanceof u&&(t=t.toBuffer());var i=new m;return i.add(e.concat([t,e.from([255&(r||u.SIGHASH_ALL)])])),i},m.buildPublicKeyHashIn=function(t,r,i){return h.checkArgument(r instanceof u||e.isBuffer(r)),h.checkArgument(d.isUndefined(i)||d.isNumber(i)),r instanceof u&&(r=r.toBuffer()),(new m).add(e.concat([r,e.from([255&(i||u.SIGHASH_ALL)])])).add(new c(t).toBuffer())},m.empty=function(){return new m},m.prototype.toScriptHashOut=function(){return m.buildScriptHashOut(this)},m.fromAddress=function(t){if((t=i(t)).isPayToScriptHash())return m.buildScriptHashOut(t);if(t.isPayToPublicKeyHash())return m.buildPublicKeyHashOut(t);throw new p.Script.UnrecognizedAddress(t)},m.prototype.getAddressInfo=function(t){if(this._isInput)return this._getInputAddressInfo();if(this._isOutput)return this._getOutputAddressInfo();var e=this._getOutputAddressInfo();return e||this._getInputAddressInfo()},m.prototype._getOutputAddressInfo=function(){var t={};if(this.isScriptHashOut())t.hashBuffer=this.getData(),t.type=i.PayToScriptHash;else{if(!this.isPublicKeyHashOut())return!1;t.hashBuffer=this.getData(),t.type=i.PayToPublicKeyHash}return t},m.prototype._getInputAddressInfo=function(){var t={};if(this.isPublicKeyHashIn())t.hashBuffer=s.sha256ripemd160(this.chunks[1].buf),t.type=i.PayToPublicKeyHash;else{if(!this.isScriptHashIn())return!1;t.hashBuffer=s.sha256ripemd160(this.chunks[this.chunks.length-1].buf),t.type=i.PayToScriptHash}return t},m.prototype.toAddress=function(t){var e=this.getAddressInfo();return!!e&&(e.network=f.get(t)||this._network||f.defaultNetwork,new i(e))},m.prototype.findAndDelete=function(t){for(var e=t.toBuffer().toString("hex"),r=0;r<this.chunks.length;r++){e===m({chunks:[this.chunks[r]]}).toBuffer().toString("hex")&&this.chunks.splice(r,1)}return this},m.prototype.checkMinimalPush=function(t){var e=this.chunks[t],r=e.buf,i=e.opcodenum;return!r||(0===r.length?i===a.OP_0:1===r.length&&r[0]>=1&&r[0]<=16?i===a.OP_1+(r[0]-1):1===r.length&&129===r[0]?i===a.OP_1NEGATE:r.length<=75?i===r.length:r.length<=255?i===a.OP_PUSHDATA1:!(r.length<=65535)||i===a.OP_PUSHDATA2)},m.prototype._decodeOP_N=function(t){if(t===a.OP_0)return 0;if(t>=a.OP_1&&t<=a.OP_16)return t-(a.OP_1-1);throw new Error("Invalid opcode: "+JSON.stringify(t))},m.prototype.getSignatureOperationsCount=function(t){t=!!d.isUndefined(t)||t;var e=this,r=0,i=a.OP_INVALIDOPCODE;return d.each(e.chunks,(function(n){var o=n.opcodenum;o===a.OP_CHECKSIG||o===a.OP_CHECKSIGVERIFY?r++:o!==a.OP_CHECKMULTISIG&&o!==a.OP_CHECKMULTISIGVERIFY||(t&&i>=a.OP_1&&i<=a.OP_16?r+=e._decodeOP_N(i):r+=20),i=o})),r},t.exports=m}).call(this,r(0).Buffer)},function(t,e,r){"use strict";var i=Object.prototype.toString;t.exports=function(t){var e=i.call(t),r="[object Arguments]"===e;return r||(r="[object Array]"!==e&&null!==t&&"object"==typeof t&&"number"==typeof t.length&&t.length>=0&&"[object Function]"===i.call(t.callee)),r}},function(t,e,r){"use strict";t.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var t={},e=Symbol("test"),r=Object(e);if("string"==typeof e)return!1;if("[object Symbol]"!==Object.prototype.toString.call(e))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(var i in t[e]=42,t)return!1;if("function"==typeof Object.keys&&0!==Object.keys(t).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(t).length)return!1;var n=Object.getOwnPropertySymbols(t);if(1!==n.length||n[0]!==e)return!1;if(!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var o=Object.getOwnPropertyDescriptor(t,e);if(42!==o.value||!0!==o.enumerable)return!1}return!0}},function(t,e,r){"use strict";t.exports=TypeError},function(t,e,r){"use strict";var i=r(127);if(i)try{i([],"length")}catch(t){i=null}t.exports=i},function(t,e,r){"use strict";t.exports="undefined"!=typeof Reflect&&Reflect.getPrototypeOf||null},function(t,e,r){"use strict";var i=r(46);t.exports=i.getPrototypeOf||null},function(t,e,r){"use strict";var i=r(36),n=r(64),o=r(47),s=r(133);t.exports=function(t){if(t.length<1||"function"!=typeof t[0])throw new n("a function is required");return s(i,o,t)}},function(t,e,r){"use strict";t.exports=Function.prototype.apply},function(t,e){var r=Object.prototype.toString;function i(t){return"function"==typeof t.constructor?t.constructor.name:null}t.exports=function(t){if(void 0===t)return"undefined";if(null===t)return"null";var e=typeof t;if("boolean"===e)return"boolean";if("string"===e)return"string";if("number"===e)return"number";if("symbol"===e)return"symbol";if("function"===e)return"GeneratorFunction"===i(t)?"generatorfunction":"function";if(function(t){return Array.isArray?Array.isArray(t):t instanceof Array}(t))return"array";if(function(t){if(t.constructor&&"function"==typeof t.constructor.isBuffer)return t.constructor.isBuffer(t);return!1}(t))return"buffer";if(function(t){try{if("number"==typeof t.length&&"function"==typeof t.callee)return!0}catch(t){if(-1!==t.message.indexOf("callee"))return!0}return!1}(t))return"arguments";if(function(t){return t instanceof Date||"function"==typeof t.toDateString&&"function"==typeof t.getDate&&"function"==typeof t.setDate}(t))return"date";if(function(t){return t instanceof Error||"string"==typeof t.message&&t.constructor&&"number"==typeof t.constructor.stackTraceLimit}(t))return"error";if(function(t){return t instanceof RegExp||"string"==typeof t.flags&&"boolean"==typeof t.ignoreCase&&"boolean"==typeof t.multiline&&"boolean"==typeof t.global}(t))return"regexp";switch(i(t)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(function(t){return"function"==typeof t.throw&&"function"==typeof t.return&&"function"==typeof t.next}(t))return"generator";switch(e=r.call(t)){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return e.slice(8,-1).toLowerCase().replace(/\s/g,"")}},function(t,e,r){"use strict";(function(e){var i=r(1),n=r(2),o=r(0),s=r(10),a=r(5),c=r(18),u=r(16),f=r(28),h=r(6),d=r(4),p=r(19),l=r(25),g=r(72),m=r(50),b=m.PublicKeyHash,y=m.PublicKey,v=m.MultiSigScriptHash,S=m.MultiSig,_=r(20),w=r(12),I=r(34),O=r(3),P=r(49).SCRIPT_ENABLE_SIGHASH_FORKID;function A(t){if(!(this instanceof A))return new A(t);if(this.inputs=[],this.outputs=[],this._inputAmount=void 0,this._outputAmount=void 0,t){if(t instanceof A)return A.shallowCopy(t);if(a.isHexa(t))this.fromString(t);else if(e.isBuffer(t))this.fromBuffer(t);else{if(!i.isObject(t))throw new s.InvalidArgument("Must provide an object or string to deserialize a transaction");this.fromObject(t)}}else this._newTransaction()}A.DUST_AMOUNT=546,A.FEE_SECURITY_MARGIN=150,A.MAX_MONEY=21e14,A.NLOCKTIME_BLOCKHEIGHT_LIMIT=5e8,A.NLOCKTIME_MAX_VALUE=4294967295,A.FEE_PER_KB=500,A.CHANGE_OUTPUT_MAX_SIZE=62,A.shallowCopy=function(t){return new A(t.toBuffer())};var E={configurable:!1,enumerable:!0,get:function(){return this._hash=new c(this._getHash()).readReverse().toString("hex"),this._hash}};Object.defineProperty(A.prototype,"hash",E),Object.defineProperty(A.prototype,"id",E);var k={configurable:!1,enumerable:!0,get:function(){return this._getInputAmount()}};Object.defineProperty(A.prototype,"inputAmount",k),k.get=function(){return this._getOutputAmount()},Object.defineProperty(A.prototype,"outputAmount",k),A.prototype._getHash=function(){return h.sha256sha256(this.toBuffer())},A.prototype.serialize=function(t){return!0===t||t&&t.disableAll?this.uncheckedSerialize():this.checkedSerialize(t)},A.prototype.uncheckedSerialize=A.prototype.toString=function(){return this.toBuffer().toString("hex")},A.prototype.checkedSerialize=function(t){var e=this.getSerializationError(t);if(e)throw e.message+=" - For more information please see: https://bsv.io/api/lib/transaction#serialization-checks",e;return this.uncheckedSerialize()},A.prototype.invalidSatoshis=function(){for(var t=!1,e=0;e<this.outputs.length;e++)this.outputs[e].invalidSatoshis()&&(t=!0);return t},A.prototype.getSerializationError=function(t){if(t=t||{},this.invalidSatoshis())return new s.Transaction.InvalidSatoshis;var e,r=this._getUnspentValue();return r<0?t.disableMoreOutputThanInput||(e=new s.Transaction.InvalidOutputAmountSum):e=this._hasFeeError(t,r),e||this._hasDustOutputs(t)||this._isMissingSignatures(t)},A.prototype._hasFeeError=function(t,e){if(!i.isUndefined(this._fee)&&this._fee!==e)return new s.Transaction.FeeError.Different("Unspent value is "+e+" but specified fee is "+this._fee);if(!t.disableLargeFees){var r=Math.floor(A.FEE_SECURITY_MARGIN*this._estimateFee());if(e>r)return this._missingChange()?new s.Transaction.ChangeAddressMissing("Fee is too large and no change address was provided"):new s.Transaction.FeeError.TooLarge("expected less than "+r+" but got "+e)}},A.prototype._missingChange=function(){return!this._changeScript},A.prototype._hasDustOutputs=function(t){var e,r;if(!t.disableDustOutputs)for(e in this.outputs)if((r=this.outputs[e]).satoshis<A.DUST_AMOUNT&&!r.script.isDataOut()&&!r.script.isSafeDataOut())return new s.Transaction.DustOutputs},A.prototype._isMissingSignatures=function(t){if(!t.disableIsFullySigned)return this.isFullySigned()?void 0:new s.Transaction.MissingSignatures},A.prototype.inspect=function(){return"<Transaction: "+this.uncheckedSerialize()+">"},A.prototype.toBuffer=function(){var t=new u;return this.toBufferWriter(t).toBuffer()},A.prototype.toBufferWriter=function(t){return t.writeInt32LE(this.version),t.writeVarintNum(this.inputs.length),i.each(this.inputs,(function(e){e.toBufferWriter(t)})),t.writeVarintNum(this.outputs.length),i.each(this.outputs,(function(e){e.toBufferWriter(t)})),t.writeUInt32LE(this.nLockTime),t},A.prototype.fromBuffer=function(t){var e=new c(t);return this.fromBufferReader(e)},A.prototype.fromBufferReader=function(t){var e,r,i;for(n.checkArgument(!t.finished(),"No transaction data received"),this.version=t.readInt32LE(),r=t.readVarintNum(),e=0;e<r;e++){var o=m.fromBufferReader(t);this.inputs.push(o)}for(i=t.readVarintNum(),e=0;e<i;e++)this.outputs.push(_.fromBufferReader(t));return this.nLockTime=t.readUInt32LE(),this},A.prototype.toObject=A.prototype.toJSON=function(){var t=[];this.inputs.forEach((function(e){t.push(e.toObject())}));var e=[];this.outputs.forEach((function(t){e.push(t.toObject())}));var r={hash:this.hash,version:this.version,inputs:t,outputs:e,nLockTime:this.nLockTime};return this._changeScript&&(r.changeScript=this._changeScript.toString()),i.isUndefined(this._changeIndex)||(r.changeIndex=this._changeIndex),i.isUndefined(this._fee)||(r.fee=this._fee),r},A.prototype.fromObject=function(t){n.checkArgument(i.isObject(t)||t instanceof A);var e,r=this;return e=t instanceof A?e.toObject():t,i.each(e.inputs,(function(t){if(t.output&&t.output.script){var e,i=new w(t.output.script);if(i.isPublicKeyHashOut())e=new m.PublicKeyHash(t);else if(i.isScriptHashOut()&&t.publicKeys&&t.threshold)e=new m.MultiSigScriptHash(t,t.publicKeys,t.threshold,t.signatures);else{if(!i.isPublicKeyOut())throw new s.Transaction.Input.UnsupportedScript(t.output.script);e=new m.PublicKey(t)}r.addInput(e)}else r.uncheckedAddInput(new m(t))})),i.each(e.outputs,(function(t){r.addOutput(new _(t))})),e.changeIndex&&(this._changeIndex=e.changeIndex),e.changeScript&&(this._changeScript=new w(e.changeScript)),e.fee&&(this._fee=e.fee),this.nLockTime=e.nLockTime,this.version=e.version,this._checkConsistency(t),this},A.prototype._checkConsistency=function(t){i.isUndefined(this._changeIndex)||(n.checkState(this._changeScript,"Change script is expected."),n.checkState(this.outputs[this._changeIndex],"Change index points to undefined output."),n.checkState(this.outputs[this._changeIndex].script.toString()===this._changeScript.toString(),"Change output has an unexpected script.")),t&&t.hash&&n.checkState(t.hash===this.hash,"Hash in object does not match transaction hash.")},A.prototype.lockUntilDate=function(t){if(n.checkArgument(t),i.isNumber(t)&&t<A.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new s.Transaction.LockTimeTooEarly;i.isDate(t)&&(t=t.getTime()/1e3);for(var e=0;e<this.inputs.length;e++)this.inputs[e].sequenceNumber===m.DEFAULT_SEQNUMBER&&(this.inputs[e].sequenceNumber=m.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=t,this},A.prototype.lockUntilBlockHeight=function(t){if(n.checkArgument(i.isNumber(t)),t>=A.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new s.Transaction.BlockHeightTooHigh;if(t<0)throw new s.Transaction.NLockTimeOutOfRange;for(var e=0;e<this.inputs.length;e++)this.inputs[e].sequenceNumber===m.DEFAULT_SEQNUMBER&&(this.inputs[e].sequenceNumber=m.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=t,this},A.prototype.getLockTime=function(){return this.nLockTime?this.nLockTime<A.NLOCKTIME_BLOCKHEIGHT_LIMIT?this.nLockTime:new Date(1e3*this.nLockTime):null},A.prototype.fromString=function(t){this.fromBuffer(o.Buffer.from(t,"hex"))},A.prototype._newTransaction=function(){this.version=1,this.nLockTime=0},A.prototype.from=function(t,e,r){if(i.isArray(t)){var n=this;return i.each(t,(function(t){n.from(t,e,r)})),this}return i.some(this.inputs,(function(e){return e.prevTxId.toString("hex")===t.txId&&e.outputIndex===t.outputIndex}))||(e&&r?this._fromMultisigUtxo(t,e,r):this._fromNonP2SH(t)),this},A.prototype._fromNonP2SH=function(t){var e;e=(t=new g(t)).script.isPublicKeyHashOut()?b:t.script.isPublicKeyOut()?y:m,this.addInput(new e({output:new _({script:t.script,satoshis:t.satoshis}),prevTxId:t.txId,outputIndex:t.outputIndex,script:w.empty()}))},A.prototype._fromMultisigUtxo=function(t,e,r){var i;if(n.checkArgument(r<=e.length,"Number of required signatures must be greater than the number of public keys"),(t=new g(t)).script.isMultisigOut())i=S;else{if(!t.script.isScriptHashOut())throw new Error("@TODO");i=v}this.addInput(new i({output:new _({script:t.script,satoshis:t.satoshis}),prevTxId:t.txId,outputIndex:t.outputIndex,script:w.empty()},e,r))},A.prototype.addInput=function(t,e,r){if(n.checkArgumentType(t,m,"input"),!t.output&&(i.isUndefined(e)||i.isUndefined(r)))throw new s.Transaction.NeedMoreInfo("Need information about the UTXO script and satoshis");return t.output||!e||i.isUndefined(r)||(e=e instanceof w?e:new w(e),n.checkArgumentType(r,"number","satoshis"),t.output=new _({script:e,satoshis:r})),this.uncheckedAddInput(t)},A.prototype.uncheckedAddInput=function(t){return n.checkArgumentType(t,m,"input"),this.inputs.push(t),this._inputAmount=void 0,this._updateChangeOutput(),this},A.prototype.hasAllUtxoInfo=function(){return i.every(this.inputs.map((function(t){return!!t.output})))},A.prototype.fee=function(t){return n.checkArgument(i.isNumber(t),"amount must be a number"),this._fee=t,this._updateChangeOutput(),this},A.prototype.feePerKb=function(t){return n.checkArgument(i.isNumber(t),"amount must be a number"),this._feePerKb=t,this._updateChangeOutput(),this},A.prototype.change=function(t){return n.checkArgument(t,"address is required"),this._changeScript=w.fromAddress(t),this._updateChangeOutput(),this},A.prototype.getChangeOutput=function(){return i.isUndefined(this._changeIndex)?null:this.outputs[this._changeIndex]},A.prototype.to=function(t,e){if(i.isArray(t)){var r=this;return i.each(t,(function(t){r.to(t.address,t.satoshis)})),this}return n.checkArgument(a.isNaturalNumber(e),"Amount is expected to be a positive integer"),this.addOutput(new _({script:w(new l(t)),satoshis:e})),this},A.prototype.addData=function(t){return this.addOutput(new _({script:w.buildDataOut(t),satoshis:0})),this},A.prototype.addSafeData=function(t){return this.addOutput(new _({script:w.buildSafeDataOut(t),satoshis:0})),this},A.prototype.addOutput=function(t){return n.checkArgumentType(t,_,"output"),this._addOutput(t),this._updateChangeOutput(),this},A.prototype.clearOutputs=function(){return this.outputs=[],this._clearSignatures(),this._outputAmount=void 0,this._changeIndex=void 0,this._updateChangeOutput(),this},A.prototype._addOutput=function(t){this.outputs.push(t),this._outputAmount=void 0},A.prototype._getOutputAmount=function(){if(i.isUndefined(this._outputAmount)){var t=this;this._outputAmount=0,i.each(this.outputs,(function(e){t._outputAmount+=e.satoshis}))}return this._outputAmount},A.prototype._getInputAmount=function(){if(i.isUndefined(this._inputAmount)){var t=this;this._inputAmount=0,i.each(this.inputs,(function(e){if(i.isUndefined(e.output))throw new s.Transaction.Input.MissingPreviousOutput;t._inputAmount+=e.output.satoshis}))}return this._inputAmount},A.prototype._updateChangeOutput=function(){if(this._changeScript){this._clearSignatures(),i.isUndefined(this._changeIndex)||this._removeOutput(this._changeIndex),this._changeIndex=this.outputs.length,this._addOutput(new _({script:this._changeScript,satoshis:0}));var t=this._getUnspentValue()-this.getFee();this._removeOutput(this._changeIndex),this._changeIndex=void 0,t>=A.DUST_AMOUNT&&(this._changeIndex=this.outputs.length,this._addOutput(new _({script:this._changeScript,satoshis:t})))}},A.prototype.getFee=function(){return this.isCoinbase()?0:i.isUndefined(this._fee)?this._changeScript?this._estimateFee():this._getUnspentValue():this._fee},A.prototype._estimateFee=function(){var t=this._estimateSize();return Math.ceil(t/1e3*(this._feePerKb||A.FEE_PER_KB))},A.prototype._getUnspentValue=function(){return this._getInputAmount()-this._getOutputAmount()},A.prototype._clearSignatures=function(){i.each(this.inputs,(function(t){t.clearSignatures()}))},A.prototype._estimateSize=function(){var t=8;return t+=f(this.inputs.length).toBuffer().length,t+=f(this.outputs.length).toBuffer().length,i.each(this.inputs,(function(e){t+=e._estimateSize()})),i.each(this.outputs,(function(e){t+=e.getSize()})),t},A.prototype._removeOutput=function(t){var e=this.outputs[t];this.outputs=i.without(this.outputs,e),this._outputAmount=void 0},A.prototype.removeOutput=function(t){this._removeOutput(t),this._updateChangeOutput()},A.prototype.sort=function(){return this.sortInputs((function(t){var e=Array.prototype.concat.apply([],t);return e.sort((function(t,e){return t.prevTxId.compare(e.prevTxId)||t.outputIndex-e.outputIndex})),e})),this.sortOutputs((function(t){var e=Array.prototype.concat.apply([],t);return e.sort((function(t,e){return t.satoshis-e.satoshis||t.script.toBuffer().compare(e.script.toBuffer())})),e})),this},A.prototype.shuffleOutputs=function(){return this.sortOutputs(i.shuffle)},A.prototype.sortOutputs=function(t){var e=t(this.outputs);return this._newOutputOrder(e)},A.prototype.sortInputs=function(t){return this.inputs=t(this.inputs),this._clearSignatures(),this},A.prototype._newOutputOrder=function(t){if(this.outputs.length!==t.length||0!==i.difference(this.outputs,t).length)throw new s.Transaction.InvalidSorting;if(!i.isUndefined(this._changeIndex)){var e=this.outputs[this._changeIndex];this._changeIndex=t.indexOf(e)}return this.outputs=t,this},A.prototype.removeInput=function(t,e){var r;if((r=!e&&i.isNumber(t)?t:i.findIndex(this.inputs,(function(r){return r.prevTxId.toString("hex")===t&&r.outputIndex===e})))<0||r>=this.inputs.length)throw new s.Transaction.InvalidIndex(r,this.inputs.length);var n=this.inputs[r];this.inputs=i.without(this.inputs,n),this._inputAmount=void 0,this._updateChangeOutput()},A.prototype.sign=function(t,e){n.checkState(this.hasAllUtxoInfo(),"Not all utxo information is available to sign the transaction.");var r=this;return i.isArray(t)?(i.each(t,(function(t){r.sign(t,e)})),this):(i.each(this.getSignatures(t,e),(function(t){r.applySignature(t)})),this)},A.prototype.getSignatures=function(t,e){t=new I(t),e=e||d.SIGHASH_ALL|d.SIGHASH_FORKID;var r=this,n=[],o=h.sha256ripemd160(t.publicKey.toBuffer());return i.each(this.inputs,(function(s,a){i.each(s.getSignatures(r,t,a,e,o),(function(t){n.push(t)}))})),n},A.prototype.applySignature=function(t){return this.inputs[t.inputIndex].addSignature(this,t),this},A.prototype.isFullySigned=function(){return i.each(this.inputs,(function(t){if(t.isFullySigned===m.prototype.isFullySigned)throw new s.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction")})),i.every(i.map(this.inputs,(function(t){return t.isFullySigned()})))},A.prototype.isValidSignature=function(t){if(this.inputs[t.inputIndex].isValidSignature===m.prototype.isValidSignature)throw new s.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction");return this.inputs[t.inputIndex].isValidSignature(this,t)},A.prototype.verifySignature=function(t,e,r,i,n,o){return p.verify(this,t,e,r,i,n,o)},A.prototype.verify=function(){if(0===this.inputs.length)return"transaction txins empty";if(0===this.outputs.length)return"transaction txouts empty";for(var t=new O(0),e=0;e<this.outputs.length;e++){var r=this.outputs[e];if(r.invalidSatoshis())return"transaction txout "+e+" satoshis is invalid";if(r._satoshisBN.gt(new O(A.MAX_MONEY,10)))return"transaction txout "+e+" greater than MAX_MONEY";if((t=t.add(r._satoshisBN)).gt(new O(A.MAX_MONEY)))return"transaction txout "+e+" total output greater than MAX_MONEY"}if(this.toBuffer().length>1e6)return"transaction over the maximum block size";var n={};for(e=0;e<this.inputs.length;e++){var o=this.inputs[e],s=o.prevTxId+":"+o.outputIndex;if(!i.isUndefined(n[s]))return"transaction input "+e+" duplicate input";n[s]=!0}if(this.isCoinbase()){var a=this.inputs[0]._scriptBuffer;if(a.length<2||a.length>100)return"coinbase transaction script size invalid"}else for(e=0;e<this.inputs.length;e++)if(this.inputs[e].isNull())return"transaction input "+e+" has null input";return!0},A.prototype.isCoinbase=function(){return 1===this.inputs.length&&this.inputs[0].isNull()},A.prototype.sighash=function(t,e,r,i,n){e=e||d.SIGHASH_ALL|d.SIGHASH_FORKID;var o=this.inputs[t];if(!o)throw new Error("Input index "+t+" does not exist");return!r&&o.output&&(r=o.output.script),!i&&o.output&&(i=new O(o.output.satoshis)),n=n||P,p.sighash(this,e,t,r,i,n)},t.exports=A}).call(this,r(0).Buffer)},function(t,e,r){"use strict";var i=r(1),n=r(2),o=r(5),s=r(12),a=r(25);function c(t){if(!(this instanceof c))return new c(t);n.checkArgument(i.isObject(t),"Must provide an object from where to extract data");var e=t.address?new a(t.address):void 0,r=t.txid?t.txid:t.txId;if(!r||!o.isHexaString(r)||r.length>64)throw new Error("Invalid TXID in object",t);var u=i.isUndefined(t.vout)?t.outputIndex:t.vout;if(!i.isNumber(u))throw new Error("Invalid outputIndex, received "+u);n.checkArgument(!i.isUndefined(t.scriptPubKey)||!i.isUndefined(t.script),"Must provide the scriptPubKey for that output!");var f=new s(t.scriptPubKey||t.script);n.checkArgument(!i.isUndefined(t.amount)||!i.isUndefined(t.satoshis),"Must provide an amount for the output");var h=i.isUndefined(t.amount)?t.satoshis:Math.round(1e8*t.amount);n.checkArgument(i.isNumber(h),"Amount must be a number"),o.defineImmutable(this,{address:e,txId:r,outputIndex:u,script:f,satoshis:h})}c.prototype.inspect=function(){return"<UnspentOutput: "+this.txId+":"+this.outputIndex+", satoshis: "+this.satoshis+", address: "+this.address+">"},c.prototype.toString=function(){return this.txId+":"+this.outputIndex},c.fromObject=function(t){return new c(t)},c.prototype.toObject=c.prototype.toJSON=function(){return{address:this.address?this.address.toString():void 0,txid:this.txId,vout:this.outputIndex,scriptPubKey:this.script.toBuffer().toString("hex"),amount:Number.parseFloat((this.satoshis/1e8).toFixed(8))}},t.exports=c},function(t,e,r){"use strict";(function(e){var i=r(1),n=r(39),o=r(18),s=r(16),a=r(6),c=r(37),u=r(10),f=r(2);function h(t){if(!(this instanceof h))return new h(t);var r={};if(e.isBuffer(t))r=h._fromBufferReader(o(t));else{if(!i.isObject(t))throw new TypeError("Unrecognized argument for MerkleBlock");r={header:t.header instanceof n?t.header:n.fromObject(t.header),numTransactions:t.numTransactions,hashes:t.hashes,flags:t.flags}}return i.extend(this,r),this._flagBitsUsed=0,this._hashesUsed=0,this}h.fromBuffer=function(t){return h.fromBufferReader(o(t))},h.fromBufferReader=function(t){return new h(h._fromBufferReader(t))},h.prototype.toBuffer=function(){return this.toBufferWriter().concat()},h.prototype.toBufferWriter=function(t){t||(t=new s),t.write(this.header.toBuffer()),t.writeUInt32LE(this.numTransactions),t.writeVarintNum(this.hashes.length);for(var r=0;r<this.hashes.length;r++)t.write(e.from(this.hashes[r],"hex"));for(t.writeVarintNum(this.flags.length),r=0;r<this.flags.length;r++)t.writeUInt8(this.flags[r]);return t},h.prototype.toObject=h.prototype.toJSON=function(){return{header:this.header.toObject(),numTransactions:this.numTransactions,hashes:this.hashes,flags:this.flags}},h.prototype.validMerkleTree=function(){if(f.checkState(i.isArray(this.flags),"MerkleBlock flags is not an array"),f.checkState(i.isArray(this.hashes),"MerkleBlock hashes is not an array"),this.hashes.length>this.numTransactions)return!1;if(8*this.flags.length<this.hashes.length)return!1;var t=this._calcTreeHeight(),e={hashesUsed:0,flagBitsUsed:0},r=this._traverseMerkleTree(t,0,e);return e.hashesUsed===this.hashes.length&&r.equals(this.header.merkleRoot)},h.prototype.filterdTxsHash=function(){throw new Error("filterdTxsHash has been deprecated. use filteredTxsHash.")},h.prototype.filteredTxsHash=function(){if(f.checkState(i.isArray(this.flags),"MerkleBlock flags is not an array"),f.checkState(i.isArray(this.hashes),"MerkleBlock hashes is not an array"),this.hashes.length>this.numTransactions)throw new u.MerkleBlock.InvalidMerkleTree;if(8*this.flags.length<this.hashes.length)throw new u.MerkleBlock.InvalidMerkleTree;if(1===this.hashes.length)return[];var t=this._calcTreeHeight(),e={hashesUsed:0,flagBitsUsed:0},r=this._traverseMerkleTree(t,0,e,!0);if(e.hashesUsed!==this.hashes.length)throw new u.MerkleBlock.InvalidMerkleTree;return r},h.prototype._traverseMerkleTree=function(t,r,i,n){if((i=i||{}).txs=i.txs||[],i.flagBitsUsed=i.flagBitsUsed||0,i.hashesUsed=i.hashesUsed||0,n=n||!1,i.flagBitsUsed>8*this.flags.length)return null;var o=this.flags[i.flagBitsUsed>>3]>>>(7&i.flagBitsUsed++)&1;if(0!==t&&o){var s=this._traverseMerkleTree(t-1,2*r,i),c=s;return 2*r+1<this._calcTreeWidth(t-1)&&(c=this._traverseMerkleTree(t-1,2*r+1,i)),n?i.txs:a.sha256sha256(e.concat([s,c]))}if(i.hashesUsed>=this.hashes.length)return null;var u=this.hashes[i.hashesUsed++];return 0===t&&o&&i.txs.push(u),e.from(u,"hex")},h.prototype._calcTreeWidth=function(t){return this.numTransactions+(1<<t)-1>>t},h.prototype._calcTreeHeight=function(){for(var t=0;this._calcTreeWidth(t)>1;)t++;return t},h.prototype.hasTransaction=function(t){f.checkArgument(!i.isUndefined(t),"tx cannot be undefined"),f.checkArgument(t instanceof c||"string"==typeof t,'Invalid tx given, tx must be a "string" or "Transaction"');var r=t;t instanceof c&&(r=e.from(t.id,"hex").reverse().toString("hex"));var n=[],o=this._calcTreeHeight();return this._traverseMerkleTree(o,0,{txs:n}),-1!==n.indexOf(r)},h._fromBufferReader=function(t){f.checkState(!t.finished(),"No merkleblock data received");var e={};e.header=n.fromBufferReader(t),e.numTransactions=t.readUInt32LE();var r=t.readVarintNum();e.hashes=[];for(var i=0;i<r;i++)e.hashes.push(t.read(32).toString("hex"));var o=t.readVarintNum();for(e.flags=[],i=0;i<o;i++)e.flags.push(t.readUInt8());return e},h.fromObject=function(t){return new h(t)},t.exports=h}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(45),n=r(0),o=r(1),s=r(2),a=r(3),c=r(35),u=r(27),f=r(6),h=r(23),d=r(11),p=r(34),l=r(38),g=r(10),m=g.HDPrivateKey,b=r(5);function y(t){if(t instanceof y)return t;if(!(this instanceof y))return new y(t);if(!t)return this._generateRandomly();if(h.get(t))return this._generateRandomly(t);if(o.isString(t)||e.isBuffer(t))if(y.isValidSerialized(t))this._buildFromSerialized(t);else if(b.isValidJSON(t))this._buildFromJSON(t);else{if(!e.isBuffer(t)||!y.isValidSerialized(t.toString()))throw y.getSerializedError(t);this._buildFromSerialized(t.toString())}else{if(!o.isObject(t))throw new m.UnrecognizedArgument(t);this._buildFromObject(t)}}y.fromRandom=function(){return new y},y.isValidPath=function(t,e){if(o.isString(t)){var r=y._getDerivationIndexes(t);return null!==r&&o.every(r,y.isValidPath)}return!!o.isNumber(t)&&(t<y.Hardened&&!0===e&&(t+=y.Hardened),t>=0&&t<y.MaxIndex)},y._getDerivationIndexes=function(t){var e=t.split("/");if(o.includes(y.RootElementAlias,t))return[];if(!o.includes(y.RootElementAlias,e[0]))return null;var r=e.slice(1).map((function(t){var e="'"===t.slice(-1);if(e&&(t=t.slice(0,-1)),!t||"-"===t[0])return NaN;var r=+t;return e&&(r+=y.Hardened),r}));return o.some(r,isNaN)?null:r},y.prototype.derive=function(){throw new Error("derive has been deprecated. use deriveChild or, for the old way, deriveNonCompliantChild.")},y.prototype.deriveChild=function(t,e){if(o.isNumber(t))return this._deriveWithNumber(t,e);if(o.isString(t))return this._deriveFromString(t);throw new m.InvalidDerivationArgument(t)},y.prototype.deriveNonCompliantChild=function(t,e){if(o.isNumber(t))return this._deriveWithNumber(t,e,!0);if(o.isString(t))return this._deriveFromString(t,!0);throw new m.InvalidDerivationArgument(t)},y.prototype._deriveWithNumber=function(t,r,o){if(!y.isValidPath(t,r))throw new m.InvalidPath(t);r=t>=y.Hardened||r,t<y.Hardened&&!0===r&&(t+=y.Hardened);var s,c=b.integerAsBuffer(t);if(r&&o){var u=this.privateKey.bn.toBuffer();s=e.concat([n.Buffer.from([0]),u,c])}else if(r){var h=this.privateKey.bn.toBuffer({size:32});i(32===h.length,"length of private key buffer is expected to be 32 bytes"),s=e.concat([n.Buffer.from([0]),h,c])}else s=e.concat([this.publicKey.toBuffer(),c]);var l=f.sha512hmac(s,this._buffers.chainCode),g=a.fromBuffer(l.slice(0,32),{size:32}),v=l.slice(32,64),S=g.add(this.privateKey.toBigNumber()).umod(d.getN()).toBuffer({size:32});return p.isValid(S)?new y({network:this.network,depth:this.depth+1,parentFingerPrint:this.fingerPrint,childIndex:t,chainCode:v,privateKey:S}):this._deriveWithNumber(t+1,null,o)},y.prototype._deriveFromString=function(t,e){if(!y.isValidPath(t))throw new m.InvalidPath(t);return y._getDerivationIndexes(t).reduce((function(t,r){return t._deriveWithNumber(r,null,e)}),this)},y.isValidSerialized=function(t,e){return!y.getSerializedError(t,e)},y.getSerializedError=function(t,r){if(!o.isString(t)&&!e.isBuffer(t))return new m.UnrecognizedArgument("Expected string or buffer");if(!c.validCharacters(t))return new g.InvalidB58Char("(unknown)",t);try{t=u.decode(t)}catch(e){return new g.InvalidB58Checksum(t)}if(t.length!==y.DataLength)return new m.InvalidLength(t);if(!o.isUndefined(r)){var i=y._validateNetwork(t,r);if(i)return i}return null},y._validateNetwork=function(t,e){var r=h.get(e);if(!r)return new g.InvalidNetworkArgument(e);var i=t.slice(0,4);return i.readUInt32BE(0)!==r.xprivkey?new g.InvalidNetwork(i):null},y.fromString=function(t){return s.checkArgument(o.isString(t),"No valid string was provided"),new y(t)},y.fromObject=function(t){return s.checkArgument(o.isObject(t),"No valid argument was provided"),new y(t)},y.prototype._buildFromJSON=function(t){return this._buildFromObject(JSON.parse(t))},y.prototype._buildFromObject=function(t){var r={version:t.network?b.integerAsBuffer(h.get(t.network).xprivkey):t.version,depth:o.isNumber(t.depth)?e.from([255&t.depth]):t.depth,parentFingerPrint:o.isNumber(t.parentFingerPrint)?b.integerAsBuffer(t.parentFingerPrint):t.parentFingerPrint,childIndex:o.isNumber(t.childIndex)?b.integerAsBuffer(t.childIndex):t.childIndex,chainCode:o.isString(t.chainCode)?e.from(t.chainCode,"hex"):t.chainCode,privateKey:o.isString(t.privateKey)&&b.isHexa(t.privateKey)?e.from(t.privateKey,"hex"):t.privateKey,checksum:t.checksum?t.checksum.length?t.checksum:b.integerAsBuffer(t.checksum):void 0};return this._buildFromBuffers(r)},y.prototype._buildFromSerialized=function(t){var e=u.decode(t),r={version:e.slice(y.VersionStart,y.VersionEnd),depth:e.slice(y.DepthStart,y.DepthEnd),parentFingerPrint:e.slice(y.ParentFingerPrintStart,y.ParentFingerPrintEnd),childIndex:e.slice(y.ChildIndexStart,y.ChildIndexEnd),chainCode:e.slice(y.ChainCodeStart,y.ChainCodeEnd),privateKey:e.slice(y.PrivateKeyStart,y.PrivateKeyEnd),checksum:e.slice(y.ChecksumStart,y.ChecksumEnd),xprivkey:t};return this._buildFromBuffers(r)},y.prototype._generateRandomly=function(t){return y.fromSeed(l.getRandomBuffer(64),t)},y.fromSeed=function(t,r){if(b.isHexaString(t)&&(t=e.from(t,"hex")),!e.isBuffer(t))throw new m.InvalidEntropyArgument(t);if(t.length<16)throw new m.InvalidEntropyArgument.NotEnoughEntropy(t);if(t.length>64)throw new m.InvalidEntropyArgument.TooMuchEntropy(t);var i=f.sha512hmac(t,n.Buffer.from("Bitcoin seed"));return new y({network:h.get(r)||h.defaultNetwork,depth:0,parentFingerPrint:0,childIndex:0,privateKey:i.slice(0,32),chainCode:i.slice(32,64)})},y.prototype._calcHDPublicKey=function(){if(!this._hdPublicKey){var t=r(75);this._hdPublicKey=new t(this)}},y.prototype._buildFromBuffers=function(t){y._validateBufferArguments(t),b.defineImmutable(this,{_buffers:t});var r=[t.version,t.depth,t.parentFingerPrint,t.childIndex,t.chainCode,e.alloc(1),t.privateKey],i=n.Buffer.concat(r);if(t.checksum&&t.checksum.length){if(t.checksum.toString()!==u.checksum(i).toString())throw new g.InvalidB58Checksum(i)}else t.checksum=u.checksum(i);var o,s=h.get(t.version.readUInt32BE(0));o=u.encode(n.Buffer.concat(r)),t.xprivkey=e.from(o);var c=new p(a.fromBuffer(t.privateKey),s),d=c.toPublicKey(),l=y.ParentFingerPrintSize,m=f.sha256ripemd160(d.toBuffer()).slice(0,l);return b.defineImmutable(this,{xprivkey:o,network:s,depth:t.depth[0],privateKey:c,publicKey:d,fingerPrint:m}),this._hdPublicKey=null,Object.defineProperty(this,"hdPublicKey",{configurable:!1,enumerable:!0,get:function(){return this._calcHDPublicKey(),this._hdPublicKey}}),Object.defineProperty(this,"xpubkey",{configurable:!1,enumerable:!0,get:function(){return this._calcHDPublicKey(),this._hdPublicKey.xpubkey}}),this},y._validateBufferArguments=function(t){var r=function(r,n){var o=t[r];i(e.isBuffer(o),r+" argument is not a buffer"),i(o.length===n,r+" has not the expected size: found "+o.length+", expected "+n)};r("version",y.VersionSize),r("depth",y.DepthSize),r("parentFingerPrint",y.ParentFingerPrintSize),r("childIndex",y.ChildIndexSize),r("chainCode",y.ChainCodeSize),r("privateKey",y.PrivateKeySize),t.checksum&&t.checksum.length&&r("checksum",y.CheckSumSize)},y.prototype.toString=function(){return this.xprivkey},y.prototype.inspect=function(){return"<HDPrivateKey: "+this.xprivkey+">"},y.prototype.toObject=y.prototype.toJSON=function(){return{network:h.get(this._buffers.version.readUInt32BE(0),"xprivkey").name,depth:this._buffers.depth[0],fingerPrint:this.fingerPrint.readUInt32BE(0),parentFingerPrint:this._buffers.parentFingerPrint.readUInt32BE(0),childIndex:this._buffers.childIndex.readUInt32BE(0),chainCode:this._buffers.chainCode.toString("hex"),privateKey:this.privateKey.toBuffer().toString("hex"),checksum:this._buffers.checksum.readUInt32BE(0),xprivkey:this.xprivkey}},y.fromBuffer=function(t){return new y(t.toString())},y.fromHex=function(t){return y.fromBuffer(e.from(t,"hex"))},y.prototype.toBuffer=function(){return e.from(this.toString())},y.prototype.toHex=function(){return this.toBuffer().toString("hex")},y.DefaultDepth=0,y.DefaultFingerprint=0,y.DefaultChildIndex=0,y.Hardened=2147483648,y.MaxIndex=2*y.Hardened,y.RootElementAlias=["m","M","m'","M'"],y.VersionSize=4,y.DepthSize=1,y.ParentFingerPrintSize=4,y.ChildIndexSize=4,y.ChainCodeSize=32,y.PrivateKeySize=32,y.CheckSumSize=4,y.DataLength=78,y.SerializedByteSize=82,y.VersionStart=0,y.VersionEnd=y.VersionStart+y.VersionSize,y.DepthStart=y.VersionEnd,y.DepthEnd=y.DepthStart+y.DepthSize,y.ParentFingerPrintStart=y.DepthEnd,y.ParentFingerPrintEnd=y.ParentFingerPrintStart+y.ParentFingerPrintSize,y.ChildIndexStart=y.ParentFingerPrintEnd,y.ChildIndexEnd=y.ChildIndexStart+y.ChildIndexSize,y.ChainCodeStart=y.ChildIndexEnd,y.ChainCodeEnd=y.ChainCodeStart+y.ChainCodeSize,y.PrivateKeyStart=y.ChainCodeEnd+1,y.PrivateKeyEnd=y.PrivateKeyStart+y.PrivateKeySize,y.ChecksumStart=y.PrivateKeyEnd,y.ChecksumEnd=y.ChecksumStart+y.CheckSumSize,i(y.ChecksumEnd===y.SerializedByteSize),t.exports=y}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(1),n=r(2),o=r(3),s=r(35),a=r(27),c=r(6),u=r(74),f=r(23),h=r(11),d=r(14),p=r(10),l=p,g=p.HDPublicKey,m=r(45),b=r(5);function y(t){if(t instanceof y)return t;if(!(this instanceof y))return new y(t);if(t){if(i.isString(t)||e.isBuffer(t)){var r=y.getSerializedError(t);if(r){if(e.isBuffer(t)&&!y.getSerializedError(t.toString()))return this._buildFromSerialized(t.toString());if(r instanceof g.ArgumentIsPrivateExtended)return new u(t).hdPublicKey;throw r}return this._buildFromSerialized(t)}if(i.isObject(t))return t instanceof u?this._buildFromPrivate(t):this._buildFromObject(t);throw new g.UnrecognizedArgument(t)}throw new g.MustSupplyArgument}y.fromHDPrivateKey=function(t){return new y(t)},y.isValidPath=function(t){if(i.isString(t)){var e=u._getDerivationIndexes(t);return null!==e&&i.every(e,y.isValidPath)}return!!i.isNumber(t)&&(t>=0&&t<y.Hardened)},y.prototype.derive=function(){throw new Error("derive has been deprecated. use deriveChild or, for the old way, deriveNonCompliantChild.")},y.prototype.deriveChild=function(t,e){if(i.isNumber(t))return this._deriveWithNumber(t,e);if(i.isString(t))return this._deriveFromString(t);throw new g.InvalidDerivationArgument(t)},y.prototype._deriveWithNumber=function(t,r){if(t>=y.Hardened||r)throw new g.InvalidIndexCantDeriveHardened;if(t<0)throw new g.InvalidPath(t);var i,n=b.integerAsBuffer(t),s=e.concat([this.publicKey.toBuffer(),n]),a=c.sha512hmac(s,this._buffers.chainCode),u=o.fromBuffer(a.slice(0,32),{size:32}),f=a.slice(32,64);try{i=d.fromPoint(h.getG().mul(u).add(this.publicKey.point))}catch(e){return this._deriveWithNumber(t+1)}return new y({network:this.network,depth:this.depth+1,parentFingerPrint:this.fingerPrint,childIndex:t,chainCode:f,publicKey:i})},y.prototype._deriveFromString=function(t){if(i.includes(t,"'"))throw new g.InvalidIndexCantDeriveHardened;if(!y.isValidPath(t))throw new g.InvalidPath(t);return u._getDerivationIndexes(t).reduce((function(t,e){return t._deriveWithNumber(e)}),this)},y.isValidSerialized=function(t,e){return i.isNull(y.getSerializedError(t,e))},y.getSerializedError=function(t,r){if(!i.isString(t)&&!e.isBuffer(t))return new g.UnrecognizedArgument("expected buffer or string");if(!s.validCharacters(t))return new l.InvalidB58Char("(unknown)",t);try{t=a.decode(t)}catch(e){return new l.InvalidB58Checksum(t)}if(t.length!==y.DataSize)return new g.InvalidLength(t);if(!i.isUndefined(r)){var n=y._validateNetwork(t,r);if(n)return n}var o=t.readUInt32BE(0);return o===f.livenet.xprivkey||o===f.testnet.xprivkey?new g.ArgumentIsPrivateExtended:null},y._validateNetwork=function(t,e){var r=f.get(e);if(!r)return new l.InvalidNetworkArgument(e);var i=t.slice(y.VersionStart,y.VersionEnd);return i.readUInt32BE(0)!==r.xpubkey?new l.InvalidNetwork(i):null},y.prototype._buildFromPrivate=function(t){var e=i.clone(t._buffers),r=h.getG().mul(o.fromBuffer(e.privateKey));return e.publicKey=h.pointToCompressed(r),e.version=b.integerAsBuffer(f.get(e.version.readUInt32BE(0)).xpubkey),e.privateKey=void 0,e.checksum=void 0,e.xprivkey=void 0,this._buildFromBuffers(e)},y.prototype._buildFromObject=function(t){var r={version:t.network?b.integerAsBuffer(f.get(t.network).xpubkey):t.version,depth:i.isNumber(t.depth)?e.from([255&t.depth]):t.depth,parentFingerPrint:i.isNumber(t.parentFingerPrint)?b.integerAsBuffer(t.parentFingerPrint):t.parentFingerPrint,childIndex:i.isNumber(t.childIndex)?b.integerAsBuffer(t.childIndex):t.childIndex,chainCode:i.isString(t.chainCode)?e.from(t.chainCode,"hex"):t.chainCode,publicKey:i.isString(t.publicKey)?e.from(t.publicKey,"hex"):e.isBuffer(t.publicKey)?t.publicKey:t.publicKey.toBuffer(),checksum:i.isNumber(t.checksum)?b.integerAsBuffer(t.checksum):t.checksum};return this._buildFromBuffers(r)},y.prototype._buildFromSerialized=function(t){var e=a.decode(t),r={version:e.slice(y.VersionStart,y.VersionEnd),depth:e.slice(y.DepthStart,y.DepthEnd),parentFingerPrint:e.slice(y.ParentFingerPrintStart,y.ParentFingerPrintEnd),childIndex:e.slice(y.ChildIndexStart,y.ChildIndexEnd),chainCode:e.slice(y.ChainCodeStart,y.ChainCodeEnd),publicKey:e.slice(y.PublicKeyStart,y.PublicKeyEnd),checksum:e.slice(y.ChecksumStart,y.ChecksumEnd),xpubkey:t};return this._buildFromBuffers(r)},y.prototype._buildFromBuffers=function(t){y._validateBufferArguments(t),b.defineImmutable(this,{_buffers:t});var r=[t.version,t.depth,t.parentFingerPrint,t.childIndex,t.chainCode,t.publicKey],i=e.concat(r),n=a.checksum(i);if(t.checksum&&t.checksum.length){if(t.checksum.toString("hex")!==n.toString("hex"))throw new l.InvalidB58Checksum(i,n)}else t.checksum=n;var o,s=f.get(t.version.readUInt32BE(0));o=a.encode(e.concat(r)),t.xpubkey=e.from(o);var u=new d(t.publicKey,{network:s}),h=y.ParentFingerPrintSize,p=c.sha256ripemd160(u.toBuffer()).slice(0,h);return b.defineImmutable(this,{xpubkey:o,network:s,depth:t.depth[0],publicKey:u,fingerPrint:p}),this},y._validateBufferArguments=function(t){var r=function(r,i){var n=t[r];m(e.isBuffer(n),r+" argument is not a buffer, it's "+typeof n),m(n.length===i,r+" has not the expected size: found "+n.length+", expected "+i)};r("version",y.VersionSize),r("depth",y.DepthSize),r("parentFingerPrint",y.ParentFingerPrintSize),r("childIndex",y.ChildIndexSize),r("chainCode",y.ChainCodeSize),r("publicKey",y.PublicKeySize),t.checksum&&t.checksum.length&&r("checksum",y.CheckSumSize)},y.fromString=function(t){return n.checkArgument(i.isString(t),"No valid string was provided"),new y(t)},y.fromObject=function(t){return n.checkArgument(i.isObject(t),"No valid argument was provided"),new y(t)},y.prototype.toString=function(){return this.xpubkey},y.prototype.inspect=function(){return"<HDPublicKey: "+this.xpubkey+">"},y.prototype.toObject=y.prototype.toJSON=function(){return{network:f.get(this._buffers.version.readUInt32BE(0)).name,depth:this._buffers.depth[0],fingerPrint:this.fingerPrint.readUInt32BE(0),parentFingerPrint:this._buffers.parentFingerPrint.readUInt32BE(0),childIndex:this._buffers.childIndex.readUInt32BE(0),chainCode:this._buffers.chainCode.toString("hex"),publicKey:this.publicKey.toString(),checksum:this._buffers.checksum.readUInt32BE(0),xpubkey:this.xpubkey}},y.fromBuffer=function(t){return new y(t)},y.fromHex=function(t){return y.fromBuffer(e.from(t,"hex"))},y.prototype.toBuffer=function(){return e.from(this._buffers.xpubkey)},y.prototype.toHex=function(){return this.toBuffer().toString("hex")},y.Hardened=2147483648,y.RootElementAlias=["m","M"],y.VersionSize=4,y.DepthSize=1,y.ParentFingerPrintSize=4,y.ChildIndexSize=4,y.ChainCodeSize=32,y.PublicKeySize=33,y.CheckSumSize=4,y.DataSize=78,y.SerializedByteSize=82,y.VersionStart=0,y.VersionEnd=y.VersionStart+y.VersionSize,y.DepthStart=y.VersionEnd,y.DepthEnd=y.DepthStart+y.DepthSize,y.ParentFingerPrintStart=y.DepthEnd,y.ParentFingerPrintEnd=y.ParentFingerPrintStart+y.ParentFingerPrintSize,y.ChildIndexStart=y.ParentFingerPrintEnd,y.ChildIndexEnd=y.ChildIndexStart+y.ChildIndexSize,y.ChainCodeStart=y.ChildIndexEnd,y.ChainCodeEnd=y.ChainCodeStart+y.ChainCodeSize,y.PublicKeyStart=y.ChainCodeEnd,y.PublicKeyEnd=y.PublicKeyStart+y.PublicKeySize,y.ChecksumStart=y.PublicKeyEnd,y.ChecksumEnd=y.ChecksumStart+y.CheckSumSize,m(y.PublicKeyEnd===y.DataSize),m(y.ChecksumEnd===y.SerializedByteSize),t.exports=y}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(t,e){const{opcodeMap:i,scriptNum:n,utils:o}=r(77);class s{constructor(){this.operations=[],this.comments=[]}comment(t){return this.comments.push("// "+t),this}push(e){if("number"==typeof e)if(e>=-1&&e<=16)-1===e?this.operations.push("OP_1NEGATE"):0===e?this.operations.push("OP_0"):this.operations.push("OP_"+e);else{const t=n.encode(e);this.operations.push(t.toString("hex"))}else if("string"==typeof e)this.operations.push(e);else{if(!t.isBuffer(e))throw new Error("Invalid value type: "+typeof e);this.operations.push(e.toString("hex"))}return this}dup(){return this.operations.push("OP_DUP"),this}drop(){return this.operations.push("OP_DROP"),this}swap(){return this.operations.push("OP_SWAP"),this}over(){return this.operations.push("OP_OVER"),this}rot(){return this.operations.push("OP_ROT"),this}pick(t){return this.push(t),this.operations.push("OP_PICK"),this}roll(t){return this.push(t),this.operations.push("OP_ROLL"),this}depth(){return this.operations.push("OP_DEPTH"),this}add(){return this.operations.push("OP_ADD"),this}sub(){return this.operations.push("OP_SUB"),this}mul(){return this.operations.push("OP_MUL"),this}div(){return this.operations.push("OP_DIV"),this}mod(){return this.operations.push("OP_MOD"),this}negate(){return this.operations.push("OP_NEGATE"),this}abs(){return this.operations.push("OP_ABS"),this}min(){return this.operations.push("OP_MIN"),this}max(){return this.operations.push("OP_MAX"),this}equal(){return this.operations.push("OP_EQUAL"),this}equalVerify(){return this.operations.push("OP_EQUALVERIFY"),this}numEqual(){return this.operations.push("OP_NUMEQUAL"),this}numNotEqual(){return this.operations.push("OP_NUMNOTEQUAL"),this}lessThan(){return this.operations.push("OP_LESSTHAN"),this}greaterThan(){return this.operations.push("OP_GREATERTHAN"),this}lessThanOrEqual(){return this.operations.push("OP_LESSTHANOREQUAL"),this}greaterThanOrEqual(){return this.operations.push("OP_GREATERTHANOREQUAL"),this}within(){return this.operations.push("OP_WITHIN"),this}not(){return this.operations.push("OP_NOT"),this}boolAnd(){return this.operations.push("OP_BOOLAND"),this}boolOr(){return this.operations.push("OP_BOOLOR"),this}and(){return this.operations.push("OP_AND"),this}or(){return this.operations.push("OP_OR"),this}xor(){return this.operations.push("OP_XOR"),this}invert(){return this.operations.push("OP_INVERT"),this}cat(){return this.operations.push("OP_CAT"),this}split(){return this.operations.push("OP_SPLIT"),this}size(){return this.operations.push("OP_SIZE"),this}left(t){return this.push(t),this.operations.push("OP_LEFT"),this}right(t){return this.push(t),this.operations.push("OP_RIGHT"),this}substr(t,e){return this.push(e).push(t),this.operations.push("OP_SUBSTR"),this}sha256(){return this.operations.push("OP_SHA256"),this}hash256(){return this.operations.push("OP_HASH256"),this}hash160(){return this.operations.push("OP_HASH160"),this}ripemd160(){return this.operations.push("OP_RIPEMD160"),this}verify(){return this.operations.push("OP_VERIFY"),this}return(){return this.operations.push("OP_RETURN"),this}extractField(t){this.comment(`Extract ${t} field from preimage`);const e={nVersion:{strategy:"LEFT",offset:0,length:4},hashPrevouts:{strategy:"LEFT",offset:4,length:32},hashSequence:{strategy:"LEFT",offset:36,length:32},outpoint:{strategy:"LEFT",offset:68,length:36},scriptLen:{strategy:"DYNAMIC",position:"after_outpoint"},scriptCode:{strategy:"DYNAMIC",variable_length:!0},value:{strategy:"RIGHT",offsetFromEnd:52,length:8},nSequence:{strategy:"RIGHT",offsetFromEnd:44,length:4},hashOutputs:{strategy:"RIGHT",offsetFromEnd:40,length:32},nLocktime:{strategy:"RIGHT",offsetFromEnd:8,length:4},sighashType:{strategy:"RIGHT",offsetFromEnd:4,length:4}}[t];if(!e)throw new Error("Unknown field: "+t);if("LEFT"===e.strategy)this.push(e.offset+e.length).split().drop().push(e.offset).split().swap().drop();else if("RIGHT"===e.strategy)this.size().push(e.offsetFromEnd).sub().split().drop().push(e.length).split().drop();else if("DYNAMIC"===e.strategy){if("scriptLen"!==t)throw new Error(`Dynamic extraction for ${t} not implemented`);this.push(104).split().drop().push(1).split().swap().drop()}return this}validateField(t,e){return this.comment(`Validate ${t} equals expected value`),this.extractField(t),this.push(e),this.equalVerify(),this}validateRange(t,e,r){return this.comment(`Validate ${t} is within range [${e}, ${r})`),this.extractField(t),this.dup(),this.push(e),this.greaterThanOrEqual(),this.verify(),this.push(r),this.lessThan(),this.verify(),this}validateFields(t){return this.comment("Multi-field validation"),Object.entries(t).forEach(([t,e])=>{e.equals?this.validateField(t,e.equals):void 0===e.min&&void 0===e.max||this.validateRange(t,e.min||0,e.max||Number.MAX_SAFE_INTEGER)}),this}if(t){return this.comment("Begin IF block"),"function"==typeof t&&t(this),this.operations.push("OP_IF"),this}else(){return this.comment("ELSE block"),this.operations.push("OP_ELSE"),this}endif(){return this.comment("End IF block"),this.operations.push("OP_ENDIF"),this}build(){const t=this.operations.join(" "),e=this._cleanASM(t);return{operations:[...this.operations],comments:[...this.comments],asm:t,cleanedASM:e,hex:this._asmToHex(e),size:e.split(" ").length}}_cleanASM(t){return t.split(" ").map(t=>{if(/^\d+$/.test(t)){const e=parseInt(t);return e>=1&&e<=75?e.toString(16).padStart(2,"0"):n.encode(e).toString("hex")}return t}).join(" ")}_asmToHex(t){return t.split(" ").map(t=>i[t]?i[t].code.toString(16).padStart(2,"0"):/^[0-9a-fA-F]+$/.test(t)?t:"00").join("")}simulate(t=[]){return o.simulate(this.operations,t)}document(){const t=this.build();return{title:"Covenant Script Documentation",operations:t.operations.length,size:t.size,asm:t.cleanedASM,comments:this.comments,structure:this._analyzeStructure()}}_analyzeStructure(){const t={stack_operations:0,arithmetic:0,comparisons:0,crypto:0,data_manipulation:0,flow_control:0};return this.operations.forEach(e=>{const r=i[e];if(r)switch(r.category){case"stack":t.stack_operations++;break;case"arithmetic":t.arithmetic++;break;case"bitwise":t.comparisons++;break;case"crypto":t.crypto++;break;case"data":t.data_manipulation++;break;case"flow_control":t.flow_control++}}),t}}const a={valueLock:t=>(new s).comment("Value Lock Covenant").comment("Expected value: "+t).validateField("value",t).push(1),hashLock:t=>(new s).comment("Hash Lock Covenant").comment("Expected hash: "+t).sha256().push(t).equalVerify().push(1),multiSigWithValidation:(t,e,r)=>{const i=(new s).comment("Multi-Signature Covenant with Field Validation").comment("Required signatures: "+t);return i.validateFields(r),i.comment("Signature validation (placeholder)").push(1),i},timeLock:t=>(new s).comment("Time Lock Covenant").comment("Locktime: "+t).validateField("nLocktime",t).push(1),complexValidation:t=>{const e=(new s).comment("Complex Validation Covenant");return t.valueRange&&e.validateRange("value",t.valueRange.min,t.valueRange.max),t.fields&&e.validateFields(t.fields),t.hashValidation&&e.sha256().push(t.hashValidation.expectedHash).equalVerify(),e.push(1),e}};if(e.exports={CovenantBuilder:s,CovenantTemplates:a},r.c[r.s]===e){console.log("🏗️ Covenant Builder Demonstration"),console.log("=================================="),console.log("\n📊 Example 1: Value Lock Covenant");const t=a.valueLock("50c3000000000000").build();console.log("ASM:",t.cleanedASM),console.log("Size:",t.size,"operations"),console.log("\n📊 Example 2: Custom Arithmetic Covenant");const e=(new s).comment("Validate that value field equals 5 + 3").extractField("value").push(5).push(3).add().numEqual().verify().push(1),r=e.build();console.log("Operations:",r.operations.length),console.log("ASM:",r.cleanedASM),console.log("\n📊 Example 3: Documentation Generation");const i=e.document();console.log("Structure analysis:",i.structure),console.log("Comments:"),i.comments.forEach(t=>console.log(" "+t))}}).call(this,r(0).Buffer,r(31)(t))},function(t,e,r){(function(t,e){const i={encode:e=>{if(0===e)return t.alloc(0);const r=e<0,i=[];let n=Math.abs(e);for(;n>0;)i.push(255&n),n>>=8;return 128&i[i.length-1]?i.push(r?128:0):r&&(i[i.length-1]|=128),t.from(i)},decode:t=>{if(0===t.length)return 0;const e=Array.from(t),r=128&e[e.length-1];r&&(e[e.length-1]&=127);let i=0;for(let t=e.length-1;t>=0;t--)i=(i<<8)+e[t];return r?-i:i}},n={OP_FALSE:{code:0,category:"constants",description:"Push empty array (false value)",action:e=>e.push(t.alloc(0))},OP_0:{code:0,category:"constants",description:"Push empty array (alias for OP_FALSE)",action:e=>e.push(t.alloc(0))},OP_PUSHDATA1:{code:76,category:"pushdata",description:"Push next [1 byte] bytes of data",action:"Read next byte as length; push that many bytes"},OP_PUSHDATA2:{code:77,category:"pushdata",description:"Push next [2 bytes LE] bytes of data",action:"Read next 2 bytes as length; push that many bytes"},OP_PUSHDATA4:{code:78,category:"pushdata",description:"Push next [4 bytes LE] bytes of data",action:"Read next 4 bytes as length; push that many bytes"},OP_1NEGATE:{code:79,category:"constants",description:"Push number -1",action:t=>t.push(i.encode(-1))},OP_RESERVED:{code:80,category:"reserved",description:"Reserved opcode (makes transaction invalid)",action:()=>{throw new Error("OP_RESERVED encountered")}},OP_TRUE:{code:81,category:"constants",description:"Push number 1 (true value)",action:t=>t.push(i.encode(1))},OP_1:{code:81,category:"constants",description:"Push number 1 (alias for OP_TRUE)",action:t=>t.push(i.encode(1))},OP_2:{code:82,category:"constants",description:"Push number 2",action:t=>t.push(i.encode(2))},OP_3:{code:83,category:"constants",description:"Push number 3",action:t=>t.push(i.encode(3))},OP_4:{code:84,category:"constants",description:"Push number 4",action:t=>t.push(i.encode(4))},OP_5:{code:85,category:"constants",description:"Push number 5",action:t=>t.push(i.encode(5))},OP_6:{code:86,category:"constants",description:"Push number 6",action:t=>t.push(i.encode(6))},OP_7:{code:87,category:"constants",description:"Push number 7",action:t=>t.push(i.encode(7))},OP_8:{code:88,category:"constants",description:"Push number 8",action:t=>t.push(i.encode(8))},OP_9:{code:89,category:"constants",description:"Push number 9",action:t=>t.push(i.encode(9))},OP_10:{code:90,category:"constants",description:"Push number 10",action:t=>t.push(i.encode(10))},OP_11:{code:91,category:"constants",description:"Push number 11",action:t=>t.push(i.encode(11))},OP_12:{code:92,category:"constants",description:"Push number 12",action:t=>t.push(i.encode(12))},OP_13:{code:93,category:"constants",description:"Push number 13",action:t=>t.push(i.encode(13))},OP_14:{code:94,category:"constants",description:"Push number 14",action:t=>t.push(i.encode(14))},OP_15:{code:95,category:"constants",description:"Push number 15",action:t=>t.push(i.encode(15))},OP_16:{code:96,category:"constants",description:"Push number 16",action:t=>t.push(i.encode(16))},OP_NOP:{code:97,category:"flow_control",description:"No operation (do nothing)",action:t=>{}},OP_VER:{code:98,category:"flow_control",description:"Push transaction version (disabled)",action:()=>{throw new Error("OP_VER is disabled")}},OP_IF:{code:99,category:"flow_control",description:"Execute if top stack value is true",action:"// Conditional execution (requires parser state)"},OP_NOTIF:{code:100,category:"flow_control",description:"Execute if top stack value is false",action:"// Conditional execution (requires parser state)"},OP_VERIF:{code:101,category:"flow_control",description:"Conditional execution based on transaction version (disabled)",action:()=>{throw new Error("OP_VERIF is disabled")}},OP_VERNOTIF:{code:102,category:"flow_control",description:"Conditional execution based on transaction version (disabled)",action:()=>{throw new Error("OP_VERNOTIF is disabled")}},OP_ELSE:{code:103,category:"flow_control",description:"Else branch of conditional",action:"// Conditional execution (requires parser state)"},OP_ENDIF:{code:104,category:"flow_control",description:"End conditional block",action:"// Conditional execution (requires parser state)"},OP_VERIFY:{code:105,category:"flow_control",description:"Fail if top stack value is not true",action:t=>{const e=t.pop();if(!e||0===e.length||0===i.decode(e))throw new Error("OP_VERIFY failed")}},OP_RETURN:{code:106,category:"flow_control",description:"Terminate script execution immediately",action:()=>{throw new Error("Script terminated by OP_RETURN")}},OP_TOALTSTACK:{code:107,category:"stack",description:"Move top item from main stack to alt stack",action:(t,e)=>e.push(t.pop())},OP_FROMALTSTACK:{code:108,category:"stack",description:"Move top item from alt stack to main stack",action:(t,e)=>t.push(e.pop())},OP_2DROP:{code:109,category:"stack",description:"Remove top two stack items",action:t=>{t.pop(),t.pop()}},OP_2DUP:{code:110,category:"stack",description:"Duplicate top two stack items",action:e=>{const r=e[e.length-1],i=e[e.length-2];e.push(t.from(i),t.from(r))}},OP_3DUP:{code:111,category:"stack",description:"Duplicate top three stack items",action:e=>{const r=e[e.length-1],i=e[e.length-2],n=e[e.length-3];e.push(t.from(n),t.from(i),t.from(r))}},OP_2OVER:{code:112,category:"stack",description:"Copy 3rd and 4th items to top",action:e=>{const r=e[e.length-3],i=e[e.length-4];e.push(t.from(i),t.from(r))}},OP_2ROT:{code:113,category:"stack",description:"Move 5th and 6th items to top",action:t=>{const e=t.splice(-5,1)[0],r=t.splice(-5,1)[0];t.push(e,r)}},OP_2SWAP:{code:114,category:"stack",description:"Swap top two pairs of items",action:t=>{const e=t.pop(),r=t.pop(),i=t.pop(),n=t.pop();t.push(r,e,n,i)}},OP_IFDUP:{code:115,category:"stack",description:"Duplicate top item if it is not zero",action:e=>{const r=e[e.length-1];r.length>0&&0!==i.decode(r)&&e.push(t.from(r))}},OP_DEPTH:{code:116,category:"stack",description:"Push stack size as number",action:t=>t.push(i.encode(t.length))},OP_DROP:{code:117,category:"stack",description:"Remove top stack item",action:t=>t.pop()},OP_DUP:{code:118,category:"stack",description:"Duplicate top stack item",action:e=>e.push(t.from(e[e.length-1]))},OP_NIP:{code:119,category:"stack",description:"Remove second-to-top item",action:t=>{const e=t.pop();t.pop(),t.push(e)}},OP_OVER:{code:120,category:"stack",description:"Copy second-to-top item to top",action:e=>e.push(t.from(e[e.length-2]))},OP_PICK:{code:121,category:"stack",description:"Copy nth item to top (0-indexed from top)",action:e=>{const r=i.decode(e.pop());e.push(t.from(e[e.length-1-r]))}},OP_ROLL:{code:122,category:"stack",description:"Move nth item to top (0-indexed from top)",action:t=>{const e=i.decode(t.pop()),r=t.splice(t.length-1-e,1)[0];t.push(r)}},OP_ROT:{code:123,category:"stack",description:"Rotate top three items left",action:t=>{const e=t.pop(),r=t.pop(),i=t.pop();t.push(r,e,i)}},OP_SWAP:{code:124,category:"stack",description:"Swap top two items",action:t=>{const e=t.pop(),r=t.pop();t.push(e,r)}},OP_TUCK:{code:125,category:"stack",description:"Copy top item below second item",action:t=>{const e=t.pop(),r=t.pop();t.push(e,r,e)}},OP_CAT:{code:126,category:"data",description:"Concatenate top two items",action:e=>{const r=e.pop(),i=e.pop();e.push(t.concat([i,r]))}},OP_SPLIT:{code:127,category:"data",description:"Split item at position n",action:t=>{const e=i.decode(t.pop()),r=t.pop();t.push(r.slice(0,e),r.slice(e))}},OP_NUM2BIN:{code:128,category:"data",description:"Convert number to byte sequence of length n",action:e=>{const r=i.decode(e.pop()),n=i.decode(e.pop()),o=t.alloc(r),s=i.encode(n);s.copy(o,0,0,Math.min(s.length,r)),e.push(o)}},OP_BIN2NUM:{code:129,category:"data",description:"Convert byte sequence to number",action:t=>{const e=t.pop();t.push(i.encode(i.decode(e)))}},OP_SIZE:{code:130,category:"data",description:"Push size of top item (without removing item)",action:t=>t.push(i.encode(t[t.length-1].length))},OP_INVERT:{code:131,category:"bitwise",description:"Bitwise NOT of top item",action:e=>{const r=e.pop();e.push(t.from(r.map(t=>~t)))}},OP_AND:{code:132,category:"bitwise",description:"Bitwise AND of top two items",action:e=>{const r=e.pop(),i=e.pop(),n=Math.max(r.length,i.length),o=t.alloc(n);for(let t=0;t<n;t++)o[t]=(r[t]||0)&(i[t]||0);e.push(o)}},OP_OR:{code:133,category:"bitwise",description:"Bitwise OR of top two items",action:e=>{const r=e.pop(),i=e.pop(),n=Math.max(r.length,i.length),o=t.alloc(n);for(let t=0;t<n;t++)o[t]=(r[t]||0)|(i[t]||0);e.push(o)}},OP_XOR:{code:134,category:"bitwise",description:"Bitwise XOR of top two items",action:e=>{const r=e.pop(),i=e.pop(),n=Math.max(r.length,i.length),o=t.alloc(n);for(let t=0;t<n;t++)o[t]=(r[t]||0)^(i[t]||0);e.push(o)}},OP_EQUAL:{code:135,category:"bitwise",description:"Push 1 if top two items are equal, 0 otherwise",action:t=>{const e=t.pop(),r=t.pop();t.push(e.equals(r)?i.encode(1):i.encode(0))}},OP_EQUALVERIFY:{code:136,category:"bitwise",description:"Fail if top two items are not equal",action:t=>{const e=t.pop(),r=t.pop();if(!e.equals(r))throw new Error("OP_EQUALVERIFY failed")}},OP_1ADD:{code:139,category:"arithmetic",description:"Add 1 to top item",action:t=>{const e=i.decode(t.pop());t.push(i.encode(e+1))}},OP_1SUB:{code:140,category:"arithmetic",description:"Subtract 1 from top item",action:t=>{const e=i.decode(t.pop());t.push(i.encode(e-1))}},OP_2MUL:{code:141,category:"arithmetic",description:"Multiply top item by 2 (disabled)",action:()=>{throw new Error("OP_2MUL is disabled")}},OP_2DIV:{code:142,category:"arithmetic",description:"Divide top item by 2 (disabled)",action:()=>{throw new Error("OP_2DIV is disabled")}},OP_NEGATE:{code:143,category:"arithmetic",description:"Negate top item",action:t=>{const e=i.decode(t.pop());t.push(i.encode(-e))}},OP_ABS:{code:144,category:"arithmetic",description:"Absolute value of top item",action:t=>{const e=i.decode(t.pop());t.push(i.encode(Math.abs(e)))}},OP_NOT:{code:145,category:"arithmetic",description:"Logical NOT (0→1, non-zero→0)",action:t=>{const e=i.decode(t.pop());t.push(i.encode(0===e?1:0))}},OP_0NOTEQUAL:{code:146,category:"arithmetic",description:"Push 1 if top item is not zero, 0 otherwise",action:t=>{const e=i.decode(t.pop());t.push(i.encode(0!==e?1:0))}},OP_ADD:{code:147,category:"arithmetic",description:"Add top two items",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());t.push(i.encode(r+e))}},OP_SUB:{code:148,category:"arithmetic",description:"Subtract: second - first",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());t.push(i.encode(r-e))}},OP_MUL:{code:149,category:"arithmetic",description:"Multiply top two items",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());t.push(i.encode(r*e))}},OP_DIV:{code:150,category:"arithmetic",description:"Divide: second / first",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());if(0===e)throw new Error("Division by zero");t.push(i.encode(Math.floor(r/e)))}},OP_MOD:{code:151,category:"arithmetic",description:"Modulo: second % first",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());if(0===e)throw new Error("Division by zero");t.push(i.encode(r%e))}},OP_LSHIFT:{code:152,category:"arithmetic",description:"Left shift: second << first",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());t.push(i.encode(r<<e))}},OP_RSHIFT:{code:153,category:"arithmetic",description:"Right shift: second >> first",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());t.push(i.encode(r>>e))}},OP_BOOLAND:{code:154,category:"arithmetic",description:"Boolean AND: 1 if both non-zero, 0 otherwise",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());t.push(i.encode(0!==e&&0!==r?1:0))}},OP_BOOLOR:{code:155,category:"arithmetic",description:"Boolean OR: 1 if either non-zero, 0 otherwise",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());t.push(i.encode(0!==e||0!==r?1:0))}},OP_NUMEQUAL:{code:156,category:"arithmetic",description:"Push 1 if numbers are equal, 0 otherwise",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());t.push(i.encode(e===r?1:0))}},OP_NUMEQUALVERIFY:{code:157,category:"arithmetic",description:"Fail if numbers are not equal",action:t=>{if(i.decode(t.pop())!==i.decode(t.pop()))throw new Error("OP_NUMEQUALVERIFY failed")}},OP_NUMNOTEQUAL:{code:158,category:"arithmetic",description:"Push 1 if numbers are not equal, 0 otherwise",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());t.push(i.encode(e!==r?1:0))}},OP_LESSTHAN:{code:159,category:"arithmetic",description:"Push 1 if second < first, 0 otherwise",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());t.push(i.encode(r<e?1:0))}},OP_GREATERTHAN:{code:160,category:"arithmetic",description:"Push 1 if second > first, 0 otherwise",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());t.push(i.encode(r>e?1:0))}},OP_LESSTHANOREQUAL:{code:161,category:"arithmetic",description:"Push 1 if second <= first, 0 otherwise",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());t.push(i.encode(r<=e?1:0))}},OP_GREATERTHANOREQUAL:{code:162,category:"arithmetic",description:"Push 1 if second >= first, 0 otherwise",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());t.push(i.encode(r>=e?1:0))}},OP_MIN:{code:163,category:"arithmetic",description:"Push smaller of top two numbers",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());t.push(i.encode(Math.min(e,r)))}},OP_MAX:{code:164,category:"arithmetic",description:"Push larger of top two numbers",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop());t.push(i.encode(Math.max(e,r)))}},OP_WITHIN:{code:165,category:"arithmetic",description:"Push 1 if x is within [min, max), 0 otherwise",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop()),n=i.decode(t.pop());t.push(i.encode(n>=r&&n<e?1:0))}},OP_RIPEMD160:{code:166,category:"crypto",description:"RIPEMD-160 hash of top item",action:t=>{const e=r(15).createHash("ripemd160").update(t.pop()).digest();t.push(e)}},OP_SHA1:{code:167,category:"crypto",description:"SHA-1 hash of top item",action:t=>{const e=r(15).createHash("sha1").update(t.pop()).digest();t.push(e)}},OP_SHA256:{code:168,category:"crypto",description:"SHA-256 hash of top item",action:t=>{const e=r(15).createHash("sha256").update(t.pop()).digest();t.push(e)}},OP_HASH160:{code:169,category:"crypto",description:"SHA-256 then RIPEMD-160 hash of top item",action:t=>{const e=r(15),i=e.createHash("sha256").update(t.pop()).digest(),n=e.createHash("ripemd160").update(i).digest();t.push(n)}},OP_HASH256:{code:170,category:"crypto",description:"Double SHA-256 hash of top item",action:t=>{const e=r(15),i=e.createHash("sha256").update(t.pop()).digest(),n=e.createHash("sha256").update(i).digest();t.push(n)}},OP_CODESEPARATOR:{code:171,category:"crypto",description:"Mark signature checking boundary",action:t=>{}},OP_CHECKSIG:{code:172,category:"crypto",description:"Verify signature against public key",action:"// Signature verification (requires transaction context)"},OP_CHECKSIGVERIFY:{code:173,category:"crypto",description:"Verify signature, then fail if invalid",action:"// Signature verification with VERIFY (requires transaction context)"},OP_CHECKMULTISIG:{code:174,category:"crypto",description:"Verify multiple signatures against public keys",action:"// Multi-signature verification (requires transaction context)"},OP_CHECKMULTISIGVERIFY:{code:175,category:"crypto",description:"Verify multiple signatures, then fail if invalid",action:"// Multi-signature verification with VERIFY (requires transaction context)"},OP_SUBSTR:{code:179,category:"string",description:"Extract substring: string[start:start+length]",action:t=>{const e=i.decode(t.pop()),r=i.decode(t.pop()),n=t.pop();t.push(n.slice(r,r+e))}},OP_LEFT:{code:180,category:"string",description:"Extract leftmost n bytes",action:t=>{const e=i.decode(t.pop()),r=t.pop();t.push(r.slice(0,e))}},OP_RIGHT:{code:181,category:"string",description:"Extract rightmost n bytes",action:t=>{const e=i.decode(t.pop()),r=t.pop();t.push(r.slice(-e))}},OP_NOP1:{code:176,category:"nop",description:"No operation (reserved for future use)",action:t=>{}},OP_NOP2:{code:177,category:"nop",description:"No operation (formerly CHECKLOCKTIMEVERIFY)",action:t=>{}},OP_NOP3:{code:178,category:"nop",description:"No operation (formerly CHECKSEQUENCEVERIFY)",action:t=>{}},OP_NOP4:{code:182,category:"nop",description:"No operation (reserved for future use)",action:t=>{}},OP_NOP5:{code:183,category:"nop",description:"No operation (reserved for future use)",action:t=>{}},OP_NOP6:{code:184,category:"nop",description:"No operation (reserved for future use)",action:t=>{}},OP_NOP7:{code:185,category:"nop",description:"No operation (reserved for future use)",action:t=>{}},OP_NOP8:{code:186,category:"nop",description:"No operation (reserved for future use)",action:t=>{}},OP_NOP9:{code:187,category:"nop",description:"No operation (reserved for future use)",action:t=>{}},OP_NOP10:{code:188,category:"nop",description:"No operation (reserved for future use)",action:t=>{}},OP_RESERVED1:{code:137,category:"reserved",description:"Reserved opcode (makes transaction invalid)",action:()=>{throw new Error("OP_RESERVED1 encountered")}},OP_RESERVED2:{code:138,category:"reserved",description:"Reserved opcode (makes transaction invalid)",action:()=>{throw new Error("OP_RESERVED2 encountered")}},OP_CHECKLOCKTIMEVERIFY:{code:177,category:"disabled",description:"Check locktime (disabled post-Genesis)",action:t=>{}},OP_CHECKSEQUENCEVERIFY:{code:178,category:"disabled",description:"Check sequence (disabled post-Genesis)",action:t=>{}},OP_PUBKEYHASH:{code:253,category:"pseudo",description:"Template matching: public key hash",action:"// Template matching only"},OP_PUBKEY:{code:254,category:"pseudo",description:"Template matching: public key",action:"// Template matching only"},OP_INVALIDOPCODE:{code:255,category:"pseudo",description:"Invalid opcode placeholder",action:()=>{throw new Error("Invalid opcode encountered")}}},o={getByCategory:t=>Object.entries(n).filter(([e,r])=>r.category===t).reduce((t,[e,r])=>({...t,[e]:r}),{}),getCategories:()=>{const t=new Set;return Object.values(n).forEach(e=>t.add(e.category)),Array.from(t).sort()},createASM:e=>{const r=[];return e.forEach(e=>{if("string"==typeof e&&n[e])r.push(e);else if("number"==typeof e)if(e>=1&&e<=16)r.push("OP_"+e);else if(0===e)r.push("OP_0");else if(-1===e)r.push("OP_1NEGATE");else{const t=i.encode(e);r.push(t.toString("hex"))}else{if(!t.isBuffer(e))throw new Error("Invalid operation: "+e);r.push(e.toString("hex"))}}),r.join(" ")},simulate:(t,e=[])=>{const r=[...e],i=[],o=[];return t.forEach((t,e)=>{if(!n[t])throw new Error("Unknown opcode: "+t);const s=n[t],a=[...r];if("function"==typeof s.action)try{s.action(r,i),o.push({step:e+1,opcode:t,beforeStack:a.map(t=>t.toString("hex")),afterStack:r.map(t=>t.toString("hex")),description:s.description})}catch(r){throw o.push({step:e+1,opcode:t,beforeStack:a.map(t=>t.toString("hex")),afterStack:[],error:r.message,description:s.description}),r}else o.push({step:e+1,opcode:t,beforeStack:a.map(t=>t.toString("hex")),afterStack:a.map(t=>t.toString("hex")),note:s.action,description:s.description})}),{finalStack:r.map(t=>t.toString("hex")),finalAltStack:i.map(t=>t.toString("hex")),history:o}},opcodeToName:t=>{const e=Object.entries(n).find(([e,r])=>r.code===t);return e?e[0]:"UNKNOWN_"+t.toString(16).padStart(2,"0")},nameToOpcode:t=>n[t]&&n[t].code,generateCovenantTemplate:(e,r)=>{const i=[];return"value"===e&&(i.push("OP_SIZE"),i.push(52),i.push("OP_SUB"),i.push("OP_SPLIT"),i.push("OP_DROP"),i.push(8),i.push("OP_SPLIT"),i.push("OP_DROP")),r&&(i.push(t.from(r,"hex")),i.push("OP_EQUAL")),{operations:i,asm:o.createASM(i),description:`Extract ${e} field and compare with expected value`}}};if(e.exports={opcodeMap:n,scriptNum:i,utils:o},r.c[r.s]===e){console.log("🔧 Comprehensive Bitcoin Script Opcode Map"),console.log("=========================================="),console.log("Total opcodes mapped: "+Object.keys(n).length),console.log("\n📊 Categories:"),o.getCategories().forEach(t=>{const e=Object.values(n).filter(e=>e.category===t).length;console.log(` ${t}: ${e} opcodes`)}),console.log("\n🧪 Example: Stack manipulation simulation");try{const t=["OP_1","OP_2","OP_ADD","OP_3","OP_EQUAL"],e=o.simulate(t);console.log("Operations:",t.join(" ")),console.log("Final stack:",e.finalStack),console.log("Expected: ['01'] (true, since 1+2=3)"),console.log("\n📝 Step-by-step execution:"),e.history.forEach(t=>{console.log(` ${t.step}. ${t.opcode}: ${t.description}`),console.log(` Stack: [${t.beforeStack.join(", ")}] → [${t.afterStack.join(", ")}]`)})}catch(t){console.log("❌ Simulation error:",t.message)}console.log("\n🎯 Example: Covenant template generation");const t=o.generateCovenantTemplate("value","50c3000000000000");console.log("Generated ASM:",t.asm),console.log("Description:",t.description)}}).call(this,r(0).Buffer,r(31)(t))},function(t,e,r){"use strict";e.byteLength=function(t){var e=u(t),r=e[0],i=e[1];return 3*(r+i)/4-i},e.toByteArray=function(t){var e,r,i=u(t),s=i[0],a=i[1],c=new o(function(t,e,r){return 3*(e+r)/4-r}(0,s,a)),f=0,h=a>0?s-4:s;for(r=0;r<h;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],c[f++]=e>>16&255,c[f++]=e>>8&255,c[f++]=255&e;2===a&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,c[f++]=255&e);1===a&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,c[f++]=e>>8&255,c[f++]=255&e);return c},e.fromByteArray=function(t){for(var e,r=t.length,n=r%3,o=[],s=0,a=r-n;s<a;s+=16383)o.push(f(t,s,s+16383>a?a:s+16383));1===n?(e=t[r-1],o.push(i[e>>2]+i[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],o.push(i[e>>10]+i[e>>4&63]+i[e<<2&63]+"="));return o.join("")};for(var i=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a<c;++a)i[a]=s[a],n[s.charCodeAt(a)]=a;function u(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function f(t,e,r){for(var n,o,s=[],a=e;a<r;a+=3)n=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(i[(o=n)>>18&63]+i[o>>12&63]+i[o>>6&63]+i[63&o]);return s.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},function(t,e){
14
+ */function i(t,e){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}function o(t){return e.Buffer&&"function"==typeof e.Buffer.isBuffer?e.Buffer.isBuffer(t):!(null==t||!t._isBuffer)}var s=r(70),a=Object.prototype.hasOwnProperty,c=Array.prototype.slice,u="foo"===function(){}.name;function f(t){return Object.prototype.toString.call(t)}function h(t){return!o(t)&&("function"==typeof e.ArrayBuffer&&("function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):!!t&&(t instanceof DataView||!!(t.buffer&&t.buffer instanceof ArrayBuffer))))}var d=t.exports=y,p=/\s*function\s+([^\(\s]*)\s*/;function l(t){if(s.isFunction(t)){if(u)return t.name;var e=t.toString().match(p);return e&&e[1]}}function g(t,e){return"string"==typeof t?t.length<e?t:t.slice(0,e):t}function m(t){if(u||!s.isFunction(t))return s.inspect(t);var e=l(t);return"[Function"+(e?": "+e:"")+"]"}function b(t,e,r,n,i){throw new d.AssertionError({message:r,actual:t,expected:e,operator:n,stackStartFunction:i})}function y(t,e){t||b(t,!0,e,"==",d.ok)}function v(t,e,r,n){if(t===e)return!0;if(o(t)&&o(e))return 0===i(t,e);if(s.isDate(t)&&s.isDate(e))return t.getTime()===e.getTime();if(s.isRegExp(t)&&s.isRegExp(e))return t.source===e.source&&t.global===e.global&&t.multiline===e.multiline&&t.lastIndex===e.lastIndex&&t.ignoreCase===e.ignoreCase;if(null!==t&&"object"==typeof t||null!==e&&"object"==typeof e){if(h(t)&&h(e)&&f(t)===f(e)&&!(t instanceof Float32Array||t instanceof Float64Array))return 0===i(new Uint8Array(t.buffer),new Uint8Array(e.buffer));if(o(t)!==o(e))return!1;var a=(n=n||{actual:[],expected:[]}).actual.indexOf(t);return-1!==a&&a===n.expected.indexOf(e)||(n.actual.push(t),n.expected.push(e),function(t,e,r,n){if(null==t||null==e)return!1;if(s.isPrimitive(t)||s.isPrimitive(e))return t===e;if(r&&Object.getPrototypeOf(t)!==Object.getPrototypeOf(e))return!1;var i=S(t),o=S(e);if(i&&!o||!i&&o)return!1;if(i)return t=c.call(t),e=c.call(e),v(t,e,r);var a,u,f=I(t),h=I(e);if(f.length!==h.length)return!1;for(f.sort(),h.sort(),u=f.length-1;u>=0;u--)if(f[u]!==h[u])return!1;for(u=f.length-1;u>=0;u--)if(a=f[u],!v(t[a],e[a],r,n))return!1;return!0}(t,e,r,n))}return r?t===e:t==e}function S(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function _(t,e){if(!t||!e)return!1;if("[object RegExp]"==Object.prototype.toString.call(e))return e.test(t);try{if(t instanceof e)return!0}catch(t){}return!Error.isPrototypeOf(e)&&!0===e.call({},t)}function w(t,e,r,n){var i;if("function"!=typeof e)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(t){var e;try{t()}catch(t){e=t}return e}(e),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),t&&!i&&b(i,r,"Missing expected exception"+n);var o="string"==typeof n,a=!t&&i&&!r;if((!t&&s.isError(i)&&o&&_(i,r)||a)&&b(i,r,"Got unwanted exception"+n),t&&i&&r&&!_(i,r)||!t&&i)throw i}d.AssertionError=function(t){this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=function(t){return g(m(t.actual),128)+" "+t.operator+" "+g(m(t.expected),128)}(this),this.generatedMessage=!0);var e=t.stackStartFunction||b;if(Error.captureStackTrace)Error.captureStackTrace(this,e);else{var r=new Error;if(r.stack){var n=r.stack,i=l(e),o=n.indexOf("\n"+i);if(o>=0){var s=n.indexOf("\n",o+1);n=n.substring(s+1)}this.stack=n}}},s.inherits(d.AssertionError,Error),d.fail=b,d.ok=y,d.equal=function(t,e,r){t!=e&&b(t,e,r,"==",d.equal)},d.notEqual=function(t,e,r){t==e&&b(t,e,r,"!=",d.notEqual)},d.deepEqual=function(t,e,r){v(t,e,!1)||b(t,e,r,"deepEqual",d.deepEqual)},d.deepStrictEqual=function(t,e,r){v(t,e,!0)||b(t,e,r,"deepStrictEqual",d.deepStrictEqual)},d.notDeepEqual=function(t,e,r){v(t,e,!1)&&b(t,e,r,"notDeepEqual",d.notDeepEqual)},d.notDeepStrictEqual=function t(e,r,n){v(e,r,!0)&&b(e,r,n,"notDeepStrictEqual",t)},d.strictEqual=function(t,e,r){t!==e&&b(t,e,r,"===",d.strictEqual)},d.notStrictEqual=function(t,e,r){t===e&&b(t,e,r,"!==",d.notStrictEqual)},d.throws=function(t,e,r){w(!0,t,e,r)},d.doesNotThrow=function(t,e,r){w(!1,t,e,r)},d.ifError=function(t){if(t)throw t},d.strict=n((function t(e,r){e||b(e,!0,r,"==",t)}),d,{equal:d.strictEqual,deepEqual:d.deepStrictEqual,notEqual:d.notStrictEqual,notDeepEqual:d.notDeepStrictEqual}),d.strict.strict=d.strict;var I=Object.keys||function(t){var e=[];for(var r in t)a.call(t,r)&&e.push(r);return e}}).call(this,r(40))},function(t,e,r){"use strict";t.exports=Object},function(t,e,r){"use strict";t.exports=Function.prototype.call},function(t,e,r){"use strict";(function(e){var n=r(1),i=r(2),o=r(6);function s(t){if(!(this instanceof s))return new s(t);var e;if(n.isNumber(t))e=t;else{if(!n.isString(t))throw new TypeError('Unrecognized num type: "'+typeof t+'" for Opcode');e=s.map[t]}return o.defineImmutable(this,{num:e}),this}for(var a in s.fromBuffer=function(t){return i.checkArgument(e.isBuffer(t)),new s(Number("0x"+t.toString("hex")))},s.fromNumber=function(t){return i.checkArgument(n.isNumber(t)),new s(t)},s.fromString=function(t){i.checkArgument(n.isString(t));var e=s.map[t];if(void 0===e)throw new TypeError("Invalid opcodestr");return new s(e)},s.prototype.toHex=function(){return this.num.toString(16)},s.prototype.toBuffer=function(){return e.from(this.toHex(),"hex")},s.prototype.toNumber=function(){return this.num},s.prototype.toString=function(){var t=s.reverseMap[this.num];if(void 0===t)throw new Error("Opcode does not have a string representation");return t},s.smallInt=function(t){return i.checkArgument(n.isNumber(t),"Invalid Argument: n should be number"),i.checkArgument(t>=0&&t<=16,"Invalid Argument: n must be between 0 and 16"),0===t?s("OP_0"):new s(s.map.OP_1+t-1)},s.map={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SPLIT:127,OP_NUM2BIN:128,OP_BIN2NUM:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_CHECKLOCKTIMEVERIFY:177,OP_CHECKSEQUENCEVERIFY:178,OP_NOP1:176,OP_NOP2:177,OP_NOP3:178,OP_SUBSTR:179,OP_LEFT:180,OP_RIGHT:181,OP_NOP4:182,OP_NOP5:183,OP_NOP6:184,OP_NOP7:185,OP_NOP8:186,OP_NOP9:187,OP_NOP10:188,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255},s.reverseMap=[],s.map)s.reverseMap[s.map[a]]=a;n.extend(s,s.map),s.isSmallIntOp=function(t){return t instanceof s&&(t=t.toNumber()),t===s.map.OP_0||t>=s.map.OP_1&&t<=s.map.OP_16},s.prototype.inspect=function(){return"<Opcode: "+this.toString()+", hex: "+this.toHex()+", decimal: "+this.num+">"},t.exports=s}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var n=r(1),i=r(61),o=r(48),s=r(3),a=r(7),c=r(5),u=r(14),f=r(138),h=function t(e){if(!(this instanceof t))return new t(e);e?(this.initialize(),this.set(e)):this.initialize()};h.prototype.verify=function(t,e,o,s,a,c){var u,f=r(37);if(n.isUndefined(o)&&(o=new f),n.isUndefined(s)&&(s=0),n.isUndefined(a)&&(a=0),a&h.SCRIPT_ENABLE_SIGHASH_FORKID&&(a|=h.SCRIPT_VERIFY_STRICTENC,!c))throw new Error("internal error - need satoshisBN to verify FORKID transactions");if(this.set({script:t,tx:o,nin:s,flags:a,satoshisBN:c}),0!=(a&h.SCRIPT_VERIFY_SIGPUSHONLY)&&!t.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(!this.evaluate())return!1;a&h.SCRIPT_VERIFY_P2SH&&(u=this.stack.slice());var d=this.stack;if(this.initialize(),this.set({script:e,stack:d,tx:o,nin:s,flags:a,satoshisBN:c}),!this.evaluate())return!1;if(0===this.stack.length)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_RESULT",!1;var p=this.stack[this.stack.length-1];if(!h.castToBool(p))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_STACK",!1;if(a&h.SCRIPT_VERIFY_P2SH&&e.isScriptHashOut()){if(!t.isPushOnly())return this.errstr="SCRIPT_ERR_SIG_PUSHONLY",!1;if(0===u.length)throw new Error("internal error - stack copy empty");var l=u[u.length-1],g=i.fromBuffer(l);if(u.pop(),this.initialize(),this.set({script:g,stack:u,tx:o,nin:s,flags:a,satoshisBN:c}),!this.evaluate())return!1;if(0===u.length)return this.errstr="SCRIPT_ERR_EVAL_FALSE_NO_P2SH_STACK",!1;if(!h.castToBool(u[u.length-1]))return this.errstr="SCRIPT_ERR_EVAL_FALSE_IN_P2SH_STACK",!1}if(0!=(a&h.SCRIPT_VERIFY_CLEANSTACK)){if(0==(a&h.SCRIPT_VERIFY_P2SH))throw new Error("internal error - CLEANSTACK without P2SH");if(1!==u.length)return this.errstr="SCRIPT_ERR_CLEANSTACK",!1}return!0},t.exports=h,h.prototype.initialize=function(t){this.stack=[],this.altstack=[],this.pc=0,this.pbegincodehash=0,this.nOpCount=0,this.vfExec=[],this.errstr="",this.flags=0},h.prototype.set=function(t){this.script=t.script||this.script,this.tx=t.tx||this.tx,this.nin=void 0!==t.nin?t.nin:this.nin,this.satoshisBN=t.satoshisBN||this.satoshisBN,this.stack=t.stack||this.stack,this.altstack=t.altstack||this.altstack,this.pc=void 0!==t.pc?t.pc:this.pc,this.pbegincodehash=void 0!==t.pbegincodehash?t.pbegincodehash:this.pbegincodehash,this.nOpCount=void 0!==t.nOpCount?t.nOpCount:this.nOpCount,this.vfExec=t.vfExec||this.vfExec,this.errstr=t.errstr||this.errstr,this.flags=void 0!==t.flags?t.flags:this.flags},h.true=e.from([1]),h.false=e.from([]),h.MAX_SCRIPT_ELEMENT_SIZE=520,h.MAXIMUM_ELEMENT_SIZE=4,h.LOCKTIME_THRESHOLD_BN=new s(h.LOCKTIME_THRESHOLD=5e8),h.SCRIPT_VERIFY_NONE=0,h.SCRIPT_VERIFY_P2SH=1,h.SCRIPT_VERIFY_STRICTENC=2,h.SCRIPT_VERIFY_DERSIG=4,h.SCRIPT_VERIFY_LOW_S=8,h.SCRIPT_VERIFY_NULLDUMMY=16,h.SCRIPT_VERIFY_SIGPUSHONLY=32,h.SCRIPT_VERIFY_MINIMALDATA=64,h.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS=128,h.SCRIPT_VERIFY_CLEANSTACK=256,h.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY=512,h.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY=1024,h.SCRIPT_VERIFY_MINIMALIF=8192,h.SCRIPT_VERIFY_NULLFAIL=16384,h.SCRIPT_VERIFY_COMPRESSED_PUBKEYTYPE=32768,h.SCRIPT_ENABLE_SIGHASH_FORKID=65536,h.SCRIPT_ENABLE_REPLAY_PROTECTION=1<<17,h.SCRIPT_ENABLE_MONOLITH_OPCODES=1<<18,h.SCRIPT_ENABLE_MAGNETIC_OPCODES=1<<19,h.SEQUENCE_LOCKTIME_DISABLE_FLAG=1<<31,h.SEQUENCE_LOCKTIME_TYPE_FLAG=1<<22,h.SEQUENCE_LOCKTIME_MASK=65535,h.castToBool=function(t){for(var e=0;e<t.length;e++)if(0!==t[e])return e!==t.length-1||128!==t[e];return!1},h.prototype.checkSignatureEncoding=function(t){var e;if(0===t.length)return!0;if(0!=(this.flags&(h.SCRIPT_VERIFY_DERSIG|h.SCRIPT_VERIFY_LOW_S|h.SCRIPT_VERIFY_STRICTENC))&&!c.isTxDER(t))return this.errstr="SCRIPT_ERR_SIG_DER_INVALID_FORMAT",!1;if(0!=(this.flags&h.SCRIPT_VERIFY_LOW_S)){if(!(e=c.fromTxFormat(t)).hasLowS())return this.errstr="SCRIPT_ERR_SIG_DER_HIGH_S",!1}else if(0!=(this.flags&h.SCRIPT_VERIFY_STRICTENC)){if(!(e=c.fromTxFormat(t)).hasDefinedHashtype())return this.errstr="SCRIPT_ERR_SIG_HASHTYPE",!1;if(!(this.flags&h.SCRIPT_ENABLE_SIGHASH_FORKID)&&e.nhashtype&c.SIGHASH_FORKID)return this.errstr="SCRIPT_ERR_ILLEGAL_FORKID",!1;if(this.flags&h.SCRIPT_ENABLE_SIGHASH_FORKID&&!(e.nhashtype&c.SIGHASH_FORKID))return this.errstr="SCRIPT_ERR_MUST_USE_FORKID",!1}return!0},h.prototype.checkPubkeyEncoding=function(t){return!(0!=(this.flags&h.SCRIPT_VERIFY_STRICTENC)&&!u.isValid(t))||(this.errstr="SCRIPT_ERR_PUBKEYTYPE",!1)},h._isMinimallyEncoded=function(t,e){return e=e||h.MAXIMUM_ELEMENT_SIZE,!(t.length>e)&&!(t.length>0&&0==(127&t[t.length-1])&&(t.length<=1||0==(128&t[t.length-2])))},h._minimallyEncode=function(t){if(0===t.length)return t;var r=t[t.length-1];if(127&r)return t;if(1===t.length)return e.from("");if(128&t[t.length-2])return t;for(var n=t.length-1;n>0;n--)if(0!==t[n-1])return 128&t[n-1]?t[n++]=r:t[n-1]|=r,t.slice(0,n);return e.from("")},h.prototype.evaluate=function(){if(this.script.toBuffer().length>1e4)return this.errstr="SCRIPT_ERR_SCRIPT_SIZE",!1;try{for(;this.pc<this.script.chunks.length;){let t={pc:this.pc,opcode:o.fromNumber(this.script.chunks[this.pc].opcodenum)};if(!this.step())return!1;this._callbackStep(t)}if(this.stack.length+this.altstack.length>1e3)return this.errstr="SCRIPT_ERR_STACK_SIZE",!1}catch(t){return this.errstr="SCRIPT_ERR_UNKNOWN_ERROR: "+t,!1}return!(this.vfExec.length>0)||(this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1)},h.prototype._callbackStep=function(t){if("function"==typeof this.stepListener)try{this.stepListener(t,f(this.stack,!0),f(this.altstack,!0))}catch(t){console.log("Error in Step callback:"+t)}},h.prototype.checkLockTime=function(t){return!!(this.tx.nLockTime<h.LOCKTIME_THRESHOLD&&t.lt(h.LOCKTIME_THRESHOLD_BN)||this.tx.nLockTime>=h.LOCKTIME_THRESHOLD&&t.gte(h.LOCKTIME_THRESHOLD_BN))&&(!t.gt(new s(this.tx.nLockTime))&&!this.tx.inputs[this.nin].isFinal())},h.prototype.checkSequence=function(t){var e=this.tx.inputs[this.nin].sequenceNumber;if(this.tx.version<2)return!1;if(e&h.SEQUENCE_LOCKTIME_DISABLE_FLAG)return!1;var r=h.SEQUENCE_LOCKTIME_TYPE_FLAG|h.SEQUENCE_LOCKTIME_MASK,n=new s(e&r),i=t.and(r),o=new s(h.SEQUENCE_LOCKTIME_TYPE_FLAG);return!!(n.lt(o)&&i.lt(o)||n.gte(o)&&i.gte(o))&&!i.gt(n)},h.prototype.step=function(){var t=this;function r(e){return t.stack[t.stack.length+e]}var f,d,p,l,g,m,b,y,v,S,_,w,I,O,P,A,E,k=0!=(this.flags&h.SCRIPT_VERIFY_MINIMALDATA),x=-1===this.vfExec.indexOf(!1),T=this.script.chunks[this.pc];this.pc++;var R=T.opcodenum;if(n.isUndefined(R))return this.errstr="SCRIPT_ERR_UNDEFINED_OPCODE",!1;if(T.buf&&T.buf.length>h.MAX_SCRIPT_ELEMENT_SIZE)return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;if(R>o.OP_16&&++this.nOpCount>201)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;if(function(e){switch(e){case o.OP_2MUL:case o.OP_2DIV:return!0;case o.OP_INVERT:case o.OP_MUL:case o.OP_LSHIFT:case o.OP_RSHIFT:if(0==(t.flags&h.SCRIPT_ENABLE_MAGNETIC_OPCODES))return!0;break;case o.OP_DIV:case o.OP_MOD:case o.OP_SPLIT:case o.OP_CAT:case o.OP_AND:case o.OP_OR:case o.OP_XOR:case o.OP_BIN2NUM:case o.OP_NUM2BIN:return!1}return!1}(R))return this.errstr="SCRIPT_ERR_DISABLED_OPCODE",!1;if(x&&R>=0&&R<=o.OP_PUSHDATA4){if(k&&!this.script.checkMinimalPush(this.pc-1))return this.errstr="SCRIPT_ERR_MINIMALDATA",!1;if(T.buf){if(T.len!==T.buf.length)throw new Error(`Length of push value not equal to length of data (${T.len},${T.buf.length})`);this.stack.push(T.buf)}else this.stack.push(h.false)}else if(x||o.OP_IF<=R&&R<=o.OP_ENDIF)switch(R){case o.OP_1NEGATE:case o.OP_1:case o.OP_2:case o.OP_3:case o.OP_4:case o.OP_5:case o.OP_6:case o.OP_7:case o.OP_8:case o.OP_9:case o.OP_10:case o.OP_11:case o.OP_12:case o.OP_13:case o.OP_14:case o.OP_15:case o.OP_16:g=R-(o.OP_1-1),f=new s(g).toScriptNumBuffer(),this.stack.push(f);break;case o.OP_NOP:break;case o.OP_NOP2:case o.OP_CHECKLOCKTIMEVERIFY:if(!(this.flags&h.SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)){if(this.flags&h.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var M=s.fromScriptNumBuffer(this.stack[this.stack.length-1],k,5);if(M.lt(new s(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if(!this.checkLockTime(M))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case o.OP_NOP3:case o.OP_CHECKSEQUENCEVERIFY:if(!(this.flags&h.SCRIPT_VERIFY_CHECKSEQUENCEVERIFY)){if(this.flags&h.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var N=s.fromScriptNumBuffer(r(-1),k,5);if(N.lt(new s(0)))return this.errstr="SCRIPT_ERR_NEGATIVE_LOCKTIME",!1;if(0!=(N&h.SEQUENCE_LOCKTIME_DISABLE_FLAG))break;if(!this.checkSequence(N))return this.errstr="SCRIPT_ERR_UNSATISFIED_LOCKTIME",!1;break;case o.OP_NOP1:case o.OP_NOP4:case o.OP_NOP5:case o.OP_NOP6:case o.OP_NOP7:case o.OP_NOP8:case o.OP_NOP9:case o.OP_NOP10:if(this.flags&h.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS)return this.errstr="SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS",!1;break;case o.OP_IF:case o.OP_NOTIF:if(A=!1,x){if(this.stack.length<1)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;if(f=r(-1),this.flags&h.SCRIPT_VERIFY_MINIMALIF){if(f.length>1)return this.errstr="SCRIPT_ERR_MINIMALIF",!1;if(1===f.length&&1!==f[0])return this.errstr="SCRIPT_ERR_MINIMALIF",!1}A=h.castToBool(f),R===o.OP_NOTIF&&(A=!A),this.stack.pop()}this.vfExec.push(A);break;case o.OP_ELSE:if(0===this.vfExec.length)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec[this.vfExec.length-1]=!this.vfExec[this.vfExec.length-1];break;case o.OP_ENDIF:if(0===this.vfExec.length)return this.errstr="SCRIPT_ERR_UNBALANCED_CONDITIONAL",!1;this.vfExec.pop();break;case o.OP_VERIFY:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(f=r(-1),!(A=h.castToBool(f)))return this.errstr="SCRIPT_ERR_VERIFY",!1;this.stack.pop();break;case o.OP_RETURN:return this.errstr="SCRIPT_ERR_OP_RETURN",!1;case o.OP_TOALTSTACK:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.altstack.push(this.stack.pop());break;case o.OP_FROMALTSTACK:if(this.altstack.length<1)return this.errstr="SCRIPT_ERR_INVALID_ALTSTACK_OPERATION",!1;this.stack.push(this.altstack.pop());break;case o.OP_2DROP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop(),this.stack.pop();break;case o.OP_2DUP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;d=r(-2),p=r(-1),this.stack.push(e.from(d)),this.stack.push(e.from(p));break;case o.OP_3DUP:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;d=r(-3),p=r(-2);var B=r(-1);this.stack.push(e.from(d)),this.stack.push(e.from(p)),this.stack.push(e.from(B));break;case o.OP_2OVER:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;d=r(-4),p=r(-3),this.stack.push(e.from(d)),this.stack.push(e.from(p));break;case o.OP_2ROT:if(this.stack.length<6)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;l=this.stack.splice(this.stack.length-6,2),this.stack.push(l[0]),this.stack.push(l[1]);break;case o.OP_2SWAP:if(this.stack.length<4)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;l=this.stack.splice(this.stack.length-4,2),this.stack.push(l[0]),this.stack.push(l[1]);break;case o.OP_IFDUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;f=r(-1),(A=h.castToBool(f))&&this.stack.push(e.from(f));break;case o.OP_DEPTH:f=new s(this.stack.length).toScriptNumBuffer(),this.stack.push(f);break;case o.OP_DROP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.pop();break;case o.OP_DUP:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(e.from(r(-1)));break;case o.OP_NIP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,1);break;case o.OP_OVER:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.push(e.from(r(-2)));break;case o.OP_PICK:case o.OP_ROLL:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(f=r(-1),g=(y=s.fromScriptNumBuffer(f,k)).toNumber(),this.stack.pop(),g<0||g>=this.stack.length)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;f=r(-g-1),R===o.OP_ROLL&&this.stack.splice(this.stack.length-g-1,1),this.stack.push(e.from(f));break;case o.OP_ROT:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;m=r(-3),b=r(-2);var C=r(-1);this.stack[this.stack.length-3]=b,this.stack[this.stack.length-2]=C,this.stack[this.stack.length-1]=m;break;case o.OP_SWAP:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;m=r(-2),b=r(-1),this.stack[this.stack.length-2]=b,this.stack[this.stack.length-1]=m;break;case o.OP_TUCK:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;this.stack.splice(this.stack.length-2,0,e.from(r(-1)));break;case o.OP_SIZE:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;y=new s(r(-1).length),this.stack.push(y.toScriptNumBuffer());break;case o.OP_AND:case o.OP_OR:case o.OP_XOR:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(d=r(-2),p=r(-1),d.length!==p.length)return this.errstr="SCRIPT_ERR_INVALID_OPERAND_SIZE",!1;switch(R){case o.OP_AND:for(let t=0;t<d.length;t++)d[t]&=p[t];break;case o.OP_OR:for(let t=0;t<d.length;t++)d[t]|=p[t];break;case o.OP_XOR:for(let t=0;t<d.length;t++)d[t]^=p[t]}this.stack.pop();break;case o.OP_INVERT:this.stack.length<1&&(this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION"),f=r(-1);for(let t=0;t<f.length;t++)f[t]=~f[t];break;case o.OP_LSHIFT:case o.OP_RSHIFT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(0===(d=r(-2)).length)this.stack.pop();else{if(v=new s(d),(g=(S=s.fromScriptNumBuffer(r(-1),k)).toNumber())<0)return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;let t;this.stack.pop(),this.stack.pop(),R===o.OP_LSHIFT&&(t=v.ushln(g)),R===o.OP_RSHIFT&&(t=v.ushrn(g));let n=function(t,r){let n=t;for(;n.length<r;)n=e.concat([e.from([0]),n]);return n}(e.from(t.toArray().slice(-1*d.length)),d.length);this.stack.push(n)}break;case o.OP_EQUAL:case o.OP_EQUALVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;d=r(-2),p=r(-1);var H=d.toString("hex")===p.toString("hex");if(this.stack.pop(),this.stack.pop(),this.stack.push(H?h.true:h.false),R===o.OP_EQUALVERIFY){if(!H)return this.errstr="SCRIPT_ERR_EQUALVERIFY",!1;this.stack.pop()}break;case o.OP_1ADD:case o.OP_1SUB:case o.OP_NEGATE:case o.OP_ABS:case o.OP_NOT:case o.OP_0NOTEQUAL:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(f=r(-1),y=s.fromScriptNumBuffer(f,k),R){case o.OP_1ADD:y=y.add(s.One);break;case o.OP_1SUB:y=y.sub(s.One);break;case o.OP_NEGATE:y=y.neg();break;case o.OP_ABS:y.cmp(s.Zero)<0&&(y=y.neg());break;case o.OP_NOT:y=new s((0===y.cmp(s.Zero))+0);break;case o.OP_0NOTEQUAL:y=new s((0!==y.cmp(s.Zero))+0)}this.stack.pop(),this.stack.push(y.toScriptNumBuffer());break;case o.OP_ADD:case o.OP_SUB:case o.OP_MUL:case o.OP_MOD:case o.OP_DIV:case o.OP_BOOLAND:case o.OP_BOOLOR:case o.OP_NUMEQUAL:case o.OP_NUMEQUALVERIFY:case o.OP_NUMNOTEQUAL:case o.OP_LESSTHAN:case o.OP_GREATERTHAN:case o.OP_LESSTHANOREQUAL:case o.OP_GREATERTHANOREQUAL:case o.OP_MIN:case o.OP_MAX:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;switch(v=s.fromScriptNumBuffer(r(-2),k),S=s.fromScriptNumBuffer(r(-1),k),y=new s(0),R){case o.OP_ADD:y=v.add(S);break;case o.OP_SUB:y=v.sub(S);break;case o.OP_MUL:y=v.mul(S);break;case o.OP_DIV:if(0===S)return this.errstr="SCRIPT_ERR_DIV_BY_ZERO",!1;y=v.div(S);break;case o.OP_MOD:if(0===S)return this.errstr="SCRIPT_ERR_DIV_BY_ZERO",!1;y=v.mod(S);break;case o.OP_BOOLAND:y=new s((0!==v.cmp(s.Zero)&&0!==S.cmp(s.Zero))+0);break;case o.OP_BOOLOR:y=new s((0!==v.cmp(s.Zero)||0!==S.cmp(s.Zero))+0);break;case o.OP_NUMEQUAL:case o.OP_NUMEQUALVERIFY:y=new s((0===v.cmp(S))+0);break;case o.OP_NUMNOTEQUAL:y=new s((0!==v.cmp(S))+0);break;case o.OP_LESSTHAN:y=new s((v.cmp(S)<0)+0);break;case o.OP_GREATERTHAN:y=new s((v.cmp(S)>0)+0);break;case o.OP_LESSTHANOREQUAL:y=new s((v.cmp(S)<=0)+0);break;case o.OP_GREATERTHANOREQUAL:y=new s((v.cmp(S)>=0)+0);break;case o.OP_MIN:y=v.cmp(S)<0?v:S;break;case o.OP_MAX:y=v.cmp(S)>0?v:S}if(this.stack.pop(),this.stack.pop(),this.stack.push(y.toScriptNumBuffer()),R===o.OP_NUMEQUALVERIFY){if(!h.castToBool(r(-1)))return this.errstr="SCRIPT_ERR_NUMEQUALVERIFY",!1;this.stack.pop()}break;case o.OP_WITHIN:if(this.stack.length<3)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;v=s.fromScriptNumBuffer(r(-3),k),S=s.fromScriptNumBuffer(r(-2),k);var U=s.fromScriptNumBuffer(r(-1),k);A=S.cmp(v)<=0&&v.cmp(U)<0,this.stack.pop(),this.stack.pop(),this.stack.pop(),this.stack.push(A?h.true:h.false);break;case o.OP_RIPEMD160:case o.OP_SHA1:case o.OP_SHA256:case o.OP_HASH160:case o.OP_HASH256:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var L;f=r(-1),R===o.OP_RIPEMD160?L=a.ripemd160(f):R===o.OP_SHA1?L=a.sha1(f):R===o.OP_SHA256?L=a.sha256(f):R===o.OP_HASH160?L=a.sha256ripemd160(f):R===o.OP_HASH256&&(L=a.sha256sha256(f)),this.stack.pop(),this.stack.push(L);break;case o.OP_CODESEPARATOR:this.pbegincodehash=this.pc;break;case o.OP_CHECKSIG:case o.OP_CHECKSIGVERIFY:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(_=r(-2),w=r(-1),!this.checkSignatureEncoding(_)||!this.checkPubkeyEncoding(w))return!1;I=(new i).set({chunks:this.script.chunks.slice(this.pbegincodehash)});var F=(new i).add(_);I.findAndDelete(F);try{O=c.fromTxFormat(_),P=u.fromBuffer(w,!1),E=this.tx.verifySignature(O,P,this.nin,I,this.satoshisBN,this.flags)}catch(t){E=!1}if(!E&&this.flags&h.SCRIPT_VERIFY_NULLFAIL&&_.length)return this.errstr="SCRIPT_ERR_NULLFAIL",!1;if(this.stack.pop(),this.stack.pop(),this.stack.push(E?h.true:h.false),R===o.OP_CHECKSIGVERIFY){if(!E)return this.errstr="SCRIPT_ERR_CHECKSIGVERIFY",!1;this.stack.pop()}break;case o.OP_CHECKMULTISIG:case o.OP_CHECKMULTISIGVERIFY:var D=1;if(this.stack.length<D)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var K=s.fromScriptNumBuffer(r(-D),k).toNumber();if(K<0||K>20)return this.errstr="SCRIPT_ERR_PUBKEY_COUNT",!1;if(this.nOpCount+=K,this.nOpCount>201)return this.errstr="SCRIPT_ERR_OP_COUNT",!1;var z=++D;D+=K;var j=K+2;if(this.stack.length<D)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var V=s.fromScriptNumBuffer(r(-D),k).toNumber();if(V<0||V>K)return this.errstr="SCRIPT_ERR_SIG_COUNT",!1;var G=++D;if(D+=V,this.stack.length<D)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;I=(new i).set({chunks:this.script.chunks.slice(this.pbegincodehash)});for(var q=0;q<V;q++)_=r(-G-q),I.findAndDelete((new i).add(_));for(E=!0;E&&V>0;){if(_=r(-G),w=r(-z),!this.checkSignatureEncoding(_)||!this.checkPubkeyEncoding(w))return!1;var Y;try{O=c.fromTxFormat(_),P=u.fromBuffer(w,!1),Y=this.tx.verifySignature(O,P,this.nin,I,this.satoshisBN,this.flags)}catch(t){Y=!1}Y&&(G++,V--),z++,V>--K&&(E=!1)}for(;D-- >1;){if(!E&&this.flags&h.SCRIPT_VERIFY_NULLFAIL&&!j&&r(-1).length)return this.errstr="SCRIPT_ERR_NULLFAIL",!1;j>0&&j--,this.stack.pop()}if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(this.flags&h.SCRIPT_VERIFY_NULLDUMMY&&r(-1).length)return this.errstr="SCRIPT_ERR_SIG_NULLDUMMY",!1;if(this.stack.pop(),this.stack.push(E?h.true:h.false),R===o.OP_CHECKMULTISIGVERIFY){if(!E)return this.errstr="SCRIPT_ERR_CHECKMULTISIGVERIFY",!1;this.stack.pop()}break;case o.OP_CAT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(d=r(-2),p=r(-1),d.length+p.length>h.MAX_SCRIPT_ELEMENT_SIZE)return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;this.stack[this.stack.length-2]=e.concat([d,p]),this.stack.pop();break;case o.OP_SPLIT:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;d=r(-2);var X=s.fromScriptNumBuffer(r(-1),k).toNumber();if(X<0||X>d.length)return this.errstr="SCRIPT_ERR_INVALID_SPLIT_RANGE",!1;var W=e.from(d);this.stack[this.stack.length-2]=W.slice(0,X),this.stack[this.stack.length-1]=W.slice(X);break;case o.OP_NUM2BIN:if(this.stack.length<2)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;var Z=s.fromScriptNumBuffer(r(-1),k).toNumber();if(Z>h.MAX_SCRIPT_ELEMENT_SIZE)return this.errstr="SCRIPT_ERR_PUSH_SIZE",!1;this.stack.pop();var $=r(-1);if(($=h._minimallyEncode($)).length>Z)return this.errstr="SCRIPT_ERR_IMPOSSIBLE_ENCODING",!1;if($.length===Z){this.stack[this.stack.length-1]=$;break}var Q=0;$.length>0&&(Q=128&$[$.length-1],$[$.length-1]&=127);var J=e.alloc(Z);$.copy(J,0);for(var tt=$.length-1;tt++<Z-2;)J[tt]=0;J[tt]=Q,this.stack[this.stack.length-1]=J;break;case o.OP_BIN2NUM:if(this.stack.length<1)return this.errstr="SCRIPT_ERR_INVALID_STACK_OPERATION",!1;if(d=r(-1),p=h._minimallyEncode(d),this.stack[this.stack.length-1]=p,!h._isMinimallyEncoded(p))return this.errstr="SCRIPT_ERR_INVALID_NUMBER_RANGE",!1;break;default:return this.errstr="SCRIPT_ERR_BAD_OPCODE",!1}return!0}}).call(this,r(0).Buffer)},function(t,e,r){t.exports=r(30),t.exports.PublicKey=r(142),t.exports.PublicKeyHash=r(143),t.exports.MultiSig=r(144),t.exports.MultiSigScriptHash=r(145)},function(t,e,r){"use strict";(function(e){const n=r(3),i=r(11),o=r(44),s=i.getN(),a=s.shrn(1);t.exports={smartVerify:function(t,i,c){if(!e.isBuffer(t)||32!==t.length)throw new Error("Invalid message hash: must be 32-byte buffer");if(!i)return!1;let u=i;if(e.isBuffer(i))try{u=r(5).fromDER(i)}catch(t){return!1}if(!u||!u.r||!u.s)return!1;const f=n.isBN(u.r)?u.r:new n(u.r),h=n.isBN(u.s)?u.s:new n(u.s);if(f.isZero()||h.isZero())return!1;if(f.gte(s)||h.gte(s))return!1;let d=h;h.gt(a)&&(d=s.sub(h));const p=new(r(5))({r:f,s:d});return o.verify(t,p,c)},isCanonical:function(t){if(!t)return!1;let i=t;if(e.isBuffer(t))try{i=r(5).fromDER(t)}catch(t){return!1}return!(!i||!i.s)&&(n.isBN(i.s)?i.s:new n(i.s)).lte(a)},canonicalize:function(t){if(!t||!t.r||!t.s)throw new Error("Invalid signature object");const e=n.isBN(t.r)?t.r:new n(t.r),r=n.isBN(t.s)?t.s:new n(t.s);let i=r;return r.gt(a)&&(i=s.sub(r)),{r:e,s:i}},constants:{n:s,nh:a}}}).call(this,r(0).Buffer)},function(t,e,r){"use strict";const{ec:n}=r(41),i=new n("secp256k1"),o=i.verify.bind(i);i.verify=function(t,e,r,n,i){if(!e||"object"!=typeof e)return!1;if(!e.r||!e.s)return!1;const s="function"==typeof e.r.cmp?e.r:this.curve.n.red?this.curve.n.fromRed(e.r):e.r,a="function"==typeof e.s.cmp?e.s:this.curve.n.red?this.curve.n.fromRed(e.s):e.s;return!(s&&s.cmp&&s.cmp(this.curve.n)>=0)&&(!(a&&a.cmp&&a.cmp(this.curve.n)>=0)&&(!(s&&s.isZero&&s.isZero())&&(!(a&&a.isZero&&a.isZero())&&o(t,e,r,n,i))))};const s=i.sign.bind(i);i.sign=function(t,e,r,n){const i=s(t,e,r,n);if(i.s&&i.s.cmp){const t=this.curve.n.shrn(1);i.s.cmp(t)>0&&(i.s=this.curve.n.sub(i.s))}return i},t.exports=i},function(t,e,r){(function(t){function r(t,e){for(var r=0,n=t.length-1;n>=0;n--){var i=t[n];"."===i?t.splice(n,1):".."===i?(t.splice(n,1),r++):r&&(t.splice(n,1),r--)}if(e)for(;r--;r)t.unshift("..");return t}function n(t,e){if(t.filter)return t.filter(e);for(var r=[],n=0;n<t.length;n++)e(t[n],n,t)&&r.push(t[n]);return r}e.resolve=function(){for(var e="",i=!1,o=arguments.length-1;o>=-1&&!i;o--){var s=o>=0?arguments[o]:t.cwd();if("string"!=typeof s)throw new TypeError("Arguments to path.resolve must be strings");s&&(e=s+"/"+e,i="/"===s.charAt(0))}return(i?"/":"")+(e=r(n(e.split("/"),(function(t){return!!t})),!i).join("/"))||"."},e.normalize=function(t){var o=e.isAbsolute(t),s="/"===i(t,-1);return(t=r(n(t.split("/"),(function(t){return!!t})),!o).join("/"))||o||(t="."),t&&s&&(t+="/"),(o?"/":"")+t},e.isAbsolute=function(t){return"/"===t.charAt(0)},e.join=function(){var t=Array.prototype.slice.call(arguments,0);return e.normalize(n(t,(function(t,e){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t})).join("/"))},e.relative=function(t,r){function n(t){for(var e=0;e<t.length&&""===t[e];e++);for(var r=t.length-1;r>=0&&""===t[r];r--);return e>r?[]:t.slice(e,r-e+1)}t=e.resolve(t).substr(1),r=e.resolve(r).substr(1);for(var i=n(t.split("/")),o=n(r.split("/")),s=Math.min(i.length,o.length),a=s,c=0;c<s;c++)if(i[c]!==o[c]){a=c;break}var u=[];for(c=a;c<i.length;c++)u.push("..");return(u=u.concat(o.slice(a))).join("/")},e.sep="/",e.delimiter=":",e.dirname=function(t){if("string"!=typeof t&&(t+=""),0===t.length)return".";for(var e=t.charCodeAt(0),r=47===e,n=-1,i=!0,o=t.length-1;o>=1;--o)if(47===(e=t.charCodeAt(o))){if(!i){n=o;break}}else i=!1;return-1===n?r?"/":".":r&&1===n?"/":t.slice(0,n)},e.basename=function(t,e){var r=function(t){"string"!=typeof t&&(t+="");var e,r=0,n=-1,i=!0;for(e=t.length-1;e>=0;--e)if(47===t.charCodeAt(e)){if(!i){r=e+1;break}}else-1===n&&(i=!1,n=e+1);return-1===n?"":t.slice(r,n)}(t);return e&&r.substr(-1*e.length)===e&&(r=r.substr(0,r.length-e.length)),r},e.extname=function(t){"string"!=typeof t&&(t+="");for(var e=-1,r=0,n=-1,i=!0,o=0,s=t.length-1;s>=0;--s){var a=t.charCodeAt(s);if(47!==a)-1===n&&(i=!1,n=s+1),46===a?-1===e?e=s:1!==o&&(o=1):-1!==e&&(o=-1);else if(!i){r=s+1;break}}return-1===e||-1===n||0===o||1===o&&e===n-1&&e===r+1?"":t.slice(e,n)};var i="b"==="ab".substr(-1)?function(t,e,r){return t.substr(e,r)}:function(t,e,r){return e<0&&(e=t.length+e),t.substr(e,r)}}).call(this,r(18))},function(t,e,r){var n=r(83);t.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},function(t,e,r){"use strict";var n=e;function i(t){return 1===t.length?"0"+t:t}function o(t){for(var e="",r=0;r<t.length;r++)e+=i(t[r].toString(16));return e}n.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"!=typeof t){for(var n=0;n<t.length;n++)r[n]=0|t[n];return r}if("hex"===e){(t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t);for(n=0;n<t.length;n+=2)r.push(parseInt(t[n]+t[n+1],16))}else for(n=0;n<t.length;n++){var i=t.charCodeAt(n),o=i>>8,s=255&i;o?r.push(o,s):r.push(s)}return r},n.zero2=i,n.toHex=o,n.encode=function(t,e){return"hex"===e?o(t):t}},function(t,e,r){var n;function i(t){this.rand=t}if(t.exports=function(t){return n||(n=new i(null)),n.generate(t)},t.exports.Rand=i,i.prototype.generate=function(t){return this._rand(t)},i.prototype._rand=function(t){if(this.rand.getBytes)return this.rand.getBytes(t);for(var e=new Uint8Array(t),r=0;r<e.length;r++)e[r]=this.rand.getByte();return e},"object"==typeof self)self.crypto&&self.crypto.getRandomValues?i.prototype._rand=function(t){var e=new Uint8Array(t);return self.crypto.getRandomValues(e),e}:self.msCrypto&&self.msCrypto.getRandomValues?i.prototype._rand=function(t){var e=new Uint8Array(t);return self.msCrypto.getRandomValues(e),e}:"object"==typeof window&&(i.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var o=r(86);if("function"!=typeof o.randomBytes)throw new Error("Not supported");i.prototype._rand=function(t){return o.randomBytes(t)}}catch(t){}},function(t,e,r){"use strict";var n=e;n.base=r(32),n.short=r(87),n.mont=r(88),n.edwards=r(89)},function(t,e,r){"use strict";var n=r(13).rotr32;function i(t,e,r){return t&e^~t&r}function o(t,e,r){return t&e^t&r^e&r}function s(t,e,r){return t^e^r}e.ft_1=function(t,e,r,n){return 0===t?i(e,r,n):1===t||3===t?s(e,r,n):2===t?o(e,r,n):void 0},e.ch32=i,e.maj32=o,e.p32=s,e.s0_256=function(t){return n(t,2)^n(t,13)^n(t,22)},e.s1_256=function(t){return n(t,6)^n(t,11)^n(t,25)},e.g0_256=function(t){return n(t,7)^n(t,18)^t>>>3},e.g1_256=function(t){return n(t,17)^n(t,19)^t>>>10}},function(t,e,r){"use strict";var n=r(13),i=r(27),o=r(58),s=r(22),a=n.sum32,c=n.sum32_4,u=n.sum32_5,f=o.ch32,h=o.maj32,d=o.s0_256,p=o.s1_256,l=o.g0_256,g=o.g1_256,m=i.BlockHash,b=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function y(){if(!(this instanceof y))return new y;m.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=b,this.W=new Array(64)}n.inherits(y,m),t.exports=y,y.blockSize=512,y.outSize=256,y.hmacStrength=192,y.padLength=64,y.prototype._update=function(t,e){for(var r=this.W,n=0;n<16;n++)r[n]=t[e+n];for(;n<r.length;n++)r[n]=c(g(r[n-2]),r[n-7],l(r[n-15]),r[n-16]);var i=this.h[0],o=this.h[1],m=this.h[2],b=this.h[3],y=this.h[4],v=this.h[5],S=this.h[6],_=this.h[7];for(s(this.k.length===r.length),n=0;n<r.length;n++){var w=u(_,p(y),f(y,v,S),this.k[n],r[n]),I=a(d(i),h(i,o,m));_=S,S=v,v=y,y=a(b,w),b=m,m=o,o=i,i=a(w,I)}this.h[0]=a(this.h[0],i),this.h[1]=a(this.h[1],o),this.h[2]=a(this.h[2],m),this.h[3]=a(this.h[3],b),this.h[4]=a(this.h[4],y),this.h[5]=a(this.h[5],v),this.h[6]=a(this.h[6],S),this.h[7]=a(this.h[7],_)},y.prototype._digest=function(t){return"hex"===t?n.toHex32(this.h,"big"):n.split32(this.h,"big")}},function(t,e,r){"use strict";var n=r(13),i=r(27),o=r(22),s=n.rotr64_hi,a=n.rotr64_lo,c=n.shr64_hi,u=n.shr64_lo,f=n.sum64,h=n.sum64_hi,d=n.sum64_lo,p=n.sum64_4_hi,l=n.sum64_4_lo,g=n.sum64_5_hi,m=n.sum64_5_lo,b=i.BlockHash,y=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function v(){if(!(this instanceof v))return new v;b.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=y,this.W=new Array(160)}function S(t,e,r,n,i){var o=t&r^~t&i;return o<0&&(o+=4294967296),o}function _(t,e,r,n,i,o){var s=e&n^~e&o;return s<0&&(s+=4294967296),s}function w(t,e,r,n,i){var o=t&r^t&i^r&i;return o<0&&(o+=4294967296),o}function I(t,e,r,n,i,o){var s=e&n^e&o^n&o;return s<0&&(s+=4294967296),s}function O(t,e){var r=s(t,e,28)^s(e,t,2)^s(e,t,7);return r<0&&(r+=4294967296),r}function P(t,e){var r=a(t,e,28)^a(e,t,2)^a(e,t,7);return r<0&&(r+=4294967296),r}function A(t,e){var r=s(t,e,14)^s(t,e,18)^s(e,t,9);return r<0&&(r+=4294967296),r}function E(t,e){var r=a(t,e,14)^a(t,e,18)^a(e,t,9);return r<0&&(r+=4294967296),r}function k(t,e){var r=s(t,e,1)^s(t,e,8)^c(t,e,7);return r<0&&(r+=4294967296),r}function x(t,e){var r=a(t,e,1)^a(t,e,8)^u(t,e,7);return r<0&&(r+=4294967296),r}function T(t,e){var r=s(t,e,19)^s(e,t,29)^c(t,e,6);return r<0&&(r+=4294967296),r}function R(t,e){var r=a(t,e,19)^a(e,t,29)^u(t,e,6);return r<0&&(r+=4294967296),r}n.inherits(v,b),t.exports=v,v.blockSize=1024,v.outSize=512,v.hmacStrength=192,v.padLength=128,v.prototype._prepareBlock=function(t,e){for(var r=this.W,n=0;n<32;n++)r[n]=t[e+n];for(;n<r.length;n+=2){var i=T(r[n-4],r[n-3]),o=R(r[n-4],r[n-3]),s=r[n-14],a=r[n-13],c=k(r[n-30],r[n-29]),u=x(r[n-30],r[n-29]),f=r[n-32],h=r[n-31];r[n]=p(i,o,s,a,c,u,f,h),r[n+1]=l(i,o,s,a,c,u,f,h)}},v.prototype._update=function(t,e){this._prepareBlock(t,e);var r=this.W,n=this.h[0],i=this.h[1],s=this.h[2],a=this.h[3],c=this.h[4],u=this.h[5],p=this.h[6],l=this.h[7],b=this.h[8],y=this.h[9],v=this.h[10],k=this.h[11],x=this.h[12],T=this.h[13],R=this.h[14],M=this.h[15];o(this.k.length===r.length);for(var N=0;N<r.length;N+=2){var B=R,C=M,H=A(b,y),U=E(b,y),L=S(b,y,v,k,x),F=_(b,y,v,k,x,T),D=this.k[N],K=this.k[N+1],z=r[N],j=r[N+1],V=g(B,C,H,U,L,F,D,K,z,j),G=m(B,C,H,U,L,F,D,K,z,j);B=O(n,i),C=P(n,i),H=w(n,i,s,a,c),U=I(n,i,s,a,c,u);var q=h(B,C,H,U),Y=d(B,C,H,U);R=x,M=T,x=v,T=k,v=b,k=y,b=h(p,l,V,G),y=d(l,l,V,G),p=c,l=u,c=s,u=a,s=n,a=i,n=h(V,G,q,Y),i=d(V,G,q,Y)}f(this.h,0,n,i),f(this.h,2,s,a),f(this.h,4,c,u),f(this.h,6,p,l),f(this.h,8,b,y),f(this.h,10,v,k),f(this.h,12,x,T),f(this.h,14,R,M)},v.prototype._digest=function(t){return"hex"===t?n.toHex32(this.h,"big"):n.split32(this.h,"big")}},function(t,e,r){"use strict";(function(e){var n=r(26),i=r(19),o=r(16),s=r(7),a=r(48),c=r(14),u=r(5),f=r(24),h=r(2),d=r(1),p=r(10),l=r(0),g=r(6),m=function t(r){return this instanceof t?(this.chunks=[],e.isBuffer(r)?t.fromBuffer(r):r instanceof n?t.fromAddress(r):r instanceof t?t.fromBuffer(r.toBuffer()):d.isString(r)?t.fromString(r):void(d.isObject(r)&&d.isArray(r.chunks)&&this.set(r))):new t(r)};m.prototype.set=function(t){return h.checkArgument(d.isObject(t)),h.checkArgument(d.isArray(t.chunks)),this.chunks=t.chunks,this},m.fromBuffer=function(t){var e=new m;e.chunks=[];for(var r=new i(t);!r.finished();)try{var n,o,s=r.readUInt8();s>0&&s<a.OP_PUSHDATA1?(n=s,e.chunks.push({buf:r.read(n),len:n,opcodenum:s})):s===a.OP_PUSHDATA1?(n=r.readUInt8(),o=r.read(n),e.chunks.push({buf:o,len:n,opcodenum:s})):s===a.OP_PUSHDATA2?(n=r.readUInt16LE(),o=r.read(n),e.chunks.push({buf:o,len:n,opcodenum:s})):s===a.OP_PUSHDATA4?(n=r.readUInt32LE(),o=r.read(n),e.chunks.push({buf:o,len:n,opcodenum:s})):e.chunks.push({opcodenum:s})}catch(e){if(e instanceof RangeError)throw new p.Script.InvalidBuffer(t.toString("hex"));throw e}return e},m.prototype.toBuffer=function(){for(var t=new o,e=0;e<this.chunks.length;e++){var r=this.chunks[e],n=r.opcodenum;t.writeUInt8(r.opcodenum),r.buf&&(n<a.OP_PUSHDATA1?t.write(r.buf):n===a.OP_PUSHDATA1?(t.writeUInt8(r.len),t.write(r.buf)):n===a.OP_PUSHDATA2?(t.writeUInt16LE(r.len),t.write(r.buf)):n===a.OP_PUSHDATA4&&(t.writeUInt32LE(r.len),t.write(r.buf)))}return t.concat()},m.fromASM=function(t){var r=new m;r.chunks=[];for(var n=t.split(" "),i=0;i<n.length;){var o=n[i],s=a(o).toNumber();if("0"===o)s=0,r.chunks.push({opcodenum:s}),i+=1;else if("-1"===o)s=a.OP_1NEGATE,r.chunks.push({opcodenum:s}),i+=1;else if(d.isUndefined(s)){var c=e.from(n[i],"hex");if(c.toString("hex")!==n[i])throw new Error("invalid hex string in script");var u=c.length;u>=0&&u<a.OP_PUSHDATA1?s=u:u<Math.pow(2,8)?s=a.OP_PUSHDATA1:u<Math.pow(2,16)?s=a.OP_PUSHDATA2:u<Math.pow(2,32)&&(s=a.OP_PUSHDATA4),r.chunks.push({buf:c,len:c.length,opcodenum:s}),i+=1}else r.chunks.push({opcodenum:s}),i+=1}return r},m.fromHex=function(t){return new m(l.Buffer.from(t,"hex"))},m.fromString=function(t){if(g.isHexa(t)||0===t.length)return new m(l.Buffer.from(t,"hex"));var r=new m;r.chunks=[];for(var n=t.split(" "),i=0;i<n.length;){var o=n[i],s=a(o).toNumber();if(d.isUndefined(s)){if(!((s=parseInt(o))>0&&s<a.OP_PUSHDATA1))throw new Error("Invalid script: "+JSON.stringify(t));r.chunks.push({buf:e.from(n[i+1].slice(2),"hex"),len:s,opcodenum:s}),i+=2}else if(s===a.OP_PUSHDATA1||s===a.OP_PUSHDATA2||s===a.OP_PUSHDATA4){if("0x"!==n[i+2].slice(0,2))throw new Error("Pushdata data must start with 0x");r.chunks.push({buf:e.from(n[i+2].slice(2),"hex"),len:parseInt(n[i+1]),opcodenum:s}),i+=3}else r.chunks.push({opcodenum:s}),i+=1}return r},m.prototype._chunkToString=function(t,e){var r=t.opcodenum,n="asm"===e,i="";if(t.buf)n||r!==a.OP_PUSHDATA1&&r!==a.OP_PUSHDATA2&&r!==a.OP_PUSHDATA4||(i=i+" "+a(r).toString()),t.len>0&&(i=n?i+" "+t.buf.toString("hex"):i+" "+t.len+" 0x"+t.buf.toString("hex"));else if(void 0!==a.reverseMap[r])n?0===r?i+=" 0":79===r?i+=" -1":i=i+" "+a(r).toString():i=i+" "+a(r).toString();else{var o=r.toString(16);o.length%2!=0&&(o="0"+o),i=n?i+" "+o:i+" 0x"+o}return i},m.prototype.toASM=function(){for(var t="",e=0;e<this.chunks.length;e++){var r=this.chunks[e];t+=this._chunkToString(r,"asm")}return t.substr(1)},m.prototype.toString=function(){for(var t="",e=0;e<this.chunks.length;e++){var r=this.chunks[e];t+=this._chunkToString(r)}return t.substr(1)},m.prototype.toHex=function(){return this.toBuffer().toString("hex")},m.prototype.inspect=function(){return"<Script: "+this.toString()+">"},m.prototype.isPublicKeyHashOut=function(){return!(5!==this.chunks.length||this.chunks[0].opcodenum!==a.OP_DUP||this.chunks[1].opcodenum!==a.OP_HASH160||!this.chunks[2].buf||20!==this.chunks[2].buf.length||this.chunks[3].opcodenum!==a.OP_EQUALVERIFY||this.chunks[4].opcodenum!==a.OP_CHECKSIG)},m.prototype.isPublicKeyHashIn=function(){if(2===this.chunks.length){var t=this.chunks[0].buf,e=this.chunks[1].buf;if(t&&t.length&&48===t[0]&&e&&e.length){var r=e[0];if((4===r||6===r||7===r)&&65===e.length)return!0;if((3===r||2===r)&&33===e.length)return!0}}return!1},m.prototype.getPublicKey=function(){return h.checkState(this.isPublicKeyOut(),"Can't retrieve PublicKey from a non-PK output"),this.chunks[0].buf},m.prototype.getPublicKeyHash=function(){return h.checkState(this.isPublicKeyHashOut(),"Can't retrieve PublicKeyHash from a non-PKH output"),this.chunks[2].buf},m.prototype.isPublicKeyOut=function(){if(2===this.chunks.length&&this.chunks[0].buf&&this.chunks[0].buf.length&&this.chunks[1].opcodenum===a.OP_CHECKSIG){var t=this.chunks[0].buf,e=t[0],r=!1;if((4!==e&&6!==e&&7!==e||65!==t.length)&&(3!==e&&2!==e||33!==t.length)||(r=!0),r)return c.isValid(t)}return!1},m.prototype.isPublicKeyIn=function(){if(1===this.chunks.length){var t=this.chunks[0].buf;if(t&&t.length&&48===t[0])return!0}return!1},m.prototype.isScriptHashOut=function(){var t=this.toBuffer();return 23===t.length&&t[0]===a.OP_HASH160&&20===t[1]&&t[t.length-1]===a.OP_EQUAL},m.prototype.isScriptHashIn=function(){if(this.chunks.length<=1)return!1;var t,e=this.chunks[this.chunks.length-1].buf;if(!e)return!1;try{t=m.fromBuffer(e)}catch(t){if(t instanceof p.Script.InvalidBuffer)return!1;throw t}return t.classify()!==m.types.UNKNOWN},m.prototype.isMultisigOut=function(){return this.chunks.length>3&&a.isSmallIntOp(this.chunks[0].opcodenum)&&this.chunks.slice(1,this.chunks.length-2).every((function(t){return t.buf&&e.isBuffer(t.buf)}))&&a.isSmallIntOp(this.chunks[this.chunks.length-2].opcodenum)&&this.chunks[this.chunks.length-1].opcodenum===a.OP_CHECKMULTISIG},m.prototype.isMultisigIn=function(){return this.chunks.length>=2&&0===this.chunks[0].opcodenum&&this.chunks.slice(1,this.chunks.length).every((function(t){return t.buf&&e.isBuffer(t.buf)&&u.isTxDER(t.buf)}))},m.prototype.isDataOut=function(){if(!(this.chunks.length>=1&&this.chunks[0].opcodenum===a.OP_RETURN))return!1;var t=this.chunks.slice(1);return new m({chunks:t}).isPushOnly()},m.prototype.isSafeDataOut=function(){if(this.chunks.length<2)return!1;if(this.chunks[0].opcodenum!==a.OP_FALSE)return!1;var t=this.chunks.slice(1);return new m({chunks:t}).isDataOut()},m.prototype.getData=function(){if(this.isSafeDataOut())return this.chunks.slice(2).map(t=>t.buf);if(this.isDataOut()||this.isScriptHashOut())return d.isUndefined(this.chunks[1])?e.alloc(0):e.from(this.chunks[1].buf);if(this.isPublicKeyHashOut())return e.from(this.chunks[2].buf);throw new Error("Unrecognized script type to get data from")},m.prototype.isPushOnly=function(){return d.every(this.chunks,(function(t){return t.opcodenum<=a.OP_16||t.opcodenum===a.OP_PUSHDATA1||t.opcodenum===a.OP_PUSHDATA2||t.opcodenum===a.OP_PUSHDATA4}))},(m.types={}).UNKNOWN="Unknown",m.types.PUBKEY_OUT="Pay to public key",m.types.PUBKEY_IN="Spend from public key",m.types.PUBKEYHASH_OUT="Pay to public key hash",m.types.PUBKEYHASH_IN="Spend from public key hash",m.types.SCRIPTHASH_OUT="Pay to script hash",m.types.SCRIPTHASH_IN="Spend from script hash",m.types.MULTISIG_OUT="Pay to multisig",m.types.MULTISIG_IN="Spend from multisig",m.types.DATA_OUT="Data push",m.types.SAFE_DATA_OUT="Safe data push",m.OP_RETURN_STANDARD_SIZE=220,m.prototype.classify=function(){if(this._isInput)return this.classifyInput();if(this._isOutput)return this.classifyOutput();var t=this.classifyOutput();return t!==m.types.UNKNOWN?t:this.classifyInput()},(m.outputIdentifiers={}).PUBKEY_OUT=m.prototype.isPublicKeyOut,m.outputIdentifiers.PUBKEYHASH_OUT=m.prototype.isPublicKeyHashOut,m.outputIdentifiers.MULTISIG_OUT=m.prototype.isMultisigOut,m.outputIdentifiers.SCRIPTHASH_OUT=m.prototype.isScriptHashOut,m.outputIdentifiers.DATA_OUT=m.prototype.isDataOut,m.outputIdentifiers.SAFE_DATA_OUT=m.prototype.isSafeDataOut,m.prototype.classifyOutput=function(){for(var t in m.outputIdentifiers)if(m.outputIdentifiers[t].bind(this)())return m.types[t];return m.types.UNKNOWN},(m.inputIdentifiers={}).PUBKEY_IN=m.prototype.isPublicKeyIn,m.inputIdentifiers.PUBKEYHASH_IN=m.prototype.isPublicKeyHashIn,m.inputIdentifiers.MULTISIG_IN=m.prototype.isMultisigIn,m.inputIdentifiers.SCRIPTHASH_IN=m.prototype.isScriptHashIn,m.prototype.classifyInput=function(){for(var t in m.inputIdentifiers)if(m.inputIdentifiers[t].bind(this)())return m.types[t];return m.types.UNKNOWN},m.prototype.isStandard=function(){return this.classify()!==m.types.UNKNOWN},m.prototype.prepend=function(t){return this._addByType(t,!0),this},m.prototype.equals=function(t){if(h.checkState(t instanceof m,"Must provide another script"),this.chunks.length!==t.chunks.length)return!1;var r;for(r=0;r<this.chunks.length;r++){if(e.isBuffer(this.chunks[r].buf)&&!e.isBuffer(t.chunks[r].buf))return!1;if(e.isBuffer(this.chunks[r].buf)&&!this.chunks[r].buf.equals(t.chunks[r].buf))return!1;if(this.chunks[r].opcodenum!==t.chunks[r].opcodenum)return!1}return!0},m.prototype.add=function(t){return this._addByType(t,!1),this},m.prototype._addByType=function(t,r){if("string"==typeof t)this._addOpcode(t,r);else if("number"==typeof t)this._addOpcode(t,r);else if(t instanceof a)this._addOpcode(t,r);else if(e.isBuffer(t))this._addBuffer(t,r);else if(t instanceof m)this.chunks=this.chunks.concat(t.chunks);else{if("object"!=typeof t)throw new Error("Invalid script chunk");this._insertAtPosition(t,r)}},m.prototype._insertAtPosition=function(t,e){e?this.chunks.unshift(t):this.chunks.push(t)},m.prototype._addOpcode=function(t,e){var r;return r="number"==typeof t?t:t instanceof a?t.toNumber():a(t).toNumber(),this._insertAtPosition({opcodenum:r},e),this},m.prototype._addBuffer=function(t,e){var r,n=t.length;if(n>=0&&n<a.OP_PUSHDATA1)r=n;else if(n<Math.pow(2,8))r=a.OP_PUSHDATA1;else if(n<Math.pow(2,16))r=a.OP_PUSHDATA2;else{if(!(n<Math.pow(2,32)))throw new Error("You can't push that much data");r=a.OP_PUSHDATA4}return this._insertAtPosition({buf:t,len:n,opcodenum:r},e),this},m.prototype.removeCodeseparators=function(){for(var t=[],e=0;e<this.chunks.length;e++)this.chunks[e].opcodenum!==a.OP_CODESEPARATOR&&t.push(this.chunks[e]);return this.chunks=t,this},m.buildMultisigOut=function(t,e,r){h.checkArgument(e<=t.length,"Number of required signatures must be less than or equal to the number of public keys"),r=r||{};var n=new m;n.add(a.smallInt(e));var i=t=d.map(t,c);r.noSorting||(i=t.map(t=>t.toString("hex")).sort().map(t=>new c(t)));for(var o=0;o<i.length;o++){var s=i[o];n.add(s.toBuffer())}return n.add(a.smallInt(t.length)),n.add(a.OP_CHECKMULTISIG),n},m.buildMultisigIn=function(t,r,n,i){h.checkArgument(d.isArray(t)),h.checkArgument(d.isNumber(r)),h.checkArgument(d.isArray(n)),i=i||{};var o=new m;return o.add(a.OP_0),d.each(n,(function(t){h.checkArgument(e.isBuffer(t),"Signatures must be an array of Buffers"),o.add(t)})),o},m.buildP2SHMultisigIn=function(t,r,n,i){h.checkArgument(d.isArray(t)),h.checkArgument(d.isNumber(r)),h.checkArgument(d.isArray(n)),i=i||{};var o=new m;return o.add(a.OP_0),d.each(n,(function(t){h.checkArgument(e.isBuffer(t),"Signatures must be an array of Buffers"),o.add(t)})),o.add((i.cachedMultisig||m.buildMultisigOut(t,r,i)).toBuffer()),o},m.buildPublicKeyHashOut=function(t){h.checkArgument(!d.isUndefined(t)),h.checkArgument(t instanceof c||t instanceof n||d.isString(t)),t instanceof c?t=t.toAddress():d.isString(t)&&(t=new n(t));var e=new m;return e.add(a.OP_DUP).add(a.OP_HASH160).add(t.hashBuffer).add(a.OP_EQUALVERIFY).add(a.OP_CHECKSIG),e._network=t.network,e},m.buildPublicKeyOut=function(t){h.checkArgument(t instanceof c);var e=new m;return e.add(t.toBuffer()).add(a.OP_CHECKSIG),e},m.buildDataOut=function(t,r){h.checkArgument(d.isUndefined(t)||d.isString(t)||d.isArray(t)||e.isBuffer(t));var n=t;d.isArray(n)||(n=[t]);var i=new m;i.add(a.OP_RETURN);for(let t of n)h.checkArgument(d.isUndefined(t)||d.isString(t)||e.isBuffer(t)),d.isString(t)&&(t=e.from(t,r)),d.isUndefined(t)||i.add(t);return i},m.buildSafeDataOut=function(t,e){var r=m.buildDataOut(t,e),n=new m;return n.add(a.OP_FALSE),n.add(r),n},m.buildScriptHashOut=function(t){h.checkArgument(t instanceof m||t instanceof n&&t.isPayToScriptHash());var e=new m;return e.add(a.OP_HASH160).add(t instanceof n?t.hashBuffer:s.sha256ripemd160(t.toBuffer())).add(a.OP_EQUAL),e._network=t._network||t.network,e},m.buildPublicKeyIn=function(t,r){h.checkArgument(t instanceof u||e.isBuffer(t)),h.checkArgument(d.isUndefined(r)||d.isNumber(r)),t instanceof u&&(t=t.toBuffer());var n=new m;return n.add(e.concat([t,e.from([255&(r||u.SIGHASH_ALL)])])),n},m.buildPublicKeyHashIn=function(t,r,n){return h.checkArgument(r instanceof u||e.isBuffer(r)),h.checkArgument(d.isUndefined(n)||d.isNumber(n)),r instanceof u&&(r=r.toBuffer()),(new m).add(e.concat([r,e.from([255&(n||u.SIGHASH_ALL)])])).add(new c(t).toBuffer())},m.empty=function(){return new m},m.prototype.toScriptHashOut=function(){return m.buildScriptHashOut(this)},m.fromAddress=function(t){if((t=n(t)).isPayToScriptHash())return m.buildScriptHashOut(t);if(t.isPayToPublicKeyHash())return m.buildPublicKeyHashOut(t);throw new p.Script.UnrecognizedAddress(t)},m.prototype.getAddressInfo=function(t){if(this._isInput)return this._getInputAddressInfo();if(this._isOutput)return this._getOutputAddressInfo();var e=this._getOutputAddressInfo();return e||this._getInputAddressInfo()},m.prototype._getOutputAddressInfo=function(){var t={};if(this.isScriptHashOut())t.hashBuffer=this.getData(),t.type=n.PayToScriptHash;else{if(!this.isPublicKeyHashOut())return!1;t.hashBuffer=this.getData(),t.type=n.PayToPublicKeyHash}return t},m.prototype._getInputAddressInfo=function(){var t={};if(this.isPublicKeyHashIn())t.hashBuffer=s.sha256ripemd160(this.chunks[1].buf),t.type=n.PayToPublicKeyHash;else{if(!this.isScriptHashIn())return!1;t.hashBuffer=s.sha256ripemd160(this.chunks[this.chunks.length-1].buf),t.type=n.PayToScriptHash}return t},m.prototype.toAddress=function(t){var e=this.getAddressInfo();return!!e&&(e.network=f.get(t)||this._network||f.defaultNetwork,new n(e))},m.prototype.findAndDelete=function(t){for(var e=t.toBuffer().toString("hex"),r=0;r<this.chunks.length;r++){e===m({chunks:[this.chunks[r]]}).toBuffer().toString("hex")&&this.chunks.splice(r,1)}return this},m.prototype.checkMinimalPush=function(t){var e=this.chunks[t],r=e.buf,n=e.opcodenum;return!r||(0===r.length?n===a.OP_0:1===r.length&&r[0]>=1&&r[0]<=16?n===a.OP_1+(r[0]-1):1===r.length&&129===r[0]?n===a.OP_1NEGATE:r.length<=75?n===r.length:r.length<=255?n===a.OP_PUSHDATA1:!(r.length<=65535)||n===a.OP_PUSHDATA2)},m.prototype._decodeOP_N=function(t){if(t===a.OP_0)return 0;if(t>=a.OP_1&&t<=a.OP_16)return t-(a.OP_1-1);throw new Error("Invalid opcode: "+JSON.stringify(t))},m.prototype.getSignatureOperationsCount=function(t){t=!!d.isUndefined(t)||t;var e=this,r=0,n=a.OP_INVALIDOPCODE;return d.each(e.chunks,(function(i){var o=i.opcodenum;o===a.OP_CHECKSIG||o===a.OP_CHECKSIGVERIFY?r++:o!==a.OP_CHECKMULTISIG&&o!==a.OP_CHECKMULTISIGVERIFY||(t&&n>=a.OP_1&&n<=a.OP_16?r+=e._decodeOP_N(n):r+=20),n=o})),r},t.exports=m}).call(this,r(0).Buffer)},function(t,e,r){"use strict";var n=Object.prototype.toString;t.exports=function(t){var e=n.call(t),r="[object Arguments]"===e;return r||(r="[object Array]"!==e&&null!==t&&"object"==typeof t&&"number"==typeof t.length&&t.length>=0&&"[object Function]"===n.call(t.callee)),r}},function(t,e,r){"use strict";t.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var t={},e=Symbol("test"),r=Object(e);if("string"==typeof e)return!1;if("[object Symbol]"!==Object.prototype.toString.call(e))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(var n in t[e]=42,t)return!1;if("function"==typeof Object.keys&&0!==Object.keys(t).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(t).length)return!1;var i=Object.getOwnPropertySymbols(t);if(1!==i.length||i[0]!==e)return!1;if(!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var o=Object.getOwnPropertyDescriptor(t,e);if(42!==o.value||!0!==o.enumerable)return!1}return!0}},function(t,e,r){"use strict";t.exports=TypeError},function(t,e,r){"use strict";var n=r(128);if(n)try{n([],"length")}catch(t){n=null}t.exports=n},function(t,e,r){"use strict";t.exports="undefined"!=typeof Reflect&&Reflect.getPrototypeOf||null},function(t,e,r){"use strict";var n=r(46);t.exports=n.getPrototypeOf||null},function(t,e,r){"use strict";var n=r(36),i=r(64),o=r(47),s=r(134);t.exports=function(t){if(t.length<1||"function"!=typeof t[0])throw new i("a function is required");return s(n,o,t)}},function(t,e,r){"use strict";t.exports=Function.prototype.apply},function(t,e,r){(function(t){var n=Object.getOwnPropertyDescriptors||function(t){for(var e=Object.keys(t),r={},n=0;n<e.length;n++)r[e[n]]=Object.getOwnPropertyDescriptor(t,e[n]);return r},i=/%[sdj%]/g;e.format=function(t){if(!b(t)){for(var e=[],r=0;r<arguments.length;r++)e.push(a(arguments[r]));return e.join(" ")}r=1;for(var n=arguments,o=n.length,s=String(t).replace(i,(function(t){if("%%"===t)return"%";if(r>=o)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}})),c=n[r];r<o;c=n[++r])g(c)||!S(c)?s+=" "+c:s+=" "+a(c);return s},e.deprecate=function(r,n){if(void 0!==t&&!0===t.noDeprecation)return r;if(void 0===t)return function(){return e.deprecate(r,n).apply(this,arguments)};var i=!1;return function(){if(!i){if(t.throwDeprecation)throw new Error(n);t.traceDeprecation?console.trace(n):console.error(n),i=!0}return r.apply(this,arguments)}};var o,s={};function a(t,r){var n={seen:[],stylize:u};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),l(r)?n.showHidden=r:r&&e._extend(n,r),y(n.showHidden)&&(n.showHidden=!1),y(n.depth)&&(n.depth=2),y(n.colors)&&(n.colors=!1),y(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=c),f(n,t,n.depth)}function c(t,e){var r=a.styles[e];return r?"["+a.colors[r][0]+"m"+t+"["+a.colors[r][1]+"m":t}function u(t,e){return t}function f(t,r,n){if(t.customInspect&&r&&I(r.inspect)&&r.inspect!==e.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,t);return b(i)||(i=f(t,i,n)),i}var o=function(t,e){if(y(e))return t.stylize("undefined","undefined");if(b(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}if(m(e))return t.stylize(""+e,"number");if(l(e))return t.stylize(""+e,"boolean");if(g(e))return t.stylize("null","null")}(t,r);if(o)return o;var s=Object.keys(r),a=function(t){var e={};return t.forEach((function(t,r){e[t]=!0})),e}(s);if(t.showHidden&&(s=Object.getOwnPropertyNames(r)),w(r)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return h(r);if(0===s.length){if(I(r)){var c=r.name?": "+r.name:"";return t.stylize("[Function"+c+"]","special")}if(v(r))return t.stylize(RegExp.prototype.toString.call(r),"regexp");if(_(r))return t.stylize(Date.prototype.toString.call(r),"date");if(w(r))return h(r)}var u,S="",O=!1,P=["{","}"];(p(r)&&(O=!0,P=["[","]"]),I(r))&&(S=" [Function"+(r.name?": "+r.name:"")+"]");return v(r)&&(S=" "+RegExp.prototype.toString.call(r)),_(r)&&(S=" "+Date.prototype.toUTCString.call(r)),w(r)&&(S=" "+h(r)),0!==s.length||O&&0!=r.length?n<0?v(r)?t.stylize(RegExp.prototype.toString.call(r),"regexp"):t.stylize("[Object]","special"):(t.seen.push(r),u=O?function(t,e,r,n,i){for(var o=[],s=0,a=e.length;s<a;++s)k(e,String(s))?o.push(d(t,e,r,n,String(s),!0)):o.push("");return i.forEach((function(i){i.match(/^\d+$/)||o.push(d(t,e,r,n,i,!0))})),o}(t,r,n,a,s):s.map((function(e){return d(t,r,n,a,e,O)})),t.seen.pop(),function(t,e,r){if(t.reduce((function(t,e){return e.indexOf("\n")>=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60)return r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1];return r[0]+e+" "+t.join(", ")+" "+r[1]}(u,S,P)):P[0]+S+P[1]}function h(t){return"["+Error.prototype.toString.call(t)+"]"}function d(t,e,r,n,i,o){var s,a,c;if((c=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?a=c.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):c.set&&(a=t.stylize("[Setter]","special")),k(n,i)||(s="["+i+"]"),a||(t.seen.indexOf(c.value)<0?(a=g(r)?f(t,c.value,null):f(t,c.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(t){return" "+t})).join("\n").substr(2):"\n"+a.split("\n").map((function(t){return" "+t})).join("\n")):a=t.stylize("[Circular]","special")),y(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=t.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=t.stylize(s,"string"))}return s+": "+a}function p(t){return Array.isArray(t)}function l(t){return"boolean"==typeof t}function g(t){return null===t}function m(t){return"number"==typeof t}function b(t){return"string"==typeof t}function y(t){return void 0===t}function v(t){return S(t)&&"[object RegExp]"===O(t)}function S(t){return"object"==typeof t&&null!==t}function _(t){return S(t)&&"[object Date]"===O(t)}function w(t){return S(t)&&("[object Error]"===O(t)||t instanceof Error)}function I(t){return"function"==typeof t}function O(t){return Object.prototype.toString.call(t)}function P(t){return t<10?"0"+t.toString(10):t.toString(10)}e.debuglog=function(r){if(y(o)&&(o=t.env.NODE_DEBUG||""),r=r.toUpperCase(),!s[r])if(new RegExp("\\b"+r+"\\b","i").test(o)){var n=t.pid;s[r]=function(){var t=e.format.apply(e,arguments);console.error("%s %d: %s",r,n,t)}}else s[r]=function(){};return s[r]},e.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=p,e.isBoolean=l,e.isNull=g,e.isNullOrUndefined=function(t){return null==t},e.isNumber=m,e.isString=b,e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=y,e.isRegExp=v,e.isObject=S,e.isDate=_,e.isError=w,e.isFunction=I,e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=r(137);var A=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function E(){var t=new Date,e=[P(t.getHours()),P(t.getMinutes()),P(t.getSeconds())].join(":");return[t.getDate(),A[t.getMonth()],e].join(" ")}function k(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.log=function(){console.log("%s - %s",E(),e.format.apply(e,arguments))},e.inherits=r(23),e._extend=function(t,e){if(!e||!S(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t};var x="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function T(t,e){if(!t){var r=new Error("Promise was rejected with a falsy value");r.reason=t,t=r}return e(t)}e.promisify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');if(x&&t[x]){var e;if("function"!=typeof(e=t[x]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(e,x,{value:e,enumerable:!1,writable:!1,configurable:!0}),e}function e(){for(var e,r,n=new Promise((function(t,n){e=t,r=n})),i=[],o=0;o<arguments.length;o++)i.push(arguments[o]);i.push((function(t,n){t?r(t):e(n)}));try{t.apply(this,i)}catch(t){r(t)}return n}return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),x&&Object.defineProperty(e,x,{value:e,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(e,n(t))},e.promisify.custom=x,e.callbackify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');function r(){for(var r=[],n=0;n<arguments.length;n++)r.push(arguments[n]);var i=r.pop();if("function"!=typeof i)throw new TypeError("The last argument must be of type Function");var o=this,s=function(){return i.apply(o,arguments)};e.apply(this,r).then((function(e){t.nextTick(s,null,e)}),(function(e){t.nextTick(T,e,s)}))}return Object.setPrototypeOf(r,Object.getPrototypeOf(e)),Object.defineProperties(r,n(e)),r}}).call(this,r(18))},function(t,e){var r=Object.prototype.toString;function n(t){return"function"==typeof t.constructor?t.constructor.name:null}t.exports=function(t){if(void 0===t)return"undefined";if(null===t)return"null";var e=typeof t;if("boolean"===e)return"boolean";if("string"===e)return"string";if("number"===e)return"number";if("symbol"===e)return"symbol";if("function"===e)return"GeneratorFunction"===n(t)?"generatorfunction":"function";if(function(t){return Array.isArray?Array.isArray(t):t instanceof Array}(t))return"array";if(function(t){if(t.constructor&&"function"==typeof t.constructor.isBuffer)return t.constructor.isBuffer(t);return!1}(t))return"buffer";if(function(t){try{if("number"==typeof t.length&&"function"==typeof t.callee)return!0}catch(t){if(-1!==t.message.indexOf("callee"))return!0}return!1}(t))return"arguments";if(function(t){return t instanceof Date||"function"==typeof t.toDateString&&"function"==typeof t.getDate&&"function"==typeof t.setDate}(t))return"date";if(function(t){return t instanceof Error||"string"==typeof t.message&&t.constructor&&"number"==typeof t.constructor.stackTraceLimit}(t))return"error";if(function(t){return t instanceof RegExp||"string"==typeof t.flags&&"boolean"==typeof t.ignoreCase&&"boolean"==typeof t.multiline&&"boolean"==typeof t.global}(t))return"regexp";switch(n(t)){case"Symbol":return"symbol";case"Promise":return"promise";case"WeakMap":return"weakmap";case"WeakSet":return"weakset";case"Map":return"map";case"Set":return"set";case"Int8Array":return"int8array";case"Uint8Array":return"uint8array";case"Uint8ClampedArray":return"uint8clampedarray";case"Int16Array":return"int16array";case"Uint16Array":return"uint16array";case"Int32Array":return"int32array";case"Uint32Array":return"uint32array";case"Float32Array":return"float32array";case"Float64Array":return"float64array"}if(function(t){return"function"==typeof t.throw&&"function"==typeof t.return&&"function"==typeof t.next}(t))return"generator";switch(e=r.call(t)){case"[object Object]":return"object";case"[object Map Iterator]":return"mapiterator";case"[object Set Iterator]":return"setiterator";case"[object String Iterator]":return"stringiterator";case"[object Array Iterator]":return"arrayiterator"}return e.slice(8,-1).toLowerCase().replace(/\s/g,"")}},function(t,e,r){"use strict";(function(e){var n=r(1),i=r(2),o=r(0),s=r(10),a=r(6),c=r(19),u=r(16),f=r(29),h=r(7),d=r(5),p=r(20),l=r(26),g=r(73),m=r(50),b=m.PublicKeyHash,y=m.PublicKey,v=m.MultiSigScriptHash,S=m.MultiSig,_=r(21),w=r(12),I=r(34),O=r(3),P=r(49).SCRIPT_ENABLE_SIGHASH_FORKID;function A(t){if(!(this instanceof A))return new A(t);if(this.inputs=[],this.outputs=[],this._inputAmount=void 0,this._outputAmount=void 0,t){if(t instanceof A)return A.shallowCopy(t);if(a.isHexa(t))this.fromString(t);else if(e.isBuffer(t))this.fromBuffer(t);else{if(!n.isObject(t))throw new s.InvalidArgument("Must provide an object or string to deserialize a transaction");this.fromObject(t)}}else this._newTransaction()}A.DUST_AMOUNT=546,A.FEE_SECURITY_MARGIN=150,A.MAX_MONEY=21e14,A.NLOCKTIME_BLOCKHEIGHT_LIMIT=5e8,A.NLOCKTIME_MAX_VALUE=4294967295,A.FEE_PER_KB=500,A.CHANGE_OUTPUT_MAX_SIZE=62,A.shallowCopy=function(t){return new A(t.toBuffer())};var E={configurable:!1,enumerable:!0,get:function(){return this._hash=new c(this._getHash()).readReverse().toString("hex"),this._hash}};Object.defineProperty(A.prototype,"hash",E),Object.defineProperty(A.prototype,"id",E);var k={configurable:!1,enumerable:!0,get:function(){return this._getInputAmount()}};Object.defineProperty(A.prototype,"inputAmount",k),k.get=function(){return this._getOutputAmount()},Object.defineProperty(A.prototype,"outputAmount",k),A.prototype._getHash=function(){return h.sha256sha256(this.toBuffer())},A.prototype.serialize=function(t){return!0===t||t&&t.disableAll?this.uncheckedSerialize():this.checkedSerialize(t)},A.prototype.uncheckedSerialize=A.prototype.toString=function(){return this.toBuffer().toString("hex")},A.prototype.checkedSerialize=function(t){var e=this.getSerializationError(t);if(e)throw e.message+=" - For more information please see: https://bsv.io/api/lib/transaction#serialization-checks",e;return this.uncheckedSerialize()},A.prototype.invalidSatoshis=function(){for(var t=!1,e=0;e<this.outputs.length;e++)this.outputs[e].invalidSatoshis()&&(t=!0);return t},A.prototype.getSerializationError=function(t){if(t=t||{},this.invalidSatoshis())return new s.Transaction.InvalidSatoshis;var e,r=this._getUnspentValue();return r<0?t.disableMoreOutputThanInput||(e=new s.Transaction.InvalidOutputAmountSum):e=this._hasFeeError(t,r),e||this._hasDustOutputs(t)||this._isMissingSignatures(t)},A.prototype._hasFeeError=function(t,e){if(!n.isUndefined(this._fee)&&this._fee!==e)return new s.Transaction.FeeError.Different("Unspent value is "+e+" but specified fee is "+this._fee);if(!t.disableLargeFees){var r=Math.floor(A.FEE_SECURITY_MARGIN*this._estimateFee());if(e>r)return this._missingChange()?new s.Transaction.ChangeAddressMissing("Fee is too large and no change address was provided"):new s.Transaction.FeeError.TooLarge("expected less than "+r+" but got "+e)}},A.prototype._missingChange=function(){return!this._changeScript},A.prototype._hasDustOutputs=function(t){var e,r;if(!t.disableDustOutputs)for(e in this.outputs)if((r=this.outputs[e]).satoshis<A.DUST_AMOUNT&&!r.script.isDataOut()&&!r.script.isSafeDataOut())return new s.Transaction.DustOutputs},A.prototype._isMissingSignatures=function(t){if(!t.disableIsFullySigned)return this.isFullySigned()?void 0:new s.Transaction.MissingSignatures},A.prototype.inspect=function(){return"<Transaction: "+this.uncheckedSerialize()+">"},A.prototype.toBuffer=function(){var t=new u;return this.toBufferWriter(t).toBuffer()},A.prototype.toBufferWriter=function(t){return t.writeInt32LE(this.version),t.writeVarintNum(this.inputs.length),n.each(this.inputs,(function(e){e.toBufferWriter(t)})),t.writeVarintNum(this.outputs.length),n.each(this.outputs,(function(e){e.toBufferWriter(t)})),t.writeUInt32LE(this.nLockTime),t},A.prototype.fromBuffer=function(t){var e=new c(t);return this.fromBufferReader(e)},A.prototype.fromBufferReader=function(t){var e,r,n;for(i.checkArgument(!t.finished(),"No transaction data received"),this.version=t.readInt32LE(),r=t.readVarintNum(),e=0;e<r;e++){var o=m.fromBufferReader(t);this.inputs.push(o)}for(n=t.readVarintNum(),e=0;e<n;e++)this.outputs.push(_.fromBufferReader(t));return this.nLockTime=t.readUInt32LE(),this},A.prototype.toObject=A.prototype.toJSON=function(){var t=[];this.inputs.forEach((function(e){t.push(e.toObject())}));var e=[];this.outputs.forEach((function(t){e.push(t.toObject())}));var r={hash:this.hash,version:this.version,inputs:t,outputs:e,nLockTime:this.nLockTime};return this._changeScript&&(r.changeScript=this._changeScript.toString()),n.isUndefined(this._changeIndex)||(r.changeIndex=this._changeIndex),n.isUndefined(this._fee)||(r.fee=this._fee),r},A.prototype.fromObject=function(t){i.checkArgument(n.isObject(t)||t instanceof A);var e,r=this;return e=t instanceof A?e.toObject():t,n.each(e.inputs,(function(t){if(t.output&&t.output.script){var e,n=new w(t.output.script);if(n.isPublicKeyHashOut())e=new m.PublicKeyHash(t);else if(n.isScriptHashOut()&&t.publicKeys&&t.threshold)e=new m.MultiSigScriptHash(t,t.publicKeys,t.threshold,t.signatures);else{if(!n.isPublicKeyOut())throw new s.Transaction.Input.UnsupportedScript(t.output.script);e=new m.PublicKey(t)}r.addInput(e)}else r.uncheckedAddInput(new m(t))})),n.each(e.outputs,(function(t){r.addOutput(new _(t))})),e.changeIndex&&(this._changeIndex=e.changeIndex),e.changeScript&&(this._changeScript=new w(e.changeScript)),e.fee&&(this._fee=e.fee),this.nLockTime=e.nLockTime,this.version=e.version,this._checkConsistency(t),this},A.prototype._checkConsistency=function(t){n.isUndefined(this._changeIndex)||(i.checkState(this._changeScript,"Change script is expected."),i.checkState(this.outputs[this._changeIndex],"Change index points to undefined output."),i.checkState(this.outputs[this._changeIndex].script.toString()===this._changeScript.toString(),"Change output has an unexpected script.")),t&&t.hash&&i.checkState(t.hash===this.hash,"Hash in object does not match transaction hash.")},A.prototype.lockUntilDate=function(t){if(i.checkArgument(t),n.isNumber(t)&&t<A.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new s.Transaction.LockTimeTooEarly;n.isDate(t)&&(t=t.getTime()/1e3);for(var e=0;e<this.inputs.length;e++)this.inputs[e].sequenceNumber===m.DEFAULT_SEQNUMBER&&(this.inputs[e].sequenceNumber=m.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=t,this},A.prototype.lockUntilBlockHeight=function(t){if(i.checkArgument(n.isNumber(t)),t>=A.NLOCKTIME_BLOCKHEIGHT_LIMIT)throw new s.Transaction.BlockHeightTooHigh;if(t<0)throw new s.Transaction.NLockTimeOutOfRange;for(var e=0;e<this.inputs.length;e++)this.inputs[e].sequenceNumber===m.DEFAULT_SEQNUMBER&&(this.inputs[e].sequenceNumber=m.DEFAULT_LOCKTIME_SEQNUMBER);return this.nLockTime=t,this},A.prototype.getLockTime=function(){return this.nLockTime?this.nLockTime<A.NLOCKTIME_BLOCKHEIGHT_LIMIT?this.nLockTime:new Date(1e3*this.nLockTime):null},A.prototype.fromString=function(t){this.fromBuffer(o.Buffer.from(t,"hex"))},A.prototype._newTransaction=function(){this.version=1,this.nLockTime=0},A.prototype.from=function(t,e,r){if(n.isArray(t)){var i=this;return n.each(t,(function(t){i.from(t,e,r)})),this}return n.some(this.inputs,(function(e){return e.prevTxId.toString("hex")===t.txId&&e.outputIndex===t.outputIndex}))||(e&&r?this._fromMultisigUtxo(t,e,r):this._fromNonP2SH(t)),this},A.prototype._fromNonP2SH=function(t){var e;e=(t=new g(t)).script.isPublicKeyHashOut()?b:t.script.isPublicKeyOut()?y:m,this.addInput(new e({output:new _({script:t.script,satoshis:t.satoshis}),prevTxId:t.txId,outputIndex:t.outputIndex,script:w.empty()}))},A.prototype._fromMultisigUtxo=function(t,e,r){var n;if(i.checkArgument(r<=e.length,"Number of required signatures must be greater than the number of public keys"),(t=new g(t)).script.isMultisigOut())n=S;else{if(!t.script.isScriptHashOut())throw new Error("@TODO");n=v}this.addInput(new n({output:new _({script:t.script,satoshis:t.satoshis}),prevTxId:t.txId,outputIndex:t.outputIndex,script:w.empty()},e,r))},A.prototype.addInput=function(t,e,r){if(i.checkArgumentType(t,m,"input"),!t.output&&(n.isUndefined(e)||n.isUndefined(r)))throw new s.Transaction.NeedMoreInfo("Need information about the UTXO script and satoshis");return t.output||!e||n.isUndefined(r)||(e=e instanceof w?e:new w(e),i.checkArgumentType(r,"number","satoshis"),t.output=new _({script:e,satoshis:r})),this.uncheckedAddInput(t)},A.prototype.uncheckedAddInput=function(t){return i.checkArgumentType(t,m,"input"),this.inputs.push(t),this._inputAmount=void 0,this._updateChangeOutput(),this},A.prototype.hasAllUtxoInfo=function(){return n.every(this.inputs.map((function(t){return!!t.output})))},A.prototype.fee=function(t){return i.checkArgument(n.isNumber(t),"amount must be a number"),this._fee=t,this._updateChangeOutput(),this},A.prototype.feePerKb=function(t){return i.checkArgument(n.isNumber(t),"amount must be a number"),this._feePerKb=t,this._updateChangeOutput(),this},A.prototype.change=function(t){return i.checkArgument(t,"address is required"),this._changeScript=w.fromAddress(t),this._updateChangeOutput(),this},A.prototype.getChangeOutput=function(){return n.isUndefined(this._changeIndex)?null:this.outputs[this._changeIndex]},A.prototype.to=function(t,e){if(n.isArray(t)){var r=this;return n.each(t,(function(t){r.to(t.address,t.satoshis)})),this}return i.checkArgument(a.isNaturalNumber(e),"Amount is expected to be a positive integer"),this.addOutput(new _({script:w(new l(t)),satoshis:e})),this},A.prototype.addData=function(t){return this.addOutput(new _({script:w.buildDataOut(t),satoshis:0})),this},A.prototype.addSafeData=function(t){return this.addOutput(new _({script:w.buildSafeDataOut(t),satoshis:0})),this},A.prototype.addOutput=function(t){return i.checkArgumentType(t,_,"output"),this._addOutput(t),this._updateChangeOutput(),this},A.prototype.clearOutputs=function(){return this.outputs=[],this._clearSignatures(),this._outputAmount=void 0,this._changeIndex=void 0,this._updateChangeOutput(),this},A.prototype._addOutput=function(t){this.outputs.push(t),this._outputAmount=void 0},A.prototype._getOutputAmount=function(){if(n.isUndefined(this._outputAmount)){var t=this;this._outputAmount=0,n.each(this.outputs,(function(e){t._outputAmount+=e.satoshis}))}return this._outputAmount},A.prototype._getInputAmount=function(){if(n.isUndefined(this._inputAmount)){var t=this;this._inputAmount=0,n.each(this.inputs,(function(e){if(n.isUndefined(e.output))throw new s.Transaction.Input.MissingPreviousOutput;t._inputAmount+=e.output.satoshis}))}return this._inputAmount},A.prototype._updateChangeOutput=function(){if(this._changeScript){this._clearSignatures(),n.isUndefined(this._changeIndex)||this._removeOutput(this._changeIndex),this._changeIndex=this.outputs.length,this._addOutput(new _({script:this._changeScript,satoshis:0}));var t=this._getUnspentValue()-this.getFee();this._removeOutput(this._changeIndex),this._changeIndex=void 0,t>=A.DUST_AMOUNT&&(this._changeIndex=this.outputs.length,this._addOutput(new _({script:this._changeScript,satoshis:t})))}},A.prototype.getFee=function(){return this.isCoinbase()?0:n.isUndefined(this._fee)?this._changeScript?this._estimateFee():this._getUnspentValue():this._fee},A.prototype._estimateFee=function(){var t=this._estimateSize();return Math.ceil(t/1e3*(this._feePerKb||A.FEE_PER_KB))},A.prototype._getUnspentValue=function(){return this._getInputAmount()-this._getOutputAmount()},A.prototype._clearSignatures=function(){n.each(this.inputs,(function(t){t.clearSignatures()}))},A.prototype._estimateSize=function(){var t=8;return t+=f(this.inputs.length).toBuffer().length,t+=f(this.outputs.length).toBuffer().length,n.each(this.inputs,(function(e){t+=e._estimateSize()})),n.each(this.outputs,(function(e){t+=e.getSize()})),t},A.prototype._removeOutput=function(t){var e=this.outputs[t];this.outputs=n.without(this.outputs,e),this._outputAmount=void 0},A.prototype.removeOutput=function(t){this._removeOutput(t),this._updateChangeOutput()},A.prototype.sort=function(){return this.sortInputs((function(t){var e=Array.prototype.concat.apply([],t);return e.sort((function(t,e){return t.prevTxId.compare(e.prevTxId)||t.outputIndex-e.outputIndex})),e})),this.sortOutputs((function(t){var e=Array.prototype.concat.apply([],t);return e.sort((function(t,e){return t.satoshis-e.satoshis||t.script.toBuffer().compare(e.script.toBuffer())})),e})),this},A.prototype.shuffleOutputs=function(){return this.sortOutputs(n.shuffle)},A.prototype.sortOutputs=function(t){var e=t(this.outputs);return this._newOutputOrder(e)},A.prototype.sortInputs=function(t){return this.inputs=t(this.inputs),this._clearSignatures(),this},A.prototype._newOutputOrder=function(t){if(this.outputs.length!==t.length||0!==n.difference(this.outputs,t).length)throw new s.Transaction.InvalidSorting;if(!n.isUndefined(this._changeIndex)){var e=this.outputs[this._changeIndex];this._changeIndex=t.indexOf(e)}return this.outputs=t,this},A.prototype.removeInput=function(t,e){var r;if((r=!e&&n.isNumber(t)?t:n.findIndex(this.inputs,(function(r){return r.prevTxId.toString("hex")===t&&r.outputIndex===e})))<0||r>=this.inputs.length)throw new s.Transaction.InvalidIndex(r,this.inputs.length);var i=this.inputs[r];this.inputs=n.without(this.inputs,i),this._inputAmount=void 0,this._updateChangeOutput()},A.prototype.sign=function(t,e){i.checkState(this.hasAllUtxoInfo(),"Not all utxo information is available to sign the transaction.");var r=this;return n.isArray(t)?(n.each(t,(function(t){r.sign(t,e)})),this):(n.each(this.getSignatures(t,e),(function(t){r.applySignature(t)})),this)},A.prototype.getSignatures=function(t,e){t=new I(t),e=e||d.SIGHASH_ALL|d.SIGHASH_FORKID;var r=this,i=[],o=h.sha256ripemd160(t.publicKey.toBuffer());return n.each(this.inputs,(function(s,a){n.each(s.getSignatures(r,t,a,e,o),(function(t){i.push(t)}))})),i},A.prototype.applySignature=function(t){return this.inputs[t.inputIndex].addSignature(this,t),this},A.prototype.isFullySigned=function(){return n.each(this.inputs,(function(t){if(t.isFullySigned===m.prototype.isFullySigned)throw new s.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction")})),n.every(n.map(this.inputs,(function(t){return t.isFullySigned()})))},A.prototype.isValidSignature=function(t){if(this.inputs[t.inputIndex].isValidSignature===m.prototype.isValidSignature)throw new s.Transaction.UnableToVerifySignature("Unrecognized script kind, or not enough information to execute script.This usually happens when creating a transaction from a serialized transaction");return this.inputs[t.inputIndex].isValidSignature(this,t)},A.prototype.verifySignature=function(t,e,r,n,i,o){return p.verify(this,t,e,r,n,i,o)},A.prototype.verify=function(){if(0===this.inputs.length)return"transaction txins empty";if(0===this.outputs.length)return"transaction txouts empty";for(var t=new O(0),e=0;e<this.outputs.length;e++){var r=this.outputs[e];if(r.invalidSatoshis())return"transaction txout "+e+" satoshis is invalid";if(r._satoshisBN.gt(new O(A.MAX_MONEY,10)))return"transaction txout "+e+" greater than MAX_MONEY";if((t=t.add(r._satoshisBN)).gt(new O(A.MAX_MONEY)))return"transaction txout "+e+" total output greater than MAX_MONEY"}if(this.toBuffer().length>1e6)return"transaction over the maximum block size";var i={};for(e=0;e<this.inputs.length;e++){var o=this.inputs[e],s=o.prevTxId+":"+o.outputIndex;if(!n.isUndefined(i[s]))return"transaction input "+e+" duplicate input";i[s]=!0}if(this.isCoinbase()){var a=this.inputs[0]._scriptBuffer;if(a.length<2||a.length>100)return"coinbase transaction script size invalid"}else for(e=0;e<this.inputs.length;e++)if(this.inputs[e].isNull())return"transaction input "+e+" has null input";return!0},A.prototype.isCoinbase=function(){return 1===this.inputs.length&&this.inputs[0].isNull()},A.prototype.sighash=function(t,e,r,n,i){e=e||d.SIGHASH_ALL|d.SIGHASH_FORKID;var o=this.inputs[t];if(!o)throw new Error("Input index "+t+" does not exist");return!r&&o.output&&(r=o.output.script),!n&&o.output&&(n=new O(o.output.satoshis)),i=i||P,p.sighash(this,e,t,r,n,i)},t.exports=A}).call(this,r(0).Buffer)},function(t,e,r){"use strict";var n=r(1),i=r(2),o=r(6),s=r(12),a=r(26);function c(t){if(!(this instanceof c))return new c(t);i.checkArgument(n.isObject(t),"Must provide an object from where to extract data");var e=t.address?new a(t.address):void 0,r=t.txid?t.txid:t.txId;if(!r||!o.isHexaString(r)||r.length>64)throw new Error("Invalid TXID in object",t);var u=n.isUndefined(t.vout)?t.outputIndex:t.vout;if(!n.isNumber(u))throw new Error("Invalid outputIndex, received "+u);i.checkArgument(!n.isUndefined(t.scriptPubKey)||!n.isUndefined(t.script),"Must provide the scriptPubKey for that output!");var f=new s(t.scriptPubKey||t.script);i.checkArgument(!n.isUndefined(t.amount)||!n.isUndefined(t.satoshis),"Must provide an amount for the output");var h=n.isUndefined(t.amount)?t.satoshis:Math.round(1e8*t.amount);i.checkArgument(n.isNumber(h),"Amount must be a number"),o.defineImmutable(this,{address:e,txId:r,outputIndex:u,script:f,satoshis:h})}c.prototype.inspect=function(){return"<UnspentOutput: "+this.txId+":"+this.outputIndex+", satoshis: "+this.satoshis+", address: "+this.address+">"},c.prototype.toString=function(){return this.txId+":"+this.outputIndex},c.fromObject=function(t){return new c(t)},c.prototype.toObject=c.prototype.toJSON=function(){return{address:this.address?this.address.toString():void 0,txid:this.txId,vout:this.outputIndex,scriptPubKey:this.script.toBuffer().toString("hex"),amount:Number.parseFloat((this.satoshis/1e8).toFixed(8))}},t.exports=c},function(t,e,r){"use strict";(function(e){var n=r(1),i=r(39),o=r(19),s=r(16),a=r(7),c=r(37),u=r(10),f=r(2);function h(t){if(!(this instanceof h))return new h(t);var r={};if(e.isBuffer(t))r=h._fromBufferReader(o(t));else{if(!n.isObject(t))throw new TypeError("Unrecognized argument for MerkleBlock");r={header:t.header instanceof i?t.header:i.fromObject(t.header),numTransactions:t.numTransactions,hashes:t.hashes,flags:t.flags}}return n.extend(this,r),this._flagBitsUsed=0,this._hashesUsed=0,this}h.fromBuffer=function(t){return h.fromBufferReader(o(t))},h.fromBufferReader=function(t){return new h(h._fromBufferReader(t))},h.prototype.toBuffer=function(){return this.toBufferWriter().concat()},h.prototype.toBufferWriter=function(t){t||(t=new s),t.write(this.header.toBuffer()),t.writeUInt32LE(this.numTransactions),t.writeVarintNum(this.hashes.length);for(var r=0;r<this.hashes.length;r++)t.write(e.from(this.hashes[r],"hex"));for(t.writeVarintNum(this.flags.length),r=0;r<this.flags.length;r++)t.writeUInt8(this.flags[r]);return t},h.prototype.toObject=h.prototype.toJSON=function(){return{header:this.header.toObject(),numTransactions:this.numTransactions,hashes:this.hashes,flags:this.flags}},h.prototype.validMerkleTree=function(){if(f.checkState(n.isArray(this.flags),"MerkleBlock flags is not an array"),f.checkState(n.isArray(this.hashes),"MerkleBlock hashes is not an array"),this.hashes.length>this.numTransactions)return!1;if(8*this.flags.length<this.hashes.length)return!1;var t=this._calcTreeHeight(),e={hashesUsed:0,flagBitsUsed:0},r=this._traverseMerkleTree(t,0,e);return e.hashesUsed===this.hashes.length&&r.equals(this.header.merkleRoot)},h.prototype.filterdTxsHash=function(){throw new Error("filterdTxsHash has been deprecated. use filteredTxsHash.")},h.prototype.filteredTxsHash=function(){if(f.checkState(n.isArray(this.flags),"MerkleBlock flags is not an array"),f.checkState(n.isArray(this.hashes),"MerkleBlock hashes is not an array"),this.hashes.length>this.numTransactions)throw new u.MerkleBlock.InvalidMerkleTree;if(8*this.flags.length<this.hashes.length)throw new u.MerkleBlock.InvalidMerkleTree;if(1===this.hashes.length)return[];var t=this._calcTreeHeight(),e={hashesUsed:0,flagBitsUsed:0},r=this._traverseMerkleTree(t,0,e,!0);if(e.hashesUsed!==this.hashes.length)throw new u.MerkleBlock.InvalidMerkleTree;return r},h.prototype._traverseMerkleTree=function(t,r,n,i){if((n=n||{}).txs=n.txs||[],n.flagBitsUsed=n.flagBitsUsed||0,n.hashesUsed=n.hashesUsed||0,i=i||!1,n.flagBitsUsed>8*this.flags.length)return null;var o=this.flags[n.flagBitsUsed>>3]>>>(7&n.flagBitsUsed++)&1;if(0!==t&&o){var s=this._traverseMerkleTree(t-1,2*r,n),c=s;return 2*r+1<this._calcTreeWidth(t-1)&&(c=this._traverseMerkleTree(t-1,2*r+1,n)),i?n.txs:a.sha256sha256(e.concat([s,c]))}if(n.hashesUsed>=this.hashes.length)return null;var u=this.hashes[n.hashesUsed++];return 0===t&&o&&n.txs.push(u),e.from(u,"hex")},h.prototype._calcTreeWidth=function(t){return this.numTransactions+(1<<t)-1>>t},h.prototype._calcTreeHeight=function(){for(var t=0;this._calcTreeWidth(t)>1;)t++;return t},h.prototype.hasTransaction=function(t){f.checkArgument(!n.isUndefined(t),"tx cannot be undefined"),f.checkArgument(t instanceof c||"string"==typeof t,'Invalid tx given, tx must be a "string" or "Transaction"');var r=t;t instanceof c&&(r=e.from(t.id,"hex").reverse().toString("hex"));var i=[],o=this._calcTreeHeight();return this._traverseMerkleTree(o,0,{txs:i}),-1!==i.indexOf(r)},h._fromBufferReader=function(t){f.checkState(!t.finished(),"No merkleblock data received");var e={};e.header=i.fromBufferReader(t),e.numTransactions=t.readUInt32LE();var r=t.readVarintNum();e.hashes=[];for(var n=0;n<r;n++)e.hashes.push(t.read(32).toString("hex"));var o=t.readVarintNum();for(e.flags=[],n=0;n<o;n++)e.flags.push(t.readUInt8());return e},h.fromObject=function(t){return new h(t)},t.exports=h}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var n=r(45),i=r(0),o=r(1),s=r(2),a=r(3),c=r(35),u=r(28),f=r(7),h=r(24),d=r(11),p=r(34),l=r(38),g=r(10),m=g.HDPrivateKey,b=r(6);function y(t){if(t instanceof y)return t;if(!(this instanceof y))return new y(t);if(!t)return this._generateRandomly();if(h.get(t))return this._generateRandomly(t);if(o.isString(t)||e.isBuffer(t))if(y.isValidSerialized(t))this._buildFromSerialized(t);else if(b.isValidJSON(t))this._buildFromJSON(t);else{if(!e.isBuffer(t)||!y.isValidSerialized(t.toString()))throw y.getSerializedError(t);this._buildFromSerialized(t.toString())}else{if(!o.isObject(t))throw new m.UnrecognizedArgument(t);this._buildFromObject(t)}}y.fromRandom=function(){return new y},y.isValidPath=function(t,e){if(o.isString(t)){var r=y._getDerivationIndexes(t);return null!==r&&o.every(r,y.isValidPath)}return!!o.isNumber(t)&&(t<y.Hardened&&!0===e&&(t+=y.Hardened),t>=0&&t<y.MaxIndex)},y._getDerivationIndexes=function(t){var e=t.split("/");if(o.includes(y.RootElementAlias,t))return[];if(!o.includes(y.RootElementAlias,e[0]))return null;var r=e.slice(1).map((function(t){var e="'"===t.slice(-1);if(e&&(t=t.slice(0,-1)),!t||"-"===t[0])return NaN;var r=+t;return e&&(r+=y.Hardened),r}));return o.some(r,isNaN)?null:r},y.prototype.derive=function(){throw new Error("derive has been deprecated. use deriveChild or, for the old way, deriveNonCompliantChild.")},y.prototype.deriveChild=function(t,e){if(o.isNumber(t))return this._deriveWithNumber(t,e);if(o.isString(t))return this._deriveFromString(t);throw new m.InvalidDerivationArgument(t)},y.prototype.deriveNonCompliantChild=function(t,e){if(o.isNumber(t))return this._deriveWithNumber(t,e,!0);if(o.isString(t))return this._deriveFromString(t,!0);throw new m.InvalidDerivationArgument(t)},y.prototype._deriveWithNumber=function(t,r,o){if(!y.isValidPath(t,r))throw new m.InvalidPath(t);r=t>=y.Hardened||r,t<y.Hardened&&!0===r&&(t+=y.Hardened);var s,c=b.integerAsBuffer(t);if(r&&o){var u=this.privateKey.bn.toBuffer();s=e.concat([i.Buffer.from([0]),u,c])}else if(r){var h=this.privateKey.bn.toBuffer({size:32});n(32===h.length,"length of private key buffer is expected to be 32 bytes"),s=e.concat([i.Buffer.from([0]),h,c])}else s=e.concat([this.publicKey.toBuffer(),c]);var l=f.sha512hmac(s,this._buffers.chainCode),g=a.fromBuffer(l.slice(0,32),{size:32}),v=l.slice(32,64),S=g.add(this.privateKey.toBigNumber()).umod(d.getN()).toBuffer({size:32});return p.isValid(S)?new y({network:this.network,depth:this.depth+1,parentFingerPrint:this.fingerPrint,childIndex:t,chainCode:v,privateKey:S}):this._deriveWithNumber(t+1,null,o)},y.prototype._deriveFromString=function(t,e){if(!y.isValidPath(t))throw new m.InvalidPath(t);return y._getDerivationIndexes(t).reduce((function(t,r){return t._deriveWithNumber(r,null,e)}),this)},y.isValidSerialized=function(t,e){return!y.getSerializedError(t,e)},y.getSerializedError=function(t,r){if(!o.isString(t)&&!e.isBuffer(t))return new m.UnrecognizedArgument("Expected string or buffer");if(!c.validCharacters(t))return new g.InvalidB58Char("(unknown)",t);try{t=u.decode(t)}catch(e){return new g.InvalidB58Checksum(t)}if(t.length!==y.DataLength)return new m.InvalidLength(t);if(!o.isUndefined(r)){var n=y._validateNetwork(t,r);if(n)return n}return null},y._validateNetwork=function(t,e){var r=h.get(e);if(!r)return new g.InvalidNetworkArgument(e);var n=t.slice(0,4);return n.readUInt32BE(0)!==r.xprivkey?new g.InvalidNetwork(n):null},y.fromString=function(t){return s.checkArgument(o.isString(t),"No valid string was provided"),new y(t)},y.fromObject=function(t){return s.checkArgument(o.isObject(t),"No valid argument was provided"),new y(t)},y.prototype._buildFromJSON=function(t){return this._buildFromObject(JSON.parse(t))},y.prototype._buildFromObject=function(t){var r={version:t.network?b.integerAsBuffer(h.get(t.network).xprivkey):t.version,depth:o.isNumber(t.depth)?e.from([255&t.depth]):t.depth,parentFingerPrint:o.isNumber(t.parentFingerPrint)?b.integerAsBuffer(t.parentFingerPrint):t.parentFingerPrint,childIndex:o.isNumber(t.childIndex)?b.integerAsBuffer(t.childIndex):t.childIndex,chainCode:o.isString(t.chainCode)?e.from(t.chainCode,"hex"):t.chainCode,privateKey:o.isString(t.privateKey)&&b.isHexa(t.privateKey)?e.from(t.privateKey,"hex"):t.privateKey,checksum:t.checksum?t.checksum.length?t.checksum:b.integerAsBuffer(t.checksum):void 0};return this._buildFromBuffers(r)},y.prototype._buildFromSerialized=function(t){var e=u.decode(t),r={version:e.slice(y.VersionStart,y.VersionEnd),depth:e.slice(y.DepthStart,y.DepthEnd),parentFingerPrint:e.slice(y.ParentFingerPrintStart,y.ParentFingerPrintEnd),childIndex:e.slice(y.ChildIndexStart,y.ChildIndexEnd),chainCode:e.slice(y.ChainCodeStart,y.ChainCodeEnd),privateKey:e.slice(y.PrivateKeyStart,y.PrivateKeyEnd),checksum:e.slice(y.ChecksumStart,y.ChecksumEnd),xprivkey:t};return this._buildFromBuffers(r)},y.prototype._generateRandomly=function(t){return y.fromSeed(l.getRandomBuffer(64),t)},y.fromSeed=function(t,r){if(b.isHexaString(t)&&(t=e.from(t,"hex")),!e.isBuffer(t))throw new m.InvalidEntropyArgument(t);if(t.length<16)throw new m.InvalidEntropyArgument.NotEnoughEntropy(t);if(t.length>64)throw new m.InvalidEntropyArgument.TooMuchEntropy(t);var n=f.sha512hmac(t,i.Buffer.from("Bitcoin seed"));return new y({network:h.get(r)||h.defaultNetwork,depth:0,parentFingerPrint:0,childIndex:0,privateKey:n.slice(0,32),chainCode:n.slice(32,64)})},y.prototype._calcHDPublicKey=function(){if(!this._hdPublicKey){var t=r(76);this._hdPublicKey=new t(this)}},y.prototype._buildFromBuffers=function(t){y._validateBufferArguments(t),b.defineImmutable(this,{_buffers:t});var r=[t.version,t.depth,t.parentFingerPrint,t.childIndex,t.chainCode,e.alloc(1),t.privateKey],n=i.Buffer.concat(r);if(t.checksum&&t.checksum.length){if(t.checksum.toString()!==u.checksum(n).toString())throw new g.InvalidB58Checksum(n)}else t.checksum=u.checksum(n);var o,s=h.get(t.version.readUInt32BE(0));o=u.encode(i.Buffer.concat(r)),t.xprivkey=e.from(o);var c=new p(a.fromBuffer(t.privateKey),s),d=c.toPublicKey(),l=y.ParentFingerPrintSize,m=f.sha256ripemd160(d.toBuffer()).slice(0,l);return b.defineImmutable(this,{xprivkey:o,network:s,depth:t.depth[0],privateKey:c,publicKey:d,fingerPrint:m}),this._hdPublicKey=null,Object.defineProperty(this,"hdPublicKey",{configurable:!1,enumerable:!0,get:function(){return this._calcHDPublicKey(),this._hdPublicKey}}),Object.defineProperty(this,"xpubkey",{configurable:!1,enumerable:!0,get:function(){return this._calcHDPublicKey(),this._hdPublicKey.xpubkey}}),this},y._validateBufferArguments=function(t){var r=function(r,i){var o=t[r];n(e.isBuffer(o),r+" argument is not a buffer"),n(o.length===i,r+" has not the expected size: found "+o.length+", expected "+i)};r("version",y.VersionSize),r("depth",y.DepthSize),r("parentFingerPrint",y.ParentFingerPrintSize),r("childIndex",y.ChildIndexSize),r("chainCode",y.ChainCodeSize),r("privateKey",y.PrivateKeySize),t.checksum&&t.checksum.length&&r("checksum",y.CheckSumSize)},y.prototype.toString=function(){return this.xprivkey},y.prototype.inspect=function(){return"<HDPrivateKey: "+this.xprivkey+">"},y.prototype.toObject=y.prototype.toJSON=function(){return{network:h.get(this._buffers.version.readUInt32BE(0),"xprivkey").name,depth:this._buffers.depth[0],fingerPrint:this.fingerPrint.readUInt32BE(0),parentFingerPrint:this._buffers.parentFingerPrint.readUInt32BE(0),childIndex:this._buffers.childIndex.readUInt32BE(0),chainCode:this._buffers.chainCode.toString("hex"),privateKey:this.privateKey.toBuffer().toString("hex"),checksum:this._buffers.checksum.readUInt32BE(0),xprivkey:this.xprivkey}},y.fromBuffer=function(t){return new y(t.toString())},y.fromHex=function(t){return y.fromBuffer(e.from(t,"hex"))},y.prototype.toBuffer=function(){return e.from(this.toString())},y.prototype.toHex=function(){return this.toBuffer().toString("hex")},y.DefaultDepth=0,y.DefaultFingerprint=0,y.DefaultChildIndex=0,y.Hardened=2147483648,y.MaxIndex=2*y.Hardened,y.RootElementAlias=["m","M","m'","M'"],y.VersionSize=4,y.DepthSize=1,y.ParentFingerPrintSize=4,y.ChildIndexSize=4,y.ChainCodeSize=32,y.PrivateKeySize=32,y.CheckSumSize=4,y.DataLength=78,y.SerializedByteSize=82,y.VersionStart=0,y.VersionEnd=y.VersionStart+y.VersionSize,y.DepthStart=y.VersionEnd,y.DepthEnd=y.DepthStart+y.DepthSize,y.ParentFingerPrintStart=y.DepthEnd,y.ParentFingerPrintEnd=y.ParentFingerPrintStart+y.ParentFingerPrintSize,y.ChildIndexStart=y.ParentFingerPrintEnd,y.ChildIndexEnd=y.ChildIndexStart+y.ChildIndexSize,y.ChainCodeStart=y.ChildIndexEnd,y.ChainCodeEnd=y.ChainCodeStart+y.ChainCodeSize,y.PrivateKeyStart=y.ChainCodeEnd+1,y.PrivateKeyEnd=y.PrivateKeyStart+y.PrivateKeySize,y.ChecksumStart=y.PrivateKeyEnd,y.ChecksumEnd=y.ChecksumStart+y.CheckSumSize,n(y.ChecksumEnd===y.SerializedByteSize),t.exports=y}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var n=r(1),i=r(2),o=r(3),s=r(35),a=r(28),c=r(7),u=r(75),f=r(24),h=r(11),d=r(14),p=r(10),l=p,g=p.HDPublicKey,m=r(45),b=r(6);function y(t){if(t instanceof y)return t;if(!(this instanceof y))return new y(t);if(t){if(n.isString(t)||e.isBuffer(t)){var r=y.getSerializedError(t);if(r){if(e.isBuffer(t)&&!y.getSerializedError(t.toString()))return this._buildFromSerialized(t.toString());if(r instanceof g.ArgumentIsPrivateExtended)return new u(t).hdPublicKey;throw r}return this._buildFromSerialized(t)}if(n.isObject(t))return t instanceof u?this._buildFromPrivate(t):this._buildFromObject(t);throw new g.UnrecognizedArgument(t)}throw new g.MustSupplyArgument}y.fromHDPrivateKey=function(t){return new y(t)},y.isValidPath=function(t){if(n.isString(t)){var e=u._getDerivationIndexes(t);return null!==e&&n.every(e,y.isValidPath)}return!!n.isNumber(t)&&(t>=0&&t<y.Hardened)},y.prototype.derive=function(){throw new Error("derive has been deprecated. use deriveChild or, for the old way, deriveNonCompliantChild.")},y.prototype.deriveChild=function(t,e){if(n.isNumber(t))return this._deriveWithNumber(t,e);if(n.isString(t))return this._deriveFromString(t);throw new g.InvalidDerivationArgument(t)},y.prototype._deriveWithNumber=function(t,r){if(t>=y.Hardened||r)throw new g.InvalidIndexCantDeriveHardened;if(t<0)throw new g.InvalidPath(t);var n,i=b.integerAsBuffer(t),s=e.concat([this.publicKey.toBuffer(),i]),a=c.sha512hmac(s,this._buffers.chainCode),u=o.fromBuffer(a.slice(0,32),{size:32}),f=a.slice(32,64);try{n=d.fromPoint(h.getG().mul(u).add(this.publicKey.point))}catch(e){return this._deriveWithNumber(t+1)}return new y({network:this.network,depth:this.depth+1,parentFingerPrint:this.fingerPrint,childIndex:t,chainCode:f,publicKey:n})},y.prototype._deriveFromString=function(t){if(n.includes(t,"'"))throw new g.InvalidIndexCantDeriveHardened;if(!y.isValidPath(t))throw new g.InvalidPath(t);return u._getDerivationIndexes(t).reduce((function(t,e){return t._deriveWithNumber(e)}),this)},y.isValidSerialized=function(t,e){return n.isNull(y.getSerializedError(t,e))},y.getSerializedError=function(t,r){if(!n.isString(t)&&!e.isBuffer(t))return new g.UnrecognizedArgument("expected buffer or string");if(!s.validCharacters(t))return new l.InvalidB58Char("(unknown)",t);try{t=a.decode(t)}catch(e){return new l.InvalidB58Checksum(t)}if(t.length!==y.DataSize)return new g.InvalidLength(t);if(!n.isUndefined(r)){var i=y._validateNetwork(t,r);if(i)return i}var o=t.readUInt32BE(0);return o===f.livenet.xprivkey||o===f.testnet.xprivkey?new g.ArgumentIsPrivateExtended:null},y._validateNetwork=function(t,e){var r=f.get(e);if(!r)return new l.InvalidNetworkArgument(e);var n=t.slice(y.VersionStart,y.VersionEnd);return n.readUInt32BE(0)!==r.xpubkey?new l.InvalidNetwork(n):null},y.prototype._buildFromPrivate=function(t){var e=n.clone(t._buffers),r=h.getG().mul(o.fromBuffer(e.privateKey));return e.publicKey=h.pointToCompressed(r),e.version=b.integerAsBuffer(f.get(e.version.readUInt32BE(0)).xpubkey),e.privateKey=void 0,e.checksum=void 0,e.xprivkey=void 0,this._buildFromBuffers(e)},y.prototype._buildFromObject=function(t){var r={version:t.network?b.integerAsBuffer(f.get(t.network).xpubkey):t.version,depth:n.isNumber(t.depth)?e.from([255&t.depth]):t.depth,parentFingerPrint:n.isNumber(t.parentFingerPrint)?b.integerAsBuffer(t.parentFingerPrint):t.parentFingerPrint,childIndex:n.isNumber(t.childIndex)?b.integerAsBuffer(t.childIndex):t.childIndex,chainCode:n.isString(t.chainCode)?e.from(t.chainCode,"hex"):t.chainCode,publicKey:n.isString(t.publicKey)?e.from(t.publicKey,"hex"):e.isBuffer(t.publicKey)?t.publicKey:t.publicKey.toBuffer(),checksum:n.isNumber(t.checksum)?b.integerAsBuffer(t.checksum):t.checksum};return this._buildFromBuffers(r)},y.prototype._buildFromSerialized=function(t){var e=a.decode(t),r={version:e.slice(y.VersionStart,y.VersionEnd),depth:e.slice(y.DepthStart,y.DepthEnd),parentFingerPrint:e.slice(y.ParentFingerPrintStart,y.ParentFingerPrintEnd),childIndex:e.slice(y.ChildIndexStart,y.ChildIndexEnd),chainCode:e.slice(y.ChainCodeStart,y.ChainCodeEnd),publicKey:e.slice(y.PublicKeyStart,y.PublicKeyEnd),checksum:e.slice(y.ChecksumStart,y.ChecksumEnd),xpubkey:t};return this._buildFromBuffers(r)},y.prototype._buildFromBuffers=function(t){y._validateBufferArguments(t),b.defineImmutable(this,{_buffers:t});var r=[t.version,t.depth,t.parentFingerPrint,t.childIndex,t.chainCode,t.publicKey],n=e.concat(r),i=a.checksum(n);if(t.checksum&&t.checksum.length){if(t.checksum.toString("hex")!==i.toString("hex"))throw new l.InvalidB58Checksum(n,i)}else t.checksum=i;var o,s=f.get(t.version.readUInt32BE(0));o=a.encode(e.concat(r)),t.xpubkey=e.from(o);var u=new d(t.publicKey,{network:s}),h=y.ParentFingerPrintSize,p=c.sha256ripemd160(u.toBuffer()).slice(0,h);return b.defineImmutable(this,{xpubkey:o,network:s,depth:t.depth[0],publicKey:u,fingerPrint:p}),this},y._validateBufferArguments=function(t){var r=function(r,n){var i=t[r];m(e.isBuffer(i),r+" argument is not a buffer, it's "+typeof i),m(i.length===n,r+" has not the expected size: found "+i.length+", expected "+n)};r("version",y.VersionSize),r("depth",y.DepthSize),r("parentFingerPrint",y.ParentFingerPrintSize),r("childIndex",y.ChildIndexSize),r("chainCode",y.ChainCodeSize),r("publicKey",y.PublicKeySize),t.checksum&&t.checksum.length&&r("checksum",y.CheckSumSize)},y.fromString=function(t){return i.checkArgument(n.isString(t),"No valid string was provided"),new y(t)},y.fromObject=function(t){return i.checkArgument(n.isObject(t),"No valid argument was provided"),new y(t)},y.prototype.toString=function(){return this.xpubkey},y.prototype.inspect=function(){return"<HDPublicKey: "+this.xpubkey+">"},y.prototype.toObject=y.prototype.toJSON=function(){return{network:f.get(this._buffers.version.readUInt32BE(0)).name,depth:this._buffers.depth[0],fingerPrint:this.fingerPrint.readUInt32BE(0),parentFingerPrint:this._buffers.parentFingerPrint.readUInt32BE(0),childIndex:this._buffers.childIndex.readUInt32BE(0),chainCode:this._buffers.chainCode.toString("hex"),publicKey:this.publicKey.toString(),checksum:this._buffers.checksum.readUInt32BE(0),xpubkey:this.xpubkey}},y.fromBuffer=function(t){return new y(t)},y.fromHex=function(t){return y.fromBuffer(e.from(t,"hex"))},y.prototype.toBuffer=function(){return e.from(this._buffers.xpubkey)},y.prototype.toHex=function(){return this.toBuffer().toString("hex")},y.Hardened=2147483648,y.RootElementAlias=["m","M"],y.VersionSize=4,y.DepthSize=1,y.ParentFingerPrintSize=4,y.ChildIndexSize=4,y.ChainCodeSize=32,y.PublicKeySize=33,y.CheckSumSize=4,y.DataSize=78,y.SerializedByteSize=82,y.VersionStart=0,y.VersionEnd=y.VersionStart+y.VersionSize,y.DepthStart=y.VersionEnd,y.DepthEnd=y.DepthStart+y.DepthSize,y.ParentFingerPrintStart=y.DepthEnd,y.ParentFingerPrintEnd=y.ParentFingerPrintStart+y.ParentFingerPrintSize,y.ChildIndexStart=y.ParentFingerPrintEnd,y.ChildIndexEnd=y.ChildIndexStart+y.ChildIndexSize,y.ChainCodeStart=y.ChildIndexEnd,y.ChainCodeEnd=y.ChainCodeStart+y.ChainCodeSize,y.PublicKeyStart=y.ChainCodeEnd,y.PublicKeyEnd=y.PublicKeyStart+y.PublicKeySize,y.ChecksumStart=y.PublicKeyEnd,y.ChecksumEnd=y.ChecksumStart+y.CheckSumSize,m(y.PublicKeyEnd===y.DataSize),m(y.ChecksumEnd===y.SerializedByteSize),t.exports=y}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(t,e){const{opcodeMap:n,scriptNum:i,utils:o}=r(78);class s{constructor(){this.operations=[],this.comments=[]}comment(t){return this.comments.push("// "+t),this}push(e){if("number"==typeof e)if(e>=-1&&e<=16)-1===e?this.operations.push("OP_1NEGATE"):0===e?this.operations.push("OP_0"):this.operations.push("OP_"+e);else{const t=i.encode(e);this.operations.push(t.toString("hex"))}else if("string"==typeof e)this.operations.push(e);else{if(!t.isBuffer(e))throw new Error("Invalid value type: "+typeof e);this.operations.push(e.toString("hex"))}return this}dup(){return this.operations.push("OP_DUP"),this}drop(){return this.operations.push("OP_DROP"),this}swap(){return this.operations.push("OP_SWAP"),this}over(){return this.operations.push("OP_OVER"),this}rot(){return this.operations.push("OP_ROT"),this}pick(t){return this.push(t),this.operations.push("OP_PICK"),this}roll(t){return this.push(t),this.operations.push("OP_ROLL"),this}depth(){return this.operations.push("OP_DEPTH"),this}add(){return this.operations.push("OP_ADD"),this}sub(){return this.operations.push("OP_SUB"),this}mul(){return this.operations.push("OP_MUL"),this}div(){return this.operations.push("OP_DIV"),this}mod(){return this.operations.push("OP_MOD"),this}negate(){return this.operations.push("OP_NEGATE"),this}abs(){return this.operations.push("OP_ABS"),this}min(){return this.operations.push("OP_MIN"),this}max(){return this.operations.push("OP_MAX"),this}equal(){return this.operations.push("OP_EQUAL"),this}equalVerify(){return this.operations.push("OP_EQUALVERIFY"),this}numEqual(){return this.operations.push("OP_NUMEQUAL"),this}numNotEqual(){return this.operations.push("OP_NUMNOTEQUAL"),this}lessThan(){return this.operations.push("OP_LESSTHAN"),this}greaterThan(){return this.operations.push("OP_GREATERTHAN"),this}lessThanOrEqual(){return this.operations.push("OP_LESSTHANOREQUAL"),this}greaterThanOrEqual(){return this.operations.push("OP_GREATERTHANOREQUAL"),this}within(){return this.operations.push("OP_WITHIN"),this}not(){return this.operations.push("OP_NOT"),this}boolAnd(){return this.operations.push("OP_BOOLAND"),this}boolOr(){return this.operations.push("OP_BOOLOR"),this}and(){return this.operations.push("OP_AND"),this}or(){return this.operations.push("OP_OR"),this}xor(){return this.operations.push("OP_XOR"),this}invert(){return this.operations.push("OP_INVERT"),this}cat(){return this.operations.push("OP_CAT"),this}split(){return this.operations.push("OP_SPLIT"),this}size(){return this.operations.push("OP_SIZE"),this}left(t){return this.push(t),this.operations.push("OP_LEFT"),this}right(t){return this.push(t),this.operations.push("OP_RIGHT"),this}substr(t,e){return this.push(e).push(t),this.operations.push("OP_SUBSTR"),this}sha256(){return this.operations.push("OP_SHA256"),this}hash256(){return this.operations.push("OP_HASH256"),this}hash160(){return this.operations.push("OP_HASH160"),this}ripemd160(){return this.operations.push("OP_RIPEMD160"),this}verify(){return this.operations.push("OP_VERIFY"),this}return(){return this.operations.push("OP_RETURN"),this}extractField(t){this.comment(`Extract ${t} field from preimage`);const e={nVersion:{strategy:"LEFT",offset:0,length:4},hashPrevouts:{strategy:"LEFT",offset:4,length:32},hashSequence:{strategy:"LEFT",offset:36,length:32},outpoint:{strategy:"LEFT",offset:68,length:36},scriptLen:{strategy:"DYNAMIC",position:"after_outpoint"},scriptCode:{strategy:"DYNAMIC",variable_length:!0},value:{strategy:"RIGHT",offsetFromEnd:52,length:8},nSequence:{strategy:"RIGHT",offsetFromEnd:44,length:4},hashOutputs:{strategy:"RIGHT",offsetFromEnd:40,length:32},nLocktime:{strategy:"RIGHT",offsetFromEnd:8,length:4},sighashType:{strategy:"RIGHT",offsetFromEnd:4,length:4}}[t];if(!e)throw new Error("Unknown field: "+t);if("LEFT"===e.strategy)this.push(e.offset+e.length).split().drop().push(e.offset).split().swap().drop();else if("RIGHT"===e.strategy)this.size().push(e.offsetFromEnd).sub().split().drop().push(e.length).split().drop();else if("DYNAMIC"===e.strategy){if("scriptLen"!==t)throw new Error(`Dynamic extraction for ${t} not implemented`);this.push(104).split().drop().push(1).split().swap().drop()}return this}validateField(t,e){return this.comment(`Validate ${t} equals expected value`),this.extractField(t),this.push(e),this.equalVerify(),this}validateRange(t,e,r){return this.comment(`Validate ${t} is within range [${e}, ${r})`),this.extractField(t),this.dup(),this.push(e),this.greaterThanOrEqual(),this.verify(),this.push(r),this.lessThan(),this.verify(),this}validateFields(t){return this.comment("Multi-field validation"),Object.entries(t).forEach(([t,e])=>{e.equals?this.validateField(t,e.equals):void 0===e.min&&void 0===e.max||this.validateRange(t,e.min||0,e.max||Number.MAX_SAFE_INTEGER)}),this}if(t){return this.comment("Begin IF block"),"function"==typeof t&&t(this),this.operations.push("OP_IF"),this}else(){return this.comment("ELSE block"),this.operations.push("OP_ELSE"),this}endif(){return this.comment("End IF block"),this.operations.push("OP_ENDIF"),this}build(){const t=this.operations.join(" "),e=this._cleanASM(t);return{operations:[...this.operations],comments:[...this.comments],asm:t,cleanedASM:e,hex:this._asmToHex(e),size:e.split(" ").length}}_cleanASM(t){return t.split(" ").map(t=>{if(/^\d+$/.test(t)){const e=parseInt(t);return e>=1&&e<=75?e.toString(16).padStart(2,"0"):i.encode(e).toString("hex")}return t}).join(" ")}_asmToHex(t){return t.split(" ").map(t=>n[t]?n[t].code.toString(16).padStart(2,"0"):/^[0-9a-fA-F]+$/.test(t)?t:"00").join("")}simulate(t=[]){return o.simulate(this.operations,t)}document(){const t=this.build();return{title:"Covenant Script Documentation",operations:t.operations.length,size:t.size,asm:t.cleanedASM,comments:this.comments,structure:this._analyzeStructure()}}_analyzeStructure(){const t={stack_operations:0,arithmetic:0,comparisons:0,crypto:0,data_manipulation:0,flow_control:0};return this.operations.forEach(e=>{const r=n[e];if(r)switch(r.category){case"stack":t.stack_operations++;break;case"arithmetic":t.arithmetic++;break;case"bitwise":t.comparisons++;break;case"crypto":t.crypto++;break;case"data":t.data_manipulation++;break;case"flow_control":t.flow_control++}}),t}}const a={valueLock:t=>(new s).comment("Value Lock Covenant").comment("Expected value: "+t).validateField("value",t).push(1),hashLock:t=>(new s).comment("Hash Lock Covenant").comment("Expected hash: "+t).sha256().push(t).equalVerify().push(1),multiSigWithValidation:(t,e,r)=>{const n=(new s).comment("Multi-Signature Covenant with Field Validation").comment("Required signatures: "+t);return n.validateFields(r),n.comment("Signature validation (placeholder)").push(1),n},timeLock:t=>(new s).comment("Time Lock Covenant").comment("Locktime: "+t).validateField("nLocktime",t).push(1),complexValidation:t=>{const e=(new s).comment("Complex Validation Covenant");return t.valueRange&&e.validateRange("value",t.valueRange.min,t.valueRange.max),t.fields&&e.validateFields(t.fields),t.hashValidation&&e.sha256().push(t.hashValidation.expectedHash).equalVerify(),e.push(1),e}};if(e.exports={CovenantBuilder:s,CovenantTemplates:a},r.c[r.s]===e){console.log("🏗️ Covenant Builder Demonstration"),console.log("=================================="),console.log("\n📊 Example 1: Value Lock Covenant");const t=a.valueLock("50c3000000000000").build();console.log("ASM:",t.cleanedASM),console.log("Size:",t.size,"operations"),console.log("\n📊 Example 2: Custom Arithmetic Covenant");const e=(new s).comment("Validate that value field equals 5 + 3").extractField("value").push(5).push(3).add().numEqual().verify().push(1),r=e.build();console.log("Operations:",r.operations.length),console.log("ASM:",r.cleanedASM),console.log("\n📊 Example 3: Documentation Generation");const n=e.document();console.log("Structure analysis:",n.structure),console.log("Comments:"),n.comments.forEach(t=>console.log(" "+t))}}).call(this,r(0).Buffer,r(25)(t))},function(t,e,r){(function(t,e){const n={encode:e=>{if(0===e)return t.alloc(0);const r=e<0,n=[];let i=Math.abs(e);for(;i>0;)n.push(255&i),i>>=8;return 128&n[n.length-1]?n.push(r?128:0):r&&(n[n.length-1]|=128),t.from(n)},decode:t=>{if(0===t.length)return 0;const e=Array.from(t),r=128&e[e.length-1];r&&(e[e.length-1]&=127);let n=0;for(let t=e.length-1;t>=0;t--)n=(n<<8)+e[t];return r?-n:n}},i={OP_FALSE:{code:0,category:"constants",description:"Push empty array (false value)",action:e=>e.push(t.alloc(0))},OP_0:{code:0,category:"constants",description:"Push empty array (alias for OP_FALSE)",action:e=>e.push(t.alloc(0))},OP_PUSHDATA1:{code:76,category:"pushdata",description:"Push next [1 byte] bytes of data",action:"Read next byte as length; push that many bytes"},OP_PUSHDATA2:{code:77,category:"pushdata",description:"Push next [2 bytes LE] bytes of data",action:"Read next 2 bytes as length; push that many bytes"},OP_PUSHDATA4:{code:78,category:"pushdata",description:"Push next [4 bytes LE] bytes of data",action:"Read next 4 bytes as length; push that many bytes"},OP_1NEGATE:{code:79,category:"constants",description:"Push number -1",action:t=>t.push(n.encode(-1))},OP_RESERVED:{code:80,category:"reserved",description:"Reserved opcode (makes transaction invalid)",action:()=>{throw new Error("OP_RESERVED encountered")}},OP_TRUE:{code:81,category:"constants",description:"Push number 1 (true value)",action:t=>t.push(n.encode(1))},OP_1:{code:81,category:"constants",description:"Push number 1 (alias for OP_TRUE)",action:t=>t.push(n.encode(1))},OP_2:{code:82,category:"constants",description:"Push number 2",action:t=>t.push(n.encode(2))},OP_3:{code:83,category:"constants",description:"Push number 3",action:t=>t.push(n.encode(3))},OP_4:{code:84,category:"constants",description:"Push number 4",action:t=>t.push(n.encode(4))},OP_5:{code:85,category:"constants",description:"Push number 5",action:t=>t.push(n.encode(5))},OP_6:{code:86,category:"constants",description:"Push number 6",action:t=>t.push(n.encode(6))},OP_7:{code:87,category:"constants",description:"Push number 7",action:t=>t.push(n.encode(7))},OP_8:{code:88,category:"constants",description:"Push number 8",action:t=>t.push(n.encode(8))},OP_9:{code:89,category:"constants",description:"Push number 9",action:t=>t.push(n.encode(9))},OP_10:{code:90,category:"constants",description:"Push number 10",action:t=>t.push(n.encode(10))},OP_11:{code:91,category:"constants",description:"Push number 11",action:t=>t.push(n.encode(11))},OP_12:{code:92,category:"constants",description:"Push number 12",action:t=>t.push(n.encode(12))},OP_13:{code:93,category:"constants",description:"Push number 13",action:t=>t.push(n.encode(13))},OP_14:{code:94,category:"constants",description:"Push number 14",action:t=>t.push(n.encode(14))},OP_15:{code:95,category:"constants",description:"Push number 15",action:t=>t.push(n.encode(15))},OP_16:{code:96,category:"constants",description:"Push number 16",action:t=>t.push(n.encode(16))},OP_NOP:{code:97,category:"flow_control",description:"No operation (do nothing)",action:t=>{}},OP_VER:{code:98,category:"flow_control",description:"Push transaction version (disabled)",action:()=>{throw new Error("OP_VER is disabled")}},OP_IF:{code:99,category:"flow_control",description:"Execute if top stack value is true",action:"// Conditional execution (requires parser state)"},OP_NOTIF:{code:100,category:"flow_control",description:"Execute if top stack value is false",action:"// Conditional execution (requires parser state)"},OP_VERIF:{code:101,category:"flow_control",description:"Conditional execution based on transaction version (disabled)",action:()=>{throw new Error("OP_VERIF is disabled")}},OP_VERNOTIF:{code:102,category:"flow_control",description:"Conditional execution based on transaction version (disabled)",action:()=>{throw new Error("OP_VERNOTIF is disabled")}},OP_ELSE:{code:103,category:"flow_control",description:"Else branch of conditional",action:"// Conditional execution (requires parser state)"},OP_ENDIF:{code:104,category:"flow_control",description:"End conditional block",action:"// Conditional execution (requires parser state)"},OP_VERIFY:{code:105,category:"flow_control",description:"Fail if top stack value is not true",action:t=>{const e=t.pop();if(!e||0===e.length||0===n.decode(e))throw new Error("OP_VERIFY failed")}},OP_RETURN:{code:106,category:"flow_control",description:"Terminate script execution immediately",action:()=>{throw new Error("Script terminated by OP_RETURN")}},OP_TOALTSTACK:{code:107,category:"stack",description:"Move top item from main stack to alt stack",action:(t,e)=>e.push(t.pop())},OP_FROMALTSTACK:{code:108,category:"stack",description:"Move top item from alt stack to main stack",action:(t,e)=>t.push(e.pop())},OP_2DROP:{code:109,category:"stack",description:"Remove top two stack items",action:t=>{t.pop(),t.pop()}},OP_2DUP:{code:110,category:"stack",description:"Duplicate top two stack items",action:e=>{const r=e[e.length-1],n=e[e.length-2];e.push(t.from(n),t.from(r))}},OP_3DUP:{code:111,category:"stack",description:"Duplicate top three stack items",action:e=>{const r=e[e.length-1],n=e[e.length-2],i=e[e.length-3];e.push(t.from(i),t.from(n),t.from(r))}},OP_2OVER:{code:112,category:"stack",description:"Copy 3rd and 4th items to top",action:e=>{const r=e[e.length-3],n=e[e.length-4];e.push(t.from(n),t.from(r))}},OP_2ROT:{code:113,category:"stack",description:"Move 5th and 6th items to top",action:t=>{const e=t.splice(-5,1)[0],r=t.splice(-5,1)[0];t.push(e,r)}},OP_2SWAP:{code:114,category:"stack",description:"Swap top two pairs of items",action:t=>{const e=t.pop(),r=t.pop(),n=t.pop(),i=t.pop();t.push(r,e,i,n)}},OP_IFDUP:{code:115,category:"stack",description:"Duplicate top item if it is not zero",action:e=>{const r=e[e.length-1];r.length>0&&0!==n.decode(r)&&e.push(t.from(r))}},OP_DEPTH:{code:116,category:"stack",description:"Push stack size as number",action:t=>t.push(n.encode(t.length))},OP_DROP:{code:117,category:"stack",description:"Remove top stack item",action:t=>t.pop()},OP_DUP:{code:118,category:"stack",description:"Duplicate top stack item",action:e=>e.push(t.from(e[e.length-1]))},OP_NIP:{code:119,category:"stack",description:"Remove second-to-top item",action:t=>{const e=t.pop();t.pop(),t.push(e)}},OP_OVER:{code:120,category:"stack",description:"Copy second-to-top item to top",action:e=>e.push(t.from(e[e.length-2]))},OP_PICK:{code:121,category:"stack",description:"Copy nth item to top (0-indexed from top)",action:e=>{const r=n.decode(e.pop());e.push(t.from(e[e.length-1-r]))}},OP_ROLL:{code:122,category:"stack",description:"Move nth item to top (0-indexed from top)",action:t=>{const e=n.decode(t.pop()),r=t.splice(t.length-1-e,1)[0];t.push(r)}},OP_ROT:{code:123,category:"stack",description:"Rotate top three items left",action:t=>{const e=t.pop(),r=t.pop(),n=t.pop();t.push(r,e,n)}},OP_SWAP:{code:124,category:"stack",description:"Swap top two items",action:t=>{const e=t.pop(),r=t.pop();t.push(e,r)}},OP_TUCK:{code:125,category:"stack",description:"Copy top item below second item",action:t=>{const e=t.pop(),r=t.pop();t.push(e,r,e)}},OP_CAT:{code:126,category:"data",description:"Concatenate top two items",action:e=>{const r=e.pop(),n=e.pop();e.push(t.concat([n,r]))}},OP_SPLIT:{code:127,category:"data",description:"Split item at position n",action:t=>{const e=n.decode(t.pop()),r=t.pop();t.push(r.slice(0,e),r.slice(e))}},OP_NUM2BIN:{code:128,category:"data",description:"Convert number to byte sequence of length n",action:e=>{const r=n.decode(e.pop()),i=n.decode(e.pop()),o=t.alloc(r),s=n.encode(i);s.copy(o,0,0,Math.min(s.length,r)),e.push(o)}},OP_BIN2NUM:{code:129,category:"data",description:"Convert byte sequence to number",action:t=>{const e=t.pop();t.push(n.encode(n.decode(e)))}},OP_SIZE:{code:130,category:"data",description:"Push size of top item (without removing item)",action:t=>t.push(n.encode(t[t.length-1].length))},OP_INVERT:{code:131,category:"bitwise",description:"Bitwise NOT of top item",action:e=>{const r=e.pop();e.push(t.from(r.map(t=>~t)))}},OP_AND:{code:132,category:"bitwise",description:"Bitwise AND of top two items",action:e=>{const r=e.pop(),n=e.pop(),i=Math.max(r.length,n.length),o=t.alloc(i);for(let t=0;t<i;t++)o[t]=(r[t]||0)&(n[t]||0);e.push(o)}},OP_OR:{code:133,category:"bitwise",description:"Bitwise OR of top two items",action:e=>{const r=e.pop(),n=e.pop(),i=Math.max(r.length,n.length),o=t.alloc(i);for(let t=0;t<i;t++)o[t]=(r[t]||0)|(n[t]||0);e.push(o)}},OP_XOR:{code:134,category:"bitwise",description:"Bitwise XOR of top two items",action:e=>{const r=e.pop(),n=e.pop(),i=Math.max(r.length,n.length),o=t.alloc(i);for(let t=0;t<i;t++)o[t]=(r[t]||0)^(n[t]||0);e.push(o)}},OP_EQUAL:{code:135,category:"bitwise",description:"Push 1 if top two items are equal, 0 otherwise",action:t=>{const e=t.pop(),r=t.pop();t.push(e.equals(r)?n.encode(1):n.encode(0))}},OP_EQUALVERIFY:{code:136,category:"bitwise",description:"Fail if top two items are not equal",action:t=>{const e=t.pop(),r=t.pop();if(!e.equals(r))throw new Error("OP_EQUALVERIFY failed")}},OP_1ADD:{code:139,category:"arithmetic",description:"Add 1 to top item",action:t=>{const e=n.decode(t.pop());t.push(n.encode(e+1))}},OP_1SUB:{code:140,category:"arithmetic",description:"Subtract 1 from top item",action:t=>{const e=n.decode(t.pop());t.push(n.encode(e-1))}},OP_2MUL:{code:141,category:"arithmetic",description:"Multiply top item by 2 (disabled)",action:()=>{throw new Error("OP_2MUL is disabled")}},OP_2DIV:{code:142,category:"arithmetic",description:"Divide top item by 2 (disabled)",action:()=>{throw new Error("OP_2DIV is disabled")}},OP_NEGATE:{code:143,category:"arithmetic",description:"Negate top item",action:t=>{const e=n.decode(t.pop());t.push(n.encode(-e))}},OP_ABS:{code:144,category:"arithmetic",description:"Absolute value of top item",action:t=>{const e=n.decode(t.pop());t.push(n.encode(Math.abs(e)))}},OP_NOT:{code:145,category:"arithmetic",description:"Logical NOT (0→1, non-zero→0)",action:t=>{const e=n.decode(t.pop());t.push(n.encode(0===e?1:0))}},OP_0NOTEQUAL:{code:146,category:"arithmetic",description:"Push 1 if top item is not zero, 0 otherwise",action:t=>{const e=n.decode(t.pop());t.push(n.encode(0!==e?1:0))}},OP_ADD:{code:147,category:"arithmetic",description:"Add top two items",action:t=>{const e=n.decode(t.pop()),r=n.decode(t.pop());t.push(n.encode(r+e))}},OP_SUB:{code:148,category:"arithmetic",description:"Subtract: second - first",action:t=>{const e=n.decode(t.pop()),r=n.decode(t.pop());t.push(n.encode(r-e))}},OP_MUL:{code:149,category:"arithmetic",description:"Multiply top two items",action:t=>{const e=n.decode(t.pop()),r=n.decode(t.pop());t.push(n.encode(r*e))}},OP_DIV:{code:150,category:"arithmetic",description:"Divide: second / first",action:t=>{const e=n.decode(t.pop()),r=n.decode(t.pop());if(0===e)throw new Error("Division by zero");t.push(n.encode(Math.floor(r/e)))}},OP_MOD:{code:151,category:"arithmetic",description:"Modulo: second % first",action:t=>{const e=n.decode(t.pop()),r=n.decode(t.pop());if(0===e)throw new Error("Division by zero");t.push(n.encode(r%e))}},OP_LSHIFT:{code:152,category:"arithmetic",description:"Left shift: second << first",action:t=>{const e=n.decode(t.pop()),r=n.decode(t.pop());t.push(n.encode(r<<e))}},OP_RSHIFT:{code:153,category:"arithmetic",description:"Right shift: second >> first",action:t=>{const e=n.decode(t.pop()),r=n.decode(t.pop());t.push(n.encode(r>>e))}},OP_BOOLAND:{code:154,category:"arithmetic",description:"Boolean AND: 1 if both non-zero, 0 otherwise",action:t=>{const e=n.decode(t.pop()),r=n.decode(t.pop());t.push(n.encode(0!==e&&0!==r?1:0))}},OP_BOOLOR:{code:155,category:"arithmetic",description:"Boolean OR: 1 if either non-zero, 0 otherwise",action:t=>{const e=n.decode(t.pop()),r=n.decode(t.pop());t.push(n.encode(0!==e||0!==r?1:0))}},OP_NUMEQUAL:{code:156,category:"arithmetic",description:"Push 1 if numbers are equal, 0 otherwise",action:t=>{const e=n.decode(t.pop()),r=n.decode(t.pop());t.push(n.encode(e===r?1:0))}},OP_NUMEQUALVERIFY:{code:157,category:"arithmetic",description:"Fail if numbers are not equal",action:t=>{if(n.decode(t.pop())!==n.decode(t.pop()))throw new Error("OP_NUMEQUALVERIFY failed")}},OP_NUMNOTEQUAL:{code:158,category:"arithmetic",description:"Push 1 if numbers are not equal, 0 otherwise",action:t=>{const e=n.decode(t.pop()),r=n.decode(t.pop());t.push(n.encode(e!==r?1:0))}},OP_LESSTHAN:{code:159,category:"arithmetic",description:"Push 1 if second < first, 0 otherwise",action:t=>{const e=n.decode(t.pop()),r=n.decode(t.pop());t.push(n.encode(r<e?1:0))}},OP_GREATERTHAN:{code:160,category:"arithmetic",description:"Push 1 if second > first, 0 otherwise",action:t=>{const e=n.decode(t.pop()),r=n.decode(t.pop());t.push(n.encode(r>e?1:0))}},OP_LESSTHANOREQUAL:{code:161,category:"arithmetic",description:"Push 1 if second <= first, 0 otherwise",action:t=>{const e=n.decode(t.pop()),r=n.decode(t.pop());t.push(n.encode(r<=e?1:0))}},OP_GREATERTHANOREQUAL:{code:162,category:"arithmetic",description:"Push 1 if second >= first, 0 otherwise",action:t=>{const e=n.decode(t.pop()),r=n.decode(t.pop());t.push(n.encode(r>=e?1:0))}},OP_MIN:{code:163,category:"arithmetic",description:"Push smaller of top two numbers",action:t=>{const e=n.decode(t.pop()),r=n.decode(t.pop());t.push(n.encode(Math.min(e,r)))}},OP_MAX:{code:164,category:"arithmetic",description:"Push larger of top two numbers",action:t=>{const e=n.decode(t.pop()),r=n.decode(t.pop());t.push(n.encode(Math.max(e,r)))}},OP_WITHIN:{code:165,category:"arithmetic",description:"Push 1 if x is within [min, max), 0 otherwise",action:t=>{const e=n.decode(t.pop()),r=n.decode(t.pop()),i=n.decode(t.pop());t.push(n.encode(i>=r&&i<e?1:0))}},OP_RIPEMD160:{code:166,category:"crypto",description:"RIPEMD-160 hash of top item",action:t=>{const e=r(15).createHash("ripemd160").update(t.pop()).digest();t.push(e)}},OP_SHA1:{code:167,category:"crypto",description:"SHA-1 hash of top item",action:t=>{const e=r(15).createHash("sha1").update(t.pop()).digest();t.push(e)}},OP_SHA256:{code:168,category:"crypto",description:"SHA-256 hash of top item",action:t=>{const e=r(15).createHash("sha256").update(t.pop()).digest();t.push(e)}},OP_HASH160:{code:169,category:"crypto",description:"SHA-256 then RIPEMD-160 hash of top item",action:t=>{const e=r(15),n=e.createHash("sha256").update(t.pop()).digest(),i=e.createHash("ripemd160").update(n).digest();t.push(i)}},OP_HASH256:{code:170,category:"crypto",description:"Double SHA-256 hash of top item",action:t=>{const e=r(15),n=e.createHash("sha256").update(t.pop()).digest(),i=e.createHash("sha256").update(n).digest();t.push(i)}},OP_CODESEPARATOR:{code:171,category:"crypto",description:"Mark signature checking boundary",action:t=>{}},OP_CHECKSIG:{code:172,category:"crypto",description:"Verify signature against public key",action:"// Signature verification (requires transaction context)"},OP_CHECKSIGVERIFY:{code:173,category:"crypto",description:"Verify signature, then fail if invalid",action:"// Signature verification with VERIFY (requires transaction context)"},OP_CHECKMULTISIG:{code:174,category:"crypto",description:"Verify multiple signatures against public keys",action:"// Multi-signature verification (requires transaction context)"},OP_CHECKMULTISIGVERIFY:{code:175,category:"crypto",description:"Verify multiple signatures, then fail if invalid",action:"// Multi-signature verification with VERIFY (requires transaction context)"},OP_SUBSTR:{code:179,category:"string",description:"Extract substring: string[start:start+length]",action:t=>{const e=n.decode(t.pop()),r=n.decode(t.pop()),i=t.pop();t.push(i.slice(r,r+e))}},OP_LEFT:{code:180,category:"string",description:"Extract leftmost n bytes",action:t=>{const e=n.decode(t.pop()),r=t.pop();t.push(r.slice(0,e))}},OP_RIGHT:{code:181,category:"string",description:"Extract rightmost n bytes",action:t=>{const e=n.decode(t.pop()),r=t.pop();t.push(r.slice(-e))}},OP_NOP1:{code:176,category:"nop",description:"No operation (reserved for future use)",action:t=>{}},OP_NOP2:{code:177,category:"nop",description:"No operation (formerly CHECKLOCKTIMEVERIFY)",action:t=>{}},OP_NOP3:{code:178,category:"nop",description:"No operation (formerly CHECKSEQUENCEVERIFY)",action:t=>{}},OP_NOP4:{code:182,category:"nop",description:"No operation (reserved for future use)",action:t=>{}},OP_NOP5:{code:183,category:"nop",description:"No operation (reserved for future use)",action:t=>{}},OP_NOP6:{code:184,category:"nop",description:"No operation (reserved for future use)",action:t=>{}},OP_NOP7:{code:185,category:"nop",description:"No operation (reserved for future use)",action:t=>{}},OP_NOP8:{code:186,category:"nop",description:"No operation (reserved for future use)",action:t=>{}},OP_NOP9:{code:187,category:"nop",description:"No operation (reserved for future use)",action:t=>{}},OP_NOP10:{code:188,category:"nop",description:"No operation (reserved for future use)",action:t=>{}},OP_RESERVED1:{code:137,category:"reserved",description:"Reserved opcode (makes transaction invalid)",action:()=>{throw new Error("OP_RESERVED1 encountered")}},OP_RESERVED2:{code:138,category:"reserved",description:"Reserved opcode (makes transaction invalid)",action:()=>{throw new Error("OP_RESERVED2 encountered")}},OP_CHECKLOCKTIMEVERIFY:{code:177,category:"disabled",description:"Check locktime (disabled post-Genesis)",action:t=>{}},OP_CHECKSEQUENCEVERIFY:{code:178,category:"disabled",description:"Check sequence (disabled post-Genesis)",action:t=>{}},OP_PUBKEYHASH:{code:253,category:"pseudo",description:"Template matching: public key hash",action:"// Template matching only"},OP_PUBKEY:{code:254,category:"pseudo",description:"Template matching: public key",action:"// Template matching only"},OP_INVALIDOPCODE:{code:255,category:"pseudo",description:"Invalid opcode placeholder",action:()=>{throw new Error("Invalid opcode encountered")}}},o={getByCategory:t=>Object.entries(i).filter(([e,r])=>r.category===t).reduce((t,[e,r])=>({...t,[e]:r}),{}),getCategories:()=>{const t=new Set;return Object.values(i).forEach(e=>t.add(e.category)),Array.from(t).sort()},createASM:e=>{const r=[];return e.forEach(e=>{if("string"==typeof e&&i[e])r.push(e);else if("number"==typeof e)if(e>=1&&e<=16)r.push("OP_"+e);else if(0===e)r.push("OP_0");else if(-1===e)r.push("OP_1NEGATE");else{const t=n.encode(e);r.push(t.toString("hex"))}else{if(!t.isBuffer(e))throw new Error("Invalid operation: "+e);r.push(e.toString("hex"))}}),r.join(" ")},simulate:(t,e=[])=>{const r=[...e],n=[],o=[];return t.forEach((t,e)=>{if(!i[t])throw new Error("Unknown opcode: "+t);const s=i[t],a=[...r];if("function"==typeof s.action)try{s.action(r,n),o.push({step:e+1,opcode:t,beforeStack:a.map(t=>t.toString("hex")),afterStack:r.map(t=>t.toString("hex")),description:s.description})}catch(r){throw o.push({step:e+1,opcode:t,beforeStack:a.map(t=>t.toString("hex")),afterStack:[],error:r.message,description:s.description}),r}else o.push({step:e+1,opcode:t,beforeStack:a.map(t=>t.toString("hex")),afterStack:a.map(t=>t.toString("hex")),note:s.action,description:s.description})}),{finalStack:r.map(t=>t.toString("hex")),finalAltStack:n.map(t=>t.toString("hex")),history:o}},opcodeToName:t=>{const e=Object.entries(i).find(([e,r])=>r.code===t);return e?e[0]:"UNKNOWN_"+t.toString(16).padStart(2,"0")},nameToOpcode:t=>i[t]&&i[t].code,generateCovenantTemplate:(e,r)=>{const n=[];return"value"===e&&(n.push("OP_SIZE"),n.push(52),n.push("OP_SUB"),n.push("OP_SPLIT"),n.push("OP_DROP"),n.push(8),n.push("OP_SPLIT"),n.push("OP_DROP")),r&&(n.push(t.from(r,"hex")),n.push("OP_EQUAL")),{operations:n,asm:o.createASM(n),description:`Extract ${e} field and compare with expected value`}}};if(e.exports={opcodeMap:i,scriptNum:n,utils:o},r.c[r.s]===e){console.log("🔧 Comprehensive Bitcoin Script Opcode Map"),console.log("=========================================="),console.log("Total opcodes mapped: "+Object.keys(i).length),console.log("\n📊 Categories:"),o.getCategories().forEach(t=>{const e=Object.values(i).filter(e=>e.category===t).length;console.log(` ${t}: ${e} opcodes`)}),console.log("\n🧪 Example: Stack manipulation simulation");try{const t=["OP_1","OP_2","OP_ADD","OP_3","OP_EQUAL"],e=o.simulate(t);console.log("Operations:",t.join(" ")),console.log("Final stack:",e.finalStack),console.log("Expected: ['01'] (true, since 1+2=3)"),console.log("\n📝 Step-by-step execution:"),e.history.forEach(t=>{console.log(` ${t.step}. ${t.opcode}: ${t.description}`),console.log(` Stack: [${t.beforeStack.join(", ")}] → [${t.afterStack.join(", ")}]`)})}catch(t){console.log("❌ Simulation error:",t.message)}console.log("\n🎯 Example: Covenant template generation");const t=o.generateCovenantTemplate("value","50c3000000000000");console.log("Generated ASM:",t.asm),console.log("Description:",t.description)}}).call(this,r(0).Buffer,r(25)(t))},function(t,e,r){"use strict";e.byteLength=function(t){var e=u(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,n=u(t),s=n[0],a=n[1],c=new o(function(t,e,r){return 3*(e+r)/4-r}(0,s,a)),f=0,h=a>0?s-4:s;for(r=0;r<h;r+=4)e=i[t.charCodeAt(r)]<<18|i[t.charCodeAt(r+1)]<<12|i[t.charCodeAt(r+2)]<<6|i[t.charCodeAt(r+3)],c[f++]=e>>16&255,c[f++]=e>>8&255,c[f++]=255&e;2===a&&(e=i[t.charCodeAt(r)]<<2|i[t.charCodeAt(r+1)]>>4,c[f++]=255&e);1===a&&(e=i[t.charCodeAt(r)]<<10|i[t.charCodeAt(r+1)]<<4|i[t.charCodeAt(r+2)]>>2,c[f++]=e>>8&255,c[f++]=255&e);return c},e.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],s=0,a=r-i;s<a;s+=16383)o.push(f(t,s,s+16383>a?a:s+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a<c;++a)n[a]=s[a],i[s.charCodeAt(a)]=a;function u(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function f(t,e,r){for(var i,o,s=[],a=e;a<r;a+=3)i=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(n[(o=i)>>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(t,e){
15
15
  /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
16
- e.read=function(t,e,r,i,n){var o,s,a=8*n-i-1,c=(1<<a)-1,u=c>>1,f=-7,h=r?n-1:0,d=r?-1:1,p=t[e+h];for(h+=d,o=p&(1<<-f)-1,p>>=-f,f+=a;f>0;o=256*o+t[e+h],h+=d,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=i;f>0;s=256*s+t[e+h],h+=d,f-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,i),o-=u}return(p?-1:1)*s*Math.pow(2,o-i)},e.write=function(t,e,r,i,n,o){var s,a,c,u=8*o-n-1,f=(1<<u)-1,h=f>>1,d=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,p=i?0:o-1,l=i?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),(e+=s+h>=1?d/c:d*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=f?(a=0,s=f):s+h>=1?(a=(e*c-1)*Math.pow(2,n),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,n),s=0));n>=8;t[r+p]=255&a,p+=l,a/=256,n-=8);for(s=s<<n|a,u+=n;u>0;t[r+p]=255&s,p+=l,s/=256,u-=8);t[r+p-l]|=128*g}},function(t,e){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},function(t,e){},function(t,e,r){"use strict";var i=r(83).Buffer;t.exports=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var n=0;n<t.length;n++){var o=t.charAt(n),s=o.charCodeAt(0);if(255!==e[s])throw new TypeError(o+" is ambiguous");e[s]=n}var a=t.length,c=t.charAt(0),u=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function h(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return i.alloc(0);for(var r=0,n=0,o=0;t[r]===c;)n++,r++;for(var s=(t.length-r)*u+1>>>0,f=new Uint8Array(s);r<t.length;){var h=t.charCodeAt(r);if(h>255)return;var d=e[h];if(255===d)return;for(var p=0,l=s-1;(0!==d||p<o)&&-1!==l;l--,p++)d+=a*f[l]>>>0,f[l]=d%256>>>0,d=d/256>>>0;if(0!==d)throw new Error("Non-zero carry");o=p,r++}for(var g=s-o;g!==s&&0===f[g];)g++;var m=i.allocUnsafe(n+(s-g));m.fill(0,0,n);for(var b=n;g!==s;)m[b++]=f[g++];return m}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=i.from(e)),!i.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,n=0,o=0,s=e.length;o!==s&&0===e[o];)o++,r++;for(var u=(s-o)*f+1>>>0,h=new Uint8Array(u);o!==s;){for(var d=e[o],p=0,l=u-1;(0!==d||p<n)&&-1!==l;l--,p++)d+=256*h[l]>>>0,h[l]=d%a>>>0,d=d/a>>>0;if(0!==d)throw new Error("Non-zero carry");n=p,o++}for(var g=u-n;g!==u&&0===h[g];)g++;for(var m=c.repeat(r);g<u;++g)m+=t.charAt(h[g]);return m},decodeUnsafe:h,decode:function(t){var e=h(t);if(e)return e;throw new Error("Non-base"+a+" character")}}}},function(t,e,r){
16
+ e.read=function(t,e,r,n,i){var o,s,a=8*i-n-1,c=(1<<a)-1,u=c>>1,f=-7,h=r?i-1:0,d=r?-1:1,p=t[e+h];for(h+=d,o=p&(1<<-f)-1,p>>=-f,f+=a;f>0;o=256*o+t[e+h],h+=d,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+t[e+h],h+=d,f-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=u}return(p?-1:1)*s*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var s,a,c,u=8*o-i-1,f=(1<<u)-1,h=f>>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,l=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),(e+=s+h>=1?d/c:d*Math.pow(2,1-h))*c>=2&&(s++,c/=2),s+h>=f?(a=0,s=f):s+h>=1?(a=(e*c-1)*Math.pow(2,i),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[r+p]=255&a,p+=l,a/=256,i-=8);for(s=s<<i|a,u+=i;u>0;t[r+p]=255&s,p+=l,s/=256,u-=8);t[r+p-l]|=128*g}},function(t,e){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},function(t,e){},function(t,e,r){"use strict";var n=r(84).Buffer;t.exports=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var i=0;i<t.length;i++){var o=t.charAt(i),s=o.charCodeAt(0);if(255!==e[s])throw new TypeError(o+" is ambiguous");e[s]=i}var a=t.length,c=t.charAt(0),u=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function h(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return n.alloc(0);for(var r=0,i=0,o=0;t[r]===c;)i++,r++;for(var s=(t.length-r)*u+1>>>0,f=new Uint8Array(s);r<t.length;){var h=t.charCodeAt(r);if(h>255)return;var d=e[h];if(255===d)return;for(var p=0,l=s-1;(0!==d||p<o)&&-1!==l;l--,p++)d+=a*f[l]>>>0,f[l]=d%256>>>0,d=d/256>>>0;if(0!==d)throw new Error("Non-zero carry");o=p,r++}for(var g=s-o;g!==s&&0===f[g];)g++;var m=n.allocUnsafe(i+(s-g));m.fill(0,0,i);for(var b=i;g!==s;)m[b++]=f[g++];return m}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,s=e.length;o!==s&&0===e[o];)o++,r++;for(var u=(s-o)*f+1>>>0,h=new Uint8Array(u);o!==s;){for(var d=e[o],p=0,l=u-1;(0!==d||p<i)&&-1!==l;l--,p++)d+=256*h[l]>>>0,h[l]=d%a>>>0,d=d/a>>>0;if(0!==d)throw new Error("Non-zero carry");i=p,o++}for(var g=u-i;g!==u&&0===h[g];)g++;for(var m=c.repeat(r);g<u;++g)m+=t.charAt(h[g]);return m},decodeUnsafe:h,decode:function(t){var e=h(t);if(e)return e;throw new Error("Non-base"+a+" character")}}}},function(t,e,r){
17
17
  /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
18
- var i=r(0),n=i.Buffer;function o(t,e){for(var r in t)e[r]=t[r]}function s(t,e,r){return n(t,e,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?t.exports=i:(o(i,e),e.Buffer=s),s.prototype=Object.create(n.prototype),o(n,s),s.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return n(t,e,r)},s.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var i=n(t);return void 0!==e?"string"==typeof r?i.fill(e,r):i.fill(e):i.fill(0),i},s.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n(t)},s.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i.SlowBuffer(t)}},function(t){t.exports={name:"elliptic",version:"6.6.1",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(t,e){},function(t,e,r){"use strict";var i=r(8),n=r(9),o=r(42),s=r(32),a=i.assert;function c(t){s.call(this,"short",t),this.a=new n(t.a,16).toRed(this.red),this.b=new n(t.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(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function u(t,e,r,i){s.BasePoint.call(this,t,"affine"),null===e&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new n(e,16),this.y=new n(r,16),i&&(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(t,e,r,i){s.BasePoint.call(this,t,"jacobian"),null===e&&null===r&&null===i?(this.x=this.curve.one,this.y=this.curve.one,this.z=new n(0)):(this.x=new n(e,16),this.y=new n(r,16),this.z=new n(i,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(c,s),t.exports=c,c.prototype._getEndomorphism=function(t){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,r;if(t.beta)e=new n(t.beta,16).toRed(this.red);else{var i=this._getEndoRoots(this.p);e=(e=i[0].cmp(i[1])<0?i[0]:i[1]).toRed(this.red)}if(t.lambda)r=new n(t.lambda,16);else{var o=this._getEndoRoots(this.n);0===this.g.mul(o[0]).x.cmp(this.g.x.redMul(e))?r=o[0]:(r=o[1],a(0===this.g.mul(r).x.cmp(this.g.x.redMul(e))))}return{beta:e,lambda:r,basis:t.basis?t.basis.map((function(t){return{a:new n(t.a,16),b:new n(t.b,16)}})):this._getEndoBasis(r)}}},c.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:n.mont(t),r=new n(2).toRed(e).redInvm(),i=r.redNeg(),o=new n(3).toRed(e).redNeg().redSqrt().redMul(r);return[i.redAdd(o).fromRed(),i.redSub(o).fromRed()]},c.prototype._getEndoBasis=function(t){for(var e,r,i,o,s,a,c,u,f,h=this.n.ushrn(Math.floor(this.n.bitLength()/2)),d=t,p=this.n.clone(),l=new n(1),g=new n(0),m=new n(0),b=new n(1),y=0;0!==d.cmpn(0);){var v=p.div(d);u=p.sub(v.mul(d)),f=m.sub(v.mul(l));var S=b.sub(v.mul(g));if(!i&&u.cmp(h)<0)e=c.neg(),r=l,i=u.neg(),o=f;else if(i&&2==++y)break;c=u,p=d,d=u,m=l,l=f,b=g,g=S}s=u.neg(),a=f;var _=i.sqr().add(o.sqr());return s.sqr().add(a.sqr()).cmp(_)>=0&&(s=e,a=r),i.negative&&(i=i.neg(),o=o.neg()),s.negative&&(s=s.neg(),a=a.neg()),[{a:i,b:o},{a:s,b:a}]},c.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],i=e[1],n=i.b.mul(t).divRound(this.n),o=r.b.neg().mul(t).divRound(this.n),s=n.mul(r.a),a=o.mul(i.a),c=n.mul(r.b),u=o.mul(i.b);return{k1:t.sub(s).sub(a),k2:c.add(u).neg()}},c.prototype.pointFromX=function(t,e){(t=new n(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),i=r.redSqrt();if(0!==i.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var o=i.fromRed().isOdd();return(e&&!o||!e&&o)&&(i=i.redNeg()),this.point(t,i)},c.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,i=this.a.redMul(e),n=e.redSqr().redMul(e).redIAdd(i).redIAdd(this.b);return 0===r.redSqr().redISub(n).cmpn(0)},c.prototype._endoWnafMulAdd=function(t,e,r){for(var i=this._endoWnafT1,n=this._endoWnafT2,o=0;o<t.length;o++){var s=this._endoSplit(e[o]),a=t[o],c=a._getBeta();s.k1.negative&&(s.k1.ineg(),a=a.neg(!0)),s.k2.negative&&(s.k2.ineg(),c=c.neg(!0)),i[2*o]=a,i[2*o+1]=c,n[2*o]=s.k1,n[2*o+1]=s.k2}for(var u=this._wnafMulAdd(1,i,n,2*o,r),f=0;f<2*o;f++)i[f]=null,n[f]=null;return u},o(u,s.BasePoint),c.prototype.point=function(t,e,r){return new u(this,t,e,r)},c.prototype.pointFromJSON=function(t,e){return u.fromJSON(this,t,e)},u.prototype._getBeta=function(){if(this.curve.endo){var t=this.precomputed;if(t&&t.beta)return t.beta;var e=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(t){var r=this.curve,i=function(t){return r.point(t.x.redMul(r.endo.beta),t.y)};t.beta=e,e.precomputed={beta:null,naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(i)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(i)}}}return e}},u.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]},u.fromJSON=function(t,e,r){"string"==typeof e&&(e=JSON.parse(e));var i=t.point(e[0],e[1],r);if(!e[2])return i;function n(e){return t.point(e[0],e[1],r)}var o=e[2];return i.precomputed={beta:null,doubles:o.doubles&&{step:o.doubles.step,points:[i].concat(o.doubles.points.map(n))},naf:o.naf&&{wnd:o.naf.wnd,points:[i].concat(o.naf.points.map(n))}},i},u.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)+">"},u.prototype.isInfinity=function(){return this.inf},u.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),i=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,i)},u.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),i=t.redInvm(),n=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(i),o=n.redSqr().redISub(this.x.redAdd(this.x)),s=n.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,s)},u.prototype.getX=function(){return this.x.fromRed()},u.prototype.getY=function(){return this.y.fromRed()},u.prototype.mul=function(t){return t=new n(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},u.prototype.mulAdd=function(t,e,r){var i=[this,e],n=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n):this.curve._wnafMulAdd(1,i,n,2)},u.prototype.jmulAdd=function(t,e,r){var i=[this,e],n=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n,!0):this.curve._wnafMulAdd(1,i,n,2,!0)},u.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},u.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,i=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(i)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(i)}}}return e},u.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},o(f,s.BasePoint),c.prototype.jpoint=function(t,e,r){return new f(this,t,e,r)},f.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),i=this.y.redMul(e).redMul(t);return this.curve.point(r,i)},f.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},f.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),i=this.x.redMul(e),n=t.x.redMul(r),o=this.y.redMul(e.redMul(t.z)),s=t.y.redMul(r.redMul(this.z)),a=i.redSub(n),c=o.redSub(s);if(0===a.cmpn(0))return 0!==c.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),f=u.redMul(a),h=i.redMul(u),d=c.redSqr().redIAdd(f).redISub(h).redISub(h),p=c.redMul(h.redISub(d)).redISub(o.redMul(f)),l=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(d,p,l)},f.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,i=t.x.redMul(e),n=this.y,o=t.y.redMul(e).redMul(this.z),s=r.redSub(i),a=n.redSub(o);if(0===s.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=s.redSqr(),u=c.redMul(s),f=r.redMul(c),h=a.redSqr().redIAdd(u).redISub(f).redISub(f),d=a.redMul(f.redISub(h)).redISub(n.redMul(u)),p=this.z.redMul(s);return this.curve.jpoint(h,d,p)},f.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var r=this;for(e=0;e<t;e++)r=r.dbl();return r}var i=this.curve.a,n=this.curve.tinv,o=this.x,s=this.y,a=this.z,c=a.redSqr().redSqr(),u=s.redAdd(s);for(e=0;e<t;e++){var f=o.redSqr(),h=u.redSqr(),d=h.redSqr(),p=f.redAdd(f).redIAdd(f).redIAdd(i.redMul(c)),l=o.redMul(h),g=p.redSqr().redISub(l.redAdd(l)),m=l.redISub(g),b=p.redMul(m);b=b.redIAdd(b).redISub(d);var y=u.redMul(a);e+1<t&&(c=c.redMul(d)),o=g,a=y,u=b}return this.curve.jpoint(o,u.redMul(n),a)},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 t,e,r;if(this.zOne){var i=this.x.redSqr(),n=this.y.redSqr(),o=n.redSqr(),s=this.x.redAdd(n).redSqr().redISub(i).redISub(o);s=s.redIAdd(s);var a=i.redAdd(i).redIAdd(i),c=a.redSqr().redISub(s).redISub(s),u=o.redIAdd(o);u=(u=u.redIAdd(u)).redIAdd(u),t=c,e=a.redMul(s.redISub(c)).redISub(u),r=this.y.redAdd(this.y)}else{var f=this.x.redSqr(),h=this.y.redSqr(),d=h.redSqr(),p=this.x.redAdd(h).redSqr().redISub(f).redISub(d);p=p.redIAdd(p);var l=f.redAdd(f).redIAdd(f),g=l.redSqr(),m=d.redIAdd(d);m=(m=m.redIAdd(m)).redIAdd(m),t=g.redISub(p).redISub(p),e=l.redMul(p.redISub(t)).redISub(m),r=(r=this.y.redMul(this.z)).redIAdd(r)}return this.curve.jpoint(t,e,r)},f.prototype._threeDbl=function(){var t,e,r;if(this.zOne){var i=this.x.redSqr(),n=this.y.redSqr(),o=n.redSqr(),s=this.x.redAdd(n).redSqr().redISub(i).redISub(o);s=s.redIAdd(s);var a=i.redAdd(i).redIAdd(i).redIAdd(this.curve.a),c=a.redSqr().redISub(s).redISub(s);t=c;var u=o.redIAdd(o);u=(u=u.redIAdd(u)).redIAdd(u),e=a.redMul(s.redISub(c)).redISub(u),r=this.y.redAdd(this.y)}else{var f=this.z.redSqr(),h=this.y.redSqr(),d=this.x.redMul(h),p=this.x.redSub(f).redMul(this.x.redAdd(f));p=p.redAdd(p).redIAdd(p);var l=d.redIAdd(d),g=(l=l.redIAdd(l)).redAdd(l);t=p.redSqr().redISub(g),r=this.y.redAdd(this.z).redSqr().redISub(h).redISub(f);var m=h.redSqr();m=(m=(m=m.redIAdd(m)).redIAdd(m)).redIAdd(m),e=p.redMul(l.redISub(t)).redISub(m)}return this.curve.jpoint(t,e,r)},f.prototype._dbl=function(){var t=this.curve.a,e=this.x,r=this.y,i=this.z,n=i.redSqr().redSqr(),o=e.redSqr(),s=r.redSqr(),a=o.redAdd(o).redIAdd(o).redIAdd(t.redMul(n)),c=e.redAdd(e),u=(c=c.redIAdd(c)).redMul(s),f=a.redSqr().redISub(u.redAdd(u)),h=u.redISub(f),d=s.redSqr();d=(d=(d=d.redIAdd(d)).redIAdd(d)).redIAdd(d);var p=a.redMul(h).redISub(d),l=r.redAdd(r).redMul(i);return this.curve.jpoint(f,p,l)},f.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr(),i=e.redSqr(),n=t.redAdd(t).redIAdd(t),o=n.redSqr(),s=this.x.redAdd(e).redSqr().redISub(t).redISub(i),a=(s=(s=(s=s.redIAdd(s)).redAdd(s).redIAdd(s)).redISub(o)).redSqr(),c=i.redIAdd(i);c=(c=(c=c.redIAdd(c)).redIAdd(c)).redIAdd(c);var u=n.redIAdd(s).redSqr().redISub(o).redISub(a).redISub(c),f=e.redMul(u);f=(f=f.redIAdd(f)).redIAdd(f);var h=this.x.redMul(a).redISub(f);h=(h=h.redIAdd(h)).redIAdd(h);var d=this.y.redMul(u.redMul(c.redISub(u)).redISub(s.redMul(a)));d=(d=(d=d.redIAdd(d)).redIAdd(d)).redIAdd(d);var p=this.z.redAdd(s).redSqr().redISub(r).redISub(a);return this.curve.jpoint(h,d,p)},f.prototype.mul=function(t,e){return t=new n(t,e),this.curve._wnafMul(this,t)},f.prototype.eq=function(t){if("affine"===t.type)return this.eq(t.toJ());if(this===t)return!0;var e=this.z.redSqr(),r=t.z.redSqr();if(0!==this.x.redMul(r).redISub(t.x.redMul(e)).cmpn(0))return!1;var i=e.redMul(this.z),n=r.redMul(t.z);return 0===this.y.redMul(n).redISub(t.y.redMul(i)).cmpn(0)},f.prototype.eqXToP=function(t){var e=this.z.redSqr(),r=t.toRed(this.curve.red).redMul(e);if(0===this.x.cmp(r))return!0;for(var i=t.clone(),n=this.curve.redN.redMul(e);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(r.redIAdd(n),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(t,e,r){"use strict";var i=r(9),n=r(42),o=r(32),s=r(8);function a(t){o.call(this,"mont",t),this.a=new i(t.a,16).toRed(this.red),this.b=new i(t.b,16).toRed(this.red),this.i4=new i(4).toRed(this.red).redInvm(),this.two=new i(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function c(t,e,r){o.BasePoint.call(this,t,"projective"),null===e&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new i(e,16),this.z=new i(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}n(a,o),t.exports=a,a.prototype.validate=function(t){var e=t.normalize().x,r=e.redSqr(),i=r.redMul(e).redAdd(r.redMul(this.a)).redAdd(e);return 0===i.redSqrt().redSqr().cmp(i)},n(c,o.BasePoint),a.prototype.decodePoint=function(t,e){return this.point(s.toArray(t,e),1)},a.prototype.point=function(t,e){return new c(this,t,e)},a.prototype.pointFromJSON=function(t){return c.fromJSON(this,t)},c.prototype.precompute=function(){},c.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},c.fromJSON=function(t,e){return new c(t,e[0],e[1]||t.one)},c.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)+">"},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},c.prototype.dbl=function(){var t=this.x.redAdd(this.z).redSqr(),e=this.x.redSub(this.z).redSqr(),r=t.redSub(e),i=t.redMul(e),n=r.redMul(e.redAdd(this.curve.a24.redMul(r)));return this.curve.point(i,n)},c.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.diffAdd=function(t,e){var r=this.x.redAdd(this.z),i=this.x.redSub(this.z),n=t.x.redAdd(t.z),o=t.x.redSub(t.z).redMul(r),s=n.redMul(i),a=e.z.redMul(o.redAdd(s).redSqr()),c=e.x.redMul(o.redISub(s).redSqr());return this.curve.point(a,c)},c.prototype.mul=function(t){for(var e=t.clone(),r=this,i=this.curve.point(null,null),n=[];0!==e.cmpn(0);e.iushrn(1))n.push(e.andln(1));for(var o=n.length-1;o>=0;o--)0===n[o]?(r=r.diffAdd(i,this),i=i.dbl()):(i=r.diffAdd(i,this),r=r.dbl());return i},c.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.eq=function(t){return 0===this.getX().cmp(t.getX())},c.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},c.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},function(t,e,r){"use strict";var i=r(8),n=r(9),o=r(42),s=r(32),a=i.assert;function c(t){this.twisted=1!=(0|t.a),this.mOneA=this.twisted&&-1==(0|t.a),this.extended=this.mOneA,s.call(this,"edwards",t),this.a=new n(t.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new n(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new n(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),a(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|t.c)}function u(t,e,r,i,o){s.BasePoint.call(this,t,"projective"),null===e&&null===r&&null===i?(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 n(e,16),this.y=new n(r,16),this.z=i?new n(i,16):this.curve.one,this.t=o&&new n(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(c,s),t.exports=c,c.prototype._mulA=function(t){return this.mOneA?t.redNeg():this.a.redMul(t)},c.prototype._mulC=function(t){return this.oneC?t:this.c.redMul(t)},c.prototype.jpoint=function(t,e,r,i){return this.point(t,e,r,i)},c.prototype.pointFromX=function(t,e){(t=new n(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr(),i=this.c2.redSub(this.a.redMul(r)),o=this.one.redSub(this.c2.redMul(this.d).redMul(r)),s=i.redMul(o.redInvm()),a=s.redSqrt();if(0!==a.redSqr().redSub(s).cmp(this.zero))throw new Error("invalid point");var c=a.fromRed().isOdd();return(e&&!c||!e&&c)&&(a=a.redNeg()),this.point(t,a)},c.prototype.pointFromY=function(t,e){(t=new n(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr(),i=r.redSub(this.c2),o=r.redMul(this.d).redMul(this.c2).redSub(this.a),s=i.redMul(o.redInvm());if(0===s.cmp(this.zero)){if(e)throw new Error("invalid point");return this.point(this.zero,t)}var a=s.redSqrt();if(0!==a.redSqr().redSub(s).cmp(this.zero))throw new Error("invalid point");return a.fromRed().isOdd()!==e&&(a=a.redNeg()),this.point(a,t)},c.prototype.validate=function(t){if(t.isInfinity())return!0;t.normalize();var e=t.x.redSqr(),r=t.y.redSqr(),i=e.redMul(this.a).redAdd(r),n=this.c2.redMul(this.one.redAdd(this.d.redMul(e).redMul(r)));return 0===i.cmp(n)},o(u,s.BasePoint),c.prototype.pointFromJSON=function(t){return u.fromJSON(this,t)},c.prototype.point=function(t,e,r,i){return new u(this,t,e,r,i)},u.fromJSON=function(t,e){return new u(t,e[0],e[1],e[2])},u.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)+">"},u.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},u.prototype._extDbl=function(){var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var i=this.curve._mulA(t),n=this.x.redAdd(this.y).redSqr().redISub(t).redISub(e),o=i.redAdd(e),s=o.redSub(r),a=i.redSub(e),c=n.redMul(s),u=o.redMul(a),f=n.redMul(a),h=s.redMul(o);return this.curve.point(c,u,h,f)},u.prototype._projDbl=function(){var t,e,r,i,n,o,s=this.x.redAdd(this.y).redSqr(),a=this.x.redSqr(),c=this.y.redSqr();if(this.curve.twisted){var u=(i=this.curve._mulA(a)).redAdd(c);this.zOne?(t=s.redSub(a).redSub(c).redMul(u.redSub(this.curve.two)),e=u.redMul(i.redSub(c)),r=u.redSqr().redSub(u).redSub(u)):(n=this.z.redSqr(),o=u.redSub(n).redISub(n),t=s.redSub(a).redISub(c).redMul(o),e=u.redMul(i.redSub(c)),r=u.redMul(o))}else i=a.redAdd(c),n=this.curve._mulC(this.z).redSqr(),o=i.redSub(n).redSub(n),t=this.curve._mulC(s.redISub(i)).redMul(o),e=this.curve._mulC(i).redMul(a.redISub(c)),r=i.redMul(o);return this.curve.point(t,e,r)},u.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},u.prototype._extAdd=function(t){var e=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),r=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),i=this.t.redMul(this.curve.dd).redMul(t.t),n=this.z.redMul(t.z.redAdd(t.z)),o=r.redSub(e),s=n.redSub(i),a=n.redAdd(i),c=r.redAdd(e),u=o.redMul(s),f=a.redMul(c),h=o.redMul(c),d=s.redMul(a);return this.curve.point(u,f,d,h)},u.prototype._projAdd=function(t){var e,r,i=this.z.redMul(t.z),n=i.redSqr(),o=this.x.redMul(t.x),s=this.y.redMul(t.y),a=this.curve.d.redMul(o).redMul(s),c=n.redSub(a),u=n.redAdd(a),f=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(o).redISub(s),h=i.redMul(c).redMul(f);return this.curve.twisted?(e=i.redMul(u).redMul(s.redSub(this.curve._mulA(o))),r=c.redMul(u)):(e=i.redMul(u).redMul(s.redSub(o)),r=this.curve._mulC(c).redMul(u)),this.curve.point(h,e,r)},u.prototype.add=function(t){return this.isInfinity()?t:t.isInfinity()?this:this.curve.extended?this._extAdd(t):this._projAdd(t)},u.prototype.mul=function(t){return this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve._wnafMul(this,t)},u.prototype.mulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!1)},u.prototype.jmulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!0)},u.prototype.normalize=function(){if(this.zOne)return this;var t=this.z.redInvm();return this.x=this.x.redMul(t),this.y=this.y.redMul(t),this.t&&(this.t=this.t.redMul(t)),this.z=this.curve.one,this.zOne=!0,this},u.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},u.prototype.getX=function(){return this.normalize(),this.x.fromRed()},u.prototype.getY=function(){return this.normalize(),this.y.fromRed()},u.prototype.eq=function(t){return this===t||0===this.getX().cmp(t.getX())&&0===this.getY().cmp(t.getY())},u.prototype.eqXToP=function(t){var e=t.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(e))return!0;for(var r=t.clone(),i=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(e.redIAdd(i),0===this.x.cmp(e))return!0}},u.prototype.toP=u.prototype.normalize,u.prototype.mixedAdd=u.prototype.add},function(t,e,r){"use strict";e.sha1=r(90),e.sha224=r(91),e.sha256=r(59),e.sha384=r(92),e.sha512=r(60)},function(t,e,r){"use strict";var i=r(13),n=r(26),o=r(58),s=i.rotl32,a=i.sum32,c=i.sum32_5,u=o.ft_1,f=n.BlockHash,h=[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)}i.inherits(d,f),t.exports=d,d.blockSize=512,d.outSize=160,d.hmacStrength=80,d.padLength=64,d.prototype._update=function(t,e){for(var r=this.W,i=0;i<16;i++)r[i]=t[e+i];for(;i<r.length;i++)r[i]=s(r[i-3]^r[i-8]^r[i-14]^r[i-16],1);var n=this.h[0],o=this.h[1],f=this.h[2],d=this.h[3],p=this.h[4];for(i=0;i<r.length;i++){var l=~~(i/20),g=c(s(n,5),u(l,o,f,d),p,r[i],h[l]);p=d,d=f,f=s(o,30),o=n,n=g}this.h[0]=a(this.h[0],n),this.h[1]=a(this.h[1],o),this.h[2]=a(this.h[2],f),this.h[3]=a(this.h[3],d),this.h[4]=a(this.h[4],p)},d.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h,"big"):i.split32(this.h,"big")}},function(t,e,r){"use strict";var i=r(13),n=r(59);function o(){if(!(this instanceof o))return new o;n.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}i.inherits(o,n),t.exports=o,o.blockSize=512,o.outSize=224,o.hmacStrength=192,o.padLength=64,o.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h.slice(0,7),"big"):i.split32(this.h.slice(0,7),"big")}},function(t,e,r){"use strict";var i=r(13),n=r(60);function o(){if(!(this instanceof o))return new o;n.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}i.inherits(o,n),t.exports=o,o.blockSize=1024,o.outSize=384,o.hmacStrength=192,o.padLength=128,o.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h.slice(0,12),"big"):i.split32(this.h.slice(0,12),"big")}},function(t,e,r){"use strict";var i=r(13),n=r(26),o=i.rotl32,s=i.sum32,a=i.sum32_3,c=i.sum32_4,u=n.BlockHash;function f(){if(!(this instanceof f))return new f;u.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}function h(t,e,r,i){return t<=15?e^r^i:t<=31?e&r|~e&i:t<=47?(e|~r)^i:t<=63?e&i|r&~i:e^(r|~i)}function d(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function p(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}i.inherits(f,u),e.ripemd160=f,f.blockSize=512,f.outSize=160,f.hmacStrength=192,f.padLength=64,f.prototype._update=function(t,e){for(var r=this.h[0],i=this.h[1],n=this.h[2],u=this.h[3],f=this.h[4],y=r,v=i,S=n,_=u,w=f,I=0;I<80;I++){var O=s(o(c(r,h(I,i,n,u),t[l[I]+e],d(I)),m[I]),f);r=f,f=u,u=o(n,10),n=i,i=O,O=s(o(c(y,h(79-I,v,S,_),t[g[I]+e],p(I)),b[I]),w),y=w,w=_,_=o(S,10),S=v,v=O}O=a(this.h[1],n,_),this.h[1]=a(this.h[2],u,w),this.h[2]=a(this.h[3],f,y),this.h[3]=a(this.h[4],r,v),this.h[4]=a(this.h[0],i,S),this.h[0]=O},f.prototype._digest=function(t){return"hex"===t?i.toHex32(this.h,"little"):i.split32(this.h,"little")};var l=[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],g=[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],b=[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(t,e,r){"use strict";var i=r(13),n=r(21);function o(t,e,r){if(!(this instanceof o))return new o(t,e,r);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(i.toArray(e,r))}t.exports=o,o.prototype._init=function(t){t.length>this.blockSize&&(t=(new this.Hash).update(t).digest()),n(t.length<=this.blockSize);for(var e=t.length;e<this.blockSize;e++)t.push(0);for(e=0;e<t.length;e++)t[e]^=54;for(this.inner=(new this.Hash).update(t),e=0;e<t.length;e++)t[e]^=106;this.outer=(new this.Hash).update(t)},o.prototype.update=function(t,e){return this.inner.update(t,e),this},o.prototype.digest=function(t){return this.outer.update(this.inner.digest()),this.outer.digest(t)}},function(t,e){t.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(t,e,r){"use strict";var i=r(9),n=r(97),o=r(8),s=r(43),a=r(56),c=o.assert,u=r(98),f=r(99);function h(t){if(!(this instanceof h))return new h(t);"string"==typeof t&&(c(Object.prototype.hasOwnProperty.call(s,t),"Unknown curve "+t),t=s[t]),t instanceof s.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}t.exports=h,h.prototype.keyPair=function(t){return new u(this,t)},h.prototype.keyFromPrivate=function(t,e){return u.fromPrivate(this,t,e)},h.prototype.keyFromPublic=function(t,e){return u.fromPublic(this,t,e)},h.prototype.genKeyPair=function(t){t||(t={});for(var e=new n({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||a(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),o=this.n.sub(new i(2));;){var s=new i(e.generate(r));if(!(s.cmp(o)>0))return s.iaddn(1),this.keyFromPrivate(s)}},h.prototype._truncateToN=function(t,e,r){var n;if(i.isBN(t)||"number"==typeof t)n=(t=new i(t,16)).byteLength();else if("object"==typeof t)n=t.length,t=new i(t,16);else{var o=t.toString();n=o.length+1>>>1,t=new i(o,16)}"number"!=typeof r&&(r=8*n);var s=r-this.n.bitLength();return s>0&&(t=t.ushrn(s)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},h.prototype.sign=function(t,e,r,o){if("object"==typeof r&&(o=r,r=null),o||(o={}),"string"!=typeof t&&"number"!=typeof t&&!i.isBN(t)){c("object"==typeof t&&t&&"number"==typeof t.length,"Expected message to be an array-like, a hex string, or a BN instance"),c(t.length>>>0===t.length);for(var s=0;s<t.length;s++)c((255&t[s])===t[s])}e=this.keyFromPrivate(e,r),t=this._truncateToN(t,!1,o.msgBitLength),c(!t.isNeg(),"Can not sign a negative message");var a=this.n.byteLength(),u=e.getPrivate().toArray("be",a),h=t.toArray("be",a);c(new i(h).eq(t),"Can not sign message");for(var d=new n({hash:this.hash,entropy:u,nonce:h,pers:o.pers,persEnc:o.persEnc||"utf8"}),p=this.n.sub(new i(1)),l=0;;l++){var g=o.k?o.k(l):new i(d.generate(this.n.byteLength()));if(!((g=this._truncateToN(g,!0)).cmpn(1)<=0||g.cmp(p)>=0)){var m=this.g.mul(g);if(!m.isInfinity()){var b=m.getX(),y=b.umod(this.n);if(0!==y.cmpn(0)){var v=g.invm(this.n).mul(y.mul(e.getPrivate()).iadd(t));if(0!==(v=v.umod(this.n)).cmpn(0)){var S=(m.getY().isOdd()?1:0)|(0!==b.cmp(y)?2:0);return o.canonical&&v.cmp(this.nh)>0&&(v=this.n.sub(v),S^=1),new f({r:y,s:v,recoveryParam:S})}}}}}},h.prototype.verify=function(t,e,r,i,n){n||(n={}),t=this._truncateToN(t,!1,n.msgBitLength),r=this.keyFromPublic(r,i);var o=(e=new f(e,"hex")).r,s=e.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var a,c=s.invm(this.n),u=c.mul(t).umod(this.n),h=c.mul(o).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(u,r.getPublic(),h)).isInfinity()&&a.eqXToP(o):!(a=this.g.mulAdd(u,r.getPublic(),h)).isInfinity()&&0===a.getX().umod(this.n).cmp(o)},h.prototype.recoverPubKey=function(t,e,r,n){c((3&r)===r,"The recovery param is more than two bits"),e=new f(e,n);var o=this.n,s=new i(t),a=e.r,u=e.s,h=1&r,d=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&d)throw new Error("Unable to find sencond key candinate");a=d?this.curve.pointFromX(a.add(this.curve.n),h):this.curve.pointFromX(a,h);var p=e.r.invm(o),l=o.sub(s).mul(p).umod(o),g=u.mul(p).umod(o);return this.g.mulAdd(l,a,g)},h.prototype.getKeyRecoveryParam=function(t,e,r,i){if(null!==(e=new f(e,i)).recoveryParam)return e.recoveryParam;for(var n=0;n<4;n++){var o;try{o=this.recoverPubKey(t,e,n)}catch(t){continue}if(o.eq(r))return n}throw new Error("Unable to find valid recovery factor")}},function(t,e,r){"use strict";var i=r(33),n=r(55),o=r(21);function s(t){if(!(this instanceof s))return new s(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=n.toArray(t.entropy,t.entropyEnc||"hex"),r=n.toArray(t.nonce,t.nonceEnc||"hex"),i=n.toArray(t.pers,t.persEnc||"hex");o(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,i)}t.exports=s,s.prototype._init=function(t,e,r){var i=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var n=0;n<this.V.length;n++)this.K[n]=0,this.V[n]=1;this._update(i),this._reseed=1,this.reseedInterval=281474976710656},s.prototype._hmac=function(){return new i.hmac(this.hash,this.K)},s.prototype._update=function(t){var e=this._hmac().update(this.V).update([0]);t&&(e=e.update(t)),this.K=e.digest(),this.V=this._hmac().update(this.V).digest(),t&&(this.K=this._hmac().update(this.V).update([1]).update(t).digest(),this.V=this._hmac().update(this.V).digest())},s.prototype.reseed=function(t,e,r,i){"string"!=typeof e&&(i=r,r=e,e=null),t=n.toArray(t,e),r=n.toArray(r,i),o(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},s.prototype.generate=function(t,e,r,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(i=r,r=e,e=null),r&&(r=n.toArray(r,i||"hex"),this._update(r));for(var o=[];o.length<t;)this.V=this._hmac().update(this.V).digest(),o=o.concat(this.V);var s=o.slice(0,t);return this._update(r),this._reseed++,n.encode(s,e)}},function(t,e,r){"use strict";var i=r(9),n=r(8).assert;function o(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}t.exports=o,o.fromPublic=function(t,e,r){return e instanceof o?e:new o(t,{pub:e,pubEnc:r})},o.fromPrivate=function(t,e,r){return e instanceof o?e:new o(t,{priv:e,privEnc:r})},o.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.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(t,e){return"string"==typeof t&&(e=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,t):this.pub},o.prototype.getPrivate=function(t){return"hex"===t?this.priv.toString(16,2):this.priv},o.prototype._importPrivate=function(t,e){this.priv=new i(t,e||16),this.priv=this.priv.umod(this.ec.curve.n)},o.prototype._importPublic=function(t,e){if(t.x||t.y)return"mont"===this.ec.curve.type?n(t.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||n(t.x&&t.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(t.x,t.y));this.pub=this.ec.curve.decodePoint(t,e)},o.prototype.derive=function(t){return t.validate()||n(t.validate(),"public point not validated"),t.mul(this.priv).getX()},o.prototype.sign=function(t,e,r){return this.ec.sign(t,this,e,r)},o.prototype.verify=function(t,e,r){return this.ec.verify(t,e,this,void 0,r)},o.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"}},function(t,e,r){"use strict";var i=r(9),n=r(8),o=n.assert;function s(t,e){if(t instanceof s)return t;this._importDER(t,e)||(o(t.r&&t.s,"Signature without r or s"),this.r=new i(t.r,16),this.s=new i(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}function a(){this.place=0}function c(t,e){var r=t[e.place++];if(!(128&r))return r;var i=15&r;if(0===i||i>4)return!1;if(0===t[e.place])return!1;for(var n=0,o=0,s=e.place;o<i;o++,s++)n<<=8,n|=t[s],n>>>=0;return!(n<=127)&&(e.place=s,n)}function u(t){for(var e=0,r=t.length-1;!t[e]&&!(128&t[e+1])&&e<r;)e++;return 0===e?t:t.slice(e)}function f(t,e){if(e<128)t.push(e);else{var r=1+(Math.log(e)/Math.LN2>>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}t.exports=s,s.prototype._importDER=function(t,e){t=n.toArray(t,e);var r=new a;if(48!==t[r.place++])return!1;var o=c(t,r);if(!1===o)return!1;if(o+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var s=c(t,r);if(!1===s)return!1;if(0!=(128&t[r.place]))return!1;var u=t.slice(r.place,s+r.place);if(r.place+=s,2!==t[r.place++])return!1;var f=c(t,r);if(!1===f)return!1;if(t.length!==f+r.place)return!1;if(0!=(128&t[r.place]))return!1;var h=t.slice(r.place,f+r.place);if(0===u[0]){if(!(128&u[1]))return!1;u=u.slice(1)}if(0===h[0]){if(!(128&h[1]))return!1;h=h.slice(1)}return this.r=new i(u),this.s=new i(h),this.recoveryParam=null,!0},s.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=u(e),r=u(r);!(r[0]||128&r[1]);)r=r.slice(1);var i=[2];f(i,e.length),(i=i.concat(e)).push(2),f(i,r.length);var o=i.concat(r),s=[48];return f(s,o.length),s=s.concat(o),n.encode(s,t)}},function(t,e,r){"use strict";var i=r(33),n=r(43),o=r(8),s=o.assert,a=o.parseBytes,c=r(101),u=r(102);function f(t){if(s("ed25519"===t,"only tested with ed25519 so far"),!(this instanceof f))return new f(t);t=n[t].curve,this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=i.sha512}t.exports=f,f.prototype.sign=function(t,e){t=a(t);var r=this.keyFromSecret(e),i=this.hashInt(r.messagePrefix(),t),n=this.g.mul(i),o=this.encodePoint(n),s=this.hashInt(o,r.pubBytes(),t).mul(r.priv()),c=i.add(s).umod(this.curve.n);return this.makeSignature({R:n,S:c,Rencoded:o})},f.prototype.verify=function(t,e,r){if(t=a(t),(e=this.makeSignature(e)).S().gte(e.eddsa.curve.n)||e.S().isNeg())return!1;var i=this.keyFromPublic(r),n=this.hashInt(e.Rencoded(),i.pubBytes(),t),o=this.g.mul(e.S());return e.R().add(i.pub().mul(n)).eq(o)},f.prototype.hashInt=function(){for(var t=this.hash(),e=0;e<arguments.length;e++)t.update(arguments[e]);return o.intFromLE(t.digest()).umod(this.curve.n)},f.prototype.keyFromPublic=function(t){return c.fromPublic(this,t)},f.prototype.keyFromSecret=function(t){return c.fromSecret(this,t)},f.prototype.makeSignature=function(t){return t instanceof u?t:new u(this,t)},f.prototype.encodePoint=function(t){var e=t.getY().toArray("le",this.encodingLength);return e[this.encodingLength-1]|=t.getX().isOdd()?128:0,e},f.prototype.decodePoint=function(t){var e=(t=o.parseBytes(t)).length-1,r=t.slice(0,e).concat(-129&t[e]),i=0!=(128&t[e]),n=o.intFromLE(r);return this.curve.pointFromY(n,i)},f.prototype.encodeInt=function(t){return t.toArray("le",this.encodingLength)},f.prototype.decodeInt=function(t){return o.intFromLE(t)},f.prototype.isPoint=function(t){return t instanceof this.pointClass}},function(t,e,r){"use strict";var i=r(8),n=i.assert,o=i.parseBytes,s=i.cachedProperty;function a(t,e){this.eddsa=t,this._secret=o(e.secret),t.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=o(e.pub)}a.fromPublic=function(t,e){return e instanceof a?e:new a(t,{pub:e})},a.fromSecret=function(t,e){return e instanceof a?e:new a(t,{secret:e})},a.prototype.secret=function(){return this._secret},s(a,"pubBytes",(function(){return this.eddsa.encodePoint(this.pub())})),s(a,"pub",(function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())})),s(a,"privBytes",(function(){var t=this.eddsa,e=this.hash(),r=t.encodingLength-1,i=e.slice(0,t.encodingLength);return i[0]&=248,i[r]&=127,i[r]|=64,i})),s(a,"priv",(function(){return this.eddsa.decodeInt(this.privBytes())})),s(a,"hash",(function(){return this.eddsa.hash().update(this.secret()).digest()})),s(a,"messagePrefix",(function(){return this.hash().slice(this.eddsa.encodingLength)})),a.prototype.sign=function(t){return n(this._secret,"KeyPair can only verify"),this.eddsa.sign(t,this)},a.prototype.verify=function(t,e){return this.eddsa.verify(t,e,this)},a.prototype.getSecret=function(t){return n(this._secret,"KeyPair is public only"),i.encode(this.secret(),t)},a.prototype.getPublic=function(t){return i.encode(this.pubBytes(),t)},t.exports=a},function(t,e,r){"use strict";var i=r(9),n=r(8),o=n.assert,s=n.cachedProperty,a=n.parseBytes;function c(t,e){this.eddsa=t,"object"!=typeof e&&(e=a(e)),Array.isArray(e)&&(o(e.length===2*t.encodingLength,"Signature has invalid size"),e={R:e.slice(0,t.encodingLength),S:e.slice(t.encodingLength)}),o(e.R&&e.S,"Signature without R or S"),t.isPoint(e.R)&&(this._R=e.R),e.S instanceof i&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}s(c,"S",(function(){return this.eddsa.decodeInt(this.Sencoded())})),s(c,"R",(function(){return this.eddsa.decodePoint(this.Rencoded())})),s(c,"Rencoded",(function(){return this.eddsa.encodePoint(this.R())})),s(c,"Sencoded",(function(){return this.eddsa.encodeInt(this.S())})),c.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},c.prototype.toHex=function(){return n.encode(this.toBytes(),"hex").toUpperCase()},t.exports=c},function(t){t.exports={name:"@smartledger/bsv",version:"3.2.0",description:"Advanced Bitcoin SV library with JavaScript-to-Bitcoin Script framework - Complete BSV API + BIP143 preimage parsing + 121 opcode mapping + covenant builder + nChain PUSHTX techniques + custom script development",author:"SmartLedger Technology <hello@smartledger.technology> (https://smartledger.technology)",homepage:"https://github.com/codenlighten/smartledger-bsv#readme",bugs:{url:"https://github.com/codenlighten/smartledger-bsv/issues"},main:"index.js",scripts:{lint:"standard",test:"standard && mocha","test:signatures":"node validation_test.js","test:js2script":"node lib/smart_contract/opcode_map.js && node lib/smart_contract/covenant_builder.js","test:opcodes":"node lib/smart_contract/opcode_list.js","test:covenants":"node examples/covenants/advanced_covenant_demo.js","test:scripts":"node examples/scripts/custom_script_signature_test.js","test:basic":"node examples/basic/transaction-creation.js","test:all":"npm test && npm run test:covenants && npm run test:scripts",coverage:"nyc --reporter=text npm run test","build-bsv":'NODE_OPTIONS="--openssl-legacy-provider" webpack index.js --config webpack.config.js',"build-ecies":'NODE_OPTIONS="--openssl-legacy-provider" webpack ecies/index.js --config webpack.subproject.config.js --output-library bsvEcies -o bsv-ecies.min.js',"build-message":'NODE_OPTIONS="--openssl-legacy-provider" webpack message/index.js --config webpack.subproject.config.js --output-library bsvMessage -o bsv-message.min.js',"build-mnemonic":'NODE_OPTIONS="--openssl-legacy-provider" webpack mnemonic/index.js --config webpack.subproject.config.js --output-library bsvMnemonic -o bsv-mnemonic.min.js',"build-bundle":'NODE_OPTIONS="--openssl-legacy-provider" webpack bundle-entry.js --config webpack.bundle.config.js',build:"npm run build-bsv && npm run build-ecies && npm run build-message && npm run build-mnemonic","build-all":"npm run build && npm run build-bundle",demo:"npm run test:covenants","demo:basic":"npm run test:basic","demo:scripts":"npm run test:scripts","demo:preimage":"echo '🧠 BIP-143 Preimage Extractor Demo' && node examples/preimage/extract_preimage_bidirectional.js","preimage:extract":"node examples/preimage/extract_preimage_bidirectional.js",prepublishOnly:'NODE_OPTIONS="--openssl-legacy-provider" npm run build'},unpkg:"bsv.min.js",jsdelivr:"bsv.min.js",cdn:"bsv.min.js",files:["index.js","lib/","utilities/","ecies/","message/","mnemonic/","bsv.min.js","bsv.bundle.js","bsv-ecies.min.js","bsv-message.min.js","bsv-mnemonic.min.js","bsv.d.ts","validation_test.js","docs/","examples/","LICENSE","README.md","SECURITY.md","CHANGELOG.md"],keywords:["bitcoin","bitcoin-sv","bsv","transaction","address","cryptocurrency","blockchain","security","hardened","vulnerability-free","drop-in-replacement","covenant","covenants","pushtx","pels","bip143","preimage","nchain","custom-scripts","multisig","timelock","conditional-scripts","utxo-management","ultra-low-fees","javascript-to-script","opcode-mapping","covenant-builder","script-simulation","bitcoin-script","asm-generation","advanced-features","script-development","blockchain-simulator","miner-simulator","testing-tools","development-framework","ecies","p2p","payment","bip21","bip32","bip37","bip69","bip70"],repository:{type:"git",url:"https://github.com/codenlighten/smartledger-bsv"},browser:{request:"browser-request"},dependencies:{"aes-js":"^3.1.2","bn.js":"=4.11.9",bs58:"=4.0.1","clone-deep":"^4.0.1",elliptic:"6.6.1","hash.js":"^1.1.7",inherits:"2.0.3",unorm:"1.4.1"},devDependencies:{brfs:"2.0.1",chai:"4.2.0",mocha:"^8.4.0",nyc:"^14.1.1",sinon:"7.2.3",standard:"12.0.1",webpack:"4.29.3","webpack-cli":"^3.3.12"},license:"MIT",standard:{globals:["after","afterEach","before","beforeEach","describe","it"],ignore:["dist/**"]}}},function(t,e,r){"use strict";var i="https://docs.moneybutton.com/";t.exports=[{name:"InvalidB58Char",message:"Invalid Base58 character: {0} in {1}"},{name:"InvalidB58Checksum",message:"Invalid Base58 checksum for {0}"},{name:"InvalidNetwork",message:"Invalid version for network: got {0}"},{name:"InvalidState",message:"Invalid state: {0}"},{name:"NotImplemented",message:"Function {0} was not implemented yet"},{name:"InvalidNetworkArgument",message:'Invalid network: must be "livenet" or "testnet", got {0}'},{name:"InvalidArgument",message:function(){return"Invalid Argument"+(arguments[0]?": "+arguments[0]:"")+(arguments[1]?" Documentation: "+i+arguments[1]:"")}},{name:"AbstractMethodInvoked",message:"Abstract Method Invocation: {0}"},{name:"InvalidArgumentType",message:function(){return"Invalid Argument for "+arguments[2]+", expected "+arguments[1]+" but got "+typeof arguments[0]}},{name:"Unit",message:"Internal Error on Unit {0}",errors:[{name:"UnknownCode",message:"Unrecognized unit code: {0}"},{name:"InvalidRate",message:"Invalid exchange rate: {0}"}]},{name:"MerkleBlock",message:"Internal Error on MerkleBlock {0}",errors:[{name:"InvalidMerkleTree",message:"This MerkleBlock contain an invalid Merkle Tree"}]},{name:"Transaction",message:"Internal Error on Transaction {0}",errors:[{name:"Input",message:"Internal Error on Input {0}",errors:[{name:"MissingScript",message:"Need a script to create an input"},{name:"UnsupportedScript",message:"Unsupported input script type: {0}"},{name:"MissingPreviousOutput",message:"No previous output information."}]},{name:"NeedMoreInfo",message:"{0}"},{name:"InvalidSorting",message:"The sorting function provided did not return the change output as one of the array elements"},{name:"InvalidOutputAmountSum",message:"{0}"},{name:"MissingSignatures",message:"Some inputs have not been fully signed"},{name:"InvalidIndex",message:"Invalid index: {0} is not between 0, {1}"},{name:"UnableToVerifySignature",message:"Unable to verify signature: {0}"},{name:"DustOutputs",message:"Dust amount detected in one output"},{name:"InvalidSatoshis",message:"Output satoshis are invalid"},{name:"FeeError",message:"Internal Error on Fee {0}",errors:[{name:"TooSmall",message:"Fee is too small: {0}"},{name:"TooLarge",message:"Fee is too large: {0}"},{name:"Different",message:"Unspent value is different from specified fee: {0}"}]},{name:"ChangeAddressMissing",message:"Change address is missing"},{name:"BlockHeightTooHigh",message:"Block Height can be at most 2^32 -1"},{name:"NLockTimeOutOfRange",message:"Block Height can only be between 0 and 499 999 999"},{name:"LockTimeTooEarly",message:"Lock Time can't be earlier than UNIX date 500 000 000"}]},{name:"Script",message:"Internal Error on Script {0}",errors:[{name:"UnrecognizedAddress",message:"Expected argument {0} to be an address"},{name:"CantDeriveAddress",message:"Can't derive address associated with script {0}, needs to be p2pkh in, p2pkh out, p2sh in, or p2sh out."},{name:"InvalidBuffer",message:"Invalid script buffer: can't parse valid script from given buffer {0}"}]},{name:"HDPrivateKey",message:"Internal Error on HDPrivateKey {0}",errors:[{name:"InvalidDerivationArgument",message:"Invalid derivation argument {0}, expected string, or number and boolean"},{name:"InvalidEntropyArgument",message:"Invalid entropy: must be an hexa string or binary buffer, got {0}",errors:[{name:"TooMuchEntropy",message:'Invalid entropy: more than 512 bits is non standard, got "{0}"'},{name:"NotEnoughEntropy",message:'Invalid entropy: at least 128 bits needed, got "{0}"'}]},{name:"InvalidLength",message:"Invalid length for xprivkey string in {0}"},{name:"InvalidPath",message:"Invalid derivation path: {0}"},{name:"UnrecognizedArgument",message:'Invalid argument: creating a HDPrivateKey requires a string, buffer, json or object, got "{0}"'}]},{name:"HDPublicKey",message:"Internal Error on HDPublicKey {0}",errors:[{name:"ArgumentIsPrivateExtended",message:"Argument is an extended private key: {0}"},{name:"InvalidDerivationArgument",message:"Invalid derivation argument: got {0}"},{name:"InvalidLength",message:'Invalid length for xpubkey: got "{0}"'},{name:"InvalidPath",message:'Invalid derivation path, it should look like: "m/1/100", got "{0}"'},{name:"InvalidIndexCantDeriveHardened",message:"Invalid argument: creating a hardened path requires an HDPrivateKey"},{name:"MustSupplyArgument",message:"Must supply an argument to create a HDPublicKey"},{name:"UnrecognizedArgument",message:"Invalid argument for creation, must be string, json, buffer, or object"}]}]},function(t,e,r){"use strict";(function(e){var i=r(33),n=r(2),o=t.exports;o.sha1=function(t){return n.checkArgument(e.isBuffer(t)),e.from(i.sha1().update(t).digest("hex"),"hex")},o.sha1.blocksize=512,o.sha256=function(t){return n.checkArgument(e.isBuffer(t)),e.from(i.sha256().update(t).digest("hex"),"hex")},o.sha256.blocksize=512,o.sha256sha256=function(t){return n.checkArgument(e.isBuffer(t)),o.sha256(o.sha256(t))},o.ripemd160=function(t){return n.checkArgument(e.isBuffer(t)),e.from(i.ripemd160().update(t).digest("hex"),"hex")},o.sha256ripemd160=function(t){return n.checkArgument(e.isBuffer(t)),o.ripemd160(o.sha256(t))},o.sha512=function(t){return n.checkArgument(e.isBuffer(t)),e.from(i.sha512().update(t).digest("hex"),"hex")},o.sha512.blocksize=1024,o.hmac=function(t,r,i){n.checkArgument(e.isBuffer(r)),n.checkArgument(e.isBuffer(i)),n.checkArgument(t.blocksize);var o=t.blocksize/8;if(i.length>o)i=t(i);else if(i<o){var s=e.alloc(o);s.fill(0),i.copy(s),i=s}var a=e.alloc(o);a.fill(92);var c=e.alloc(o);c.fill(54);for(var u=e.alloc(o),f=e.alloc(o),h=0;h<o;h++)u[h]=a[h]^i[h],f[h]=c[h]^i[h];return t(e.concat([u,t(e.concat([f,r]))]))},o.sha256hmac=function(t,e){return o.hmac(o.sha256,t,e)},o.sha512hmac=function(t,e){return o.hmac(o.sha512,t,e)}}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(15),n=r(2),o=t.exports;o.sha1=function(t){return n.checkArgument(e.isBuffer(t)),i.createHash("sha1").update(t).digest()},o.sha1.blocksize=512,o.sha256=function(t){return n.checkArgument(e.isBuffer(t)),i.createHash("sha256").update(t).digest()},o.sha256.blocksize=512,o.sha256sha256=function(t){return n.checkArgument(e.isBuffer(t)),o.sha256(o.sha256(t))},o.ripemd160=function(t){return n.checkArgument(e.isBuffer(t)),i.createHash("ripemd160").update(t).digest()},o.sha256ripemd160=function(t){return n.checkArgument(e.isBuffer(t)),o.ripemd160(o.sha256(t))},o.sha512=function(t){return n.checkArgument(e.isBuffer(t)),i.createHash("sha512").update(t).digest()},o.sha512.blocksize=1024,o.hmac=function(t,r,i){n.checkArgument(e.isBuffer(r)),n.checkArgument(e.isBuffer(i)),n.checkArgument(t.blocksize);var o=t.blocksize/8;if(i.length>o)i=t(i);else if(i<o){var s=e.alloc(o);s.fill(0),i.copy(s),i=s}var a=e.alloc(o);a.fill(92);var c=e.alloc(o);c.fill(54);for(var u=e.alloc(o),f=e.alloc(o),h=0;h<o;h++)u[h]=a[h]^i[h],f[h]=c[h]^i[h];return t(e.concat([u,t(e.concat([f,r]))]))},o.sha256hmac=function(t,e){return o.hmac(o.sha256,t,e)},o.sha512hmac=function(t,e){return o.hmac(o.sha512,t,e)}}).call(this,r(0).Buffer)},function(t,e,r){"use strict";var i=r(108);t.exports=function(){return Object.assign?function(){if(!Object.assign)return!1;for(var t="abcdefghijklmnopqrst",e=t.split(""),r={},i=0;i<e.length;++i)r[e[i]]=e[i];var n=Object.assign({},r),o="";for(var s in n)o+=s;return t!==o}()||function(){if(!Object.assign||!Object.preventExtensions)return!1;var t=Object.preventExtensions({1:2});try{Object.assign(t,"xy")}catch(e){return"y"===t[1]}return!1}()?i:Object.assign:i}},function(t,e,r){"use strict";var i=r(109),n=r(63)(),o=r(111),s=r(46),a=o("Array.prototype.push"),c=o("Object.prototype.propertyIsEnumerable"),u=n?s.getOwnPropertySymbols:null;t.exports=function(t,e){if(null==t)throw new TypeError("target must be an object");var r=s(t);if(1===arguments.length)return r;for(var o=1;o<arguments.length;++o){var f=s(arguments[o]),h=i(f),d=n&&(s.getOwnPropertySymbols||u);if(d)for(var p=d(f),l=0;l<p.length;++l){var g=p[l];c(f,g)&&a(h,g)}for(var m=0;m<h.length;++m){var b=h[m];if(c(f,b)){var y=f[b];r[b]=y}}}return r}},function(t,e,r){"use strict";var i=Array.prototype.slice,n=r(62),o=Object.keys,s=o?function(t){return o(t)}:r(110),a=Object.keys;s.shim=function(){Object.keys?function(){var t=Object.keys(arguments);return t&&t.length===arguments.length}(1,2)||(Object.keys=function(t){return n(t)?a(i.call(t)):a(t)}):Object.keys=s;return Object.keys||s},t.exports=s},function(t,e,r){"use strict";var i;if(!Object.keys){var n=Object.prototype.hasOwnProperty,o=Object.prototype.toString,s=r(62),a=Object.prototype.propertyIsEnumerable,c=!a.call({toString:null},"toString"),u=a.call((function(){}),"prototype"),f=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],h=function(t){var e=t.constructor;return e&&e.prototype===t},d={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},p=function(){if("undefined"==typeof window)return!1;for(var t in window)try{if(!d["$"+t]&&n.call(window,t)&&null!==window[t]&&"object"==typeof window[t])try{h(window[t])}catch(t){return!0}}catch(t){return!0}return!1}();i=function(t){var e=null!==t&&"object"==typeof t,r="[object Function]"===o.call(t),i=s(t),a=e&&"[object String]"===o.call(t),d=[];if(!e&&!r&&!i)throw new TypeError("Object.keys called on a non-object");var l=u&&r;if(a&&t.length>0&&!n.call(t,0))for(var g=0;g<t.length;++g)d.push(String(g));if(i&&t.length>0)for(var m=0;m<t.length;++m)d.push(String(m));else for(var b in t)l&&"prototype"===b||!n.call(t,b)||d.push(String(b));if(c)for(var y=function(t){if("undefined"==typeof window||!p)return h(t);try{return h(t)}catch(t){return!1}}(t),v=0;v<f.length;++v)y&&"constructor"===f[v]||!n.call(t,f[v])||d.push(f[v]);return d}}t.exports=i},function(t,e,r){"use strict";var i=r(112),n=r(68),o=n([i("%String.prototype.indexOf%")]);t.exports=function(t,e){var r=i(t,!!e);return"function"==typeof r&&o(t,".prototype.")>-1?n([r]):r}},function(t,e,r){"use strict";var i=r(46),n=r(113),o=r(114),s=r(115),a=r(116),c=r(117),u=r(64),f=r(118),h=r(119),d=r(120),p=r(121),l=r(122),g=r(123),m=r(124),b=r(125),y=Function,v=function(t){try{return y('"use strict"; return ('+t+").constructor;")()}catch(t){}},S=r(65),_=r(128),w=function(){throw new u},I=S?function(){try{return w}catch(t){try{return S(arguments,"callee").get}catch(t){return w}}}():w,O=r(129)(),P=r(130),A=r(67),E=r(66),k=r(69),x=r(47),T={},R="undefined"!=typeof Uint8Array&&P?P(Uint8Array):void 0,M={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?void 0:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?void 0:ArrayBuffer,"%ArrayIteratorPrototype%":O&&P?P([][Symbol.iterator]()):void 0,"%AsyncFromSyncIteratorPrototype%":void 0,"%AsyncFunction%":T,"%AsyncGenerator%":T,"%AsyncGeneratorFunction%":T,"%AsyncIteratorPrototype%":T,"%Atomics%":"undefined"==typeof Atomics?void 0:Atomics,"%BigInt%":"undefined"==typeof BigInt?void 0:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?void 0:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?void 0:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?void 0:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":n,"%eval%":eval,"%EvalError%":o,"%Float16Array%":"undefined"==typeof Float16Array?void 0:Float16Array,"%Float32Array%":"undefined"==typeof Float32Array?void 0:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?void 0:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?void 0:FinalizationRegistry,"%Function%":y,"%GeneratorFunction%":T,"%Int8Array%":"undefined"==typeof Int8Array?void 0:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?void 0:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?void 0:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":O&&P?P(P([][Symbol.iterator]())):void 0,"%JSON%":"object"==typeof JSON?JSON:void 0,"%Map%":"undefined"==typeof Map?void 0:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&O&&P?P((new Map)[Symbol.iterator]()):void 0,"%Math%":Math,"%Number%":Number,"%Object%":i,"%Object.getOwnPropertyDescriptor%":S,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?void 0:Promise,"%Proxy%":"undefined"==typeof Proxy?void 0:Proxy,"%RangeError%":s,"%ReferenceError%":a,"%Reflect%":"undefined"==typeof Reflect?void 0:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?void 0:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&O&&P?P((new Set)[Symbol.iterator]()):void 0,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?void 0:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":O&&P?P(""[Symbol.iterator]()):void 0,"%Symbol%":O?Symbol:void 0,"%SyntaxError%":c,"%ThrowTypeError%":I,"%TypedArray%":R,"%TypeError%":u,"%Uint8Array%":"undefined"==typeof Uint8Array?void 0:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?void 0:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?void 0:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?void 0:Uint32Array,"%URIError%":f,"%WeakMap%":"undefined"==typeof WeakMap?void 0:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?void 0:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?void 0:WeakSet,"%Function.prototype.call%":x,"%Function.prototype.apply%":k,"%Object.defineProperty%":_,"%Object.getPrototypeOf%":A,"%Math.abs%":h,"%Math.floor%":d,"%Math.max%":p,"%Math.min%":l,"%Math.pow%":g,"%Math.round%":m,"%Math.sign%":b,"%Reflect.getPrototypeOf%":E};if(P)try{null.error}catch(t){var N=P(P(t));M["%Error.prototype%"]=N}var B={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},C=r(36),H=r(135),U=C.call(x,Array.prototype.concat),L=C.call(k,Array.prototype.splice),F=C.call(x,String.prototype.replace),D=C.call(x,String.prototype.slice),K=C.call(x,RegExp.prototype.exec),z=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,j=/\\(\\)?/g,V=function(t){var e=D(t,0,1),r=D(t,-1);if("%"===e&&"%"!==r)throw new c("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==e)throw new c("invalid intrinsic syntax, expected opening `%`");var i=[];return F(t,z,(function(t,e,r,n){i[i.length]=r?F(n,j,"$1"):e||t})),i},G=function(t,e){var r,i=t;if(H(B,i)&&(i="%"+(r=B[i])[0]+"%"),H(M,i)){var n=M[i];if(n===T&&(n=function t(e){var r;if("%AsyncFunction%"===e)r=v("async function () {}");else if("%GeneratorFunction%"===e)r=v("function* () {}");else if("%AsyncGeneratorFunction%"===e)r=v("async function* () {}");else if("%AsyncGenerator%"===e){var i=t("%AsyncGeneratorFunction%");i&&(r=i.prototype)}else if("%AsyncIteratorPrototype%"===e){var n=t("%AsyncGenerator%");n&&P&&(r=P(n.prototype))}return M[e]=r,r}(i)),void 0===n&&!e)throw new u("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:r,name:i,value:n}}throw new c("intrinsic "+t+" does not exist!")};t.exports=function(t,e){if("string"!=typeof t||0===t.length)throw new u("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof e)throw new u('"allowMissing" argument must be a boolean');if(null===K(/^%?[^%]*%?$/,t))throw new c("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=V(t),i=r.length>0?r[0]:"",n=G("%"+i+"%",e),o=n.name,s=n.value,a=!1,f=n.alias;f&&(i=f[0],L(r,U([0,1],f)));for(var h=1,d=!0;h<r.length;h+=1){var p=r[h],l=D(p,0,1),g=D(p,-1);if(('"'===l||"'"===l||"`"===l||'"'===g||"'"===g||"`"===g)&&l!==g)throw new c("property names with quotes must have matching quotes");if("constructor"!==p&&d||(a=!0),H(M,o="%"+(i+="."+p)+"%"))s=M[o];else if(null!=s){if(!(p in s)){if(!e)throw new u("base intrinsic for "+t+" exists, but the property is not available.");return}if(S&&h+1>=r.length){var m=S(s,p);s=(d=!!m)&&"get"in m&&!("originalValue"in m.get)?m.get:s[p]}else d=H(s,p),s=s[p];d&&!a&&(M[o]=s)}}return s}},function(t,e,r){"use strict";t.exports=Error},function(t,e,r){"use strict";t.exports=EvalError},function(t,e,r){"use strict";t.exports=RangeError},function(t,e,r){"use strict";t.exports=ReferenceError},function(t,e,r){"use strict";t.exports=SyntaxError},function(t,e,r){"use strict";t.exports=URIError},function(t,e,r){"use strict";t.exports=Math.abs},function(t,e,r){"use strict";t.exports=Math.floor},function(t,e,r){"use strict";t.exports=Math.max},function(t,e,r){"use strict";t.exports=Math.min},function(t,e,r){"use strict";t.exports=Math.pow},function(t,e,r){"use strict";t.exports=Math.round},function(t,e,r){"use strict";var i=r(126);t.exports=function(t){return i(t)||0===t?t:t<0?-1:1}},function(t,e,r){"use strict";t.exports=Number.isNaN||function(t){return t!=t}},function(t,e,r){"use strict";t.exports=Object.getOwnPropertyDescriptor},function(t,e,r){"use strict";var i=Object.defineProperty||!1;if(i)try{i({},"a",{value:1})}catch(t){i=!1}t.exports=i},function(t,e,r){"use strict";var i="undefined"!=typeof Symbol&&Symbol,n=r(63);t.exports=function(){return"function"==typeof i&&("function"==typeof Symbol&&("symbol"==typeof i("foo")&&("symbol"==typeof Symbol("bar")&&n())))}},function(t,e,r){"use strict";var i=r(66),n=r(67),o=r(131);t.exports=i?function(t){return i(t)}:n?function(t){if(!t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("getProto: not an object");return n(t)}:o?function(t){return o(t)}:null},function(t,e,r){"use strict";var i,n=r(68),o=r(65);try{i=[].__proto__===Array.prototype}catch(t){if(!t||"object"!=typeof t||!("code"in t)||"ERR_PROTO_ACCESS"!==t.code)throw t}var s=!!i&&o&&o(Object.prototype,"__proto__"),a=Object,c=a.getPrototypeOf;t.exports=s&&"function"==typeof s.get?n([s.get]):"function"==typeof c&&function(t){return c(null==t?t:a(t))}},function(t,e,r){"use strict";var i="Function.prototype.bind called on incompatible ",n=Object.prototype.toString,o=Math.max,s=function(t,e){for(var r=[],i=0;i<t.length;i+=1)r[i]=t[i];for(var n=0;n<e.length;n+=1)r[n+t.length]=e[n];return r},a=function(t,e){for(var r=[],i=e||0,n=0;i<t.length;i+=1,n+=1)r[n]=t[i];return r},c=function(t,e){for(var r="",i=0;i<t.length;i+=1)r+=t[i],i+1<t.length&&(r+=e);return r};t.exports=function(t){var e=this;if("function"!=typeof e||"[object Function]"!==n.apply(e))throw new TypeError(i+e);for(var r,u=a(arguments,1),f=function(){if(this instanceof r){var i=e.apply(this,s(u,arguments));return Object(i)===i?i:this}return e.apply(t,s(u,arguments))},h=o(0,e.length-u.length),d=[],p=0;p<h;p++)d[p]="$"+p;if(r=Function("binder","return function ("+c(d,",")+"){ return binder.apply(this,arguments); }")(f),e.prototype){var l=function(){};l.prototype=e.prototype,r.prototype=new l,l.prototype=null}return r}},function(t,e,r){"use strict";var i=r(36),n=r(69),o=r(47),s=r(134);t.exports=s||i.call(o,n)},function(t,e,r){"use strict";t.exports="undefined"!=typeof Reflect&&Reflect&&Reflect.apply},function(t,e,r){"use strict";var i=Function.prototype.call,n=Object.prototype.hasOwnProperty,o=r(36);t.exports=o.call(i,n)},function(t,e,r){(function(t){var i=Object.getOwnPropertyDescriptors||function(t){for(var e=Object.keys(t),r={},i=0;i<e.length;i++)r[e[i]]=Object.getOwnPropertyDescriptor(t,e[i]);return r},n=/%[sdj%]/g;e.format=function(t){if(!b(t)){for(var e=[],r=0;r<arguments.length;r++)e.push(a(arguments[r]));return e.join(" ")}r=1;for(var i=arguments,o=i.length,s=String(t).replace(n,(function(t){if("%%"===t)return"%";if(r>=o)return t;switch(t){case"%s":return String(i[r++]);case"%d":return Number(i[r++]);case"%j":try{return JSON.stringify(i[r++])}catch(t){return"[Circular]"}default:return t}})),c=i[r];r<o;c=i[++r])g(c)||!S(c)?s+=" "+c:s+=" "+a(c);return s},e.deprecate=function(r,i){if(void 0!==t&&!0===t.noDeprecation)return r;if(void 0===t)return function(){return e.deprecate(r,i).apply(this,arguments)};var n=!1;return function(){if(!n){if(t.throwDeprecation)throw new Error(i);t.traceDeprecation?console.trace(i):console.error(i),n=!0}return r.apply(this,arguments)}};var o,s={};function a(t,r){var i={seen:[],stylize:u};return arguments.length>=3&&(i.depth=arguments[2]),arguments.length>=4&&(i.colors=arguments[3]),l(r)?i.showHidden=r:r&&e._extend(i,r),y(i.showHidden)&&(i.showHidden=!1),y(i.depth)&&(i.depth=2),y(i.colors)&&(i.colors=!1),y(i.customInspect)&&(i.customInspect=!0),i.colors&&(i.stylize=c),f(i,t,i.depth)}function c(t,e){var r=a.styles[e];return r?"["+a.colors[r][0]+"m"+t+"["+a.colors[r][1]+"m":t}function u(t,e){return t}function f(t,r,i){if(t.customInspect&&r&&I(r.inspect)&&r.inspect!==e.inspect&&(!r.constructor||r.constructor.prototype!==r)){var n=r.inspect(i,t);return b(n)||(n=f(t,n,i)),n}var o=function(t,e){if(y(e))return t.stylize("undefined","undefined");if(b(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}if(m(e))return t.stylize(""+e,"number");if(l(e))return t.stylize(""+e,"boolean");if(g(e))return t.stylize("null","null")}(t,r);if(o)return o;var s=Object.keys(r),a=function(t){var e={};return t.forEach((function(t,r){e[t]=!0})),e}(s);if(t.showHidden&&(s=Object.getOwnPropertyNames(r)),w(r)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return h(r);if(0===s.length){if(I(r)){var c=r.name?": "+r.name:"";return t.stylize("[Function"+c+"]","special")}if(v(r))return t.stylize(RegExp.prototype.toString.call(r),"regexp");if(_(r))return t.stylize(Date.prototype.toString.call(r),"date");if(w(r))return h(r)}var u,S="",O=!1,P=["{","}"];(p(r)&&(O=!0,P=["[","]"]),I(r))&&(S=" [Function"+(r.name?": "+r.name:"")+"]");return v(r)&&(S=" "+RegExp.prototype.toString.call(r)),_(r)&&(S=" "+Date.prototype.toUTCString.call(r)),w(r)&&(S=" "+h(r)),0!==s.length||O&&0!=r.length?i<0?v(r)?t.stylize(RegExp.prototype.toString.call(r),"regexp"):t.stylize("[Object]","special"):(t.seen.push(r),u=O?function(t,e,r,i,n){for(var o=[],s=0,a=e.length;s<a;++s)k(e,String(s))?o.push(d(t,e,r,i,String(s),!0)):o.push("");return n.forEach((function(n){n.match(/^\d+$/)||o.push(d(t,e,r,i,n,!0))})),o}(t,r,i,a,s):s.map((function(e){return d(t,r,i,a,e,O)})),t.seen.pop(),function(t,e,r){if(t.reduce((function(t,e){return e.indexOf("\n")>=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60)return r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1];return r[0]+e+" "+t.join(", ")+" "+r[1]}(u,S,P)):P[0]+S+P[1]}function h(t){return"["+Error.prototype.toString.call(t)+"]"}function d(t,e,r,i,n,o){var s,a,c;if((c=Object.getOwnPropertyDescriptor(e,n)||{value:e[n]}).get?a=c.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):c.set&&(a=t.stylize("[Setter]","special")),k(i,n)||(s="["+n+"]"),a||(t.seen.indexOf(c.value)<0?(a=g(r)?f(t,c.value,null):f(t,c.value,r-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(t){return" "+t})).join("\n").substr(2):"\n"+a.split("\n").map((function(t){return" "+t})).join("\n")):a=t.stylize("[Circular]","special")),y(s)){if(o&&n.match(/^\d+$/))return a;(s=JSON.stringify(""+n)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=t.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=t.stylize(s,"string"))}return s+": "+a}function p(t){return Array.isArray(t)}function l(t){return"boolean"==typeof t}function g(t){return null===t}function m(t){return"number"==typeof t}function b(t){return"string"==typeof t}function y(t){return void 0===t}function v(t){return S(t)&&"[object RegExp]"===O(t)}function S(t){return"object"==typeof t&&null!==t}function _(t){return S(t)&&"[object Date]"===O(t)}function w(t){return S(t)&&("[object Error]"===O(t)||t instanceof Error)}function I(t){return"function"==typeof t}function O(t){return Object.prototype.toString.call(t)}function P(t){return t<10?"0"+t.toString(10):t.toString(10)}e.debuglog=function(r){if(y(o)&&(o=t.env.NODE_DEBUG||""),r=r.toUpperCase(),!s[r])if(new RegExp("\\b"+r+"\\b","i").test(o)){var i=t.pid;s[r]=function(){var t=e.format.apply(e,arguments);console.error("%s %d: %s",r,i,t)}}else s[r]=function(){};return s[r]},e.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=p,e.isBoolean=l,e.isNull=g,e.isNullOrUndefined=function(t){return null==t},e.isNumber=m,e.isString=b,e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=y,e.isRegExp=v,e.isObject=S,e.isDate=_,e.isError=w,e.isFunction=I,e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=r(137);var A=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function E(){var t=new Date,e=[P(t.getHours()),P(t.getMinutes()),P(t.getSeconds())].join(":");return[t.getDate(),A[t.getMonth()],e].join(" ")}function k(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.log=function(){console.log("%s - %s",E(),e.format.apply(e,arguments))},e.inherits=r(22),e._extend=function(t,e){if(!e||!S(e))return t;for(var r=Object.keys(e),i=r.length;i--;)t[r[i]]=e[r[i]];return t};var x="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function T(t,e){if(!t){var r=new Error("Promise was rejected with a falsy value");r.reason=t,t=r}return e(t)}e.promisify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');if(x&&t[x]){var e;if("function"!=typeof(e=t[x]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(e,x,{value:e,enumerable:!1,writable:!1,configurable:!0}),e}function e(){for(var e,r,i=new Promise((function(t,i){e=t,r=i})),n=[],o=0;o<arguments.length;o++)n.push(arguments[o]);n.push((function(t,i){t?r(t):e(i)}));try{t.apply(this,n)}catch(t){r(t)}return i}return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),x&&Object.defineProperty(e,x,{value:e,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(e,i(t))},e.promisify.custom=x,e.callbackify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');function r(){for(var r=[],i=0;i<arguments.length;i++)r.push(arguments[i]);var n=r.pop();if("function"!=typeof n)throw new TypeError("The last argument must be of type Function");var o=this,s=function(){return n.apply(o,arguments)};e.apply(this,r).then((function(e){t.nextTick(s,null,e)}),(function(e){t.nextTick(T,e,s)}))}return Object.setPrototypeOf(r,Object.getPrototypeOf(e)),Object.defineProperties(r,i(e)),r}}).call(this,r(24))},function(t,e){t.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},function(t,e,r){"use strict";const i=r(139),n=r(70),o=r(140);function s(t,e){switch(n(t)){case"object":return function(t,e){if("function"==typeof e)return e(t);if(e||o(t)){const r=new t.constructor;for(let i in t)r[i]=s(t[i],e);return r}return t}(t,e);case"array":return function(t,e){const r=new t.constructor(t.length);for(let i=0;i<t.length;i++)r[i]=s(t[i],e);return r}(t,e);default:return i(t)}}t.exports=s},function(t,e,r){"use strict";(function(e){
18
+ var n=r(0),i=n.Buffer;function o(t,e){for(var r in t)e[r]=t[r]}function s(t,e,r){return i(t,e,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(o(n,e),e.Buffer=s),s.prototype=Object.create(i.prototype),o(i,s),s.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return i(t,e,r)},s.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=i(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},s.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i(t)},s.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},function(t){t.exports={name:"elliptic",version:"6.6.1",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(t,e){},function(t,e,r){"use strict";var n=r(8),i=r(9),o=r(42),s=r(32),a=n.assert;function c(t){s.call(this,"short",t),this.a=new i(t.a,16).toRed(this.red),this.b=new i(t.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(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function u(t,e,r,n){s.BasePoint.call(this,t,"affine"),null===e&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new i(e,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(t,e,r,n){s.BasePoint.call(this,t,"jacobian"),null===e&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new i(0)):(this.x=new i(e,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(c,s),t.exports=c,c.prototype._getEndomorphism=function(t){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,r;if(t.beta)e=new i(t.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);e=(e=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(t.lambda)r=new i(t.lambda,16);else{var o=this._getEndoRoots(this.n);0===this.g.mul(o[0]).x.cmp(this.g.x.redMul(e))?r=o[0]:(r=o[1],a(0===this.g.mul(r).x.cmp(this.g.x.redMul(e))))}return{beta:e,lambda:r,basis:t.basis?t.basis.map((function(t){return{a:new i(t.a,16),b:new i(t.b,16)}})):this._getEndoBasis(r)}}},c.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:i.mont(t),r=new i(2).toRed(e).redInvm(),n=r.redNeg(),o=new i(3).toRed(e).redNeg().redSqrt().redMul(r);return[n.redAdd(o).fromRed(),n.redSub(o).fromRed()]},c.prototype._getEndoBasis=function(t){for(var e,r,n,o,s,a,c,u,f,h=this.n.ushrn(Math.floor(this.n.bitLength()/2)),d=t,p=this.n.clone(),l=new i(1),g=new i(0),m=new i(0),b=new i(1),y=0;0!==d.cmpn(0);){var v=p.div(d);u=p.sub(v.mul(d)),f=m.sub(v.mul(l));var S=b.sub(v.mul(g));if(!n&&u.cmp(h)<0)e=c.neg(),r=l,n=u.neg(),o=f;else if(n&&2==++y)break;c=u,p=d,d=u,m=l,l=f,b=g,g=S}s=u.neg(),a=f;var _=n.sqr().add(o.sqr());return s.sqr().add(a.sqr()).cmp(_)>=0&&(s=e,a=r),n.negative&&(n=n.neg(),o=o.neg()),s.negative&&(s=s.neg(),a=a.neg()),[{a:n,b:o},{a:s,b:a}]},c.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],n=e[1],i=n.b.mul(t).divRound(this.n),o=r.b.neg().mul(t).divRound(this.n),s=i.mul(r.a),a=o.mul(n.a),c=i.mul(r.b),u=o.mul(n.b);return{k1:t.sub(s).sub(a),k2:c.add(u).neg()}},c.prototype.pointFromX=function(t,e){(t=new i(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.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(e&&!o||!e&&o)&&(n=n.redNeg()),this.point(t,n)},c.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,n=this.a.redMul(e),i=e.redSqr().redMul(e).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},c.prototype._endoWnafMulAdd=function(t,e,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o<t.length;o++){var s=this._endoSplit(e[o]),a=t[o],c=a._getBeta();s.k1.negative&&(s.k1.ineg(),a=a.neg(!0)),s.k2.negative&&(s.k2.ineg(),c=c.neg(!0)),n[2*o]=a,n[2*o+1]=c,i[2*o]=s.k1,i[2*o+1]=s.k2}for(var u=this._wnafMulAdd(1,n,i,2*o,r),f=0;f<2*o;f++)n[f]=null,i[f]=null;return u},o(u,s.BasePoint),c.prototype.point=function(t,e,r){return new u(this,t,e,r)},c.prototype.pointFromJSON=function(t,e){return u.fromJSON(this,t,e)},u.prototype._getBeta=function(){if(this.curve.endo){var t=this.precomputed;if(t&&t.beta)return t.beta;var e=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(t){var r=this.curve,n=function(t){return r.point(t.x.redMul(r.endo.beta),t.y)};t.beta=e,e.precomputed={beta:null,naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(n)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(n)}}}return e}},u.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]},u.fromJSON=function(t,e,r){"string"==typeof e&&(e=JSON.parse(e));var n=t.point(e[0],e[1],r);if(!e[2])return n;function i(e){return t.point(e[0],e[1],r)}var o=e[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},u.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)+">"},u.prototype.isInfinity=function(){return this.inf},u.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),n=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},u.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),n=t.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),s=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,s)},u.prototype.getX=function(){return this.x.fromRed()},u.prototype.getY=function(){return this.y.fromRed()},u.prototype.mul=function(t){return t=new i(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},u.prototype.mulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},u.prototype.jmulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},u.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},u.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,n=function(t){return t.neg()};e.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 e},u.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},o(f,s.BasePoint),c.prototype.jpoint=function(t,e,r){return new f(this,t,e,r)},f.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),n=this.y.redMul(e).redMul(t);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(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(e),i=t.x.redMul(r),o=this.y.redMul(e.redMul(t.z)),s=t.y.redMul(r.redMul(this.z)),a=n.redSub(i),c=o.redSub(s);if(0===a.cmpn(0))return 0!==c.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),f=u.redMul(a),h=n.redMul(u),d=c.redSqr().redIAdd(f).redISub(h).redISub(h),p=c.redMul(h.redISub(d)).redISub(o.redMul(f)),l=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(d,p,l)},f.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,n=t.x.redMul(e),i=this.y,o=t.y.redMul(e).redMul(this.z),s=r.redSub(n),a=i.redSub(o);if(0===s.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=s.redSqr(),u=c.redMul(s),f=r.redMul(c),h=a.redSqr().redIAdd(u).redISub(f).redISub(f),d=a.redMul(f.redISub(h)).redISub(i.redMul(u)),p=this.z.redMul(s);return this.curve.jpoint(h,d,p)},f.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var r=this;for(e=0;e<t;e++)r=r.dbl();return r}var n=this.curve.a,i=this.curve.tinv,o=this.x,s=this.y,a=this.z,c=a.redSqr().redSqr(),u=s.redAdd(s);for(e=0;e<t;e++){var f=o.redSqr(),h=u.redSqr(),d=h.redSqr(),p=f.redAdd(f).redIAdd(f).redIAdd(n.redMul(c)),l=o.redMul(h),g=p.redSqr().redISub(l.redAdd(l)),m=l.redISub(g),b=p.redMul(m);b=b.redIAdd(b).redISub(d);var y=u.redMul(a);e+1<t&&(c=c.redMul(d)),o=g,a=y,u=b}return this.curve.jpoint(o,u.redMul(i),a)},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 t,e,r;if(this.zOne){var n=this.x.redSqr(),i=this.y.redSqr(),o=i.redSqr(),s=this.x.redAdd(i).redSqr().redISub(n).redISub(o);s=s.redIAdd(s);var a=n.redAdd(n).redIAdd(n),c=a.redSqr().redISub(s).redISub(s),u=o.redIAdd(o);u=(u=u.redIAdd(u)).redIAdd(u),t=c,e=a.redMul(s.redISub(c)).redISub(u),r=this.y.redAdd(this.y)}else{var f=this.x.redSqr(),h=this.y.redSqr(),d=h.redSqr(),p=this.x.redAdd(h).redSqr().redISub(f).redISub(d);p=p.redIAdd(p);var l=f.redAdd(f).redIAdd(f),g=l.redSqr(),m=d.redIAdd(d);m=(m=m.redIAdd(m)).redIAdd(m),t=g.redISub(p).redISub(p),e=l.redMul(p.redISub(t)).redISub(m),r=(r=this.y.redMul(this.z)).redIAdd(r)}return this.curve.jpoint(t,e,r)},f.prototype._threeDbl=function(){var t,e,r;if(this.zOne){var n=this.x.redSqr(),i=this.y.redSqr(),o=i.redSqr(),s=this.x.redAdd(i).redSqr().redISub(n).redISub(o);s=s.redIAdd(s);var a=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),c=a.redSqr().redISub(s).redISub(s);t=c;var u=o.redIAdd(o);u=(u=u.redIAdd(u)).redIAdd(u),e=a.redMul(s.redISub(c)).redISub(u),r=this.y.redAdd(this.y)}else{var f=this.z.redSqr(),h=this.y.redSqr(),d=this.x.redMul(h),p=this.x.redSub(f).redMul(this.x.redAdd(f));p=p.redAdd(p).redIAdd(p);var l=d.redIAdd(d),g=(l=l.redIAdd(l)).redAdd(l);t=p.redSqr().redISub(g),r=this.y.redAdd(this.z).redSqr().redISub(h).redISub(f);var m=h.redSqr();m=(m=(m=m.redIAdd(m)).redIAdd(m)).redIAdd(m),e=p.redMul(l.redISub(t)).redISub(m)}return this.curve.jpoint(t,e,r)},f.prototype._dbl=function(){var t=this.curve.a,e=this.x,r=this.y,n=this.z,i=n.redSqr().redSqr(),o=e.redSqr(),s=r.redSqr(),a=o.redAdd(o).redIAdd(o).redIAdd(t.redMul(i)),c=e.redAdd(e),u=(c=c.redIAdd(c)).redMul(s),f=a.redSqr().redISub(u.redAdd(u)),h=u.redISub(f),d=s.redSqr();d=(d=(d=d.redIAdd(d)).redIAdd(d)).redIAdd(d);var p=a.redMul(h).redISub(d),l=r.redAdd(r).redMul(n);return this.curve.jpoint(f,p,l)},f.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr(),n=e.redSqr(),i=t.redAdd(t).redIAdd(t),o=i.redSqr(),s=this.x.redAdd(e).redSqr().redISub(t).redISub(n),a=(s=(s=(s=s.redIAdd(s)).redAdd(s).redIAdd(s)).redISub(o)).redSqr(),c=n.redIAdd(n);c=(c=(c=c.redIAdd(c)).redIAdd(c)).redIAdd(c);var u=i.redIAdd(s).redSqr().redISub(o).redISub(a).redISub(c),f=e.redMul(u);f=(f=f.redIAdd(f)).redIAdd(f);var h=this.x.redMul(a).redISub(f);h=(h=h.redIAdd(h)).redIAdd(h);var d=this.y.redMul(u.redMul(c.redISub(u)).redISub(s.redMul(a)));d=(d=(d=d.redIAdd(d)).redIAdd(d)).redIAdd(d);var p=this.z.redAdd(s).redSqr().redISub(r).redISub(a);return this.curve.jpoint(h,d,p)},f.prototype.mul=function(t,e){return t=new i(t,e),this.curve._wnafMul(this,t)},f.prototype.eq=function(t){if("affine"===t.type)return this.eq(t.toJ());if(this===t)return!0;var e=this.z.redSqr(),r=t.z.redSqr();if(0!==this.x.redMul(r).redISub(t.x.redMul(e)).cmpn(0))return!1;var n=e.redMul(this.z),i=r.redMul(t.z);return 0===this.y.redMul(i).redISub(t.y.redMul(n)).cmpn(0)},f.prototype.eqXToP=function(t){var e=this.z.redSqr(),r=t.toRed(this.curve.red).redMul(e);if(0===this.x.cmp(r))return!0;for(var n=t.clone(),i=this.curve.redN.redMul(e);;){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(t,e,r){"use strict";var n=r(9),i=r(42),o=r(32),s=r(8);function a(t){o.call(this,"mont",t),this.a=new n(t.a,16).toRed(this.red),this.b=new n(t.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 c(t,e,r){o.BasePoint.call(this,t,"projective"),null===e&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new n(e,16),this.z=new n(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}i(a,o),t.exports=a,a.prototype.validate=function(t){var e=t.normalize().x,r=e.redSqr(),n=r.redMul(e).redAdd(r.redMul(this.a)).redAdd(e);return 0===n.redSqrt().redSqr().cmp(n)},i(c,o.BasePoint),a.prototype.decodePoint=function(t,e){return this.point(s.toArray(t,e),1)},a.prototype.point=function(t,e){return new c(this,t,e)},a.prototype.pointFromJSON=function(t){return c.fromJSON(this,t)},c.prototype.precompute=function(){},c.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},c.fromJSON=function(t,e){return new c(t,e[0],e[1]||t.one)},c.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)+">"},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},c.prototype.dbl=function(){var t=this.x.redAdd(this.z).redSqr(),e=this.x.redSub(this.z).redSqr(),r=t.redSub(e),n=t.redMul(e),i=r.redMul(e.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},c.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.diffAdd=function(t,e){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=t.x.redAdd(t.z),o=t.x.redSub(t.z).redMul(r),s=i.redMul(n),a=e.z.redMul(o.redAdd(s).redSqr()),c=e.x.redMul(o.redISub(s).redSqr());return this.curve.point(a,c)},c.prototype.mul=function(t){for(var e=t.clone(),r=this,n=this.curve.point(null,null),i=[];0!==e.cmpn(0);e.iushrn(1))i.push(e.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},c.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.eq=function(t){return 0===this.getX().cmp(t.getX())},c.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},c.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},function(t,e,r){"use strict";var n=r(8),i=r(9),o=r(42),s=r(32),a=n.assert;function c(t){this.twisted=1!=(0|t.a),this.mOneA=this.twisted&&-1==(0|t.a),this.extended=this.mOneA,s.call(this,"edwards",t),this.a=new i(t.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new i(t.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new i(t.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),a(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|t.c)}function u(t,e,r,n,o){s.BasePoint.call(this,t,"projective"),null===e&&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(e,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(c,s),t.exports=c,c.prototype._mulA=function(t){return this.mOneA?t.redNeg():this.a.redMul(t)},c.prototype._mulC=function(t){return this.oneC?t:this.c.redMul(t)},c.prototype.jpoint=function(t,e,r,n){return this.point(t,e,r,n)},c.prototype.pointFromX=function(t,e){(t=new i(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr(),n=this.c2.redSub(this.a.redMul(r)),o=this.one.redSub(this.c2.redMul(this.d).redMul(r)),s=n.redMul(o.redInvm()),a=s.redSqrt();if(0!==a.redSqr().redSub(s).cmp(this.zero))throw new Error("invalid point");var c=a.fromRed().isOdd();return(e&&!c||!e&&c)&&(a=a.redNeg()),this.point(t,a)},c.prototype.pointFromY=function(t,e){(t=new i(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr(),n=r.redSub(this.c2),o=r.redMul(this.d).redMul(this.c2).redSub(this.a),s=n.redMul(o.redInvm());if(0===s.cmp(this.zero)){if(e)throw new Error("invalid point");return this.point(this.zero,t)}var a=s.redSqrt();if(0!==a.redSqr().redSub(s).cmp(this.zero))throw new Error("invalid point");return a.fromRed().isOdd()!==e&&(a=a.redNeg()),this.point(a,t)},c.prototype.validate=function(t){if(t.isInfinity())return!0;t.normalize();var e=t.x.redSqr(),r=t.y.redSqr(),n=e.redMul(this.a).redAdd(r),i=this.c2.redMul(this.one.redAdd(this.d.redMul(e).redMul(r)));return 0===n.cmp(i)},o(u,s.BasePoint),c.prototype.pointFromJSON=function(t){return u.fromJSON(this,t)},c.prototype.point=function(t,e,r,n){return new u(this,t,e,r,n)},u.fromJSON=function(t,e){return new u(t,e[0],e[1],e[2])},u.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)+">"},u.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},u.prototype._extDbl=function(){var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(t),i=this.x.redAdd(this.y).redSqr().redISub(t).redISub(e),o=n.redAdd(e),s=o.redSub(r),a=n.redSub(e),c=i.redMul(s),u=o.redMul(a),f=i.redMul(a),h=s.redMul(o);return this.curve.point(c,u,h,f)},u.prototype._projDbl=function(){var t,e,r,n,i,o,s=this.x.redAdd(this.y).redSqr(),a=this.x.redSqr(),c=this.y.redSqr();if(this.curve.twisted){var u=(n=this.curve._mulA(a)).redAdd(c);this.zOne?(t=s.redSub(a).redSub(c).redMul(u.redSub(this.curve.two)),e=u.redMul(n.redSub(c)),r=u.redSqr().redSub(u).redSub(u)):(i=this.z.redSqr(),o=u.redSub(i).redISub(i),t=s.redSub(a).redISub(c).redMul(o),e=u.redMul(n.redSub(c)),r=u.redMul(o))}else n=a.redAdd(c),i=this.curve._mulC(this.z).redSqr(),o=n.redSub(i).redSub(i),t=this.curve._mulC(s.redISub(n)).redMul(o),e=this.curve._mulC(n).redMul(a.redISub(c)),r=n.redMul(o);return this.curve.point(t,e,r)},u.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},u.prototype._extAdd=function(t){var e=this.y.redSub(this.x).redMul(t.y.redSub(t.x)),r=this.y.redAdd(this.x).redMul(t.y.redAdd(t.x)),n=this.t.redMul(this.curve.dd).redMul(t.t),i=this.z.redMul(t.z.redAdd(t.z)),o=r.redSub(e),s=i.redSub(n),a=i.redAdd(n),c=r.redAdd(e),u=o.redMul(s),f=a.redMul(c),h=o.redMul(c),d=s.redMul(a);return this.curve.point(u,f,d,h)},u.prototype._projAdd=function(t){var e,r,n=this.z.redMul(t.z),i=n.redSqr(),o=this.x.redMul(t.x),s=this.y.redMul(t.y),a=this.curve.d.redMul(o).redMul(s),c=i.redSub(a),u=i.redAdd(a),f=this.x.redAdd(this.y).redMul(t.x.redAdd(t.y)).redISub(o).redISub(s),h=n.redMul(c).redMul(f);return this.curve.twisted?(e=n.redMul(u).redMul(s.redSub(this.curve._mulA(o))),r=c.redMul(u)):(e=n.redMul(u).redMul(s.redSub(o)),r=this.curve._mulC(c).redMul(u)),this.curve.point(h,e,r)},u.prototype.add=function(t){return this.isInfinity()?t:t.isInfinity()?this:this.curve.extended?this._extAdd(t):this._projAdd(t)},u.prototype.mul=function(t){return this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve._wnafMul(this,t)},u.prototype.mulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!1)},u.prototype.jmulAdd=function(t,e,r){return this.curve._wnafMulAdd(1,[this,e],[t,r],2,!0)},u.prototype.normalize=function(){if(this.zOne)return this;var t=this.z.redInvm();return this.x=this.x.redMul(t),this.y=this.y.redMul(t),this.t&&(this.t=this.t.redMul(t)),this.z=this.curve.one,this.zOne=!0,this},u.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},u.prototype.getX=function(){return this.normalize(),this.x.fromRed()},u.prototype.getY=function(){return this.normalize(),this.y.fromRed()},u.prototype.eq=function(t){return this===t||0===this.getX().cmp(t.getX())&&0===this.getY().cmp(t.getY())},u.prototype.eqXToP=function(t){var e=t.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(e))return!0;for(var r=t.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(e.redIAdd(n),0===this.x.cmp(e))return!0}},u.prototype.toP=u.prototype.normalize,u.prototype.mixedAdd=u.prototype.add},function(t,e,r){"use strict";e.sha1=r(91),e.sha224=r(92),e.sha256=r(59),e.sha384=r(93),e.sha512=r(60)},function(t,e,r){"use strict";var n=r(13),i=r(27),o=r(58),s=n.rotl32,a=n.sum32,c=n.sum32_5,u=o.ft_1,f=i.BlockHash,h=[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),t.exports=d,d.blockSize=512,d.outSize=160,d.hmacStrength=80,d.padLength=64,d.prototype._update=function(t,e){for(var r=this.W,n=0;n<16;n++)r[n]=t[e+n];for(;n<r.length;n++)r[n]=s(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],p=this.h[4];for(n=0;n<r.length;n++){var l=~~(n/20),g=c(s(i,5),u(l,o,f,d),p,r[n],h[l]);p=d,d=f,f=s(o,30),o=i,i=g}this.h[0]=a(this.h[0],i),this.h[1]=a(this.h[1],o),this.h[2]=a(this.h[2],f),this.h[3]=a(this.h[3],d),this.h[4]=a(this.h[4],p)},d.prototype._digest=function(t){return"hex"===t?n.toHex32(this.h,"big"):n.split32(this.h,"big")}},function(t,e,r){"use strict";var n=r(13),i=r(59);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),t.exports=o,o.blockSize=512,o.outSize=224,o.hmacStrength=192,o.padLength=64,o.prototype._digest=function(t){return"hex"===t?n.toHex32(this.h.slice(0,7),"big"):n.split32(this.h.slice(0,7),"big")}},function(t,e,r){"use strict";var n=r(13),i=r(60);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),t.exports=o,o.blockSize=1024,o.outSize=384,o.hmacStrength=192,o.padLength=128,o.prototype._digest=function(t){return"hex"===t?n.toHex32(this.h.slice(0,12),"big"):n.split32(this.h.slice(0,12),"big")}},function(t,e,r){"use strict";var n=r(13),i=r(27),o=n.rotl32,s=n.sum32,a=n.sum32_3,c=n.sum32_4,u=i.BlockHash;function f(){if(!(this instanceof f))return new f;u.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}function h(t,e,r,n){return t<=15?e^r^n:t<=31?e&r|~e&n:t<=47?(e|~r)^n:t<=63?e&n|r&~n:e^(r|~n)}function d(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function p(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}n.inherits(f,u),e.ripemd160=f,f.blockSize=512,f.outSize=160,f.hmacStrength=192,f.padLength=64,f.prototype._update=function(t,e){for(var r=this.h[0],n=this.h[1],i=this.h[2],u=this.h[3],f=this.h[4],y=r,v=n,S=i,_=u,w=f,I=0;I<80;I++){var O=s(o(c(r,h(I,n,i,u),t[l[I]+e],d(I)),m[I]),f);r=f,f=u,u=o(i,10),i=n,n=O,O=s(o(c(y,h(79-I,v,S,_),t[g[I]+e],p(I)),b[I]),w),y=w,w=_,_=o(S,10),S=v,v=O}O=a(this.h[1],i,_),this.h[1]=a(this.h[2],u,w),this.h[2]=a(this.h[3],f,y),this.h[3]=a(this.h[4],r,v),this.h[4]=a(this.h[0],n,S),this.h[0]=O},f.prototype._digest=function(t){return"hex"===t?n.toHex32(this.h,"little"):n.split32(this.h,"little")};var l=[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],g=[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],b=[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(t,e,r){"use strict";var n=r(13),i=r(22);function o(t,e,r){if(!(this instanceof o))return new o(t,e,r);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(n.toArray(e,r))}t.exports=o,o.prototype._init=function(t){t.length>this.blockSize&&(t=(new this.Hash).update(t).digest()),i(t.length<=this.blockSize);for(var e=t.length;e<this.blockSize;e++)t.push(0);for(e=0;e<t.length;e++)t[e]^=54;for(this.inner=(new this.Hash).update(t),e=0;e<t.length;e++)t[e]^=106;this.outer=(new this.Hash).update(t)},o.prototype.update=function(t,e){return this.inner.update(t,e),this},o.prototype.digest=function(t){return this.outer.update(this.inner.digest()),this.outer.digest(t)}},function(t,e){t.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(t,e,r){"use strict";var n=r(9),i=r(98),o=r(8),s=r(43),a=r(56),c=o.assert,u=r(99),f=r(100);function h(t){if(!(this instanceof h))return new h(t);"string"==typeof t&&(c(Object.prototype.hasOwnProperty.call(s,t),"Unknown curve "+t),t=s[t]),t instanceof s.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}t.exports=h,h.prototype.keyPair=function(t){return new u(this,t)},h.prototype.keyFromPrivate=function(t,e){return u.fromPrivate(this,t,e)},h.prototype.keyFromPublic=function(t,e){return u.fromPublic(this,t,e)},h.prototype.genKeyPair=function(t){t||(t={});for(var e=new i({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||a(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),o=this.n.sub(new n(2));;){var s=new n(e.generate(r));if(!(s.cmp(o)>0))return s.iaddn(1),this.keyFromPrivate(s)}},h.prototype._truncateToN=function(t,e,r){var i;if(n.isBN(t)||"number"==typeof t)i=(t=new n(t,16)).byteLength();else if("object"==typeof t)i=t.length,t=new n(t,16);else{var o=t.toString();i=o.length+1>>>1,t=new n(o,16)}"number"!=typeof r&&(r=8*i);var s=r-this.n.bitLength();return s>0&&(t=t.ushrn(s)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},h.prototype.sign=function(t,e,r,o){if("object"==typeof r&&(o=r,r=null),o||(o={}),"string"!=typeof t&&"number"!=typeof t&&!n.isBN(t)){c("object"==typeof t&&t&&"number"==typeof t.length,"Expected message to be an array-like, a hex string, or a BN instance"),c(t.length>>>0===t.length);for(var s=0;s<t.length;s++)c((255&t[s])===t[s])}e=this.keyFromPrivate(e,r),t=this._truncateToN(t,!1,o.msgBitLength),c(!t.isNeg(),"Can not sign a negative message");var a=this.n.byteLength(),u=e.getPrivate().toArray("be",a),h=t.toArray("be",a);c(new n(h).eq(t),"Can not sign message");for(var d=new i({hash:this.hash,entropy:u,nonce:h,pers:o.pers,persEnc:o.persEnc||"utf8"}),p=this.n.sub(new n(1)),l=0;;l++){var g=o.k?o.k(l):new n(d.generate(this.n.byteLength()));if(!((g=this._truncateToN(g,!0)).cmpn(1)<=0||g.cmp(p)>=0)){var m=this.g.mul(g);if(!m.isInfinity()){var b=m.getX(),y=b.umod(this.n);if(0!==y.cmpn(0)){var v=g.invm(this.n).mul(y.mul(e.getPrivate()).iadd(t));if(0!==(v=v.umod(this.n)).cmpn(0)){var S=(m.getY().isOdd()?1:0)|(0!==b.cmp(y)?2:0);return o.canonical&&v.cmp(this.nh)>0&&(v=this.n.sub(v),S^=1),new f({r:y,s:v,recoveryParam:S})}}}}}},h.prototype.verify=function(t,e,r,n,i){i||(i={}),t=this._truncateToN(t,!1,i.msgBitLength),r=this.keyFromPublic(r,n);var o=(e=new f(e,"hex")).r,s=e.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var a,c=s.invm(this.n),u=c.mul(t).umod(this.n),h=c.mul(o).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(u,r.getPublic(),h)).isInfinity()&&a.eqXToP(o):!(a=this.g.mulAdd(u,r.getPublic(),h)).isInfinity()&&0===a.getX().umod(this.n).cmp(o)},h.prototype.recoverPubKey=function(t,e,r,i){c((3&r)===r,"The recovery param is more than two bits"),e=new f(e,i);var o=this.n,s=new n(t),a=e.r,u=e.s,h=1&r,d=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&d)throw new Error("Unable to find sencond key candinate");a=d?this.curve.pointFromX(a.add(this.curve.n),h):this.curve.pointFromX(a,h);var p=e.r.invm(o),l=o.sub(s).mul(p).umod(o),g=u.mul(p).umod(o);return this.g.mulAdd(l,a,g)},h.prototype.getKeyRecoveryParam=function(t,e,r,n){if(null!==(e=new f(e,n)).recoveryParam)return e.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(t,e,i)}catch(t){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},function(t,e,r){"use strict";var n=r(33),i=r(55),o=r(22);function s(t){if(!(this instanceof s))return new s(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=i.toArray(t.entropy,t.entropyEnc||"hex"),r=i.toArray(t.nonce,t.nonceEnc||"hex"),n=i.toArray(t.pers,t.persEnc||"hex");o(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}t.exports=s,s.prototype._init=function(t,e,r){var n=t.concat(e).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},s.prototype._hmac=function(){return new n.hmac(this.hash,this.K)},s.prototype._update=function(t){var e=this._hmac().update(this.V).update([0]);t&&(e=e.update(t)),this.K=e.digest(),this.V=this._hmac().update(this.V).digest(),t&&(this.K=this._hmac().update(this.V).update([1]).update(t).digest(),this.V=this._hmac().update(this.V).digest())},s.prototype.reseed=function(t,e,r,n){"string"!=typeof e&&(n=r,r=e,e=null),t=i.toArray(t,e),r=i.toArray(r,n),o(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},s.prototype.generate=function(t,e,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(n=r,r=e,e=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var o=[];o.length<t;)this.V=this._hmac().update(this.V).digest(),o=o.concat(this.V);var s=o.slice(0,t);return this._update(r),this._reseed++,i.encode(s,e)}},function(t,e,r){"use strict";var n=r(9),i=r(8).assert;function o(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}t.exports=o,o.fromPublic=function(t,e,r){return e instanceof o?e:new o(t,{pub:e,pubEnc:r})},o.fromPrivate=function(t,e,r){return e instanceof o?e:new o(t,{priv:e,privEnc:r})},o.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.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(t,e){return"string"==typeof t&&(e=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,t):this.pub},o.prototype.getPrivate=function(t){return"hex"===t?this.priv.toString(16,2):this.priv},o.prototype._importPrivate=function(t,e){this.priv=new n(t,e||16),this.priv=this.priv.umod(this.ec.curve.n)},o.prototype._importPublic=function(t,e){if(t.x||t.y)return"mont"===this.ec.curve.type?i(t.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||i(t.x&&t.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(t.x,t.y));this.pub=this.ec.curve.decodePoint(t,e)},o.prototype.derive=function(t){return t.validate()||i(t.validate(),"public point not validated"),t.mul(this.priv).getX()},o.prototype.sign=function(t,e,r){return this.ec.sign(t,this,e,r)},o.prototype.verify=function(t,e,r){return this.ec.verify(t,e,this,void 0,r)},o.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"}},function(t,e,r){"use strict";var n=r(9),i=r(8),o=i.assert;function s(t,e){if(t instanceof s)return t;this._importDER(t,e)||(o(t.r&&t.s,"Signature without r or s"),this.r=new n(t.r,16),this.s=new n(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}function a(){this.place=0}function c(t,e){var r=t[e.place++];if(!(128&r))return r;var n=15&r;if(0===n||n>4)return!1;if(0===t[e.place])return!1;for(var i=0,o=0,s=e.place;o<n;o++,s++)i<<=8,i|=t[s],i>>>=0;return!(i<=127)&&(e.place=s,i)}function u(t){for(var e=0,r=t.length-1;!t[e]&&!(128&t[e+1])&&e<r;)e++;return 0===e?t:t.slice(e)}function f(t,e){if(e<128)t.push(e);else{var r=1+(Math.log(e)/Math.LN2>>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}t.exports=s,s.prototype._importDER=function(t,e){t=i.toArray(t,e);var r=new a;if(48!==t[r.place++])return!1;var o=c(t,r);if(!1===o)return!1;if(o+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var s=c(t,r);if(!1===s)return!1;if(0!=(128&t[r.place]))return!1;var u=t.slice(r.place,s+r.place);if(r.place+=s,2!==t[r.place++])return!1;var f=c(t,r);if(!1===f)return!1;if(t.length!==f+r.place)return!1;if(0!=(128&t[r.place]))return!1;var h=t.slice(r.place,f+r.place);if(0===u[0]){if(!(128&u[1]))return!1;u=u.slice(1)}if(0===h[0]){if(!(128&h[1]))return!1;h=h.slice(1)}return this.r=new n(u),this.s=new n(h),this.recoveryParam=null,!0},s.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=u(e),r=u(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];f(n,e.length),(n=n.concat(e)).push(2),f(n,r.length);var o=n.concat(r),s=[48];return f(s,o.length),s=s.concat(o),i.encode(s,t)}},function(t,e,r){"use strict";var n=r(33),i=r(43),o=r(8),s=o.assert,a=o.parseBytes,c=r(102),u=r(103);function f(t){if(s("ed25519"===t,"only tested with ed25519 so far"),!(this instanceof f))return new f(t);t=i[t].curve,this.curve=t,this.g=t.g,this.g.precompute(t.n.bitLength()+1),this.pointClass=t.point().constructor,this.encodingLength=Math.ceil(t.n.bitLength()/8),this.hash=n.sha512}t.exports=f,f.prototype.sign=function(t,e){t=a(t);var r=this.keyFromSecret(e),n=this.hashInt(r.messagePrefix(),t),i=this.g.mul(n),o=this.encodePoint(i),s=this.hashInt(o,r.pubBytes(),t).mul(r.priv()),c=n.add(s).umod(this.curve.n);return this.makeSignature({R:i,S:c,Rencoded:o})},f.prototype.verify=function(t,e,r){if(t=a(t),(e=this.makeSignature(e)).S().gte(e.eddsa.curve.n)||e.S().isNeg())return!1;var n=this.keyFromPublic(r),i=this.hashInt(e.Rencoded(),n.pubBytes(),t),o=this.g.mul(e.S());return e.R().add(n.pub().mul(i)).eq(o)},f.prototype.hashInt=function(){for(var t=this.hash(),e=0;e<arguments.length;e++)t.update(arguments[e]);return o.intFromLE(t.digest()).umod(this.curve.n)},f.prototype.keyFromPublic=function(t){return c.fromPublic(this,t)},f.prototype.keyFromSecret=function(t){return c.fromSecret(this,t)},f.prototype.makeSignature=function(t){return t instanceof u?t:new u(this,t)},f.prototype.encodePoint=function(t){var e=t.getY().toArray("le",this.encodingLength);return e[this.encodingLength-1]|=t.getX().isOdd()?128:0,e},f.prototype.decodePoint=function(t){var e=(t=o.parseBytes(t)).length-1,r=t.slice(0,e).concat(-129&t[e]),n=0!=(128&t[e]),i=o.intFromLE(r);return this.curve.pointFromY(i,n)},f.prototype.encodeInt=function(t){return t.toArray("le",this.encodingLength)},f.prototype.decodeInt=function(t){return o.intFromLE(t)},f.prototype.isPoint=function(t){return t instanceof this.pointClass}},function(t,e,r){"use strict";var n=r(8),i=n.assert,o=n.parseBytes,s=n.cachedProperty;function a(t,e){this.eddsa=t,this._secret=o(e.secret),t.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=o(e.pub)}a.fromPublic=function(t,e){return e instanceof a?e:new a(t,{pub:e})},a.fromSecret=function(t,e){return e instanceof a?e:new a(t,{secret:e})},a.prototype.secret=function(){return this._secret},s(a,"pubBytes",(function(){return this.eddsa.encodePoint(this.pub())})),s(a,"pub",(function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())})),s(a,"privBytes",(function(){var t=this.eddsa,e=this.hash(),r=t.encodingLength-1,n=e.slice(0,t.encodingLength);return n[0]&=248,n[r]&=127,n[r]|=64,n})),s(a,"priv",(function(){return this.eddsa.decodeInt(this.privBytes())})),s(a,"hash",(function(){return this.eddsa.hash().update(this.secret()).digest()})),s(a,"messagePrefix",(function(){return this.hash().slice(this.eddsa.encodingLength)})),a.prototype.sign=function(t){return i(this._secret,"KeyPair can only verify"),this.eddsa.sign(t,this)},a.prototype.verify=function(t,e){return this.eddsa.verify(t,e,this)},a.prototype.getSecret=function(t){return i(this._secret,"KeyPair is public only"),n.encode(this.secret(),t)},a.prototype.getPublic=function(t){return n.encode(this.pubBytes(),t)},t.exports=a},function(t,e,r){"use strict";var n=r(9),i=r(8),o=i.assert,s=i.cachedProperty,a=i.parseBytes;function c(t,e){this.eddsa=t,"object"!=typeof e&&(e=a(e)),Array.isArray(e)&&(o(e.length===2*t.encodingLength,"Signature has invalid size"),e={R:e.slice(0,t.encodingLength),S:e.slice(t.encodingLength)}),o(e.R&&e.S,"Signature without R or S"),t.isPoint(e.R)&&(this._R=e.R),e.S instanceof n&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}s(c,"S",(function(){return this.eddsa.decodeInt(this.Sencoded())})),s(c,"R",(function(){return this.eddsa.decodePoint(this.Rencoded())})),s(c,"Rencoded",(function(){return this.eddsa.encodePoint(this.R())})),s(c,"Sencoded",(function(){return this.eddsa.encodeInt(this.S())})),c.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},c.prototype.toHex=function(){return i.encode(this.toBytes(),"hex").toUpperCase()},t.exports=c},function(t){t.exports={name:"@smartledger/bsv",version:"3.2.1",description:"Advanced Bitcoin SV library with JavaScript-to-Bitcoin Script framework - Complete BSV API + BIP143 preimage parsing + 121 opcode mapping + covenant builder + nChain PUSHTX techniques + custom script development + integrated debugging tools",author:"SmartLedger Technology <hello@smartledger.technology> (https://smartledger.technology)",homepage:"https://github.com/codenlighten/smartledger-bsv#readme",bugs:{url:"https://github.com/codenlighten/smartledger-bsv/issues"},main:"index.js",scripts:{lint:"standard",test:"standard && mocha","test:signatures":"node validation_test.js","test:js2script":"node lib/smart_contract/opcode_map.js && node lib/smart_contract/covenant_builder.js","test:opcodes":"node lib/smart_contract/opcode_list.js","test:covenants":"node examples/covenants/advanced_covenant_demo.js","test:scripts":"node examples/scripts/custom_script_signature_test.js","test:basic":"node examples/basic/transaction-creation.js","test:all":"npm test && npm run test:covenants && npm run test:scripts",coverage:"nyc --reporter=text npm run test","build-bsv":'NODE_OPTIONS="--openssl-legacy-provider" webpack index.js --config webpack.config.js',"build-ecies":'NODE_OPTIONS="--openssl-legacy-provider" webpack ecies/index.js --config webpack.subproject.config.js --output-library bsvEcies -o bsv-ecies.min.js',"build-message":'NODE_OPTIONS="--openssl-legacy-provider" webpack message/index.js --config webpack.subproject.config.js --output-library bsvMessage -o bsv-message.min.js',"build-mnemonic":'NODE_OPTIONS="--openssl-legacy-provider" webpack mnemonic/index.js --config webpack.subproject.config.js --output-library bsvMnemonic -o bsv-mnemonic.min.js',"build-bundle":'NODE_OPTIONS="--openssl-legacy-provider" webpack bundle-entry.js --config webpack.bundle.config.js',build:"npm run build-bsv && npm run build-ecies && npm run build-message && npm run build-mnemonic","build-all":"npm run build && npm run build-bundle",demo:"npm run test:covenants","demo:basic":"npm run test:basic","demo:scripts":"npm run test:scripts","demo:preimage":"echo '🧠 BIP-143 Preimage Extractor Demo' && node examples/preimage/extract_preimage_bidirectional.js","preimage:extract":"node examples/preimage/extract_preimage_bidirectional.js",prepublishOnly:'NODE_OPTIONS="--openssl-legacy-provider" npm run build'},unpkg:"bsv.min.js",jsdelivr:"bsv.min.js",cdn:"bsv.min.js",files:["index.js","lib/","utilities/","ecies/","message/","mnemonic/","bsv.min.js","bsv.bundle.js","bsv-ecies.min.js","bsv-message.min.js","bsv-mnemonic.min.js","bsv.d.ts","validation_test.js","docs/","examples/","LICENSE","README.md","SECURITY.md","CHANGELOG.md"],keywords:["bitcoin","bitcoin-sv","bsv","transaction","address","cryptocurrency","blockchain","security","hardened","vulnerability-free","drop-in-replacement","covenant","covenants","pushtx","pels","bip143","preimage","nchain","custom-scripts","multisig","timelock","conditional-scripts","utxo-management","ultra-low-fees","javascript-to-script","opcode-mapping","covenant-builder","script-simulation","bitcoin-script","asm-generation","advanced-features","script-development","blockchain-simulator","miner-simulator","testing-tools","development-framework","ecies","p2p","payment","bip21","bip32","bip37","bip69","bip70"],repository:{type:"git",url:"https://github.com/codenlighten/smartledger-bsv"},browser:{request:"browser-request"},dependencies:{"aes-js":"^3.1.2","bn.js":"=4.11.9",bs58:"=4.0.1","clone-deep":"^4.0.1",elliptic:"6.6.1","hash.js":"^1.1.7",inherits:"2.0.3",unorm:"1.4.1"},devDependencies:{brfs:"2.0.1",chai:"4.2.0",mocha:"^8.4.0",nyc:"^14.1.1",sinon:"7.2.3",standard:"12.0.1",webpack:"4.29.3","webpack-cli":"^3.3.12"},license:"MIT",standard:{globals:["after","afterEach","before","beforeEach","describe","it"],ignore:["dist/**"]}}},function(t,e,r){"use strict";var n="https://docs.moneybutton.com/";t.exports=[{name:"InvalidB58Char",message:"Invalid Base58 character: {0} in {1}"},{name:"InvalidB58Checksum",message:"Invalid Base58 checksum for {0}"},{name:"InvalidNetwork",message:"Invalid version for network: got {0}"},{name:"InvalidState",message:"Invalid state: {0}"},{name:"NotImplemented",message:"Function {0} was not implemented yet"},{name:"InvalidNetworkArgument",message:'Invalid network: must be "livenet" or "testnet", got {0}'},{name:"InvalidArgument",message:function(){return"Invalid Argument"+(arguments[0]?": "+arguments[0]:"")+(arguments[1]?" Documentation: "+n+arguments[1]:"")}},{name:"AbstractMethodInvoked",message:"Abstract Method Invocation: {0}"},{name:"InvalidArgumentType",message:function(){return"Invalid Argument for "+arguments[2]+", expected "+arguments[1]+" but got "+typeof arguments[0]}},{name:"Unit",message:"Internal Error on Unit {0}",errors:[{name:"UnknownCode",message:"Unrecognized unit code: {0}"},{name:"InvalidRate",message:"Invalid exchange rate: {0}"}]},{name:"MerkleBlock",message:"Internal Error on MerkleBlock {0}",errors:[{name:"InvalidMerkleTree",message:"This MerkleBlock contain an invalid Merkle Tree"}]},{name:"Transaction",message:"Internal Error on Transaction {0}",errors:[{name:"Input",message:"Internal Error on Input {0}",errors:[{name:"MissingScript",message:"Need a script to create an input"},{name:"UnsupportedScript",message:"Unsupported input script type: {0}"},{name:"MissingPreviousOutput",message:"No previous output information."}]},{name:"NeedMoreInfo",message:"{0}"},{name:"InvalidSorting",message:"The sorting function provided did not return the change output as one of the array elements"},{name:"InvalidOutputAmountSum",message:"{0}"},{name:"MissingSignatures",message:"Some inputs have not been fully signed"},{name:"InvalidIndex",message:"Invalid index: {0} is not between 0, {1}"},{name:"UnableToVerifySignature",message:"Unable to verify signature: {0}"},{name:"DustOutputs",message:"Dust amount detected in one output"},{name:"InvalidSatoshis",message:"Output satoshis are invalid"},{name:"FeeError",message:"Internal Error on Fee {0}",errors:[{name:"TooSmall",message:"Fee is too small: {0}"},{name:"TooLarge",message:"Fee is too large: {0}"},{name:"Different",message:"Unspent value is different from specified fee: {0}"}]},{name:"ChangeAddressMissing",message:"Change address is missing"},{name:"BlockHeightTooHigh",message:"Block Height can be at most 2^32 -1"},{name:"NLockTimeOutOfRange",message:"Block Height can only be between 0 and 499 999 999"},{name:"LockTimeTooEarly",message:"Lock Time can't be earlier than UNIX date 500 000 000"}]},{name:"Script",message:"Internal Error on Script {0}",errors:[{name:"UnrecognizedAddress",message:"Expected argument {0} to be an address"},{name:"CantDeriveAddress",message:"Can't derive address associated with script {0}, needs to be p2pkh in, p2pkh out, p2sh in, or p2sh out."},{name:"InvalidBuffer",message:"Invalid script buffer: can't parse valid script from given buffer {0}"}]},{name:"HDPrivateKey",message:"Internal Error on HDPrivateKey {0}",errors:[{name:"InvalidDerivationArgument",message:"Invalid derivation argument {0}, expected string, or number and boolean"},{name:"InvalidEntropyArgument",message:"Invalid entropy: must be an hexa string or binary buffer, got {0}",errors:[{name:"TooMuchEntropy",message:'Invalid entropy: more than 512 bits is non standard, got "{0}"'},{name:"NotEnoughEntropy",message:'Invalid entropy: at least 128 bits needed, got "{0}"'}]},{name:"InvalidLength",message:"Invalid length for xprivkey string in {0}"},{name:"InvalidPath",message:"Invalid derivation path: {0}"},{name:"UnrecognizedArgument",message:'Invalid argument: creating a HDPrivateKey requires a string, buffer, json or object, got "{0}"'}]},{name:"HDPublicKey",message:"Internal Error on HDPublicKey {0}",errors:[{name:"ArgumentIsPrivateExtended",message:"Argument is an extended private key: {0}"},{name:"InvalidDerivationArgument",message:"Invalid derivation argument: got {0}"},{name:"InvalidLength",message:'Invalid length for xpubkey: got "{0}"'},{name:"InvalidPath",message:'Invalid derivation path, it should look like: "m/1/100", got "{0}"'},{name:"InvalidIndexCantDeriveHardened",message:"Invalid argument: creating a hardened path requires an HDPrivateKey"},{name:"MustSupplyArgument",message:"Must supply an argument to create a HDPublicKey"},{name:"UnrecognizedArgument",message:"Invalid argument for creation, must be string, json, buffer, or object"}]}]},function(t,e,r){"use strict";(function(e){var n=r(33),i=r(2),o=t.exports;o.sha1=function(t){return i.checkArgument(e.isBuffer(t)),e.from(n.sha1().update(t).digest("hex"),"hex")},o.sha1.blocksize=512,o.sha256=function(t){return i.checkArgument(e.isBuffer(t)),e.from(n.sha256().update(t).digest("hex"),"hex")},o.sha256.blocksize=512,o.sha256sha256=function(t){return i.checkArgument(e.isBuffer(t)),o.sha256(o.sha256(t))},o.ripemd160=function(t){return i.checkArgument(e.isBuffer(t)),e.from(n.ripemd160().update(t).digest("hex"),"hex")},o.sha256ripemd160=function(t){return i.checkArgument(e.isBuffer(t)),o.ripemd160(o.sha256(t))},o.sha512=function(t){return i.checkArgument(e.isBuffer(t)),e.from(n.sha512().update(t).digest("hex"),"hex")},o.sha512.blocksize=1024,o.hmac=function(t,r,n){i.checkArgument(e.isBuffer(r)),i.checkArgument(e.isBuffer(n)),i.checkArgument(t.blocksize);var o=t.blocksize/8;if(n.length>o)n=t(n);else if(n<o){var s=e.alloc(o);s.fill(0),n.copy(s),n=s}var a=e.alloc(o);a.fill(92);var c=e.alloc(o);c.fill(54);for(var u=e.alloc(o),f=e.alloc(o),h=0;h<o;h++)u[h]=a[h]^n[h],f[h]=c[h]^n[h];return t(e.concat([u,t(e.concat([f,r]))]))},o.sha256hmac=function(t,e){return o.hmac(o.sha256,t,e)},o.sha512hmac=function(t,e){return o.hmac(o.sha512,t,e)}}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var n=r(15),i=r(2),o=t.exports;o.sha1=function(t){return i.checkArgument(e.isBuffer(t)),n.createHash("sha1").update(t).digest()},o.sha1.blocksize=512,o.sha256=function(t){return i.checkArgument(e.isBuffer(t)),n.createHash("sha256").update(t).digest()},o.sha256.blocksize=512,o.sha256sha256=function(t){return i.checkArgument(e.isBuffer(t)),o.sha256(o.sha256(t))},o.ripemd160=function(t){return i.checkArgument(e.isBuffer(t)),n.createHash("ripemd160").update(t).digest()},o.sha256ripemd160=function(t){return i.checkArgument(e.isBuffer(t)),o.ripemd160(o.sha256(t))},o.sha512=function(t){return i.checkArgument(e.isBuffer(t)),n.createHash("sha512").update(t).digest()},o.sha512.blocksize=1024,o.hmac=function(t,r,n){i.checkArgument(e.isBuffer(r)),i.checkArgument(e.isBuffer(n)),i.checkArgument(t.blocksize);var o=t.blocksize/8;if(n.length>o)n=t(n);else if(n<o){var s=e.alloc(o);s.fill(0),n.copy(s),n=s}var a=e.alloc(o);a.fill(92);var c=e.alloc(o);c.fill(54);for(var u=e.alloc(o),f=e.alloc(o),h=0;h<o;h++)u[h]=a[h]^n[h],f[h]=c[h]^n[h];return t(e.concat([u,t(e.concat([f,r]))]))},o.sha256hmac=function(t,e){return o.hmac(o.sha256,t,e)},o.sha512hmac=function(t,e){return o.hmac(o.sha512,t,e)}}).call(this,r(0).Buffer)},function(t,e,r){"use strict";var n=r(109);t.exports=function(){return Object.assign?function(){if(!Object.assign)return!1;for(var t="abcdefghijklmnopqrst",e=t.split(""),r={},n=0;n<e.length;++n)r[e[n]]=e[n];var i=Object.assign({},r),o="";for(var s in i)o+=s;return t!==o}()||function(){if(!Object.assign||!Object.preventExtensions)return!1;var t=Object.preventExtensions({1:2});try{Object.assign(t,"xy")}catch(e){return"y"===t[1]}return!1}()?n:Object.assign:n}},function(t,e,r){"use strict";var n=r(110),i=r(63)(),o=r(112),s=r(46),a=o("Array.prototype.push"),c=o("Object.prototype.propertyIsEnumerable"),u=i?s.getOwnPropertySymbols:null;t.exports=function(t,e){if(null==t)throw new TypeError("target must be an object");var r=s(t);if(1===arguments.length)return r;for(var o=1;o<arguments.length;++o){var f=s(arguments[o]),h=n(f),d=i&&(s.getOwnPropertySymbols||u);if(d)for(var p=d(f),l=0;l<p.length;++l){var g=p[l];c(f,g)&&a(h,g)}for(var m=0;m<h.length;++m){var b=h[m];if(c(f,b)){var y=f[b];r[b]=y}}}return r}},function(t,e,r){"use strict";var n=Array.prototype.slice,i=r(62),o=Object.keys,s=o?function(t){return o(t)}:r(111),a=Object.keys;s.shim=function(){Object.keys?function(){var t=Object.keys(arguments);return t&&t.length===arguments.length}(1,2)||(Object.keys=function(t){return i(t)?a(n.call(t)):a(t)}):Object.keys=s;return Object.keys||s},t.exports=s},function(t,e,r){"use strict";var n;if(!Object.keys){var i=Object.prototype.hasOwnProperty,o=Object.prototype.toString,s=r(62),a=Object.prototype.propertyIsEnumerable,c=!a.call({toString:null},"toString"),u=a.call((function(){}),"prototype"),f=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],h=function(t){var e=t.constructor;return e&&e.prototype===t},d={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},p=function(){if("undefined"==typeof window)return!1;for(var t in window)try{if(!d["$"+t]&&i.call(window,t)&&null!==window[t]&&"object"==typeof window[t])try{h(window[t])}catch(t){return!0}}catch(t){return!0}return!1}();n=function(t){var e=null!==t&&"object"==typeof t,r="[object Function]"===o.call(t),n=s(t),a=e&&"[object String]"===o.call(t),d=[];if(!e&&!r&&!n)throw new TypeError("Object.keys called on a non-object");var l=u&&r;if(a&&t.length>0&&!i.call(t,0))for(var g=0;g<t.length;++g)d.push(String(g));if(n&&t.length>0)for(var m=0;m<t.length;++m)d.push(String(m));else for(var b in t)l&&"prototype"===b||!i.call(t,b)||d.push(String(b));if(c)for(var y=function(t){if("undefined"==typeof window||!p)return h(t);try{return h(t)}catch(t){return!1}}(t),v=0;v<f.length;++v)y&&"constructor"===f[v]||!i.call(t,f[v])||d.push(f[v]);return d}}t.exports=n},function(t,e,r){"use strict";var n=r(113),i=r(68),o=i([n("%String.prototype.indexOf%")]);t.exports=function(t,e){var r=n(t,!!e);return"function"==typeof r&&o(t,".prototype.")>-1?i([r]):r}},function(t,e,r){"use strict";var n=r(46),i=r(114),o=r(115),s=r(116),a=r(117),c=r(118),u=r(64),f=r(119),h=r(120),d=r(121),p=r(122),l=r(123),g=r(124),m=r(125),b=r(126),y=Function,v=function(t){try{return y('"use strict"; return ('+t+").constructor;")()}catch(t){}},S=r(65),_=r(129),w=function(){throw new u},I=S?function(){try{return w}catch(t){try{return S(arguments,"callee").get}catch(t){return w}}}():w,O=r(130)(),P=r(131),A=r(67),E=r(66),k=r(69),x=r(47),T={},R="undefined"!=typeof Uint8Array&&P?P(Uint8Array):void 0,M={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?void 0:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?void 0:ArrayBuffer,"%ArrayIteratorPrototype%":O&&P?P([][Symbol.iterator]()):void 0,"%AsyncFromSyncIteratorPrototype%":void 0,"%AsyncFunction%":T,"%AsyncGenerator%":T,"%AsyncGeneratorFunction%":T,"%AsyncIteratorPrototype%":T,"%Atomics%":"undefined"==typeof Atomics?void 0:Atomics,"%BigInt%":"undefined"==typeof BigInt?void 0:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?void 0:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?void 0:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?void 0:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":i,"%eval%":eval,"%EvalError%":o,"%Float16Array%":"undefined"==typeof Float16Array?void 0:Float16Array,"%Float32Array%":"undefined"==typeof Float32Array?void 0:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?void 0:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?void 0:FinalizationRegistry,"%Function%":y,"%GeneratorFunction%":T,"%Int8Array%":"undefined"==typeof Int8Array?void 0:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?void 0:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?void 0:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":O&&P?P(P([][Symbol.iterator]())):void 0,"%JSON%":"object"==typeof JSON?JSON:void 0,"%Map%":"undefined"==typeof Map?void 0:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&O&&P?P((new Map)[Symbol.iterator]()):void 0,"%Math%":Math,"%Number%":Number,"%Object%":n,"%Object.getOwnPropertyDescriptor%":S,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?void 0:Promise,"%Proxy%":"undefined"==typeof Proxy?void 0:Proxy,"%RangeError%":s,"%ReferenceError%":a,"%Reflect%":"undefined"==typeof Reflect?void 0:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?void 0:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&O&&P?P((new Set)[Symbol.iterator]()):void 0,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?void 0:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":O&&P?P(""[Symbol.iterator]()):void 0,"%Symbol%":O?Symbol:void 0,"%SyntaxError%":c,"%ThrowTypeError%":I,"%TypedArray%":R,"%TypeError%":u,"%Uint8Array%":"undefined"==typeof Uint8Array?void 0:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?void 0:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?void 0:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?void 0:Uint32Array,"%URIError%":f,"%WeakMap%":"undefined"==typeof WeakMap?void 0:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?void 0:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?void 0:WeakSet,"%Function.prototype.call%":x,"%Function.prototype.apply%":k,"%Object.defineProperty%":_,"%Object.getPrototypeOf%":A,"%Math.abs%":h,"%Math.floor%":d,"%Math.max%":p,"%Math.min%":l,"%Math.pow%":g,"%Math.round%":m,"%Math.sign%":b,"%Reflect.getPrototypeOf%":E};if(P)try{null.error}catch(t){var N=P(P(t));M["%Error.prototype%"]=N}var B={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},C=r(36),H=r(136),U=C.call(x,Array.prototype.concat),L=C.call(k,Array.prototype.splice),F=C.call(x,String.prototype.replace),D=C.call(x,String.prototype.slice),K=C.call(x,RegExp.prototype.exec),z=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,j=/\\(\\)?/g,V=function(t){var e=D(t,0,1),r=D(t,-1);if("%"===e&&"%"!==r)throw new c("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==e)throw new c("invalid intrinsic syntax, expected opening `%`");var n=[];return F(t,z,(function(t,e,r,i){n[n.length]=r?F(i,j,"$1"):e||t})),n},G=function(t,e){var r,n=t;if(H(B,n)&&(n="%"+(r=B[n])[0]+"%"),H(M,n)){var i=M[n];if(i===T&&(i=function t(e){var r;if("%AsyncFunction%"===e)r=v("async function () {}");else if("%GeneratorFunction%"===e)r=v("function* () {}");else if("%AsyncGeneratorFunction%"===e)r=v("async function* () {}");else if("%AsyncGenerator%"===e){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if("%AsyncIteratorPrototype%"===e){var i=t("%AsyncGenerator%");i&&P&&(r=P(i.prototype))}return M[e]=r,r}(n)),void 0===i&&!e)throw new u("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:i}}throw new c("intrinsic "+t+" does not exist!")};t.exports=function(t,e){if("string"!=typeof t||0===t.length)throw new u("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof e)throw new u('"allowMissing" argument must be a boolean');if(null===K(/^%?[^%]*%?$/,t))throw new c("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=V(t),n=r.length>0?r[0]:"",i=G("%"+n+"%",e),o=i.name,s=i.value,a=!1,f=i.alias;f&&(n=f[0],L(r,U([0,1],f)));for(var h=1,d=!0;h<r.length;h+=1){var p=r[h],l=D(p,0,1),g=D(p,-1);if(('"'===l||"'"===l||"`"===l||'"'===g||"'"===g||"`"===g)&&l!==g)throw new c("property names with quotes must have matching quotes");if("constructor"!==p&&d||(a=!0),H(M,o="%"+(n+="."+p)+"%"))s=M[o];else if(null!=s){if(!(p in s)){if(!e)throw new u("base intrinsic for "+t+" exists, but the property is not available.");return}if(S&&h+1>=r.length){var m=S(s,p);s=(d=!!m)&&"get"in m&&!("originalValue"in m.get)?m.get:s[p]}else d=H(s,p),s=s[p];d&&!a&&(M[o]=s)}}return s}},function(t,e,r){"use strict";t.exports=Error},function(t,e,r){"use strict";t.exports=EvalError},function(t,e,r){"use strict";t.exports=RangeError},function(t,e,r){"use strict";t.exports=ReferenceError},function(t,e,r){"use strict";t.exports=SyntaxError},function(t,e,r){"use strict";t.exports=URIError},function(t,e,r){"use strict";t.exports=Math.abs},function(t,e,r){"use strict";t.exports=Math.floor},function(t,e,r){"use strict";t.exports=Math.max},function(t,e,r){"use strict";t.exports=Math.min},function(t,e,r){"use strict";t.exports=Math.pow},function(t,e,r){"use strict";t.exports=Math.round},function(t,e,r){"use strict";var n=r(127);t.exports=function(t){return n(t)||0===t?t:t<0?-1:1}},function(t,e,r){"use strict";t.exports=Number.isNaN||function(t){return t!=t}},function(t,e,r){"use strict";t.exports=Object.getOwnPropertyDescriptor},function(t,e,r){"use strict";var n=Object.defineProperty||!1;if(n)try{n({},"a",{value:1})}catch(t){n=!1}t.exports=n},function(t,e,r){"use strict";var n="undefined"!=typeof Symbol&&Symbol,i=r(63);t.exports=function(){return"function"==typeof n&&("function"==typeof Symbol&&("symbol"==typeof n("foo")&&("symbol"==typeof Symbol("bar")&&i())))}},function(t,e,r){"use strict";var n=r(66),i=r(67),o=r(132);t.exports=n?function(t){return n(t)}:i?function(t){if(!t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("getProto: not an object");return i(t)}:o?function(t){return o(t)}:null},function(t,e,r){"use strict";var n,i=r(68),o=r(65);try{n=[].__proto__===Array.prototype}catch(t){if(!t||"object"!=typeof t||!("code"in t)||"ERR_PROTO_ACCESS"!==t.code)throw t}var s=!!n&&o&&o(Object.prototype,"__proto__"),a=Object,c=a.getPrototypeOf;t.exports=s&&"function"==typeof s.get?i([s.get]):"function"==typeof c&&function(t){return c(null==t?t:a(t))}},function(t,e,r){"use strict";var n="Function.prototype.bind called on incompatible ",i=Object.prototype.toString,o=Math.max,s=function(t,e){for(var r=[],n=0;n<t.length;n+=1)r[n]=t[n];for(var i=0;i<e.length;i+=1)r[i+t.length]=e[i];return r},a=function(t,e){for(var r=[],n=e||0,i=0;n<t.length;n+=1,i+=1)r[i]=t[n];return r},c=function(t,e){for(var r="",n=0;n<t.length;n+=1)r+=t[n],n+1<t.length&&(r+=e);return r};t.exports=function(t){var e=this;if("function"!=typeof e||"[object Function]"!==i.apply(e))throw new TypeError(n+e);for(var r,u=a(arguments,1),f=function(){if(this instanceof r){var n=e.apply(this,s(u,arguments));return Object(n)===n?n:this}return e.apply(t,s(u,arguments))},h=o(0,e.length-u.length),d=[],p=0;p<h;p++)d[p]="$"+p;if(r=Function("binder","return function ("+c(d,",")+"){ return binder.apply(this,arguments); }")(f),e.prototype){var l=function(){};l.prototype=e.prototype,r.prototype=new l,l.prototype=null}return r}},function(t,e,r){"use strict";var n=r(36),i=r(69),o=r(47),s=r(135);t.exports=s||n.call(o,i)},function(t,e,r){"use strict";t.exports="undefined"!=typeof Reflect&&Reflect&&Reflect.apply},function(t,e,r){"use strict";var n=Function.prototype.call,i=Object.prototype.hasOwnProperty,o=r(36);t.exports=o.call(n,i)},function(t,e){t.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},function(t,e,r){"use strict";const n=r(139),i=r(71),o=r(140);function s(t,e){switch(i(t)){case"object":return function(t,e){if("function"==typeof e)return e(t);if(e||o(t)){const r=new t.constructor;for(let n in t)r[n]=s(t[n],e);return r}return t}(t,e);case"array":return function(t,e){const r=new t.constructor(t.length);for(let n=0;n<t.length;n++)r[n]=s(t[n],e);return r}(t,e);default:return n(t)}}t.exports=s},function(t,e,r){"use strict";(function(e){
19
19
  /*!
20
20
  * shallow-clone <https://github.com/jonschlinkert/shallow-clone>
21
21
  *
22
22
  * Copyright (c) 2015-present, Jon Schlinkert.
23
23
  * Released under the MIT License.
24
24
  */
25
- const i=Symbol.prototype.valueOf,n=r(70);t.exports=function(t,r){switch(n(t)){case"array":return t.slice();case"object":return Object.assign({},t);case"date":return new t.constructor(Number(t));case"map":return new Map(t);case"set":return new Set(t);case"buffer":return function(t){const r=t.length,i=e.allocUnsafe?e.allocUnsafe(r):e.from(r);return t.copy(i),i}(t);case"symbol":return function(t){return i?Object(i.call(t)):{}}(t);case"arraybuffer":return function(t){const e=new t.constructor(t.byteLength);return new Uint8Array(e).set(new Uint8Array(t)),e}(t);case"float32array":case"float64array":case"int16array":case"int32array":case"int8array":case"uint16array":case"uint32array":case"uint8clampedarray":case"uint8array":return function(t,e){return new t.constructor(t.buffer,t.byteOffset,t.length)}(t);case"regexp":return function(t){const e=void 0!==t.flags?t.flags:/\w+$/.exec(t)||void 0,r=new t.constructor(t.source,e);return r.lastIndex=t.lastIndex,r}(t);case"error":return Object.create(t);default:return t}}}).call(this,r(0).Buffer)},function(t,e,r){"use strict";
25
+ const n=Symbol.prototype.valueOf,i=r(71);t.exports=function(t,r){switch(i(t)){case"array":return t.slice();case"object":return Object.assign({},t);case"date":return new t.constructor(Number(t));case"map":return new Map(t);case"set":return new Set(t);case"buffer":return function(t){const r=t.length,n=e.allocUnsafe?e.allocUnsafe(r):e.from(r);return t.copy(n),n}(t);case"symbol":return function(t){return n?Object(n.call(t)):{}}(t);case"arraybuffer":return function(t){const e=new t.constructor(t.byteLength);return new Uint8Array(e).set(new Uint8Array(t)),e}(t);case"float32array":case"float64array":case"int16array":case"int32array":case"int8array":case"uint16array":case"uint32array":case"uint8clampedarray":case"uint8array":return function(t,e){return new t.constructor(t.buffer,t.byteOffset,t.length)}(t);case"regexp":return function(t){const e=void 0!==t.flags?t.flags:/\w+$/.exec(t)||void 0,r=new t.constructor(t.source,e);return r.lastIndex=t.lastIndex,r}(t);case"error":return Object.create(t);default:return t}}}).call(this,r(0).Buffer)},function(t,e,r){"use strict";
26
26
  /*!
27
27
  * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
28
28
  *
29
29
  * Copyright (c) 2014-2017, Jon Schlinkert.
30
30
  * Released under the MIT License.
31
- */var i=r(141);function n(t){return!0===i(t)&&"[object Object]"===Object.prototype.toString.call(t)}t.exports=function(t){var e,r;return!1!==n(t)&&("function"==typeof(e=t.constructor)&&(!1!==n(r=e.prototype)&&!1!==r.hasOwnProperty("isPrototypeOf")))}},function(t,e,r){"use strict";
31
+ */var n=r(141);function i(t){return!0===n(t)&&"[object Object]"===Object.prototype.toString.call(t)}t.exports=function(t){var e,r;return!1!==i(t)&&("function"==typeof(e=t.constructor)&&(!1!==i(r=e.prototype)&&!1!==r.hasOwnProperty("isPrototypeOf")))}},function(t,e,r){"use strict";
32
32
  /*!
33
33
  * isobject <https://github.com/jonschlinkert/isobject>
34
34
  *
35
35
  * Copyright (c) 2014-2017, Jon Schlinkert.
36
36
  * Released under the MIT License.
37
- */t.exports=function(t){return null!=t&&"object"==typeof t&&!1===Array.isArray(t)}},function(t,e,r){"use strict";var i=r(22),n=r(2),o=r(29),s=r(20),a=r(19),c=r(12),u=r(4),f=r(30);function h(){o.apply(this,arguments)}i(h,o),h.prototype.getSignatures=function(t,e,r,i){n.checkState(this.output instanceof s),i=i||u.SIGHASH_ALL|u.SIGHASH_FORKID;var o=e.toPublicKey();return o.toString()===this.output.script.getPublicKey().toString("hex")?[new f({publicKey:o,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:a.sign(t,e,i,r,this.output.script,this.output.satoshisBN),sigtype:i})]:[]},h.prototype.addSignature=function(t,e){return n.checkState(this.isValidSignature(t,e),"Signature is invalid"),this.setScript(c.buildPublicKeyIn(e.signature.toDER(),e.sigtype)),this},h.prototype.clearSignatures=function(){return this.setScript(c.empty()),this},h.prototype.isFullySigned=function(){return this.script.isPublicKeyIn()},h.SCRIPT_MAX_SIZE=74,h.prototype._estimateSize=function(){return o.BASE_SIZE+h.SCRIPT_MAX_SIZE},t.exports=h},function(t,e,r){"use strict";var i=r(22),n=r(2),o=r(6),s=r(29),a=r(20),c=r(19),u=r(12),f=r(4),h=r(30);function d(){s.apply(this,arguments)}i(d,s),d.prototype.getSignatures=function(t,e,r,i,s){return n.checkState(this.output instanceof a),s=s||o.sha256ripemd160(e.publicKey.toBuffer()),i=i||f.SIGHASH_ALL|f.SIGHASH_FORKID,s.equals(this.output.script.getPublicKeyHash())?[new h({publicKey:e.publicKey,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:c.sign(t,e,i,r,this.output.script,this.output.satoshisBN),sigtype:i})]:[]},d.prototype.addSignature=function(t,e){return n.checkState(this.isValidSignature(t,e),"Signature is invalid"),this.setScript(u.buildPublicKeyHashIn(e.publicKey,e.signature.toDER(),e.sigtype)),this},d.prototype.clearSignatures=function(){return this.setScript(u.empty()),this},d.prototype.isFullySigned=function(){return this.script.isPublicKeyHashIn()},d.SCRIPT_MAX_SIZE=108,d.prototype._estimateSize=function(){return s.BASE_SIZE+d.SCRIPT_MAX_SIZE},t.exports=d},function(t,e,r){"use strict";(function(e){var i=r(1),n=r(22),o=r(29),s=r(20),a=r(2),c=r(12),u=r(4),f=r(19),h=r(30),d=r(14),p=r(28);function l(t,e,r,n){o.apply(this,arguments);var s=this;e=e||t.publicKeys,r=r||t.threshold,n=n||t.signatures,this.publicKeys=e.map(t=>t.toString("hex")).sort().map(t=>new d(t)),a.checkState(c.buildMultisigOut(this.publicKeys,r).equals(this.output.script),"Provided public keys don't match to the provided output script"),this.publicKeyIndex={},i.each(this.publicKeys,(function(t,e){s.publicKeyIndex[t.toString()]=e})),this.threshold=r,this.signatures=n?this._deserializeSignatures(n):new Array(this.publicKeys.length)}n(l,o),l.prototype.toObject=function(){var t=o.prototype.toObject.apply(this,arguments);return t.threshold=this.threshold,t.publicKeys=i.map(this.publicKeys,(function(t){return t.toString()})),t.signatures=this._serializeSignatures(),t},l.prototype._deserializeSignatures=function(t){return i.map(t,(function(t){if(t)return new h(t)}))},l.prototype._serializeSignatures=function(){return i.map(this.signatures,(function(t){if(t)return t.toObject()}))},l.prototype.getSignatures=function(t,e,r,n){a.checkState(this.output instanceof s),n=n||u.SIGHASH_ALL|u.SIGHASH_FORKID;var o=this,c=[];return i.each(this.publicKeys,(function(i){i.toString()===e.publicKey.toString()&&c.push(new h({publicKey:e.publicKey,prevTxId:o.prevTxId,outputIndex:o.outputIndex,inputIndex:r,signature:f.sign(t,e,n,r,o.output.script,o.output.satoshisBN),sigtype:n}))})),c},l.prototype.addSignature=function(t,e){return a.checkState(!this.isFullySigned(),"All needed signatures have already been added"),a.checkArgument(!i.isUndefined(this.publicKeyIndex[e.publicKey.toString()]),"Signature has no matching public key"),a.checkState(this.isValidSignature(t,e)),this.signatures[this.publicKeyIndex[e.publicKey.toString()]]=e,this._updateScript(),this},l.prototype._updateScript=function(){return this.setScript(c.buildMultisigIn(this.publicKeys,this.threshold,this._createSignatures())),this},l.prototype._createSignatures=function(){return i.map(i.filter(this.signatures,(function(t){return!i.isUndefined(t)})),(function(t){return e.concat([t.signature.toDER(),e.from([255&t.sigtype])])}))},l.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()},l.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold},l.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()},l.prototype.countSignatures=function(){return i.reduce(this.signatures,(function(t,e){return t+!!e}),0)},l.prototype.publicKeysWithoutSignature=function(){var t=this;return i.filter(this.publicKeys,(function(e){return!t.signatures[t.publicKeyIndex[e.toString()]]}))},l.prototype.isValidSignature=function(t,e){return e.signature.nhashtype=e.sigtype,f.verify(t,e.signature,e.publicKey,e.inputIndex,this.output.script,this.output.satoshisBN)},l.normalizeSignatures=function(t,e,r,i,n){return n.map((function(n){var o=null;return i=i.filter((function(i){if(o)return!0;var s=new h({signature:u.fromTxFormat(i),publicKey:n,prevTxId:e.prevTxId,outputIndex:e.outputIndex,inputIndex:r,sigtype:u.SIGHASH_ALL});return s.signature.nhashtype=s.sigtype,!f.verify(t,s.signature,s.publicKey,s.inputIndex,e.output.script)||(o=s,!1)})),o||null}))},l.SIGNATURE_SIZE=73,l.prototype._estimateSize=function(){var t=1+this.threshold*l.SIGNATURE_SIZE;return o.BASE_SIZE+p(t).toBuffer().length+t},t.exports=l}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(1),n=r(22),o=r(29),s=r(20),a=r(2),c=r(12),u=r(4),f=r(19),h=r(30),d=r(14),p=r(28);function l(t,e,r,n){o.apply(this,arguments);var s=this;e=e||t.publicKeys,r=r||t.threshold,n=n||t.signatures,this.publicKeys=e.map(t=>t.toString("hex")).sort().map(t=>new d(t)),this.redeemScript=c.buildMultisigOut(this.publicKeys,r),a.checkState(c.buildScriptHashOut(this.redeemScript).equals(this.output.script),"Provided public keys don't hash to the provided output"),this.publicKeyIndex={},i.each(this.publicKeys,(function(t,e){s.publicKeyIndex[t.toString()]=e})),this.threshold=r,this.signatures=n?this._deserializeSignatures(n):new Array(this.publicKeys.length)}n(l,o),l.prototype.toObject=function(){var t=o.prototype.toObject.apply(this,arguments);return t.threshold=this.threshold,t.publicKeys=i.map(this.publicKeys,(function(t){return t.toString()})),t.signatures=this._serializeSignatures(),t},l.prototype._deserializeSignatures=function(t){return i.map(t,(function(t){if(t)return new h(t)}))},l.prototype._serializeSignatures=function(){return i.map(this.signatures,(function(t){if(t)return t.toObject()}))},l.prototype.getSignatures=function(t,e,r,n){a.checkState(this.output instanceof s),n=n||u.SIGHASH_ALL|u.SIGHASH_FORKID;var o=this,c=[];return i.each(this.publicKeys,(function(i){i.toString()===e.publicKey.toString()&&c.push(new h({publicKey:e.publicKey,prevTxId:o.prevTxId,outputIndex:o.outputIndex,inputIndex:r,signature:f.sign(t,e,n,r,o.redeemScript,o.output.satoshisBN),sigtype:n}))})),c},l.prototype.addSignature=function(t,e){return a.checkState(!this.isFullySigned(),"All needed signatures have already been added"),a.checkArgument(!i.isUndefined(this.publicKeyIndex[e.publicKey.toString()]),"Signature has no matching public key"),a.checkState(this.isValidSignature(t,e)),this.signatures[this.publicKeyIndex[e.publicKey.toString()]]=e,this._updateScript(),this},l.prototype._updateScript=function(){return this.setScript(c.buildP2SHMultisigIn(this.publicKeys,this.threshold,this._createSignatures(),{cachedMultisig:this.redeemScript})),this},l.prototype._createSignatures=function(){return i.map(i.filter(this.signatures,(function(t){return!i.isUndefined(t)})),(function(t){return e.concat([t.signature.toDER(),e.from([255&t.sigtype])])}))},l.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()},l.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold},l.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()},l.prototype.countSignatures=function(){return i.reduce(this.signatures,(function(t,e){return t+!!e}),0)},l.prototype.publicKeysWithoutSignature=function(){var t=this;return i.filter(this.publicKeys,(function(e){return!t.signatures[t.publicKeyIndex[e.toString()]]}))},l.prototype.isValidSignature=function(t,e){return e.signature.nhashtype=e.sigtype,f.verify(t,e.signature,e.publicKey,e.inputIndex,this.redeemScript,this.output.satoshisBN)},l.SIGNATURE_SIZE=73,l.PUBKEY_SIZE=34,l.prototype._estimateSize=function(){var t=3+this.publicKeys.length*l.PUBKEY_SIZE,e=this.threshold*l.SIGNATURE_SIZE+1+(t<=75?1:t<=255?2:3)+t;return o.BASE_SIZE+p(e).toBuffer().length+e},t.exports=l}).call(this,r(0).Buffer)},function(t,e,r){t.exports=r(147),t.exports.BlockHeader=r(39),t.exports.MerkleBlock=r(73)},function(t,e,r){"use strict";(function(e){var i=r(1),n=r(39),o=r(3),s=r(18),a=r(16),c=r(6),u=r(37),f=r(2);function h(t){return this instanceof h?(i.extend(this,h._from(t)),this):new h(t)}h.MAX_BLOCK_SIZE=128e6,h._from=function(t){var r={};if(e.isBuffer(t))r=h._fromBufferReader(s(t));else{if(!i.isObject(t))throw new TypeError("Unrecognized argument for Block");r=h._fromObject(t)}return r},h._fromObject=function(t){var e=[];return t.transactions.forEach((function(t){t instanceof u?e.push(t):e.push(u().fromObject(t))})),{header:n.fromObject(t.header),transactions:e}},h.fromObject=function(t){var e=h._fromObject(t);return new h(e)},h._fromBufferReader=function(t){var e={};f.checkState(!t.finished(),"No block data received"),e.header=n.fromBufferReader(t);var r=t.readVarintNum();e.transactions=[];for(var i=0;i<r;i++)e.transactions.push(u().fromBufferReader(t));return e},h.fromBufferReader=function(t){f.checkArgument(t,"br is required");var e=h._fromBufferReader(t);return new h(e)},h.fromBuffer=function(t){return h.fromBufferReader(new s(t))},h.fromString=function(t){var r=e.from(t,"hex");return h.fromBuffer(r)},h.fromRawBlock=function(t){e.isBuffer(t)||(t=e.from(t,"binary"));var r=s(t);r.pos=h.Values.START_OF_BLOCK;var i=h._fromBufferReader(r);return new h(i)},h.prototype.toObject=h.prototype.toJSON=function(){var t=[];return this.transactions.forEach((function(e){t.push(e.toObject())})),{header:this.header.toObject(),transactions:t}},h.prototype.toBuffer=function(){return this.toBufferWriter().concat()},h.prototype.toString=function(){return this.toBuffer().toString("hex")},h.prototype.toBufferWriter=function(t){t||(t=new a),t.write(this.header.toBuffer()),t.writeVarintNum(this.transactions.length);for(var e=0;e<this.transactions.length;e++)this.transactions[e].toBufferWriter(t);return t},h.prototype.getTransactionHashes=function(){var t=[];if(0===this.transactions.length)return[h.Values.NULL_HASH];for(var e=0;e<this.transactions.length;e++)t.push(this.transactions[e]._getHash());return t},h.prototype.getMerkleTree=function(){for(var t=this.getTransactionHashes(),r=0,i=this.transactions.length;i>1;i=Math.floor((i+1)/2)){for(var n=0;n<i;n+=2){var o=Math.min(n+1,i-1),s=e.concat([t[r+n],t[r+o]]);t.push(c.sha256sha256(s))}r+=i}return t},h.prototype.getMerkleRoot=function(){var t=this.getMerkleTree();return t[t.length-1]},h.prototype.validMerkleRoot=function(){var t=new o(this.header.merkleRoot.toString("hex"),"hex"),e=new o(this.getMerkleRoot().toString("hex"),"hex");return 0===t.cmp(e)},h.prototype._getHash=function(){return this.header._getHash()};var d={configurable:!1,enumerable:!0,get:function(){return this._id||(this._id=this.header.id),this._id},set:i.noop};Object.defineProperty(h.prototype,"id",d),Object.defineProperty(h.prototype,"hash",d),h.prototype.inspect=function(){return"<Block "+this.id+">"},h.Values={START_OF_BLOCK:8,NULL_HASH:e.from("0000000000000000000000000000000000000000000000000000000000000000","hex")},t.exports=h}).call(this,r(0).Buffer)},function(t,e,r){var i=r(7);i.Message=r(149),t.exports=i.Message},function(t,e,r){"use strict";(function(e){var i=r(7),n=i.deps._,o=i.PrivateKey,s=i.PublicKey,a=i.Address,c=i.encoding.BufferWriter,u=i.crypto.ECDSA,f=i.crypto.Signature,h=i.crypto.Hash.sha256sha256,d=i.util.js,p=i.util.preconditions,l=function t(r){return this instanceof t?(p.checkArgument(n.isString(r)||e.isBuffer(r),"First argument should be a string or Buffer"),n.isString(r)&&(this.messageBuffer=e.from(r)),e.isBuffer(r)&&(this.messageBuffer=r),this):new t(r)};l.sign=function(t,e){return new l(t).sign(e)},l.verify=function(t,e,r){return new l(t).verify(e,r)},l.MAGIC_BYTES=e.from("Bitcoin Signed Message:\n"),l.prototype.magicHash=function(){var t=c.varintBufNum(l.MAGIC_BYTES.length),r=c.varintBufNum(this.messageBuffer.length),i=e.concat([t,l.MAGIC_BYTES,r,this.messageBuffer]);return h(i)},l.prototype._sign=function(t){p.checkArgument(t instanceof o,"First argument should be an instance of PrivateKey");var e=this.magicHash();return u.signWithCalcI(e,t)},l.prototype.sign=function(t){return this._sign(t).toCompact().toString("base64")},l.prototype._verify=function(t,e){p.checkArgument(t instanceof s,"First argument should be an instance of PublicKey"),p.checkArgument(e instanceof f,"Second argument should be an instance of Signature");var r=this.magicHash(),i=u.verify(r,e,t);return i||(this.error="The signature was invalid"),i},l.prototype.verify=function(t,r){p.checkArgument(t),p.checkArgument(r&&n.isString(r)),n.isString(t)&&(t=a.fromString(t));var i=f.fromCompact(e.from(r,"base64")),o=new u;o.hashbuf=this.magicHash(),o.sig=i;var s=o.toPublicKey(),c=a.fromPublicKey(s,t.network);return t.toString()!==c.toString()?(this.error="The signature did not match the message digest",!1):this._verify(s,i)},l.fromString=function(t){return new l(t)},l.fromJSON=function(t){return d.isValidJSON(t)&&(t=JSON.parse(t)),l.fromObject(t)},l.prototype.toObject=function(){return{messageHex:this.messageBuffer.toString("hex")}},l.fromObject=function(t){let r=e.from(t.messageHex,"hex");return new l(r)},l.prototype.toJSON=function(){return JSON.stringify(this.toObject())},l.prototype.toString=function(){return this.messageBuffer.toString()},l.prototype.inspect=function(){return"<Message: "+this.toString()+">"},t.exports=l}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){let i,n,o,s;if("undefined"==typeof window)try{i=r(!function(){var t=new Error("Cannot find module 'fs'");throw t.code="MODULE_NOT_FOUND",t}()),n=r(53),o=r(15),s=r(151)}catch(t){console.warn("SmartUTXO: Running in browser mode - some features may be limited")}t.exports=class{constructor(t={}){this.options=t||{},this.loadState()}loadState(){try{return s.loadBlockchainState()}catch(t){return console.log("⚠️ Could not load blockchain state:",t.message),null}}saveState(){try{const t=s.loadBlockchainState();s.saveBlockchainState(t);const e=Object.keys(t.globalUTXOSet||{}).length;console.log(`💾 Saved blockchain state with ${e} UTXOs`)}catch(t){console.log("⚠️ Could not save blockchain state:",t.message)}}getUTXOsForAddress(t){try{const e=s.loadBlockchainState();return e.wallets&&e.wallets[t]&&e.wallets[t].utxos||[]}catch(t){return console.log("⚠️ Error getting UTXOs:",t.message),[]}}addUTXO(t){try{s.addUTXO(t,t.address)}catch(t){console.log("⚠️ Error adding UTXO:",t.message)}}spendUTXOs(t,e="manual-spend"){try{for(const r of t)s.spendUTXO(r.txid,r.vout,e)}catch(t){console.log("⚠️ Error spending UTXOs:",t.message)}}createMockUTXOs(t,e=5,r=1e5){const i=[];for(let n=0;n<e;n++){const e={txid:o.randomBytes(32).toString("hex"),vout:n,address:t,satoshis:r,script:`76a914${o.randomBytes(20).toString("hex")}88ac`};i.push(e)}return i}getBalance(t){try{const e=s.loadBlockchainState();return e.wallets&&e.wallets[t]&&e.wallets[t].totalValue||0}catch(t){return console.log("⚠️ Error getting balance:",t.message),0}}getStats(){try{const t=s.getBlockchainStats();return{totalUTXOs:t.metadata.totalUTXOs,totalValue:t.metadata.totalValue,totalWallets:t.metadata.totalWallets,blockHeight:t.metadata.blockHeight,lastUpdated:t.metadata.lastUpdated}}catch(t){return console.log("⚠️ Error getting stats:",t.message),{totalUTXOs:0,totalValue:0,totalWallets:0,blockHeight:0}}}reset(){try{const t=n.join(e,"../utilities/blockchain-state.json");i.existsSync(t)&&(i.unlinkSync(t),console.log("🔄 Blockchain state reset"))}catch(t){console.log("⚠️ Could not reset blockchain state:",t.message)}}}}).call(this,"/")},function(t,e,r){(function(t,e,i){let n,o,s,a;if("undefined"==typeof window)try{n=r(7),o=r(!function(){var t=new Error("Cannot find module 'fs'");throw t.code="MODULE_NOT_FOUND",t}()),s=r(53),a=s.join(t,"blockchain-state.json")}catch(t){console.warn("BlockchainState: Running in browser mode - persistence disabled")}else n="undefined"!=typeof window&&window.bsv||r(7);function c(){return{metadata:{createdAt:(new Date).toISOString(),lastUpdated:(new Date).toISOString(),totalWallets:0,totalUTXOs:0,totalValue:0,blockHeight:0},wallets:{},globalUTXOSet:{},spentUTXOs:{},transactionHistory:[]}}function u(){try{if(!o||!a)return c();if(!o.existsSync(a)){console.log("🆕 Creating new blockchain state...");const t=c();return f(t),t}const t=JSON.parse(o.readFileSync(a,"utf8"));return console.log("📖 Loaded existing blockchain state"),t}catch(t){return console.error("❌ Error loading blockchain state:",t.message),c()}}function f(t){try{t.metadata.lastUpdated=(new Date).toISOString(),o&&a&&(o.writeFileSync(a,JSON.stringify(t,null,2)),console.log("💾 Blockchain state saved"))}catch(t){console.error("❌ Error saving blockchain state:",t.message)}}function h(t,e){console.log("📝 Registering wallet: "+t);const r=u();return r.wallets[t]&&console.log("ℹ️ Wallet already exists, updating..."),r.wallets[t]={address:t,registeredAt:e.registeredAt||(new Date).toISOString(),utxos:e.utxos||[],totalValue:0},e.utxos&&e.utxos.forEach(e=>{const i=`${e.txid}:${e.vout}`;r.globalUTXOSet[i]={...e,ownerAddress:t}}),r.metadata.totalWallets=Object.keys(r.wallets).length,p(r),f(r),console.log("✅ Wallet registered: "+t),r}function d(t,e){const r=u(),i=`${t}:${e}`;return r.spentUTXOs[i]?{exists:!1,spent:!0,utxo:r.spentUTXOs[i]}:r.globalUTXOSet[i]?{exists:!0,spent:!1,utxo:r.globalUTXOSet[i]}:{exists:!1,spent:!1,utxo:null}}function p(t){const e=Object.keys(t.globalUTXOSet).length,r=Object.values(t.globalUTXOSet).reduce((t,e)=>t+e.satoshis,0);t.metadata.totalUTXOs=e,t.metadata.totalValue=r,Object.values(t.wallets).forEach(t=>{t.totalValue=t.utxos.reduce((t,e)=>t+e.satoshis,0)})}function l(){const t=u();return console.log("🌐 Blockchain State Statistics:"),console.log("═══════════════════════════════════════════"),console.log("📊 Total Wallets: "+t.metadata.totalWallets),console.log("💰 Total UTXOs: "+t.metadata.totalUTXOs),console.log(`💎 Total Value: ${t.metadata.totalValue} satoshis`),console.log("🏗️ Block Height: "+t.metadata.blockHeight),console.log(`🕐 Last Updated: ${t.metadata.lastUpdated}\n`),Object.keys(t.wallets).length>0&&(console.log("👛 Registered Wallets:"),Object.entries(t.wallets).forEach(([t,e])=>{console.log(` ${t}: ${e.utxos.length} UTXOs, ${e.totalValue} sats`)})),t}function g(){const e=s.join(t,"wallet.json");if(!o.existsSync(e))return console.log("❌ No wallet.json found to import"),!1;try{const t=JSON.parse(o.readFileSync(e,"utf8"));console.log("📥 Importing wallet from wallet.json...");const r={registeredAt:(new Date).toISOString(),utxos:t.availableUTXOs||[t.utxo]};return h(t.wallet.address,r),console.log("✅ Wallet imported successfully"),!0}catch(t){return console.error("❌ Error importing wallet:",t.message),!1}}if(r.c[r.s]===e){const t=i.argv.slice(2);if("import"===t[0])g();else if("init"===t[0]){f(c()),console.log("🆕 Initialized new blockchain state")}l()}e.exports={loadBlockchainState:u,saveBlockchainState:f,registerWallet:h,getUTXO:d,isUTXOAvailable:function(t,e){const r=d(t,e);return r.exists&&!r.spent},spendUTXO:function(t,e,r){const i=u(),n=`${t}:${e}`;if(!i.globalUTXOSet[n])throw new Error(`UTXO ${n} does not exist`);if(i.spentUTXOs[n])throw new Error(`UTXO ${n} already spent`);const o=i.globalUTXOSet[n];i.spentUTXOs[n]={...o,spentInTx:r,spentAt:(new Date).toISOString()},delete i.globalUTXOSet[n];const s=i.wallets[o.ownerAddress];s&&(s.utxos=s.utxos.filter(r=>!(r.txid===t&&r.vout===e))),p(i),f(i),console.log(`❌ UTXO spent: ${n} in tx ${r}`)},addUTXO:function(t,e){const r=u(),i=`${t.txid}:${t.vout}`;if(r.globalUTXOSet[i])return void console.log(`⚠️ UTXO ${i} already exists, skipping`);r.globalUTXOSet[i]={...t,ownerAddress:e,createdAt:(new Date).toISOString()},r.wallets[e]||(r.wallets[e]={address:e,registeredAt:(new Date).toISOString(),utxos:[],totalValue:0}),r.wallets[e].utxos.some(e=>e.txid===t.txid&&e.vout===t.vout)||r.wallets[e].utxos.push(t),p(r),f(r),console.log(`✅ UTXO added: ${i} for ${e}`)},getBlockchainStats:l,importWalletFromFile:g}}).call(this,"/",r(31)(t),r(24))},function(t,e,r){"use strict";(function(e){t.exports=class{constructor(t,e={}){this.bsv=t,this.options={difficulty:e.difficulty||1,blockTime:e.blockTime||1e4,validateScripts:!1!==e.validateScripts,logLevel:e.logLevel||"info",...e},this.currentBlock={height:0,transactions:[],timestamp:Date.now()},this.mempool=[]}acceptTransaction(t){try{if(this.options.validateScripts){if(!this.validateTransactionSignatures(t))return this.log("warn","❌ Transaction rejected: Invalid signatures"),!1}return this.mempool.push(t),this.log("info","✅ Transaction accepted into mempool: "+(t.id||"unknown")),!0}catch(t){return this.log("error","❌ Transaction rejected: "+t.message),!1}}validateTransactionSignatures(t){try{const e=t.verify();return this.log("debug","📊 Transaction verification result: "+e),!0===e}catch(t){return this.log("warn","⚠️ Signature validation error: "+t.message),!1}}mineBlock(t=10){const r=this.mempool.splice(0,t),i={height:this.currentBlock.height+1,timestamp:Date.now(),transactions:r,transactionCount:r.length,previousBlockHash:this.currentBlock.hash||"0000000000000000000000000000000000000000000000000000000000000000"},n=JSON.stringify({height:i.height,timestamp:i.timestamp,previousBlockHash:i.previousBlockHash,transactions:r.map(t=>t.id||t.toString())});return i.hash=this.bsv.crypto.Hash.sha256(e.from(n)).toString("hex"),this.currentBlock=i,this.log("info",`⛏️ Mined block ${i.height} with ${r.length} transactions`),this.log("debug","📦 Block hash: "+i.hash),i}getMempoolStats(){return{transactionCount:this.mempool.length,transactions:this.mempool.map(t=>({id:t.id||"unknown",size:t.toBuffer?t.toBuffer().length:0,inputs:t.inputs?t.inputs.length:0,outputs:t.outputs?t.outputs.length:0}))}}getBlockchainStats(){return{currentHeight:this.currentBlock.height,currentBlockHash:this.currentBlock.hash,currentBlockTimestamp:this.currentBlock.timestamp,mempoolSize:this.mempool.length,difficulty:this.options.difficulty,blockTime:this.options.blockTime}}reset(){this.currentBlock={height:0,transactions:[],timestamp:Date.now()},this.mempool=[],this.log("info","🔄 Miner reset to genesis state")}log(t,e){const r={error:0,warn:1,info:2,debug:3},i=r[this.options.logLevel]||2;if(r[t]<=i){const r=(new Date).toISOString();console.log(`[${r}] [${t.toUpperCase()}] ${e}`)}}}}).call(this,r(0).Buffer)},function(t,e,r){(function(e){const i=r(7);class n{static createSignature(t,r,n,o,s,a=null){a=a||i.crypto.Signature.SIGHASH_ALL|i.crypto.Signature.SIGHASH_FORKID;const c=i.Transaction.sighash.sign(t,r,a,n,o,new i.crypto.BN(s));return e.concat([c.toDER(),e.from([a])])}static createMultisigScript(t,e){let r=(new i.Script).add(i.Opcode["OP_"+t]);for(const t of e)r=r.add(t.toBuffer());return r.add(i.Opcode["OP_"+e.length]).add(i.Opcode.OP_CHECKMULTISIG)}static createMultisigUnlocking(t){let e=(new i.Script).add(i.Opcode.OP_0);for(const r of t)e=e.add(r);return e}static createTimelockScript(t,r){const n=e.from(t.toString(16).padStart(8,"0"),"hex").reverse();return(new i.Script).add(n).add(i.Opcode.OP_CHECKLOCKTIMEVERIFY).add(i.Opcode.OP_DROP).add(r.toBuffer())}static createConditionalScript(t,e=null){let r=(new i.Script).add(i.Opcode.OP_IF).add(t.toBuffer());return e&&(r=r.add(i.Opcode.OP_ELSE).add(e.toBuffer())),r.add(i.Opcode.OP_ENDIF)}static createP2PKHScript(t){return(new i.Script).add(i.Opcode.OP_DUP).add(i.Opcode.OP_HASH160).add(t.toAddress().hashBuffer).add(i.Opcode.OP_EQUALVERIFY).add(i.Opcode.OP_CHECKSIG)}static createP2PKHUnlocking(t,e){return(new i.Script).add(t).add(e.toBuffer())}static getPreimage(t,e,r,n,o=null){return o=o||i.crypto.Signature.SIGHASH_ALL|i.crypto.Signature.SIGHASH_FORKID,i.Transaction.sighash.sighash(t,o,e,r,new i.crypto.BN(n))}static createDataScript(t){return"string"==typeof t&&(t=e.from(t,"utf8")),(new i.Script).add(t)}static createOpReturnScript(t){return"string"==typeof t&&(t=e.from(t,"utf8")),(new i.Script).add(i.Opcode.OP_FALSE).add(i.Opcode.OP_RETURN).add(t)}static validateTransaction(t){try{return t.verify()}catch(t){return console.error("Transaction validation error:",t.message),!1}}static validateScript(t,e,r,n){try{return(new i.Script.Interpreter).verify(t,e,r,n,i.Script.Interpreter.SCRIPT_VERIFY_P2SH|i.Script.Interpreter.SCRIPT_VERIFY_STRICTENC|i.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID|i.Script.Interpreter.SCRIPT_ENABLE_MAGNETIC_OPCODES|i.Script.Interpreter.SCRIPT_ENABLE_MONOLITH_OPCODES)}catch(t){return console.error("Script validation error:",t.message),!1}}static createLowFeeTransaction(t,e,r=10){let n=(new i.Transaction).feePerKb(r);for(const e of t)n=n.from(e);for(const t of e)n=n.to(t.address,t.satoshis);return n}}n.SIGHASH_ALL=i.crypto.Signature.SIGHASH_ALL|i.crypto.Signature.SIGHASH_FORKID,n.SIGHASH_NONE=i.crypto.Signature.SIGHASH_NONE|i.crypto.Signature.SIGHASH_FORKID,n.SIGHASH_SINGLE=i.crypto.Signature.SIGHASH_SINGLE|i.crypto.Signature.SIGHASH_FORKID,t.exports=n}).call(this,r(0).Buffer)},function(t,e,r){"use strict";var i=r(7),n={Covenant:r(155),Preimage:r(17),SIGHASH:r(156),Builder:r(157),UTXOGenerator:r(158),ScriptTester:r(159),CovenantBuilder:r(76).CovenantBuilder,CovenantTemplates:r(76).CovenantTemplates,OpcodeMap:r(77),ScriptUtils:r(160),createCovenant:function(t,e){return new n.Covenant(t,e)},extractPreimage:function(t,e){return new n.Preimage(t,e)},analyzeSIGHASH:function(t){return new n.SIGHASH(t)},buildCovenant:function(t,e){return new n.Builder(t,e)},createUTXOGenerator:function(t){return new n.UTXOGenerator(t)},createTestEnvironment:function(t){return n.UTXOGenerator.createTestEnvironment(t)},testScript:function(t,e,r){return n.ScriptTester.test(t,e,r)},testCovenant:function(t,e,r){return n.ScriptTester.testCovenant(t,e,r)},testFieldExtraction:function(t,e,r){return n.ScriptTester.testFieldExtraction(t,e,r)},debugScript:function(t,e){return new n.ScriptTester(e).debug(t)},explainZeroHashes:function(){return n.SIGHASH.explainZeroMystery()},getAllSIGHASHTypes:function(){return n.SIGHASH.getAllTypes()},demonstrateAllSIGHASH:function(){return n.SIGHASH.generateAllDemonstrations()},createCovenantBuilder:function(){return new n.CovenantBuilder},createValueLockCovenant:function(t){return n.CovenantTemplates.valueLock(t)},createHashLockCovenant:function(t){return n.CovenantTemplates.hashLock(t)},createComplexValidationCovenant:function(t){return n.CovenantTemplates.complexValidation(t)},getOpcodeMap:function(){return n.OpcodeMap.opcodeMap},simulateScript:function(t,e){return n.OpcodeMap.utils.simulate(t,e)},createASMFromJS:function(t){return n.OpcodeMap.utils.createASM(t)},scriptToASM:function(t){return n.ScriptUtils.scriptToASM(t)},asmToScript:function(t){return n.ScriptUtils.asmToScript(t)},asmToHex:function(t){return n.ScriptUtils.asmToHex(t)},hexToASM:function(t){return n.ScriptUtils.hexToASM(t)},scriptToHex:function(t){return n.ScriptUtils.scriptToHex(t)},validateASM:function(t){return n.ScriptUtils.validateASM(t)},validateScript:function(t){return n.ScriptUtils.validateScript(t)},estimateScriptSize:function(t){return n.ScriptUtils.estimateScriptSize(t)},optimizeScript:function(t){return n.ScriptUtils.optimizeScript(t)},compareScripts:function(t,e){return n.ScriptUtils.compareScripts(t,e)},explainScript:function(t){return n.ScriptUtils.explainScript(t)},scriptMetrics:function(t){return n.ScriptUtils.scriptMetrics(t)},analyzeComplexity:function(t){return n.ScriptUtils.analyzeComplexity(t)},findOptimizations:function(t){return n.ScriptUtils.findOptimizations(t)},covenantToEnglish:function(t){return n.ScriptUtils.covenantToEnglish(t)},batchTestScripts:function(t,e){return n.ScriptUtils.batchTestScripts(t,e)},createQuickCovenant:function(t,e){const r=n.createCovenantBuilder();switch(t){case"value_lock":return r.comment(`Value lock: minimum ${e.value} satoshis`).extractField("value").push(e.value).greaterThanOrEqual().verify().build();case"hash_lock":return r.comment("Hash lock: requires preimage of "+e.hash).push("secret_placeholder").sha256().push(e.hash).equalVerify().build();case"time_lock":return r.comment("Time lock: requires nLockTime > "+e.timestamp).extractField("nLockTime").push(e.timestamp).greaterThan().verify().build();case"multi_condition":let i=r.comment("Multi-condition covenant");return e.conditions.forEach(t=>{switch(t.type){case"value":i=i.extractField("value").push(t.value).greaterThanOrEqual().verify();break;case"hash":i=i.push("secret_placeholder").sha256().push(t.hash).equalVerify();break;case"time":i=i.extractField("nLockTime").push(t.timestamp).greaterThan().verify()}}),i.build();default:throw new Error("Unknown covenant type: "+t)}},completeCovenantFlow:function(t,e,r){return new n.Covenant(t).completeFlow(e,r)},getEducationalResources:function(){return{zeroHashMystery:n.SIGHASH.explainZeroMystery(),sighashTypes:n.SIGHASH.getAllTypes(),exampleDemonstrations:n.SIGHASH.generateAllDemonstrations()}},utils:{}};n.utils.reconstructP2pkhScript=function(t){return i.Script.buildPublicKeyHashOut(t).toHex()},n.utils.createCovenantAddress=function(t){var e=i.crypto.Hash.sha256ripemd160(t.toBuffer());return i.Address.fromScriptHash(e)},n.utils.decodeCompactSize=function(t,e){return n.Preimage.decodeCompactSize(t,e)},n.version="v1.0.0",n.description="Enterprise Smart Contract Framework for Bitcoin SV",n.features={BIP143_PREIMAGE:!0,COMPACT_SIZE_VARINT:!0,BIDIRECTIONAL_EXTRACTION:!0,SIGHASH_DETECTION:!0,ZERO_HASH_WARNINGS:!0,MULTI_FIELD_VALIDATION:!0,REAL_UTXO_GENERATION:!0,SCRIPT_TESTING:!0,LOCAL_VERIFICATION:!0,JAVASCRIPT_TO_SCRIPT:!0,OPCODE_MAPPING:!0,COVENANT_BUILDER:!0,SCRIPT_ANALYSIS:!0,SCRIPT_OPTIMIZATION:!0,SCRIPT_CONVERSION:!0,BATCH_TESTING:!0,QUICK_COVENANTS:!0,SCRIPT_EXPLANATIONS:!0,PRODUCTION_READY:!0},t.exports=n},function(t,e,r){"use strict";(function(e,i){var n,o=r(7),s=r(53);try{n=r(!function(){var t=new Error("Cannot find module 'fs'");throw t.code="MODULE_NOT_FOUND",t}())}catch(t){n=null}function a(t,r){if(!(this instanceof a))return new a(t,r);this.privateKey=t,this.publicKey=t.publicKey,this.address=t.toAddress(),r=r||{},this.storageDir=r.storageDir||(void 0!==e?s.join(e.cwd(),".bsv-covenants"):".bsv-covenants"),this.covenantUtxoPath=s.join(this.storageDir,"covenant_utxos.json"),this.sighashType=o.crypto.Signature.SIGHASH_ALL|o.crypto.Signature.SIGHASH_FORKID,n&&this._ensureStorageDir()}a.prototype.createFromP2PKH=function(t){t.script||(t.script=a.reconstructP2pkhScript(this.address));var e=(new o.Transaction).from({txId:t.txid,outputIndex:t.vout,script:t.script,satoshis:t.satoshis}).to(this.address,t.satoshis-1e3),r=o.Script.fromHex(t.script),i=o.Transaction.sighash.sighashPreimage(e,this.sighashType,0,r,new o.crypto.BN(t.satoshis)),n=o.crypto.Hash.sha256sha256(i),s=(new o.Script).add("OP_DUP").add("OP_HASH256").add(n).add("OP_EQUALVERIFY").add("OP_DROP").add(this.publicKey.toBuffer()).add("OP_CHECKSIG");return e.outputs[0].setScript(s),e.sign(this.privateKey),{transaction:e,covenantUtxo:{txid:e.id,vout:0,satoshis:t.satoshis-1e3,script:s.toHex(),scriptPubKey:s.toHex(),preimageHash:n.toString("hex"),originalPreimage:i.toString("hex"),status:"local",createdAt:(new Date).toISOString(),type:"preimage_covenant"}}},a.prototype.createSpendingTx=function(t,e,r){var n=e||this.address,s=r||t.satoshis-500,a=new o.Transaction;a.addInput(new o.Transaction.Input({prevTxId:t.txid,outputIndex:t.vout,script:o.Script.empty()}),o.Script.fromHex(t.script),t.satoshis),a.to(n,s);var c=o.Script.fromHex(t.script),u=o.Transaction.sighash.sign(a,this.privateKey,this.sighashType,0,c,new o.crypto.BN(t.satoshis)),f=i.concat([u.toDER(),i.from([this.sighashType])]),h=i.from(t.originalPreimage,"hex"),d=(new o.Script).add(f).add(h);return a.inputs[0].setScript(d),a},a.prototype.validate=function(t,e){var r=new o.Script.Interpreter,i=o.Script.Interpreter.SCRIPT_VERIFY_P2SH|o.Script.Interpreter.SCRIPT_VERIFY_STRICTENC|o.Script.Interpreter.SCRIPT_VERIFY_DERSIG|o.Script.Interpreter.SCRIPT_VERIFY_LOW_S|o.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID,n=t.inputs[0].script,s=o.Script.fromHex(e.script),a=r.verify(n,s,t,0,i,new o.crypto.BN(e.satoshis));return{valid:a,error:a?null:r.errstr}},a.prototype.save=function(t){if(!n)return console.warn("File system operations not available in browser environment"),t;var e=this.list();return e.push(t),n.writeFileSync(this.covenantUtxoPath,JSON.stringify(e,null,2)),t},a.prototype.load=function(t){var e=this.list();if(t){var r;if(!(r=e.find((function(e){return e.txid===t}))))throw new Error("Covenant UTXO with TXID "+t+" not found");return r}if(!(r=e.find((function(t){return"preimage_covenant"===t.type}))))throw new Error("No preimage covenant UTXO found");return r},a.prototype.list=function(){return n.existsSync(this.covenantUtxoPath)?JSON.parse(n.readFileSync(this.covenantUtxoPath,"utf8")):[]},a.prototype.getPortfolio=function(){var t=this.list(),e={total:t.length,totalValue:t.reduce((function(t,e){return t+e.satoshis}),0),byStatus:{},recent:t.slice(-5)};return t.forEach((function(t){var r=t.status||"local";e.byStatus[r]||(e.byStatus[r]={count:0,value:0}),e.byStatus[r].count++,e.byStatus[r].value+=t.satoshis})),e},a.prototype.completeFlow=function(t,e){var r=this.createFromP2PKH(t),i=this.save(r.covenantUtxo);e&&e(r.transaction,"creation");var n=this.createSpendingTx(i),o=this.validate(n,i);return e&&o.valid&&e(n,"spending"),{creationTx:r.transaction,spendingTx:n,covenantUtxo:i,validation:o,success:o.valid}},a.prototype._ensureStorageDir=function(){n.existsSync(this.storageDir)||n.mkdirSync(this.storageDir,{recursive:!0})},a.reconstructP2pkhScript=function(t){return o.Script.buildPublicKeyHashOut(t).toHex()},t.exports=a}).call(this,r(24),r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(7);function n(t){if(!(this instanceof n))return new n(t);this.sighashType=t||i.crypto.Signature.SIGHASH_ALL|i.crypto.Signature.SIGHASH_FORKID,this.analysis=this._analyzeFlags()}n.prototype.analyze=function(){return this.analysis},n.prototype.getZeroHashBehavior=function(){var t={hashPrevouts:!1,hashSequence:!1,hashOutputs:!1,explanation:[],criticalNote:null};return this.analysis.anyoneCanPay&&(t.hashPrevouts=!0,t.explanation.push("ANYONECANPAY: hashPrevouts becomes zero hash (0x00...00)")),"NONE"===this.analysis.baseType&&(t.hashSequence=!0,t.hashOutputs=!0,t.explanation.push("SIGHASH_NONE: hashSequence and hashOutputs become zero hash")),"SINGLE"===this.analysis.baseType&&(t.hashSequence=!0,t.hashOutputs=!0,t.explanation.push("SIGHASH_SINGLE: hashSequence becomes zero hash, hashOutputs covers only corresponding output")),(t.hashPrevouts||t.hashSequence||t.hashOutputs)&&(t.criticalNote="These zero hashes are NOT bugs - they are correct BIP-143 behavior for the specified SIGHASH flags!"),t},n.prototype.generateExample=function(){var t=i.PrivateKey.fromRandom().toAddress(),e={txId:"a".repeat(64),outputIndex:0,script:i.Script.buildPublicKeyHashOut(t).toHex(),satoshis:1e5},n=(new i.Transaction).from(e).to(t,99e3),o=i.Script.fromHex(e.script),s=i.Transaction.sighash.sighashPreimage(n,this.sighashType,0,o,new i.crypto.BN(e.satoshis)),a=new(r(17))(s);return{transaction:n,preimage:a,sighashType:this.sighashType,analysis:this.analysis,zeroHashBehavior:this.getZeroHashBehavior(),fields:a.extract(),validation:a.validate()}},n.prototype.createDemonstration=function(){var t=this.generateExample(),r=e.alloc(32).toString("hex"),i={sighashType:this.sighashType,analysis:this.analysis,zeroHashBehavior:this.getZeroHashBehavior(),preimageFields:{},observations:[],educationalNotes:[]},n=t.preimage.toObject().fields;return i.preimageFields=n,n.hashPrevouts===r&&i.observations.push({field:"hashPrevouts",value:"ZERO HASH (00...00)",reason:"ANYONECANPAY flag - this input can be combined with any other inputs"}),n.hashSequence===r&&i.observations.push({field:"hashSequence",value:"ZERO HASH (00...00)",reason:this.analysis.baseType+" flag - sequence numbers not covered by signature"}),n.hashOutputs===r&&i.observations.push({field:"hashOutputs",value:"ZERO HASH (00...00)",reason:this.analysis.baseType+" flag - outputs not fully covered by signature"}),i.educationalNotes=["Zero hashes in preimages are NOT errors - they indicate specific SIGHASH flag behavior","BIP-143 mandates these zero values when certain flags are used","ANYONECANPAY allows this input to be combined with different sets of inputs","SIGHASH_NONE means the signer doesn't care about any outputs","SIGHASH_SINGLE means the signer only cares about the corresponding output","Always check SIGHASH flags when you see 'mysterious' zero hashes in preimages"],i},n.prototype.checkCompliance=function(t){var r=t.toObject().fields,i=e.alloc(32).toString("hex"),n={compliant:!0,issues:[],expectedZeros:[],unexpectedZeros:[]},o=this.getZeroHashBehavior();return o.hashPrevouts&&r.hashPrevouts!==i?(n.compliant=!1,n.issues.push("hashPrevouts should be zero due to ANYONECANPAY flag")):o.hashPrevouts||r.hashPrevouts!==i||n.unexpectedZeros.push("hashPrevouts is zero but ANYONECANPAY not set"),o.hashSequence&&r.hashSequence!==i?(n.compliant=!1,n.issues.push("hashSequence should be zero due to "+this.analysis.baseType+" flag")):o.hashSequence||r.hashSequence!==i||n.unexpectedZeros.push("hashSequence is zero but "+this.analysis.baseType+" allows sequence coverage"),o.hashOutputs&&r.hashOutputs!==i?(n.compliant=!1,n.issues.push("hashOutputs should be zero due to "+this.analysis.baseType+" flag")):o.hashOutputs||r.hashOutputs!==i||n.unexpectedZeros.push("hashOutputs is zero but "+this.analysis.baseType+" should cover outputs"),n},n.prototype._analyzeFlags=function(){var t=31&this.sighashType,e=0!=(128&this.sighashType),r=0!=(64&this.sighashType),i="UNKNOWN";1===t?i="ALL":2===t?i="NONE":3===t&&(i="SINGLE");var n=[];return n.push(i),e&&n.push("ANYONECANPAY"),r&&n.push("FORKID"),{sighashType:this.sighashType,baseType:i,anyoneCanPay:e,forkId:r,flagName:n.join(" | "),hex:"0x"+this.sighashType.toString(16).padStart(8,"0"),binary:"0b"+this.sighashType.toString(2).padStart(32,"0")}},n.getAllTypes=function(){var t=i.crypto.Signature.SIGHASH_FORKID;return[{name:"ALL",value:i.crypto.Signature.SIGHASH_ALL|t},{name:"NONE",value:i.crypto.Signature.SIGHASH_NONE|t},{name:"SINGLE",value:i.crypto.Signature.SIGHASH_SINGLE|t},{name:"ALL | ANYONECANPAY",value:i.crypto.Signature.SIGHASH_ALL|i.crypto.Signature.SIGHASH_ANYONECANPAY|t},{name:"NONE | ANYONECANPAY",value:i.crypto.Signature.SIGHASH_NONE|i.crypto.Signature.SIGHASH_ANYONECANPAY|t},{name:"SINGLE | ANYONECANPAY",value:i.crypto.Signature.SIGHASH_SINGLE|i.crypto.Signature.SIGHASH_ANYONECANPAY|t}]},n.generateAllDemonstrations=function(){return n.getAllTypes().map((function(t){var e=new n(t.value);return{typeName:t.name,demonstration:e.createDemonstration()}}))},n.explainZeroMystery=function(){return{title:"The 'Extra Zero' Mystery in Bitcoin Preimages",problem:"Developers often see zero hashes (0x00...00) in preimage fields and think it's a bug",reality:"These zeros are CORRECT behavior mandated by BIP-143 for specific SIGHASH flags",explanation:["ANYONECANPAY sets hashPrevouts to zero - allows input combination flexibility","SIGHASH_NONE sets hashSequence and hashOutputs to zero - signer doesn't care about outputs","SIGHASH_SINGLE sets hashSequence to zero - only corresponding output matters","These are features, not bugs - they enable advanced Bitcoin transaction patterns"],solution:"Always check SIGHASH flags when analyzing preimages with zero hashes",toolTip:"Use SIGHASH.checkCompliance() to verify if zero hashes match expected flag behavior"}},t.exports=n}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var i=r(7);function n(t,e){if(!(this instanceof n))return new n(t,e);this.privateKey=t,this.publicKey=t?t.publicKey:null,this.options=e||{},this.conditions=[],this.preimageFields=[],this.scriptTemplate=null,this.validationRules=[],this.sighashType=this.options.sighashType||i.crypto.Signature.SIGHASH_ALL|i.crypto.Signature.SIGHASH_FORKID}n.prototype.validateField=function(t,e,r){var i={field:t,expectedValue:e,operator:(r=r||{}).operator||"EQUAL",required:!1!==r.required,description:r.description||"Validate "+t};return this.validationRules.push(i),this},n.prototype.addCondition=function(t,e){var r={type:"function"==typeof t?"CUSTOM":"OPCODE",condition:t,description:(e=e||{}).description||"Custom condition",required:!1!==e.required};return this.conditions.push(r),this},n.prototype.useTemplate=function(t,e){return this.scriptTemplate={name:t,params:e||{},customScript:"object"==typeof t?t:null},this},n.prototype.buildLockingScript=function(t){new i.Script;return this.scriptTemplate?this._buildFromTemplate(t):this._buildMultiFieldCovenant(t)},n.prototype.buildUnlockingScript=function(t,r,n){var o=new i.Script,s=i.Script.fromHex(n.script),a=i.Transaction.sighash.sign(t,this.privateKey,this.sighashType,r,s,new i.crypto.BN(n.satoshis)),c=e.concat([a.toDER(),e.from([this.sighashType])]);return o.add(c),n.originalPreimage&&o.add(e.from(n.originalPreimage,"hex")),this.conditions.forEach((function(t){"UNLOCK_DATA"===t.type&&o.add(t.data)})),o},n.prototype.createCovenant=function(t,e){e=e||{};var n=(new i.Transaction).from({txId:t.txid,outputIndex:t.vout,script:t.script,satoshis:t.satoshis}).to(this.privateKey.toAddress(),t.satoshis-(e.fee||1e3)),o=i.Script.fromHex(t.script),s=i.Transaction.sighash.sighashPreimage(n,this.sighashType,0,o,new i.crypto.BN(t.satoshis)),a=new(r(17))(s).extract(),c=this.buildLockingScript({preimage:s,fields:a,transaction:n});return n.outputs[0].setScript(c),n.sign(this.privateKey),{creationTx:n,covenantUtxo:{txid:n.id,vout:0,satoshis:t.satoshis-(e.fee||1e3),script:c.toHex(),originalPreimage:s.toString("hex"),preimageFields:a,validationRules:this.validationRules.slice(),conditions:this.conditions.slice(),template:this.scriptTemplate,createdAt:(new Date).toISOString(),type:"builder_covenant"},lockingScript:c,preimageData:{preimage:s,fields:a}}},n.prototype.validateSpending=function(t,e){var n={valid:!0,errors:[],warnings:[],fieldValidations:[]},o=i.Script.fromHex(e.script),s=i.Transaction.sighash.sighashPreimage(t,this.sighashType,0,o,new i.crypto.BN(e.satoshis)),a=new(r(17))(s).extract();e.validationRules&&e.validationRules.forEach(function(t){var r=this._validateFieldRule(t,a,e.preimageFields);n.fieldValidations.push(r),!r.passed&&t.required&&(n.valid=!1,n.errors.push(r.error))}.bind(this));var c=new i.Script.Interpreter,u=i.Script.Interpreter.SCRIPT_VERIFY_P2SH|i.Script.Interpreter.SCRIPT_VERIFY_STRICTENC|i.Script.Interpreter.SCRIPT_VERIFY_DERSIG|i.Script.Interpreter.SCRIPT_VERIFY_LOW_S|i.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID,f=t.inputs[0].script,h=i.Script.fromHex(e.script);return c.verify(f,h,t,0,u,new i.crypto.BN(e.satoshis))||(n.valid=!1,n.errors.push("Script interpreter validation failed: "+c.errstr)),n},n.prototype._buildFromTemplate=function(t){var e=this.scriptTemplate;if("HASH_LOCK"===e.name)return this._buildHashLockTemplate(t,e.params);if("MULTI_FIELD"===e.name)return this._buildMultiFieldTemplate(t,e.params);if(e.customScript)return e.customScript;throw new Error("Unknown template: "+e.name)},n.prototype._buildMultiFieldCovenant=function(t){var r=new i.Script;return r.add("OP_DUP"),this.validationRules.forEach((function(t,n){if(n>0&&r.add("OP_DUP"),r.add("OP_HASH256"),t.expectedValue){var o=i.crypto.Hash.sha256sha256(e.from(t.expectedValue,"hex"));r.add(o),r.add("OP_EQUALVERIFY")}})),r.add("OP_DROP"),this.publicKey&&(r.add(this.publicKey.toBuffer()),r.add("OP_CHECKSIG")),r},n.prototype._buildHashLockTemplate=function(t,e){var r=new i.Script;r.add("OP_DUP"),r.add("OP_HASH256");var n=e.hash||i.crypto.Hash.sha256sha256(t.preimage);return r.add(n),r.add("OP_EQUALVERIFY"),r.add("OP_DROP"),this.publicKey&&(r.add(this.publicKey.toBuffer()),r.add("OP_CHECKSIG")),r},n.prototype._validateFieldRule=function(t,e,r){var i=e[t.field],n=t.expectedValue;if("string"==typeof n&&n.startsWith("ORIGINAL_")){var o=n.replace("ORIGINAL_","");n=r[o]}var s=!1,a=null;switch(t.operator){case"EQUAL":(s=i&&i.equals?i.equals(n):i===n)||(a=t.field+" does not equal expected value");break;case"NOT_EQUAL":(s=i&&i.equals?!i.equals(n):i!==n)||(a=t.field+" should not equal specified value");break;case"PRESENT":(s=!!i)||(a=t.field+" is required but not present");break;default:a="Unknown validation operator: "+t.operator}return{field:t.field,operator:t.operator,passed:s,error:a,description:t.description}},n.createHashLock=function(t,e){return new n(t).useTemplate("HASH_LOCK",{hash:e})},n.createMultiField=function(t,e){var r=new n(t);return e.forEach((function(t){r.validateField(t.field,t.expectedValue,t.options)})),r},t.exports=n}).call(this,r(0).Buffer)},function(t,e,r){"use strict";var i=r(7),n=r(15);function o(t){if(!(this instanceof o))return new o(t);this.options=t||{},this.network=this.options.network||i.Networks.mainnet,this.keyRing={},this.utxoPool=[],void 0!==i.SmartUTXO&&(this.smartUTXO=new i.SmartUTXO(this.options))}o.prototype.generateKeypair=function(t){t=t||"key_"+Date.now();var e=i.PrivateKey.fromRandom(this.network),r=e.toPublicKey(),n=e.toAddress(this.network),o={label:t,privateKey:e,publicKey:r,address:n,wif:e.toWIF(),addressString:n.toString()};return this.keyRing[t]=o,o},o.prototype.createRealUTXOs=function(t){for(var e=(t=t||{}).count||3,r=t.satoshis||1e5,i=t.scriptType||"P2PKH",n=t.keypair||this.generateKeypair("utxo_owner"),o=[],s=0;s<e;s++){var a=this._createSingleUTXO({keypair:n,satoshis:r,scriptType:i,vout:s});o.push(a),this.utxoPool.push(a),this.smartUTXO&&this.smartUTXO.addUTXO(a)}return o},o.prototype._createSingleUTXO=function(t){var e,r,o=n.randomBytes(32).toString("hex");switch(t.scriptType){case"P2PKH":r=(e=i.Script.buildPublicKeyHashOut(t.keypair.address)).toHex();break;case"P2SH":var s=i.Script.buildMultisigOut([t.keypair.publicKey],1);r=(e=i.Script.buildScriptHashOut(s)).toHex();break;case"CUSTOM":r=(e=t.customScript||i.Script.buildPublicKeyHashOut(t.keypair.address)).toHex();break;default:r=(e=i.Script.buildPublicKeyHashOut(t.keypair.address)).toHex()}return{txid:o,vout:t.vout,address:t.keypair.addressString,script:r,satoshis:t.satoshis,keypair:t.keypair,scriptType:t.scriptType,scriptObj:e,created:(new Date).toISOString()}},o.prototype.createTestTransaction=function(t){var e=(t=t||{}).inputs||this.utxoPool.slice(0,1);if(0===e.length)throw new Error("No UTXOs available for transaction. Call createRealUTXOs() first.");var r=e.reduce((function(t,e){return t+e.satoshis}),0),n=new i.Transaction;e.forEach((function(t){n.from({txId:t.txid,outputIndex:t.vout,address:t.address,script:t.script,satoshis:t.satoshis})}));var o=t.outputAddress||e[0].keypair.addressString,s=t.outputAmount||r-1e4,a=t.fee||1e4;return n.to(o,s),n.fee(a),{transaction:n,inputUTXOs:e,unsignedHex:n.toString(),inputTotal:r,outputAmount:s,fee:a,sign:function(){return e.forEach((function(t){n.sign(t.keypair.privateKey)})),{signedTransaction:n,signedHex:n.toString(),txid:n.id}},generatePreimage:function(t,r){r=r||i.crypto.Signature.SIGHASH_ALL|i.crypto.Signature.SIGHASH_FORKID;var o=e[t];return i.Transaction.sighash.sighashPreimage(n,r,t,i.Script.fromHex(o.script),new i.crypto.BN(o.satoshis))}}},o.prototype.createCovenantTest=function(t){t=t||{};var e=this.generateKeypair("covenant_test"),i=this.createRealUTXOs({count:t.utxoCount||2,satoshis:t.satoshis||5e4,keypair:e,scriptType:t.scriptType||"P2PKH"}),n={inputs:i.slice(0,1),outputAmount:t.covenantAmount||4e4,fee:1e4},o=this.createTestTransaction(n),s=o.generatePreimage(0),a=s.toString("hex");return{keypair:e,utxos:i,transaction:o,preimage:{buffer:s,hex:a,length:s.length},extractField:function(t){try{return r(17).extractFromHex(a,t)}catch(t){throw new Error("SmartContract.Preimage not available: "+t.message)}},validateCovenant:function(t){return{preimageValid:s.length>=182,covenantLogic:t,testPassed:!0}},getSummary:function(){return{keypair:e.addressString,utxoCount:i.length,totalValue:i.reduce((function(t,e){return t+e.satoshis}),0),preimageLength:s.length,transactionId:o.transaction.id}}}},o.prototype.getKeypairs=function(){return this.keyRing},o.prototype.getUTXOs=function(){return this.utxoPool},o.prototype.reset=function(){this.keyRing={},this.utxoPool=[]},o.createTestEnvironment=function(t){var e=new o(t),i=e.createCovenantTest(t);return{generator:e,test:i,getPreimage:function(){return i.preimage.hex},getKeypair:function(){return i.keypair},extractField:function(t){return i.extractField(t)},generateASM:function(t){try{return r(17).generateASMFromHex(i.preimage.hex,t)}catch(t){throw new Error("Cannot generate ASM: "+t.message)}}}},t.exports=o},function(t,e,r){"use strict";(function(e){var i=r(7);function n(t){if(!(this instanceof n))return new n(t);this.options=t||{},this.flags=this.options.flags||i.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID,this.satoshis=this.options.satoshis||1e5}n.prototype.execute=function(t){var e=this._parseScript(t.unlocking),r=this._parseScript(t.locking),n=this._createDummyTransaction(),o=new i.Script.Interpreter,s=new i.crypto.BN(this.satoshis);try{return{success:o.verify(e,r,n,0,this.flags,s),unlocking:e.toASM(),locking:r.toASM(),finalStack:o.stack.map((function(t){return t.toString("hex")})),altStack:o.altstack.map((function(t){return t.toString("hex")})),error:null}}catch(t){return{success:!1,unlocking:e.toASM(),locking:r.toASM(),finalStack:[],altStack:[],error:t.message}}},n.prototype.debug=function(t){var e=this._createCombinedScript(t),r=this._createDummyTransaction(),n=new i.Script.Interpreter;n.script=e,n.tx=r,n.nIn=0,n.flags=this.flags;var o=[],s=e.chunks;try{for(var a=0;a<s.length;a++){var c=s[a],u=i.Opcode.reverseMap[c.opcodenum]||"PUSH",f=n.stack.map((function(t){return t.toString("hex")})),h=n.altstack.map((function(t){return t.toString("hex")}));try{n.step();var d=n.stack.map((function(t){return t.toString("hex")})),p=n.altstack.map((function(t){return t.toString("hex")}));o.push({step:a+1,opcode:u,beforeStack:f,afterStack:d,beforeAltStack:h,afterAltStack:p,success:!0,error:null})}catch(t){o.push({step:a+1,opcode:u,beforeStack:f,afterStack:f,beforeAltStack:h,afterAltStack:h,success:!1,error:t.message});break}}}catch(t){o.push({step:0,opcode:"INITIALIZATION",beforeStack:[],afterStack:[],beforeAltStack:[],afterAltStack:[],success:!1,error:t.message})}return{script:e.toASM(),steps:o,totalSteps:s.length,success:o.length>0&&o[o.length-1].success}},n.prototype.testCovenant=function(t){var e=t.preimage,r=t.constraints||{},i=this._buildCovenantScript(r,e),n=this.execute({unlocking:e,locking:i});return n.covenant={preimageLength:e.length/2,constraints:r,constraintResults:this._analyzeConstraints(e,r)},n},n.prototype.testFieldExtraction=function(t,e){try{var i=r(17).extractFromHex(t,e,{includeComments:!1}),n=this._cleanASM(i.asm),o=this.execute({unlocking:t,locking:n+" OP_DROP OP_TRUE"});return o.fieldExtraction={field:e,strategy:i.strategy,value:i.value,interpretation:i.interpretation,asmGenerated:i.asm,cleanedASM:n},o}catch(t){return{success:!1,error:t.message,fieldExtraction:{field:e,error:t.message}}}},n.prototype._parseScript=function(t){if(!t)return new i.Script;var r=t.trim(),n=/^[0-9a-fA-F]+$/.test(r.replace(/\s+/g,""));try{if(n){var o=r.length/2;return o>=180&&o<=250?(new i.Script).add(e.from(r,"hex")):i.Script.fromHex(r)}return i.Script.fromASM(r)}catch(t){throw new Error("Failed to parse script: "+t.message)}},n.prototype._createCombinedScript=function(t){if(t.combined)return this._parseScript(t.combined);var r=this._parseScript(t.unlocking),n=this._parseScript(t.locking),o=e.concat([r.toBuffer(),n.toBuffer()]);return i.Script.fromBuffer(o)},n.prototype._createDummyTransaction=function(){var t=new i.Transaction,e=new i.Transaction.Input({prevTxId:"0".repeat(64),outputIndex:0,script:i.Script.empty(),satoshis:this.satoshis,output:new i.Transaction.Output({satoshis:this.satoshis,script:i.Script.empty()})});return t.addInput(e),t.addOutput(new i.Transaction.Output({satoshis:this.satoshis,script:i.Script.empty()})),t},n.prototype._buildCovenantScript=function(t,e){var i=[];try{var n=r(17);if(t.minimumAmount){var o=n.generateASMFromHex(e,"value",!1);i.push(o),i.push("OP_BIN2NUM"),i.push(t.minimumAmount.toString()),i.push("OP_GREATERTHANOREQUAL"),i.push("OP_VERIFY")}if(t.requiredSighash){var s=n.generateASMFromHex(e,"sighashType",!1);i.push(s),i.push("OP_BIN2NUM"),i.push(t.requiredSighash.toString()),i.push("OP_EQUAL"),i.push("OP_VERIFY")}i.push("OP_TRUE");var a=i.join(" ");return this._cleanASM(a)}catch(t){throw new Error("Failed to build covenant script: "+t.message)}},n.prototype._cleanASM=function(t){var r=t.split("\n").map((function(t){return t.split("#")[0].trim()})).filter((function(t){return t.length>0})).join(" ").replace(/\s+/g," ").trim();return r=r.replace(/\b(\d+)\b/g,(function(t,r){var i=parseInt(r);if(i>=1&&i<=16)return"OP_"+i;if(0===i)return"OP_0";if(-1===i)return"OP_1NEGATE";var n=i,o=n<0;o&&(n=-n);for(var s=[];n>0;)s.push(255&n),n=Math.floor(n/256);return 0===s.length&&s.push(0),o?s[s.length-1]>=128?s.push(128):s[s.length-1]|=128:s.length>0&&s[s.length-1]>=128&&s.push(0),e.from(s).toString("hex")}))},n.prototype._analyzeConstraints=function(t,e){var i={};try{var n=r(17);if(e.minimumAmount){var o=n.extractFromHex(t,"value",{includeComments:!1}),s=parseInt(o.interpretation.satoshis);i.amountCheck={constraint:e.minimumAmount,actual:s,satisfied:s>=e.minimumAmount}}if(e.requiredSighash){var a=n.extractFromHex(t,"sighashType",{includeComments:!1}),c=parseInt(a.value,16);i.sighashCheck={constraint:e.requiredSighash,actual:c,satisfied:(255&c)===e.requiredSighash}}}catch(t){i.error=t.message}return i},n.test=function(t,e,r){return new n(r).execute({unlocking:t,locking:e})},n.testCovenant=function(t,e,r){return new n(r).testCovenant({preimage:t,constraints:e})},n.testFieldExtraction=function(t,e,r){return new n(r).testFieldExtraction(t,e)},t.exports=n}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){const i=r(7);function n(t){if(e.isBuffer(t)){return i.Script.fromBuffer(t).toASM()}if(t&&"function"==typeof t.toASM)return t.toASM();throw new Error("Input must be a Buffer or Script object")}function o(t){try{return i.Script.fromASM(t),{valid:!0,error:null}}catch(t){return{valid:!1,error:t.message}}}function s(t){try{let r;if("string"==typeof t)r=i.Script.fromASM(t);else if(e.isBuffer(t))r=i.Script.fromBuffer(t);else{if(!t||"function"!=typeof t.toBuffer)return{valid:!1,error:"Invalid script input type"};r=t}const n=r.toBuffer(),o=r.toASM();return{valid:!0,error:null,size:n.length,asm:o,operations:o.split(" ").length}}catch(t){return{valid:!1,error:t.message}}}function a(t){try{let r;if("string"==typeof t)r=i.Script.fromASM(t);else if(Array.isArray(t))r=i.Script.fromASM(t.join(" "));else{if(e.isBuffer(t))return t.length;if(!t||"function"!=typeof t.toBuffer)throw new Error("Invalid script input");r=t}return r.toBuffer().length}catch(t){return{error:t.message}}}function c(t){try{const e=s(t);if(!e.valid)return{error:e.error};const r=e.asm,i=r.split(" "),n=e.size,o=i.filter(t=>t.startsWith("OP_")).length,a=i.filter(t=>!t.startsWith("OP_")&&t.length>0).length;let c=0;return i.forEach(t=>{t.startsWith("OP_")&&(["OP_CHECKSIG","OP_CHECKSIGVERIFY"].includes(t)?c+=100:["OP_SHA256","OP_HASH160","OP_HASH256"].includes(t)?c+=10:c+=1)}),{size:n,operations:i.length,opcodes:o,dataElements:a,estimatedCost:c,complexity:c>50?"high":c>10?"medium":"low",asm:r}}catch(t){return{error:t.message}}}function u(t){const e=c(t);if(e.error)return e;const r={size:e.size,operations:e.operations,complexity:e.complexity,recommendations:[]};return e.size>520&&r.recommendations.push("Script exceeds standard size limit (520 bytes)"),e.estimatedCost>100&&r.recommendations.push("High execution cost - consider optimization"),e.operations>200&&r.recommendations.push("Many operations - may hit operation limits"),r}function f(t){try{let e;e="string"==typeof t?t:n(t);const r=e.split(" "),i=[];return r.forEach((t,e)=>{let r="";if(t.startsWith("OP_"))switch(t){case"OP_DUP":r="Duplicate the top stack item";break;case"OP_DROP":r="Remove the top stack item";break;case"OP_SWAP":r="Swap the top two stack items";break;case"OP_ADD":r="Add the top two numbers";break;case"OP_SUB":r="Subtract: second - first";break;case"OP_EQUAL":r="Check if top two items are equal";break;case"OP_VERIFY":r="Assert that top item is true (non-zero)";break;case"OP_CHECKSIG":r="Verify signature against public key";break;case"OP_SHA256":r="Calculate SHA256 hash of top item";break;case"OP_HASH160":r="Calculate RIPEMD160(SHA256(x)) hash";break;case"OP_IF":r="Begin conditional execution";break;case"OP_ELSE":r="Alternative branch of conditional";break;case"OP_ENDIF":r="End conditional execution";break;default:r="Execute "+t}else t.length>0&&(r=`Push data: ${t} (${t.length/2} bytes)`);r&&i.push({operation:t,position:e,explanation:r})}),{asm:e,operations:r.length,explanations:i,summary:`Script with ${r.length} operations: ${i.map(t=>t.explanation).join(" → ")}`}}catch(t){return{error:t.message}}}t.exports={scriptToASM:n,asmToScript:function(t){try{return i.Script.fromASM(t)}catch(t){throw new Error("Invalid ASM string: "+t.message)}},asmToHex:function(t){try{return i.Script.fromASM(t).toBuffer().toString("hex")}catch(t){throw new Error("Cannot convert ASM to hex: "+t.message)}},hexToASM:function(t){try{const r=e.from(t,"hex");return i.Script.fromBuffer(r).toASM()}catch(t){throw new Error("Cannot convert hex to ASM: "+t.message)}},scriptToHex:function(t){if(e.isBuffer(t))return t.toString("hex");if(t&&"function"==typeof t.toBuffer)return t.toBuffer().toString("hex");throw new Error("Input must be a Buffer or Script object")},validateASM:o,validateScript:s,validateSyntax:function(t){const e=o(t);if(!e.valid)return e;const r=t.split(" "),n=[];for(let t=0;t<r.length;t++){const e=r[t];e.startsWith("OP_")&&!i.Opcode.map[e]&&n.push(`Unknown opcode: ${e} at position ${t}`),!e.startsWith("OP_")&&e.length>0&&(/^[0-9a-fA-F]*$/.test(e)||n.push(`Invalid hex data: ${e} at position ${t}`))}return{valid:0===n.length,error:n.length>0?n.join("; "):null,issues:n,operations:r.length}},estimateScriptSize:a,scriptMetrics:c,analyzeComplexity:u,optimizeScript:function(t){try{let e;e="string"==typeof t?t:Array.isArray(t)?t.join(" "):n(t);const r=e.split(" "),i=[];for(let t=0;t<r.length;t++){const e=r[t],n=r[t+1];e&&""!==e.trim()&&("OP_DUP"!==e||"OP_DROP"!==n?(e.startsWith("OP_")||!n||n.startsWith("OP_"),i.push(e)):t++)}const o=i.join(" "),s=a(e),c=a(o);return{original:e,optimized:o,originalSize:s,optimizedSize:c,savings:s-c,improvement:s>0?((s-c)/s*100).toFixed(1)+"%":"0%"}}catch(t){return{error:t.message}}},findOptimizations:function(t){const e=[];try{let r;r="string"==typeof t?t:n(t);const i=r.split(" ");for(let t=0;t<i.length-1;t++){const r=i[t],n=i[t+1];if("OP_DUP"===r&&"OP_DROP"===n&&e.push({type:"redundant_operation",position:t,description:"Remove redundant OP_DUP OP_DROP pair",savings:2}),r.match(/^[0-9a-fA-F]+$/)&&2===r.length){const i=parseInt(r,16);i>=1&&i<=16&&e.push({type:"inefficient_push",position:t,description:`Use OP_${i} instead of pushing ${r}`,savings:1})}}return{optimizations:e,totalSavings:e.reduce((t,e)=>t+e.savings,0)}}catch(t){return{error:t.message}}},compareScripts:function(t,r){try{let o,s;o="string"==typeof t?i.Script.fromASM(t).toBuffer():e.isBuffer(t)?t:t.toBuffer(),s="string"==typeof r?i.Script.fromASM(r).toBuffer():e.isBuffer(r)?r:r.toBuffer();return{identical:o.equals(s),scriptA:{size:o.length,asm:n(o)},scriptB:{size:s.length,asm:n(s)}}}catch(t){return{error:t.message}}},explainScript:f,covenantToEnglish:function(t){try{const e=f(t);if(e.error)return e;const r=[];return e.explanations.forEach(t=>{switch(t.operation){case"OP_VERIFY":r.push("The condition must be true for the script to succeed.");break;case"OP_CHECKSIG":r.push("A valid signature must be provided.");break;case"OP_EQUAL":r.push("Two values must be identical.");break;case"OP_ADD":r.push("Two numbers are added together.");break;default:t.explanation.includes("Push data")&&r.push("Some data is made available for processing.")}}),{english:r.join(" "),technical:e.summary,operations:e.operations}}catch(t){return{error:t.message}}},batchTestScripts:function(t,e={}){const r=[];t.forEach((t,e)=>{try{const i=s(t),o=c(t),a=u(t);r.push({index:e,script:"string"==typeof t?t:n(t),valid:i.valid,size:i.size,operations:i.operations,complexity:a.complexity,estimatedCost:o.estimatedCost,recommendations:a.recommendations})}catch(i){r.push({index:e,script:"string"==typeof t?t:"Invalid script",valid:!1,error:i.message})}});const i={total:t.length,valid:r.filter(t=>t.valid).length,invalid:r.filter(t=>!t.valid).length,averageSize:r.filter(t=>t.size).reduce((t,e)=>t+e.size,0)/r.filter(t=>t.size).length||0,complexityDistribution:{low:r.filter(t=>"low"===t.complexity).length,medium:r.filter(t=>"medium"===t.complexity).length,high:r.filter(t=>"high"===t.complexity).length}};return{results:r,summary:i}}}}).call(this,r(0).Buffer)}])}));
37
+ */t.exports=function(t){return null!=t&&"object"==typeof t&&!1===Array.isArray(t)}},function(t,e,r){"use strict";var n=r(23),i=r(2),o=r(30),s=r(21),a=r(20),c=r(12),u=r(5),f=r(31);function h(){o.apply(this,arguments)}n(h,o),h.prototype.getSignatures=function(t,e,r,n){i.checkState(this.output instanceof s),n=n||u.SIGHASH_ALL|u.SIGHASH_FORKID;var o=e.toPublicKey();return o.toString()===this.output.script.getPublicKey().toString("hex")?[new f({publicKey:o,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:a.sign(t,e,n,r,this.output.script,this.output.satoshisBN),sigtype:n})]:[]},h.prototype.addSignature=function(t,e){return i.checkState(this.isValidSignature(t,e),"Signature is invalid"),this.setScript(c.buildPublicKeyIn(e.signature.toDER(),e.sigtype)),this},h.prototype.clearSignatures=function(){return this.setScript(c.empty()),this},h.prototype.isFullySigned=function(){return this.script.isPublicKeyIn()},h.SCRIPT_MAX_SIZE=74,h.prototype._estimateSize=function(){return o.BASE_SIZE+h.SCRIPT_MAX_SIZE},t.exports=h},function(t,e,r){"use strict";var n=r(23),i=r(2),o=r(7),s=r(30),a=r(21),c=r(20),u=r(12),f=r(5),h=r(31);function d(){s.apply(this,arguments)}n(d,s),d.prototype.getSignatures=function(t,e,r,n,s){return i.checkState(this.output instanceof a),s=s||o.sha256ripemd160(e.publicKey.toBuffer()),n=n||f.SIGHASH_ALL|f.SIGHASH_FORKID,s.equals(this.output.script.getPublicKeyHash())?[new h({publicKey:e.publicKey,prevTxId:this.prevTxId,outputIndex:this.outputIndex,inputIndex:r,signature:c.sign(t,e,n,r,this.output.script,this.output.satoshisBN),sigtype:n})]:[]},d.prototype.addSignature=function(t,e){return i.checkState(this.isValidSignature(t,e),"Signature is invalid"),this.setScript(u.buildPublicKeyHashIn(e.publicKey,e.signature.toDER(),e.sigtype)),this},d.prototype.clearSignatures=function(){return this.setScript(u.empty()),this},d.prototype.isFullySigned=function(){return this.script.isPublicKeyHashIn()},d.SCRIPT_MAX_SIZE=108,d.prototype._estimateSize=function(){return s.BASE_SIZE+d.SCRIPT_MAX_SIZE},t.exports=d},function(t,e,r){"use strict";(function(e){var n=r(1),i=r(23),o=r(30),s=r(21),a=r(2),c=r(12),u=r(5),f=r(20),h=r(31),d=r(14),p=r(29);function l(t,e,r,i){o.apply(this,arguments);var s=this;e=e||t.publicKeys,r=r||t.threshold,i=i||t.signatures,this.publicKeys=e.map(t=>t.toString("hex")).sort().map(t=>new d(t)),a.checkState(c.buildMultisigOut(this.publicKeys,r).equals(this.output.script),"Provided public keys don't match to the provided output script"),this.publicKeyIndex={},n.each(this.publicKeys,(function(t,e){s.publicKeyIndex[t.toString()]=e})),this.threshold=r,this.signatures=i?this._deserializeSignatures(i):new Array(this.publicKeys.length)}i(l,o),l.prototype.toObject=function(){var t=o.prototype.toObject.apply(this,arguments);return t.threshold=this.threshold,t.publicKeys=n.map(this.publicKeys,(function(t){return t.toString()})),t.signatures=this._serializeSignatures(),t},l.prototype._deserializeSignatures=function(t){return n.map(t,(function(t){if(t)return new h(t)}))},l.prototype._serializeSignatures=function(){return n.map(this.signatures,(function(t){if(t)return t.toObject()}))},l.prototype.getSignatures=function(t,e,r,i){a.checkState(this.output instanceof s),i=i||u.SIGHASH_ALL|u.SIGHASH_FORKID;var o=this,c=[];return n.each(this.publicKeys,(function(n){n.toString()===e.publicKey.toString()&&c.push(new h({publicKey:e.publicKey,prevTxId:o.prevTxId,outputIndex:o.outputIndex,inputIndex:r,signature:f.sign(t,e,i,r,o.output.script,o.output.satoshisBN),sigtype:i}))})),c},l.prototype.addSignature=function(t,e){return a.checkState(!this.isFullySigned(),"All needed signatures have already been added"),a.checkArgument(!n.isUndefined(this.publicKeyIndex[e.publicKey.toString()]),"Signature has no matching public key"),a.checkState(this.isValidSignature(t,e)),this.signatures[this.publicKeyIndex[e.publicKey.toString()]]=e,this._updateScript(),this},l.prototype._updateScript=function(){return this.setScript(c.buildMultisigIn(this.publicKeys,this.threshold,this._createSignatures())),this},l.prototype._createSignatures=function(){return n.map(n.filter(this.signatures,(function(t){return!n.isUndefined(t)})),(function(t){return e.concat([t.signature.toDER(),e.from([255&t.sigtype])])}))},l.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()},l.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold},l.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()},l.prototype.countSignatures=function(){return n.reduce(this.signatures,(function(t,e){return t+!!e}),0)},l.prototype.publicKeysWithoutSignature=function(){var t=this;return n.filter(this.publicKeys,(function(e){return!t.signatures[t.publicKeyIndex[e.toString()]]}))},l.prototype.isValidSignature=function(t,e){return e.signature.nhashtype=e.sigtype,f.verify(t,e.signature,e.publicKey,e.inputIndex,this.output.script,this.output.satoshisBN)},l.normalizeSignatures=function(t,e,r,n,i){return i.map((function(i){var o=null;return n=n.filter((function(n){if(o)return!0;var s=new h({signature:u.fromTxFormat(n),publicKey:i,prevTxId:e.prevTxId,outputIndex:e.outputIndex,inputIndex:r,sigtype:u.SIGHASH_ALL});return s.signature.nhashtype=s.sigtype,!f.verify(t,s.signature,s.publicKey,s.inputIndex,e.output.script)||(o=s,!1)})),o||null}))},l.SIGNATURE_SIZE=73,l.prototype._estimateSize=function(){var t=1+this.threshold*l.SIGNATURE_SIZE;return o.BASE_SIZE+p(t).toBuffer().length+t},t.exports=l}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var n=r(1),i=r(23),o=r(30),s=r(21),a=r(2),c=r(12),u=r(5),f=r(20),h=r(31),d=r(14),p=r(29);function l(t,e,r,i){o.apply(this,arguments);var s=this;e=e||t.publicKeys,r=r||t.threshold,i=i||t.signatures,this.publicKeys=e.map(t=>t.toString("hex")).sort().map(t=>new d(t)),this.redeemScript=c.buildMultisigOut(this.publicKeys,r),a.checkState(c.buildScriptHashOut(this.redeemScript).equals(this.output.script),"Provided public keys don't hash to the provided output"),this.publicKeyIndex={},n.each(this.publicKeys,(function(t,e){s.publicKeyIndex[t.toString()]=e})),this.threshold=r,this.signatures=i?this._deserializeSignatures(i):new Array(this.publicKeys.length)}i(l,o),l.prototype.toObject=function(){var t=o.prototype.toObject.apply(this,arguments);return t.threshold=this.threshold,t.publicKeys=n.map(this.publicKeys,(function(t){return t.toString()})),t.signatures=this._serializeSignatures(),t},l.prototype._deserializeSignatures=function(t){return n.map(t,(function(t){if(t)return new h(t)}))},l.prototype._serializeSignatures=function(){return n.map(this.signatures,(function(t){if(t)return t.toObject()}))},l.prototype.getSignatures=function(t,e,r,i){a.checkState(this.output instanceof s),i=i||u.SIGHASH_ALL|u.SIGHASH_FORKID;var o=this,c=[];return n.each(this.publicKeys,(function(n){n.toString()===e.publicKey.toString()&&c.push(new h({publicKey:e.publicKey,prevTxId:o.prevTxId,outputIndex:o.outputIndex,inputIndex:r,signature:f.sign(t,e,i,r,o.redeemScript,o.output.satoshisBN),sigtype:i}))})),c},l.prototype.addSignature=function(t,e){return a.checkState(!this.isFullySigned(),"All needed signatures have already been added"),a.checkArgument(!n.isUndefined(this.publicKeyIndex[e.publicKey.toString()]),"Signature has no matching public key"),a.checkState(this.isValidSignature(t,e)),this.signatures[this.publicKeyIndex[e.publicKey.toString()]]=e,this._updateScript(),this},l.prototype._updateScript=function(){return this.setScript(c.buildP2SHMultisigIn(this.publicKeys,this.threshold,this._createSignatures(),{cachedMultisig:this.redeemScript})),this},l.prototype._createSignatures=function(){return n.map(n.filter(this.signatures,(function(t){return!n.isUndefined(t)})),(function(t){return e.concat([t.signature.toDER(),e.from([255&t.sigtype])])}))},l.prototype.clearSignatures=function(){this.signatures=new Array(this.publicKeys.length),this._updateScript()},l.prototype.isFullySigned=function(){return this.countSignatures()===this.threshold},l.prototype.countMissingSignatures=function(){return this.threshold-this.countSignatures()},l.prototype.countSignatures=function(){return n.reduce(this.signatures,(function(t,e){return t+!!e}),0)},l.prototype.publicKeysWithoutSignature=function(){var t=this;return n.filter(this.publicKeys,(function(e){return!t.signatures[t.publicKeyIndex[e.toString()]]}))},l.prototype.isValidSignature=function(t,e){return e.signature.nhashtype=e.sigtype,f.verify(t,e.signature,e.publicKey,e.inputIndex,this.redeemScript,this.output.satoshisBN)},l.SIGNATURE_SIZE=73,l.PUBKEY_SIZE=34,l.prototype._estimateSize=function(){var t=3+this.publicKeys.length*l.PUBKEY_SIZE,e=this.threshold*l.SIGNATURE_SIZE+1+(t<=75?1:t<=255?2:3)+t;return o.BASE_SIZE+p(e).toBuffer().length+e},t.exports=l}).call(this,r(0).Buffer)},function(t,e,r){t.exports=r(147),t.exports.BlockHeader=r(39),t.exports.MerkleBlock=r(74)},function(t,e,r){"use strict";(function(e){var n=r(1),i=r(39),o=r(3),s=r(19),a=r(16),c=r(7),u=r(37),f=r(2);function h(t){return this instanceof h?(n.extend(this,h._from(t)),this):new h(t)}h.MAX_BLOCK_SIZE=128e6,h._from=function(t){var r={};if(e.isBuffer(t))r=h._fromBufferReader(s(t));else{if(!n.isObject(t))throw new TypeError("Unrecognized argument for Block");r=h._fromObject(t)}return r},h._fromObject=function(t){var e=[];return t.transactions.forEach((function(t){t instanceof u?e.push(t):e.push(u().fromObject(t))})),{header:i.fromObject(t.header),transactions:e}},h.fromObject=function(t){var e=h._fromObject(t);return new h(e)},h._fromBufferReader=function(t){var e={};f.checkState(!t.finished(),"No block data received"),e.header=i.fromBufferReader(t);var r=t.readVarintNum();e.transactions=[];for(var n=0;n<r;n++)e.transactions.push(u().fromBufferReader(t));return e},h.fromBufferReader=function(t){f.checkArgument(t,"br is required");var e=h._fromBufferReader(t);return new h(e)},h.fromBuffer=function(t){return h.fromBufferReader(new s(t))},h.fromString=function(t){var r=e.from(t,"hex");return h.fromBuffer(r)},h.fromRawBlock=function(t){e.isBuffer(t)||(t=e.from(t,"binary"));var r=s(t);r.pos=h.Values.START_OF_BLOCK;var n=h._fromBufferReader(r);return new h(n)},h.prototype.toObject=h.prototype.toJSON=function(){var t=[];return this.transactions.forEach((function(e){t.push(e.toObject())})),{header:this.header.toObject(),transactions:t}},h.prototype.toBuffer=function(){return this.toBufferWriter().concat()},h.prototype.toString=function(){return this.toBuffer().toString("hex")},h.prototype.toBufferWriter=function(t){t||(t=new a),t.write(this.header.toBuffer()),t.writeVarintNum(this.transactions.length);for(var e=0;e<this.transactions.length;e++)this.transactions[e].toBufferWriter(t);return t},h.prototype.getTransactionHashes=function(){var t=[];if(0===this.transactions.length)return[h.Values.NULL_HASH];for(var e=0;e<this.transactions.length;e++)t.push(this.transactions[e]._getHash());return t},h.prototype.getMerkleTree=function(){for(var t=this.getTransactionHashes(),r=0,n=this.transactions.length;n>1;n=Math.floor((n+1)/2)){for(var i=0;i<n;i+=2){var o=Math.min(i+1,n-1),s=e.concat([t[r+i],t[r+o]]);t.push(c.sha256sha256(s))}r+=n}return t},h.prototype.getMerkleRoot=function(){var t=this.getMerkleTree();return t[t.length-1]},h.prototype.validMerkleRoot=function(){var t=new o(this.header.merkleRoot.toString("hex"),"hex"),e=new o(this.getMerkleRoot().toString("hex"),"hex");return 0===t.cmp(e)},h.prototype._getHash=function(){return this.header._getHash()};var d={configurable:!1,enumerable:!0,get:function(){return this._id||(this._id=this.header.id),this._id},set:n.noop};Object.defineProperty(h.prototype,"id",d),Object.defineProperty(h.prototype,"hash",d),h.prototype.inspect=function(){return"<Block "+this.id+">"},h.Values={START_OF_BLOCK:8,NULL_HASH:e.from("0000000000000000000000000000000000000000000000000000000000000000","hex")},t.exports=h}).call(this,r(0).Buffer)},function(t,e,r){var n=r(4);n.Message=r(149),t.exports=n.Message},function(t,e,r){"use strict";(function(e){var n=r(4),i=n.deps._,o=n.PrivateKey,s=n.PublicKey,a=n.Address,c=n.encoding.BufferWriter,u=n.crypto.ECDSA,f=n.crypto.Signature,h=n.crypto.Hash.sha256sha256,d=n.util.js,p=n.util.preconditions,l=function t(r){return this instanceof t?(p.checkArgument(i.isString(r)||e.isBuffer(r),"First argument should be a string or Buffer"),i.isString(r)&&(this.messageBuffer=e.from(r)),e.isBuffer(r)&&(this.messageBuffer=r),this):new t(r)};l.sign=function(t,e){return new l(t).sign(e)},l.verify=function(t,e,r){return new l(t).verify(e,r)},l.MAGIC_BYTES=e.from("Bitcoin Signed Message:\n"),l.prototype.magicHash=function(){var t=c.varintBufNum(l.MAGIC_BYTES.length),r=c.varintBufNum(this.messageBuffer.length),n=e.concat([t,l.MAGIC_BYTES,r,this.messageBuffer]);return h(n)},l.prototype._sign=function(t){p.checkArgument(t instanceof o,"First argument should be an instance of PrivateKey");var e=this.magicHash();return u.signWithCalcI(e,t)},l.prototype.sign=function(t){return this._sign(t).toCompact().toString("base64")},l.prototype._verify=function(t,e){p.checkArgument(t instanceof s,"First argument should be an instance of PublicKey"),p.checkArgument(e instanceof f,"Second argument should be an instance of Signature");var r=this.magicHash(),n=u.verify(r,e,t);return n||(this.error="The signature was invalid"),n},l.prototype.verify=function(t,r){p.checkArgument(t),p.checkArgument(r&&i.isString(r)),i.isString(t)&&(t=a.fromString(t));var n=f.fromCompact(e.from(r,"base64")),o=new u;o.hashbuf=this.magicHash(),o.sig=n;var s=o.toPublicKey(),c=a.fromPublicKey(s,t.network);return t.toString()!==c.toString()?(this.error="The signature did not match the message digest",!1):this._verify(s,n)},l.fromString=function(t){return new l(t)},l.fromJSON=function(t){return d.isValidJSON(t)&&(t=JSON.parse(t)),l.fromObject(t)},l.prototype.toObject=function(){return{messageHex:this.messageBuffer.toString("hex")}},l.fromObject=function(t){let r=e.from(t.messageHex,"hex");return new l(r)},l.prototype.toJSON=function(){return JSON.stringify(this.toObject())},l.prototype.toString=function(){return this.messageBuffer.toString()},l.prototype.inspect=function(){return"<Message: "+this.toString()+">"},t.exports=l}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){let n,i,o,s;if("undefined"==typeof window)try{n=r(!function(){var t=new Error("Cannot find module 'fs'");throw t.code="MODULE_NOT_FOUND",t}()),i=r(53),o=r(15),s=r(151)}catch(t){console.warn("SmartUTXO: Running in browser mode - some features may be limited")}t.exports=class{constructor(t={}){this.options=t||{},this.loadState()}loadState(){try{return s.loadBlockchainState()}catch(t){return console.log("⚠️ Could not load blockchain state:",t.message),null}}saveState(){try{const t=s.loadBlockchainState();s.saveBlockchainState(t);const e=Object.keys(t.globalUTXOSet||{}).length;console.log(`💾 Saved blockchain state with ${e} UTXOs`)}catch(t){console.log("⚠️ Could not save blockchain state:",t.message)}}getUTXOsForAddress(t){try{const e=s.loadBlockchainState();return e.wallets&&e.wallets[t]&&e.wallets[t].utxos||[]}catch(t){return console.log("⚠️ Error getting UTXOs:",t.message),[]}}addUTXO(t){try{s.addUTXO(t,t.address)}catch(t){console.log("⚠️ Error adding UTXO:",t.message)}}spendUTXOs(t,e="manual-spend"){try{for(const r of t)s.spendUTXO(r.txid,r.vout,e)}catch(t){console.log("⚠️ Error spending UTXOs:",t.message)}}createMockUTXOs(t,e=5,r=1e5){const n=[];for(let i=0;i<e;i++){const e={txid:o.randomBytes(32).toString("hex"),vout:i,address:t,satoshis:r,script:`76a914${o.randomBytes(20).toString("hex")}88ac`};n.push(e)}return n}getBalance(t){try{const e=s.loadBlockchainState();return e.wallets&&e.wallets[t]&&e.wallets[t].totalValue||0}catch(t){return console.log("⚠️ Error getting balance:",t.message),0}}getStats(){try{const t=s.getBlockchainStats();return{totalUTXOs:t.metadata.totalUTXOs,totalValue:t.metadata.totalValue,totalWallets:t.metadata.totalWallets,blockHeight:t.metadata.blockHeight,lastUpdated:t.metadata.lastUpdated}}catch(t){return console.log("⚠️ Error getting stats:",t.message),{totalUTXOs:0,totalValue:0,totalWallets:0,blockHeight:0}}}reset(){try{const t=i.join(e,"../utilities/blockchain-state.json");n.existsSync(t)&&(n.unlinkSync(t),console.log("🔄 Blockchain state reset"))}catch(t){console.log("⚠️ Could not reset blockchain state:",t.message)}}}}).call(this,"/")},function(t,e,r){(function(t,e,n){let i,o,s,a;if("undefined"==typeof window)try{i=r(4),o=r(!function(){var t=new Error("Cannot find module 'fs'");throw t.code="MODULE_NOT_FOUND",t}()),s=r(53),a=s.join(t,"blockchain-state.json")}catch(t){console.warn("BlockchainState: Running in browser mode - persistence disabled")}else i="undefined"!=typeof window&&window.bsv||r(4);function c(){return{metadata:{createdAt:(new Date).toISOString(),lastUpdated:(new Date).toISOString(),totalWallets:0,totalUTXOs:0,totalValue:0,blockHeight:0},wallets:{},globalUTXOSet:{},spentUTXOs:{},transactionHistory:[]}}function u(){try{if(!o||!a)return c();if(!o.existsSync(a)){console.log("🆕 Creating new blockchain state...");const t=c();return f(t),t}const t=JSON.parse(o.readFileSync(a,"utf8"));return console.log("📖 Loaded existing blockchain state"),t}catch(t){return console.error("❌ Error loading blockchain state:",t.message),c()}}function f(t){try{t.metadata.lastUpdated=(new Date).toISOString(),o&&a&&(o.writeFileSync(a,JSON.stringify(t,null,2)),console.log("💾 Blockchain state saved"))}catch(t){console.error("❌ Error saving blockchain state:",t.message)}}function h(t,e){console.log("📝 Registering wallet: "+t);const r=u();return r.wallets[t]&&console.log("ℹ️ Wallet already exists, updating..."),r.wallets[t]={address:t,registeredAt:e.registeredAt||(new Date).toISOString(),utxos:e.utxos||[],totalValue:0},e.utxos&&e.utxos.forEach(e=>{const n=`${e.txid}:${e.vout}`;r.globalUTXOSet[n]={...e,ownerAddress:t}}),r.metadata.totalWallets=Object.keys(r.wallets).length,p(r),f(r),console.log("✅ Wallet registered: "+t),r}function d(t,e){const r=u(),n=`${t}:${e}`;return r.spentUTXOs[n]?{exists:!1,spent:!0,utxo:r.spentUTXOs[n]}:r.globalUTXOSet[n]?{exists:!0,spent:!1,utxo:r.globalUTXOSet[n]}:{exists:!1,spent:!1,utxo:null}}function p(t){const e=Object.keys(t.globalUTXOSet).length,r=Object.values(t.globalUTXOSet).reduce((t,e)=>t+e.satoshis,0);t.metadata.totalUTXOs=e,t.metadata.totalValue=r,Object.values(t.wallets).forEach(t=>{t.totalValue=t.utxos.reduce((t,e)=>t+e.satoshis,0)})}function l(){const t=u();return console.log("🌐 Blockchain State Statistics:"),console.log("═══════════════════════════════════════════"),console.log("📊 Total Wallets: "+t.metadata.totalWallets),console.log("💰 Total UTXOs: "+t.metadata.totalUTXOs),console.log(`💎 Total Value: ${t.metadata.totalValue} satoshis`),console.log("🏗️ Block Height: "+t.metadata.blockHeight),console.log(`🕐 Last Updated: ${t.metadata.lastUpdated}\n`),Object.keys(t.wallets).length>0&&(console.log("👛 Registered Wallets:"),Object.entries(t.wallets).forEach(([t,e])=>{console.log(` ${t}: ${e.utxos.length} UTXOs, ${e.totalValue} sats`)})),t}function g(){const e=s.join(t,"wallet.json");if(!o.existsSync(e))return console.log("❌ No wallet.json found to import"),!1;try{const t=JSON.parse(o.readFileSync(e,"utf8"));console.log("📥 Importing wallet from wallet.json...");const r={registeredAt:(new Date).toISOString(),utxos:t.availableUTXOs||[t.utxo]};return h(t.wallet.address,r),console.log("✅ Wallet imported successfully"),!0}catch(t){return console.error("❌ Error importing wallet:",t.message),!1}}if(r.c[r.s]===e){const t=n.argv.slice(2);if("import"===t[0])g();else if("init"===t[0]){f(c()),console.log("🆕 Initialized new blockchain state")}l()}e.exports={loadBlockchainState:u,saveBlockchainState:f,registerWallet:h,getUTXO:d,isUTXOAvailable:function(t,e){const r=d(t,e);return r.exists&&!r.spent},spendUTXO:function(t,e,r){const n=u(),i=`${t}:${e}`;if(!n.globalUTXOSet[i])throw new Error(`UTXO ${i} does not exist`);if(n.spentUTXOs[i])throw new Error(`UTXO ${i} already spent`);const o=n.globalUTXOSet[i];n.spentUTXOs[i]={...o,spentInTx:r,spentAt:(new Date).toISOString()},delete n.globalUTXOSet[i];const s=n.wallets[o.ownerAddress];s&&(s.utxos=s.utxos.filter(r=>!(r.txid===t&&r.vout===e))),p(n),f(n),console.log(`❌ UTXO spent: ${i} in tx ${r}`)},addUTXO:function(t,e){const r=u(),n=`${t.txid}:${t.vout}`;if(r.globalUTXOSet[n])return void console.log(`⚠️ UTXO ${n} already exists, skipping`);r.globalUTXOSet[n]={...t,ownerAddress:e,createdAt:(new Date).toISOString()},r.wallets[e]||(r.wallets[e]={address:e,registeredAt:(new Date).toISOString(),utxos:[],totalValue:0}),r.wallets[e].utxos.some(e=>e.txid===t.txid&&e.vout===t.vout)||r.wallets[e].utxos.push(t),p(r),f(r),console.log(`✅ UTXO added: ${n} for ${e}`)},getBlockchainStats:l,importWalletFromFile:g}}).call(this,"/",r(25)(t),r(18))},function(t,e,r){"use strict";(function(e){t.exports=class{constructor(t,e={}){this.bsv=t,this.options={difficulty:e.difficulty||1,blockTime:e.blockTime||1e4,validateScripts:!1!==e.validateScripts,logLevel:e.logLevel||"info",...e},this.currentBlock={height:0,transactions:[],timestamp:Date.now()},this.mempool=[]}acceptTransaction(t){try{if(this.options.validateScripts){if(!this.validateTransactionSignatures(t))return this.log("warn","❌ Transaction rejected: Invalid signatures"),!1}return this.mempool.push(t),this.log("info","✅ Transaction accepted into mempool: "+(t.id||"unknown")),!0}catch(t){return this.log("error","❌ Transaction rejected: "+t.message),!1}}validateTransactionSignatures(t){try{const e=t.verify();return this.log("debug","📊 Transaction verification result: "+e),!0===e}catch(t){return this.log("warn","⚠️ Signature validation error: "+t.message),!1}}mineBlock(t=10){const r=this.mempool.splice(0,t),n={height:this.currentBlock.height+1,timestamp:Date.now(),transactions:r,transactionCount:r.length,previousBlockHash:this.currentBlock.hash||"0000000000000000000000000000000000000000000000000000000000000000"},i=JSON.stringify({height:n.height,timestamp:n.timestamp,previousBlockHash:n.previousBlockHash,transactions:r.map(t=>t.id||t.toString())});return n.hash=this.bsv.crypto.Hash.sha256(e.from(i)).toString("hex"),this.currentBlock=n,this.log("info",`⛏️ Mined block ${n.height} with ${r.length} transactions`),this.log("debug","📦 Block hash: "+n.hash),n}getMempoolStats(){return{transactionCount:this.mempool.length,transactions:this.mempool.map(t=>({id:t.id||"unknown",size:t.toBuffer?t.toBuffer().length:0,inputs:t.inputs?t.inputs.length:0,outputs:t.outputs?t.outputs.length:0}))}}getBlockchainStats(){return{currentHeight:this.currentBlock.height,currentBlockHash:this.currentBlock.hash,currentBlockTimestamp:this.currentBlock.timestamp,mempoolSize:this.mempool.length,difficulty:this.options.difficulty,blockTime:this.options.blockTime}}reset(){this.currentBlock={height:0,transactions:[],timestamp:Date.now()},this.mempool=[],this.log("info","🔄 Miner reset to genesis state")}log(t,e){const r={error:0,warn:1,info:2,debug:3},n=r[this.options.logLevel]||2;if(r[t]<=n){const r=(new Date).toISOString();console.log(`[${r}] [${t.toUpperCase()}] ${e}`)}}}}).call(this,r(0).Buffer)},function(t,e,r){(function(e){const n=r(4);class i{static createSignature(t,r,i,o,s,a=null){a=a||n.crypto.Signature.SIGHASH_ALL|n.crypto.Signature.SIGHASH_FORKID;const c=n.Transaction.sighash.sign(t,r,a,i,o,new n.crypto.BN(s));return e.concat([c.toDER(),e.from([a])])}static createMultisigScript(t,e){let r=(new n.Script).add(n.Opcode["OP_"+t]);for(const t of e)r=r.add(t.toBuffer());return r.add(n.Opcode["OP_"+e.length]).add(n.Opcode.OP_CHECKMULTISIG)}static createMultisigUnlocking(t){let e=(new n.Script).add(n.Opcode.OP_0);for(const r of t)e=e.add(r);return e}static createTimelockScript(t,r){const i=e.from(t.toString(16).padStart(8,"0"),"hex").reverse();return(new n.Script).add(i).add(n.Opcode.OP_CHECKLOCKTIMEVERIFY).add(n.Opcode.OP_DROP).add(r.toBuffer())}static createConditionalScript(t,e=null){let r=(new n.Script).add(n.Opcode.OP_IF).add(t.toBuffer());return e&&(r=r.add(n.Opcode.OP_ELSE).add(e.toBuffer())),r.add(n.Opcode.OP_ENDIF)}static createP2PKHScript(t){return(new n.Script).add(n.Opcode.OP_DUP).add(n.Opcode.OP_HASH160).add(t.toAddress().hashBuffer).add(n.Opcode.OP_EQUALVERIFY).add(n.Opcode.OP_CHECKSIG)}static createP2PKHUnlocking(t,e){return(new n.Script).add(t).add(e.toBuffer())}static getPreimage(t,e,r,i,o=null){return o=o||n.crypto.Signature.SIGHASH_ALL|n.crypto.Signature.SIGHASH_FORKID,n.Transaction.sighash.sighash(t,o,e,r,new n.crypto.BN(i))}static createDataScript(t){return"string"==typeof t&&(t=e.from(t,"utf8")),(new n.Script).add(t)}static createOpReturnScript(t){return"string"==typeof t&&(t=e.from(t,"utf8")),(new n.Script).add(n.Opcode.OP_FALSE).add(n.Opcode.OP_RETURN).add(t)}static validateTransaction(t){try{return t.verify()}catch(t){return console.error("Transaction validation error:",t.message),!1}}static validateScript(t,e,r,i){try{return(new n.Script.Interpreter).verify(t,e,r,i,n.Script.Interpreter.SCRIPT_VERIFY_P2SH|n.Script.Interpreter.SCRIPT_VERIFY_STRICTENC|n.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID|n.Script.Interpreter.SCRIPT_ENABLE_MAGNETIC_OPCODES|n.Script.Interpreter.SCRIPT_ENABLE_MONOLITH_OPCODES)}catch(t){return console.error("Script validation error:",t.message),!1}}static createLowFeeTransaction(t,e,r=10){let i=(new n.Transaction).feePerKb(r);for(const e of t)i=i.from(e);for(const t of e)i=i.to(t.address,t.satoshis);return i}}i.SIGHASH_ALL=n.crypto.Signature.SIGHASH_ALL|n.crypto.Signature.SIGHASH_FORKID,i.SIGHASH_NONE=n.crypto.Signature.SIGHASH_NONE|n.crypto.Signature.SIGHASH_FORKID,i.SIGHASH_SINGLE=n.crypto.Signature.SIGHASH_SINGLE|n.crypto.Signature.SIGHASH_FORKID,t.exports=i}).call(this,r(0).Buffer)},function(t,e,r){"use strict";var n=r(4),i={Covenant:r(155),Preimage:r(17),SIGHASH:r(156),Builder:r(157),UTXOGenerator:r(158),ScriptTester:r(159),CovenantBuilder:r(77).CovenantBuilder,CovenantTemplates:r(77).CovenantTemplates,OpcodeMap:r(78),ScriptUtils:r(160),StackExaminer:r(161),ScriptInterpreter:r(162),createCovenant:function(t,e){return new i.Covenant(t,e)},extractPreimage:function(t,e){return new i.Preimage(t,e)},analyzeSIGHASH:function(t){return new i.SIGHASH(t)},buildCovenant:function(t,e){return new i.Builder(t,e)},createUTXOGenerator:function(t){return new i.UTXOGenerator(t)},createTestEnvironment:function(t){return i.UTXOGenerator.createTestEnvironment(t)},testScript:function(t,e,r){return i.ScriptTester.test(t,e,r)},testCovenant:function(t,e,r){return i.ScriptTester.testCovenant(t,e,r)},testFieldExtraction:function(t,e,r){return i.ScriptTester.testFieldExtraction(t,e,r)},debugScript:function(t,e){return new i.ScriptTester(e).debug(t)},explainZeroHashes:function(){return i.SIGHASH.explainZeroMystery()},getAllSIGHASHTypes:function(){return i.SIGHASH.getAllTypes()},demonstrateAllSIGHASH:function(){return i.SIGHASH.generateAllDemonstrations()},createCovenantBuilder:function(){return new i.CovenantBuilder},createValueLockCovenant:function(t){return i.CovenantTemplates.valueLock(t)},createHashLockCovenant:function(t){return i.CovenantTemplates.hashLock(t)},createComplexValidationCovenant:function(t){return i.CovenantTemplates.complexValidation(t)},getOpcodeMap:function(){return i.OpcodeMap.opcodeMap},simulateScript:function(t,e){return i.OpcodeMap.utils.simulate(t,e)},createASMFromJS:function(t){return i.OpcodeMap.utils.createASM(t)},scriptToASM:function(t){return i.ScriptUtils.scriptToASM(t)},asmToScript:function(t){return i.ScriptUtils.asmToScript(t)},asmToHex:function(t){return i.ScriptUtils.asmToHex(t)},hexToASM:function(t){return i.ScriptUtils.hexToASM(t)},scriptToHex:function(t){return i.ScriptUtils.scriptToHex(t)},validateASM:function(t){return i.ScriptUtils.validateASM(t)},validateScript:function(t){return i.ScriptUtils.validateScript(t)},estimateScriptSize:function(t){return i.ScriptUtils.estimateScriptSize(t)},optimizeScript:function(t){return i.ScriptUtils.optimizeScript(t)},compareScripts:function(t,e){return i.ScriptUtils.compareScripts(t,e)},explainScript:function(t){return i.ScriptUtils.explainScript(t)},scriptMetrics:function(t){return i.ScriptUtils.scriptMetrics(t)},analyzeComplexity:function(t){return i.ScriptUtils.analyzeComplexity(t)},findOptimizations:function(t){return i.ScriptUtils.findOptimizations(t)},covenantToEnglish:function(t){return i.ScriptUtils.covenantToEnglish(t)},batchTestScripts:function(t,e){return i.ScriptUtils.batchTestScripts(t,e)},examineStack:function(t,e){return i.StackExaminer.runScript(t,e)},debugScriptExecution:function(t,e,r){return(r=r||{}).stepMode?i.ScriptInterpreter.stepThroughScript(i.ScriptInterpreter.parseScript(t+" "+e),new n.Transaction,!0):i.ScriptInterpreter.runFullEvaluation(i.ScriptInterpreter.parseScript(t),i.ScriptInterpreter.parseScript(e),new n.Transaction)},parseScript:function(t){return i.ScriptInterpreter.parseScript(t)},printStack:function(t,e){return i.ScriptInterpreter.printStack(t,e)},createQuickCovenant:function(t,e){const r=i.createCovenantBuilder();switch(t){case"value_lock":return r.comment(`Value lock: minimum ${e.value} satoshis`).extractField("value").push(e.value).greaterThanOrEqual().verify().build();case"hash_lock":return r.comment("Hash lock: requires preimage of "+e.hash).push("secret_placeholder").sha256().push(e.hash).equalVerify().build();case"time_lock":return r.comment("Time lock: requires nLockTime > "+e.timestamp).extractField("nLockTime").push(e.timestamp).greaterThan().verify().build();case"multi_condition":let n=r.comment("Multi-condition covenant");return e.conditions.forEach(t=>{switch(t.type){case"value":n=n.extractField("value").push(t.value).greaterThanOrEqual().verify();break;case"hash":n=n.push("secret_placeholder").sha256().push(t.hash).equalVerify();break;case"time":n=n.extractField("nLockTime").push(t.timestamp).greaterThan().verify()}}),n.build();default:throw new Error("Unknown covenant type: "+t)}},completeCovenantFlow:function(t,e,r){return new i.Covenant(t).completeFlow(e,r)},getEducationalResources:function(){return{zeroHashMystery:i.SIGHASH.explainZeroMystery(),sighashTypes:i.SIGHASH.getAllTypes(),exampleDemonstrations:i.SIGHASH.generateAllDemonstrations()}},utils:{}};i.utils.reconstructP2pkhScript=function(t){return n.Script.buildPublicKeyHashOut(t).toHex()},i.utils.createCovenantAddress=function(t){var e=n.crypto.Hash.sha256ripemd160(t.toBuffer());return n.Address.fromScriptHash(e)},i.utils.decodeCompactSize=function(t,e){return i.Preimage.decodeCompactSize(t,e)},i.version="v1.0.0",i.description="Enterprise Smart Contract Framework for Bitcoin SV",i.features={BIP143_PREIMAGE:!0,COMPACT_SIZE_VARINT:!0,BIDIRECTIONAL_EXTRACTION:!0,SIGHASH_DETECTION:!0,ZERO_HASH_WARNINGS:!0,MULTI_FIELD_VALIDATION:!0,REAL_UTXO_GENERATION:!0,SCRIPT_TESTING:!0,LOCAL_VERIFICATION:!0,JAVASCRIPT_TO_SCRIPT:!0,OPCODE_MAPPING:!0,COVENANT_BUILDER:!0,SCRIPT_ANALYSIS:!0,SCRIPT_OPTIMIZATION:!0,SCRIPT_CONVERSION:!0,BATCH_TESTING:!0,QUICK_COVENANTS:!0,SCRIPT_EXPLANATIONS:!0,STACK_EXAMINATION:!0,SCRIPT_DEBUGGING:!0,STEP_BY_STEP_EXECUTION:!0,INTERACTIVE_DEBUGGING:!0,PRODUCTION_READY:!0},t.exports=i},function(t,e,r){"use strict";(function(e,n){var i,o=r(4),s=r(53);try{i=r(!function(){var t=new Error("Cannot find module 'fs'");throw t.code="MODULE_NOT_FOUND",t}())}catch(t){i=null}function a(t,r){if(!(this instanceof a))return new a(t,r);this.privateKey=t,this.publicKey=t.publicKey,this.address=t.toAddress(),r=r||{},this.storageDir=r.storageDir||(void 0!==e?s.join(e.cwd(),".bsv-covenants"):".bsv-covenants"),this.covenantUtxoPath=s.join(this.storageDir,"covenant_utxos.json"),this.sighashType=o.crypto.Signature.SIGHASH_ALL|o.crypto.Signature.SIGHASH_FORKID,i&&this._ensureStorageDir()}a.prototype.createFromP2PKH=function(t){t.script||(t.script=a.reconstructP2pkhScript(this.address));var e=(new o.Transaction).from({txId:t.txid,outputIndex:t.vout,script:t.script,satoshis:t.satoshis}).to(this.address,t.satoshis-1e3),r=o.Script.fromHex(t.script),n=o.Transaction.sighash.sighashPreimage(e,this.sighashType,0,r,new o.crypto.BN(t.satoshis)),i=o.crypto.Hash.sha256sha256(n),s=(new o.Script).add("OP_DUP").add("OP_HASH256").add(i).add("OP_EQUALVERIFY").add("OP_DROP").add(this.publicKey.toBuffer()).add("OP_CHECKSIG");return e.outputs[0].setScript(s),e.sign(this.privateKey),{transaction:e,covenantUtxo:{txid:e.id,vout:0,satoshis:t.satoshis-1e3,script:s.toHex(),scriptPubKey:s.toHex(),preimageHash:i.toString("hex"),originalPreimage:n.toString("hex"),status:"local",createdAt:(new Date).toISOString(),type:"preimage_covenant"}}},a.prototype.createSpendingTx=function(t,e,r){var i=e||this.address,s=r||t.satoshis-500,a=new o.Transaction;a.addInput(new o.Transaction.Input({prevTxId:t.txid,outputIndex:t.vout,script:o.Script.empty()}),o.Script.fromHex(t.script),t.satoshis),a.to(i,s);var c=o.Script.fromHex(t.script),u=o.Transaction.sighash.sign(a,this.privateKey,this.sighashType,0,c,new o.crypto.BN(t.satoshis)),f=n.concat([u.toDER(),n.from([this.sighashType])]),h=n.from(t.originalPreimage,"hex"),d=(new o.Script).add(f).add(h);return a.inputs[0].setScript(d),a},a.prototype.validate=function(t,e){var r=new o.Script.Interpreter,n=o.Script.Interpreter.SCRIPT_VERIFY_P2SH|o.Script.Interpreter.SCRIPT_VERIFY_STRICTENC|o.Script.Interpreter.SCRIPT_VERIFY_DERSIG|o.Script.Interpreter.SCRIPT_VERIFY_LOW_S|o.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID,i=t.inputs[0].script,s=o.Script.fromHex(e.script),a=r.verify(i,s,t,0,n,new o.crypto.BN(e.satoshis));return{valid:a,error:a?null:r.errstr}},a.prototype.save=function(t){if(!i)return console.warn("File system operations not available in browser environment"),t;var e=this.list();return e.push(t),i.writeFileSync(this.covenantUtxoPath,JSON.stringify(e,null,2)),t},a.prototype.load=function(t){var e=this.list();if(t){var r;if(!(r=e.find((function(e){return e.txid===t}))))throw new Error("Covenant UTXO with TXID "+t+" not found");return r}if(!(r=e.find((function(t){return"preimage_covenant"===t.type}))))throw new Error("No preimage covenant UTXO found");return r},a.prototype.list=function(){return i.existsSync(this.covenantUtxoPath)?JSON.parse(i.readFileSync(this.covenantUtxoPath,"utf8")):[]},a.prototype.getPortfolio=function(){var t=this.list(),e={total:t.length,totalValue:t.reduce((function(t,e){return t+e.satoshis}),0),byStatus:{},recent:t.slice(-5)};return t.forEach((function(t){var r=t.status||"local";e.byStatus[r]||(e.byStatus[r]={count:0,value:0}),e.byStatus[r].count++,e.byStatus[r].value+=t.satoshis})),e},a.prototype.completeFlow=function(t,e){var r=this.createFromP2PKH(t),n=this.save(r.covenantUtxo);e&&e(r.transaction,"creation");var i=this.createSpendingTx(n),o=this.validate(i,n);return e&&o.valid&&e(i,"spending"),{creationTx:r.transaction,spendingTx:i,covenantUtxo:n,validation:o,success:o.valid}},a.prototype._ensureStorageDir=function(){i.existsSync(this.storageDir)||i.mkdirSync(this.storageDir,{recursive:!0})},a.reconstructP2pkhScript=function(t){return o.Script.buildPublicKeyHashOut(t).toHex()},t.exports=a}).call(this,r(18),r(0).Buffer)},function(t,e,r){"use strict";(function(e){var n=r(4);function i(t){if(!(this instanceof i))return new i(t);this.sighashType=t||n.crypto.Signature.SIGHASH_ALL|n.crypto.Signature.SIGHASH_FORKID,this.analysis=this._analyzeFlags()}i.prototype.analyze=function(){return this.analysis},i.prototype.getZeroHashBehavior=function(){var t={hashPrevouts:!1,hashSequence:!1,hashOutputs:!1,explanation:[],criticalNote:null};return this.analysis.anyoneCanPay&&(t.hashPrevouts=!0,t.explanation.push("ANYONECANPAY: hashPrevouts becomes zero hash (0x00...00)")),"NONE"===this.analysis.baseType&&(t.hashSequence=!0,t.hashOutputs=!0,t.explanation.push("SIGHASH_NONE: hashSequence and hashOutputs become zero hash")),"SINGLE"===this.analysis.baseType&&(t.hashSequence=!0,t.hashOutputs=!0,t.explanation.push("SIGHASH_SINGLE: hashSequence becomes zero hash, hashOutputs covers only corresponding output")),(t.hashPrevouts||t.hashSequence||t.hashOutputs)&&(t.criticalNote="These zero hashes are NOT bugs - they are correct BIP-143 behavior for the specified SIGHASH flags!"),t},i.prototype.generateExample=function(){var t=n.PrivateKey.fromRandom().toAddress(),e={txId:"a".repeat(64),outputIndex:0,script:n.Script.buildPublicKeyHashOut(t).toHex(),satoshis:1e5},i=(new n.Transaction).from(e).to(t,99e3),o=n.Script.fromHex(e.script),s=n.Transaction.sighash.sighashPreimage(i,this.sighashType,0,o,new n.crypto.BN(e.satoshis)),a=new(r(17))(s);return{transaction:i,preimage:a,sighashType:this.sighashType,analysis:this.analysis,zeroHashBehavior:this.getZeroHashBehavior(),fields:a.extract(),validation:a.validate()}},i.prototype.createDemonstration=function(){var t=this.generateExample(),r=e.alloc(32).toString("hex"),n={sighashType:this.sighashType,analysis:this.analysis,zeroHashBehavior:this.getZeroHashBehavior(),preimageFields:{},observations:[],educationalNotes:[]},i=t.preimage.toObject().fields;return n.preimageFields=i,i.hashPrevouts===r&&n.observations.push({field:"hashPrevouts",value:"ZERO HASH (00...00)",reason:"ANYONECANPAY flag - this input can be combined with any other inputs"}),i.hashSequence===r&&n.observations.push({field:"hashSequence",value:"ZERO HASH (00...00)",reason:this.analysis.baseType+" flag - sequence numbers not covered by signature"}),i.hashOutputs===r&&n.observations.push({field:"hashOutputs",value:"ZERO HASH (00...00)",reason:this.analysis.baseType+" flag - outputs not fully covered by signature"}),n.educationalNotes=["Zero hashes in preimages are NOT errors - they indicate specific SIGHASH flag behavior","BIP-143 mandates these zero values when certain flags are used","ANYONECANPAY allows this input to be combined with different sets of inputs","SIGHASH_NONE means the signer doesn't care about any outputs","SIGHASH_SINGLE means the signer only cares about the corresponding output","Always check SIGHASH flags when you see 'mysterious' zero hashes in preimages"],n},i.prototype.checkCompliance=function(t){var r=t.toObject().fields,n=e.alloc(32).toString("hex"),i={compliant:!0,issues:[],expectedZeros:[],unexpectedZeros:[]},o=this.getZeroHashBehavior();return o.hashPrevouts&&r.hashPrevouts!==n?(i.compliant=!1,i.issues.push("hashPrevouts should be zero due to ANYONECANPAY flag")):o.hashPrevouts||r.hashPrevouts!==n||i.unexpectedZeros.push("hashPrevouts is zero but ANYONECANPAY not set"),o.hashSequence&&r.hashSequence!==n?(i.compliant=!1,i.issues.push("hashSequence should be zero due to "+this.analysis.baseType+" flag")):o.hashSequence||r.hashSequence!==n||i.unexpectedZeros.push("hashSequence is zero but "+this.analysis.baseType+" allows sequence coverage"),o.hashOutputs&&r.hashOutputs!==n?(i.compliant=!1,i.issues.push("hashOutputs should be zero due to "+this.analysis.baseType+" flag")):o.hashOutputs||r.hashOutputs!==n||i.unexpectedZeros.push("hashOutputs is zero but "+this.analysis.baseType+" should cover outputs"),i},i.prototype._analyzeFlags=function(){var t=31&this.sighashType,e=0!=(128&this.sighashType),r=0!=(64&this.sighashType),n="UNKNOWN";1===t?n="ALL":2===t?n="NONE":3===t&&(n="SINGLE");var i=[];return i.push(n),e&&i.push("ANYONECANPAY"),r&&i.push("FORKID"),{sighashType:this.sighashType,baseType:n,anyoneCanPay:e,forkId:r,flagName:i.join(" | "),hex:"0x"+this.sighashType.toString(16).padStart(8,"0"),binary:"0b"+this.sighashType.toString(2).padStart(32,"0")}},i.getAllTypes=function(){var t=n.crypto.Signature.SIGHASH_FORKID;return[{name:"ALL",value:n.crypto.Signature.SIGHASH_ALL|t},{name:"NONE",value:n.crypto.Signature.SIGHASH_NONE|t},{name:"SINGLE",value:n.crypto.Signature.SIGHASH_SINGLE|t},{name:"ALL | ANYONECANPAY",value:n.crypto.Signature.SIGHASH_ALL|n.crypto.Signature.SIGHASH_ANYONECANPAY|t},{name:"NONE | ANYONECANPAY",value:n.crypto.Signature.SIGHASH_NONE|n.crypto.Signature.SIGHASH_ANYONECANPAY|t},{name:"SINGLE | ANYONECANPAY",value:n.crypto.Signature.SIGHASH_SINGLE|n.crypto.Signature.SIGHASH_ANYONECANPAY|t}]},i.generateAllDemonstrations=function(){return i.getAllTypes().map((function(t){var e=new i(t.value);return{typeName:t.name,demonstration:e.createDemonstration()}}))},i.explainZeroMystery=function(){return{title:"The 'Extra Zero' Mystery in Bitcoin Preimages",problem:"Developers often see zero hashes (0x00...00) in preimage fields and think it's a bug",reality:"These zeros are CORRECT behavior mandated by BIP-143 for specific SIGHASH flags",explanation:["ANYONECANPAY sets hashPrevouts to zero - allows input combination flexibility","SIGHASH_NONE sets hashSequence and hashOutputs to zero - signer doesn't care about outputs","SIGHASH_SINGLE sets hashSequence to zero - only corresponding output matters","These are features, not bugs - they enable advanced Bitcoin transaction patterns"],solution:"Always check SIGHASH flags when analyzing preimages with zero hashes",toolTip:"Use SIGHASH.checkCompliance() to verify if zero hashes match expected flag behavior"}},t.exports=i}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){var n=r(4);function i(t,e){if(!(this instanceof i))return new i(t,e);this.privateKey=t,this.publicKey=t?t.publicKey:null,this.options=e||{},this.conditions=[],this.preimageFields=[],this.scriptTemplate=null,this.validationRules=[],this.sighashType=this.options.sighashType||n.crypto.Signature.SIGHASH_ALL|n.crypto.Signature.SIGHASH_FORKID}i.prototype.validateField=function(t,e,r){var n={field:t,expectedValue:e,operator:(r=r||{}).operator||"EQUAL",required:!1!==r.required,description:r.description||"Validate "+t};return this.validationRules.push(n),this},i.prototype.addCondition=function(t,e){var r={type:"function"==typeof t?"CUSTOM":"OPCODE",condition:t,description:(e=e||{}).description||"Custom condition",required:!1!==e.required};return this.conditions.push(r),this},i.prototype.useTemplate=function(t,e){return this.scriptTemplate={name:t,params:e||{},customScript:"object"==typeof t?t:null},this},i.prototype.buildLockingScript=function(t){new n.Script;return this.scriptTemplate?this._buildFromTemplate(t):this._buildMultiFieldCovenant(t)},i.prototype.buildUnlockingScript=function(t,r,i){var o=new n.Script,s=n.Script.fromHex(i.script),a=n.Transaction.sighash.sign(t,this.privateKey,this.sighashType,r,s,new n.crypto.BN(i.satoshis)),c=e.concat([a.toDER(),e.from([this.sighashType])]);return o.add(c),i.originalPreimage&&o.add(e.from(i.originalPreimage,"hex")),this.conditions.forEach((function(t){"UNLOCK_DATA"===t.type&&o.add(t.data)})),o},i.prototype.createCovenant=function(t,e){e=e||{};var i=(new n.Transaction).from({txId:t.txid,outputIndex:t.vout,script:t.script,satoshis:t.satoshis}).to(this.privateKey.toAddress(),t.satoshis-(e.fee||1e3)),o=n.Script.fromHex(t.script),s=n.Transaction.sighash.sighashPreimage(i,this.sighashType,0,o,new n.crypto.BN(t.satoshis)),a=new(r(17))(s).extract(),c=this.buildLockingScript({preimage:s,fields:a,transaction:i});return i.outputs[0].setScript(c),i.sign(this.privateKey),{creationTx:i,covenantUtxo:{txid:i.id,vout:0,satoshis:t.satoshis-(e.fee||1e3),script:c.toHex(),originalPreimage:s.toString("hex"),preimageFields:a,validationRules:this.validationRules.slice(),conditions:this.conditions.slice(),template:this.scriptTemplate,createdAt:(new Date).toISOString(),type:"builder_covenant"},lockingScript:c,preimageData:{preimage:s,fields:a}}},i.prototype.validateSpending=function(t,e){var i={valid:!0,errors:[],warnings:[],fieldValidations:[]},o=n.Script.fromHex(e.script),s=n.Transaction.sighash.sighashPreimage(t,this.sighashType,0,o,new n.crypto.BN(e.satoshis)),a=new(r(17))(s).extract();e.validationRules&&e.validationRules.forEach(function(t){var r=this._validateFieldRule(t,a,e.preimageFields);i.fieldValidations.push(r),!r.passed&&t.required&&(i.valid=!1,i.errors.push(r.error))}.bind(this));var c=new n.Script.Interpreter,u=n.Script.Interpreter.SCRIPT_VERIFY_P2SH|n.Script.Interpreter.SCRIPT_VERIFY_STRICTENC|n.Script.Interpreter.SCRIPT_VERIFY_DERSIG|n.Script.Interpreter.SCRIPT_VERIFY_LOW_S|n.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID,f=t.inputs[0].script,h=n.Script.fromHex(e.script);return c.verify(f,h,t,0,u,new n.crypto.BN(e.satoshis))||(i.valid=!1,i.errors.push("Script interpreter validation failed: "+c.errstr)),i},i.prototype._buildFromTemplate=function(t){var e=this.scriptTemplate;if("HASH_LOCK"===e.name)return this._buildHashLockTemplate(t,e.params);if("MULTI_FIELD"===e.name)return this._buildMultiFieldTemplate(t,e.params);if(e.customScript)return e.customScript;throw new Error("Unknown template: "+e.name)},i.prototype._buildMultiFieldCovenant=function(t){var r=new n.Script;return r.add("OP_DUP"),this.validationRules.forEach((function(t,i){if(i>0&&r.add("OP_DUP"),r.add("OP_HASH256"),t.expectedValue){var o=n.crypto.Hash.sha256sha256(e.from(t.expectedValue,"hex"));r.add(o),r.add("OP_EQUALVERIFY")}})),r.add("OP_DROP"),this.publicKey&&(r.add(this.publicKey.toBuffer()),r.add("OP_CHECKSIG")),r},i.prototype._buildHashLockTemplate=function(t,e){var r=new n.Script;r.add("OP_DUP"),r.add("OP_HASH256");var i=e.hash||n.crypto.Hash.sha256sha256(t.preimage);return r.add(i),r.add("OP_EQUALVERIFY"),r.add("OP_DROP"),this.publicKey&&(r.add(this.publicKey.toBuffer()),r.add("OP_CHECKSIG")),r},i.prototype._validateFieldRule=function(t,e,r){var n=e[t.field],i=t.expectedValue;if("string"==typeof i&&i.startsWith("ORIGINAL_")){var o=i.replace("ORIGINAL_","");i=r[o]}var s=!1,a=null;switch(t.operator){case"EQUAL":(s=n&&n.equals?n.equals(i):n===i)||(a=t.field+" does not equal expected value");break;case"NOT_EQUAL":(s=n&&n.equals?!n.equals(i):n!==i)||(a=t.field+" should not equal specified value");break;case"PRESENT":(s=!!n)||(a=t.field+" is required but not present");break;default:a="Unknown validation operator: "+t.operator}return{field:t.field,operator:t.operator,passed:s,error:a,description:t.description}},i.createHashLock=function(t,e){return new i(t).useTemplate("HASH_LOCK",{hash:e})},i.createMultiField=function(t,e){var r=new i(t);return e.forEach((function(t){r.validateField(t.field,t.expectedValue,t.options)})),r},t.exports=i}).call(this,r(0).Buffer)},function(t,e,r){"use strict";var n=r(4),i=r(15);function o(t){if(!(this instanceof o))return new o(t);this.options=t||{},this.network=this.options.network||n.Networks.mainnet,this.keyRing={},this.utxoPool=[],void 0!==n.SmartUTXO&&(this.smartUTXO=new n.SmartUTXO(this.options))}o.prototype.generateKeypair=function(t){t=t||"key_"+Date.now();var e=n.PrivateKey.fromRandom(this.network),r=e.toPublicKey(),i=e.toAddress(this.network),o={label:t,privateKey:e,publicKey:r,address:i,wif:e.toWIF(),addressString:i.toString()};return this.keyRing[t]=o,o},o.prototype.createRealUTXOs=function(t){for(var e=(t=t||{}).count||3,r=t.satoshis||1e5,n=t.scriptType||"P2PKH",i=t.keypair||this.generateKeypair("utxo_owner"),o=[],s=0;s<e;s++){var a=this._createSingleUTXO({keypair:i,satoshis:r,scriptType:n,vout:s});o.push(a),this.utxoPool.push(a),this.smartUTXO&&this.smartUTXO.addUTXO(a)}return o},o.prototype._createSingleUTXO=function(t){var e,r,o=i.randomBytes(32).toString("hex");switch(t.scriptType){case"P2PKH":r=(e=n.Script.buildPublicKeyHashOut(t.keypair.address)).toHex();break;case"P2SH":var s=n.Script.buildMultisigOut([t.keypair.publicKey],1);r=(e=n.Script.buildScriptHashOut(s)).toHex();break;case"CUSTOM":r=(e=t.customScript||n.Script.buildPublicKeyHashOut(t.keypair.address)).toHex();break;default:r=(e=n.Script.buildPublicKeyHashOut(t.keypair.address)).toHex()}return{txid:o,vout:t.vout,address:t.keypair.addressString,script:r,satoshis:t.satoshis,keypair:t.keypair,scriptType:t.scriptType,scriptObj:e,created:(new Date).toISOString()}},o.prototype.createTestTransaction=function(t){var e=(t=t||{}).inputs||this.utxoPool.slice(0,1);if(0===e.length)throw new Error("No UTXOs available for transaction. Call createRealUTXOs() first.");var r=e.reduce((function(t,e){return t+e.satoshis}),0),i=new n.Transaction;e.forEach((function(t){i.from({txId:t.txid,outputIndex:t.vout,address:t.address,script:t.script,satoshis:t.satoshis})}));var o=t.outputAddress||e[0].keypair.addressString,s=t.outputAmount||r-1e4,a=t.fee||1e4;return i.to(o,s),i.fee(a),{transaction:i,inputUTXOs:e,unsignedHex:i.toString(),inputTotal:r,outputAmount:s,fee:a,sign:function(){return e.forEach((function(t){i.sign(t.keypair.privateKey)})),{signedTransaction:i,signedHex:i.toString(),txid:i.id}},generatePreimage:function(t,r){r=r||n.crypto.Signature.SIGHASH_ALL|n.crypto.Signature.SIGHASH_FORKID;var o=e[t];return n.Transaction.sighash.sighashPreimage(i,r,t,n.Script.fromHex(o.script),new n.crypto.BN(o.satoshis))}}},o.prototype.createCovenantTest=function(t){t=t||{};var e=this.generateKeypair("covenant_test"),n=this.createRealUTXOs({count:t.utxoCount||2,satoshis:t.satoshis||5e4,keypair:e,scriptType:t.scriptType||"P2PKH"}),i={inputs:n.slice(0,1),outputAmount:t.covenantAmount||4e4,fee:1e4},o=this.createTestTransaction(i),s=o.generatePreimage(0),a=s.toString("hex");return{keypair:e,utxos:n,transaction:o,preimage:{buffer:s,hex:a,length:s.length},extractField:function(t){try{return r(17).extractFromHex(a,t)}catch(t){throw new Error("SmartContract.Preimage not available: "+t.message)}},validateCovenant:function(t){return{preimageValid:s.length>=182,covenantLogic:t,testPassed:!0}},getSummary:function(){return{keypair:e.addressString,utxoCount:n.length,totalValue:n.reduce((function(t,e){return t+e.satoshis}),0),preimageLength:s.length,transactionId:o.transaction.id}}}},o.prototype.getKeypairs=function(){return this.keyRing},o.prototype.getUTXOs=function(){return this.utxoPool},o.prototype.reset=function(){this.keyRing={},this.utxoPool=[]},o.createTestEnvironment=function(t){var e=new o(t),n=e.createCovenantTest(t);return{generator:e,test:n,getPreimage:function(){return n.preimage.hex},getKeypair:function(){return n.keypair},extractField:function(t){return n.extractField(t)},generateASM:function(t){try{return r(17).generateASMFromHex(n.preimage.hex,t)}catch(t){throw new Error("Cannot generate ASM: "+t.message)}}}},t.exports=o},function(t,e,r){"use strict";(function(e){var n=r(4);function i(t){if(!(this instanceof i))return new i(t);this.options=t||{},this.flags=this.options.flags||n.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID,this.satoshis=this.options.satoshis||1e5}i.prototype.execute=function(t){var e=this._parseScript(t.unlocking),r=this._parseScript(t.locking),i=this._createDummyTransaction(),o=new n.Script.Interpreter,s=new n.crypto.BN(this.satoshis);try{return{success:o.verify(e,r,i,0,this.flags,s),unlocking:e.toASM(),locking:r.toASM(),finalStack:o.stack.map((function(t){return t.toString("hex")})),altStack:o.altstack.map((function(t){return t.toString("hex")})),error:null}}catch(t){return{success:!1,unlocking:e.toASM(),locking:r.toASM(),finalStack:[],altStack:[],error:t.message}}},i.prototype.debug=function(t){var e=this._createCombinedScript(t),r=this._createDummyTransaction(),i=new n.Script.Interpreter;i.script=e,i.tx=r,i.nIn=0,i.flags=this.flags;var o=[],s=e.chunks;try{for(var a=0;a<s.length;a++){var c=s[a],u=n.Opcode.reverseMap[c.opcodenum]||"PUSH",f=i.stack.map((function(t){return t.toString("hex")})),h=i.altstack.map((function(t){return t.toString("hex")}));try{i.step();var d=i.stack.map((function(t){return t.toString("hex")})),p=i.altstack.map((function(t){return t.toString("hex")}));o.push({step:a+1,opcode:u,beforeStack:f,afterStack:d,beforeAltStack:h,afterAltStack:p,success:!0,error:null})}catch(t){o.push({step:a+1,opcode:u,beforeStack:f,afterStack:f,beforeAltStack:h,afterAltStack:h,success:!1,error:t.message});break}}}catch(t){o.push({step:0,opcode:"INITIALIZATION",beforeStack:[],afterStack:[],beforeAltStack:[],afterAltStack:[],success:!1,error:t.message})}return{script:e.toASM(),steps:o,totalSteps:s.length,success:o.length>0&&o[o.length-1].success}},i.prototype.testCovenant=function(t){var e=t.preimage,r=t.constraints||{},n=this._buildCovenantScript(r,e),i=this.execute({unlocking:e,locking:n});return i.covenant={preimageLength:e.length/2,constraints:r,constraintResults:this._analyzeConstraints(e,r)},i},i.prototype.testFieldExtraction=function(t,e){try{var n=r(17).extractFromHex(t,e,{includeComments:!1}),i=this._cleanASM(n.asm),o=this.execute({unlocking:t,locking:i+" OP_DROP OP_TRUE"});return o.fieldExtraction={field:e,strategy:n.strategy,value:n.value,interpretation:n.interpretation,asmGenerated:n.asm,cleanedASM:i},o}catch(t){return{success:!1,error:t.message,fieldExtraction:{field:e,error:t.message}}}},i.prototype._parseScript=function(t){if(!t)return new n.Script;var r=t.trim(),i=/^[0-9a-fA-F]+$/.test(r.replace(/\s+/g,""));try{if(i){var o=r.length/2;return o>=180&&o<=250?(new n.Script).add(e.from(r,"hex")):n.Script.fromHex(r)}return n.Script.fromASM(r)}catch(t){throw new Error("Failed to parse script: "+t.message)}},i.prototype._createCombinedScript=function(t){if(t.combined)return this._parseScript(t.combined);var r=this._parseScript(t.unlocking),i=this._parseScript(t.locking),o=e.concat([r.toBuffer(),i.toBuffer()]);return n.Script.fromBuffer(o)},i.prototype._createDummyTransaction=function(){var t=new n.Transaction,e=new n.Transaction.Input({prevTxId:"0".repeat(64),outputIndex:0,script:n.Script.empty(),satoshis:this.satoshis,output:new n.Transaction.Output({satoshis:this.satoshis,script:n.Script.empty()})});return t.addInput(e),t.addOutput(new n.Transaction.Output({satoshis:this.satoshis,script:n.Script.empty()})),t},i.prototype._buildCovenantScript=function(t,e){var n=[];try{var i=r(17);if(t.minimumAmount){var o=i.generateASMFromHex(e,"value",!1);n.push(o),n.push("OP_BIN2NUM"),n.push(t.minimumAmount.toString()),n.push("OP_GREATERTHANOREQUAL"),n.push("OP_VERIFY")}if(t.requiredSighash){var s=i.generateASMFromHex(e,"sighashType",!1);n.push(s),n.push("OP_BIN2NUM"),n.push(t.requiredSighash.toString()),n.push("OP_EQUAL"),n.push("OP_VERIFY")}n.push("OP_TRUE");var a=n.join(" ");return this._cleanASM(a)}catch(t){throw new Error("Failed to build covenant script: "+t.message)}},i.prototype._cleanASM=function(t){var r=t.split("\n").map((function(t){return t.split("#")[0].trim()})).filter((function(t){return t.length>0})).join(" ").replace(/\s+/g," ").trim();return r=r.replace(/\b(\d+)\b/g,(function(t,r){var n=parseInt(r);if(n>=1&&n<=16)return"OP_"+n;if(0===n)return"OP_0";if(-1===n)return"OP_1NEGATE";var i=n,o=i<0;o&&(i=-i);for(var s=[];i>0;)s.push(255&i),i=Math.floor(i/256);return 0===s.length&&s.push(0),o?s[s.length-1]>=128?s.push(128):s[s.length-1]|=128:s.length>0&&s[s.length-1]>=128&&s.push(0),e.from(s).toString("hex")}))},i.prototype._analyzeConstraints=function(t,e){var n={};try{var i=r(17);if(e.minimumAmount){var o=i.extractFromHex(t,"value",{includeComments:!1}),s=parseInt(o.interpretation.satoshis);n.amountCheck={constraint:e.minimumAmount,actual:s,satisfied:s>=e.minimumAmount}}if(e.requiredSighash){var a=i.extractFromHex(t,"sighashType",{includeComments:!1}),c=parseInt(a.value,16);n.sighashCheck={constraint:e.requiredSighash,actual:c,satisfied:(255&c)===e.requiredSighash}}}catch(t){n.error=t.message}return n},i.test=function(t,e,r){return new i(r).execute({unlocking:t,locking:e})},i.testCovenant=function(t,e,r){return new i(r).testCovenant({preimage:t,constraints:e})},i.testFieldExtraction=function(t,e,r){return new i(r).testFieldExtraction(t,e)},t.exports=i}).call(this,r(0).Buffer)},function(t,e,r){"use strict";(function(e){const n=r(4);function i(t){if(e.isBuffer(t)){return n.Script.fromBuffer(t).toASM()}if(t&&"function"==typeof t.toASM)return t.toASM();throw new Error("Input must be a Buffer or Script object")}function o(t){try{return n.Script.fromASM(t),{valid:!0,error:null}}catch(t){return{valid:!1,error:t.message}}}function s(t){try{let r;if("string"==typeof t)r=n.Script.fromASM(t);else if(e.isBuffer(t))r=n.Script.fromBuffer(t);else{if(!t||"function"!=typeof t.toBuffer)return{valid:!1,error:"Invalid script input type"};r=t}const i=r.toBuffer(),o=r.toASM();return{valid:!0,error:null,size:i.length,asm:o,operations:o.split(" ").length}}catch(t){return{valid:!1,error:t.message}}}function a(t){try{let r;if("string"==typeof t)r=n.Script.fromASM(t);else if(Array.isArray(t))r=n.Script.fromASM(t.join(" "));else{if(e.isBuffer(t))return t.length;if(!t||"function"!=typeof t.toBuffer)throw new Error("Invalid script input");r=t}return r.toBuffer().length}catch(t){return{error:t.message}}}function c(t){try{const e=s(t);if(!e.valid)return{error:e.error};const r=e.asm,n=r.split(" ").filter(t=>t.length>0),i=e.size,o=n.filter(t=>t.startsWith("OP_")).length,a=n.filter(t=>!t.startsWith("OP_")&&t.length>0).length;let c=0;return n.forEach(t=>{t.startsWith("OP_")&&(["OP_CHECKSIG","OP_CHECKSIGVERIFY"].includes(t)?c+=100:["OP_SHA256","OP_HASH160","OP_HASH256"].includes(t)?c+=10:c+=1)}),{length:i,size:i,operations:n.length,opcodeCount:o,opcodes:o,dataElements:a,estimatedCost:c,complexity:c>50?"high":c>10?"medium":"low",asm:r}}catch(t){return{error:t.message}}}function u(t){const e=c(t);if(e.error)return e;const r={size:e.size,operations:e.operations,complexity:e.complexity,recommendations:[]};return e.size>520&&r.recommendations.push("Script exceeds standard size limit (520 bytes)"),e.estimatedCost>100&&r.recommendations.push("High execution cost - consider optimization"),e.operations>200&&r.recommendations.push("Many operations - may hit operation limits"),r}function f(t){try{let e;e="string"==typeof t?t:i(t);const r=e.split(" "),n=[];return r.forEach((t,e)=>{let r="";if(t.startsWith("OP_"))switch(t){case"OP_DUP":r="Duplicate the top stack item";break;case"OP_DROP":r="Remove the top stack item";break;case"OP_SWAP":r="Swap the top two stack items";break;case"OP_ADD":r="Add the top two numbers";break;case"OP_SUB":r="Subtract: second - first";break;case"OP_EQUAL":r="Check if top two items are equal";break;case"OP_VERIFY":r="Assert that top item is true (non-zero)";break;case"OP_CHECKSIG":r="Verify signature against public key";break;case"OP_SHA256":r="Calculate SHA256 hash of top item";break;case"OP_HASH160":r="Calculate RIPEMD160(SHA256(x)) hash";break;case"OP_IF":r="Begin conditional execution";break;case"OP_ELSE":r="Alternative branch of conditional";break;case"OP_ENDIF":r="End conditional execution";break;default:r="Execute "+t}else t.length>0&&(r=`Push data: ${t} (${t.length/2} bytes)`);r&&n.push({operation:t,position:e,explanation:r})}),{asm:e,operations:r.length,explanations:n,summary:`Script with ${r.length} operations: ${n.map(t=>t.explanation).join(" → ")}`}}catch(t){return{error:t.message}}}t.exports={scriptToASM:i,asmToScript:function(t){try{return n.Script.fromASM(t)}catch(t){throw new Error("Invalid ASM string: "+t.message)}},asmToHex:function(t){try{return n.Script.fromASM(t).toBuffer().toString("hex")}catch(t){throw new Error("Cannot convert ASM to hex: "+t.message)}},hexToASM:function(t){try{const r=e.from(t,"hex");return n.Script.fromBuffer(r).toASM()}catch(t){throw new Error("Cannot convert hex to ASM: "+t.message)}},scriptToHex:function(t){if(e.isBuffer(t))return t.toString("hex");if(t&&"function"==typeof t.toBuffer)return t.toBuffer().toString("hex");throw new Error("Input must be a Buffer or Script object")},validateASM:o,validateScript:s,validateSyntax:function(t){const e=o(t);if(!e.valid)return e;const r=t.split(" "),i=[];for(let t=0;t<r.length;t++){const e=r[t];e.startsWith("OP_")&&!n.Opcode.map[e]&&i.push(`Unknown opcode: ${e} at position ${t}`),!e.startsWith("OP_")&&e.length>0&&(/^[0-9a-fA-F]*$/.test(e)||i.push(`Invalid hex data: ${e} at position ${t}`))}return{valid:0===i.length,error:i.length>0?i.join("; "):null,issues:i,operations:r.length}},estimateScriptSize:a,scriptMetrics:c,analyzeComplexity:u,optimizeScript:function(t){try{let e;e="string"==typeof t?t:Array.isArray(t)?t.join(" "):i(t);const r=e.split(" "),o=[];for(let t=0;t<r.length;t++){const e=r[t],n=r[t+1];e&&""!==e.trim()&&("OP_DUP"!==e||"OP_DROP"!==n?(e.startsWith("OP_")||!n||n.startsWith("OP_"),o.push(e)):t++)}const s=o.join(" "),c=a(e),u=a(s);let f=null;try{f=n.Script.fromASM(s)}catch(t){f=null}return{original:e,optimized:s,originalSize:c,optimizedSize:u,savings:c-u,improvement:c>0?((c-u)/c*100).toFixed(1)+"%":"0%",script:f}}catch(t){return{error:t.message}}},findOptimizations:function(t){const e=[];try{let r;r="string"==typeof t?t:i(t);const n=r.split(" ");for(let t=0;t<n.length-1;t++){const r=n[t],i=n[t+1];if("OP_DUP"===r&&"OP_DROP"===i&&e.push({type:"redundant_operation",position:t,description:"Remove redundant OP_DUP OP_DROP pair",savings:2}),r.match(/^[0-9a-fA-F]+$/)&&2===r.length){const n=parseInt(r,16);n>=1&&n<=16&&e.push({type:"inefficient_push",position:t,description:`Use OP_${n} instead of pushing ${r}`,savings:1})}}return{optimizations:e,totalSavings:e.reduce((t,e)=>t+e.savings,0)}}catch(t){return{error:t.message}}},compareScripts:function(t,r){try{let o,s;o="string"==typeof t?n.Script.fromASM(t).toBuffer():e.isBuffer(t)?t:t.toBuffer(),s="string"==typeof r?n.Script.fromASM(r).toBuffer():e.isBuffer(r)?r:r.toBuffer();return{identical:o.equals(s),scriptA:{size:o.length,asm:i(o)},scriptB:{size:s.length,asm:i(s)}}}catch(t){return{error:t.message}}},explainScript:f,covenantToEnglish:function(t){try{const e=f(t);if(e.error)return e;const r=[];return e.explanations.forEach(t=>{switch(t.operation){case"OP_VERIFY":r.push("The condition must be true for the script to succeed.");break;case"OP_CHECKSIG":r.push("A valid signature must be provided.");break;case"OP_EQUAL":r.push("Two values must be identical.");break;case"OP_ADD":r.push("Two numbers are added together.");break;default:t.explanation.includes("Push data")&&r.push("Some data is made available for processing.")}}),{english:r.join(" "),technical:e.summary,operations:e.operations}}catch(t){return{error:t.message}}},batchTestScripts:function(t,e={}){const r=[];t.forEach((t,e)=>{try{const n=s(t),o=c(t),a=u(t);r.push({index:e,script:"string"==typeof t?t:i(t),valid:n.valid,size:n.size,operations:n.operations,complexity:a.complexity,estimatedCost:o.estimatedCost,recommendations:a.recommendations})}catch(n){r.push({index:e,script:"string"==typeof t?t:"Invalid script",valid:!1,error:n.message})}});const n={total:t.length,valid:r.filter(t=>t.valid).length,invalid:r.filter(t=>!t.valid).length,averageSize:r.filter(t=>t.size).reduce((t,e)=>t+e.size,0)/r.filter(t=>t.size).length||0,complexityDistribution:{low:r.filter(t=>"low"===t.complexity).length,medium:r.filter(t=>"medium"===t.complexity).length,high:r.filter(t=>"high"===t.complexity).length}};return{results:r,summary:n}}}}).call(this,r(0).Buffer)},function(t,e,r){(function(t,e,n){const i="undefined"!=typeof window&&window.bsv?window.bsv:r(4);r(70);function o(t){return t.map(t=>t.toString("hex"))}function s(e,r){console.log("==========================================="),console.log("🔍 STACK EXAMINATION TOOL"),console.log("===========================================\n"),console.log("🔐 Locking Script:",e),console.log("🔓 Unlocking Script:",r),console.log("-------------------------------------------");try{const n=i.Script.fromHex(e),s=i.Script.fromHex(r),a=i.Script.fromBuffer(t.concat([s.toBuffer(),n.toBuffer()])),c=new i.Script.Interpreter,u=new i.Transaction,f=new i.Transaction.Input({prevTxId:"0".repeat(64),outputIndex:0,script:i.Script.empty()});u.addInput(f),u.addOutput(new i.Transaction.Output({satoshis:1e5,script:n}));const h=a.chunks,d=new i.Script.Interpreter;d.script=a,d.tx=u,d.nIn=0,d.flags=i.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID;for(let t=0;t<h.length;t++){const e=h[t];try{if("function"!=typeof d.step){console.log("⚠️ Step-by-step execution not supported in this BSV version");break}d.step(),console.log(`\n🧩 Step ${t+1}: ${i.Opcode.reverseMap[e.opcodenum]||"PUSH"}`),console.log("Stack:",o(d.stack)),console.log("AltStack:",o(d.altstack))}catch(e){console.log(`⚠️ Error executing opcode ${t+1}:`,e.message);break}}const p=new i.crypto.BN(1e5),l=c.verify(s,n,u,0,i.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID,p);return console.log("\n==========================================="),console.log("✅ Final Result:",l?"TRUE (Success)":"❌ FALSE (Failure)"),console.log("Final Stack:",o(d.stack||[])),console.log("AltStack:",o(d.altstack||[])),console.log("==========================================="),l}catch(t){return console.error("❌ Error in script execution:",t.message),!1}}if(r.c[r.s]===e){n.argv.length<4&&(console.log("Usage: node stack_examiner.js <locking_script_hex> <unlocking_script_hex>"),n.exit(1));s(n.argv[2],n.argv[3])}e.exports={runScript:s,bufferToHexArray:o}}).call(this,r(0).Buffer,r(25)(t),r(18))},function(t,e,r){(function(t,e,n){let i=null;try{"undefined"==typeof window&&(i=r(!function(){var t=new Error("Cannot find module 'readline'");throw t.code="MODULE_NOT_FOUND",t}()))}catch(t){i=null}const o="undefined"!=typeof window&&window.bsv?window.bsv:r(4);function s(e){if(!e)return new o.Script;const r=e.trim(),n=/^[0-9a-fA-F]+$/.test(r.replace(/\s+/g,""));try{return n?o.Script.fromHex(r):o.Script.fromASM(r)}catch(e){console.error("❌ Error parsing script:",e.message),t.exit(1)}}function a(t,e=[]){const r=t=>t.length?t.toString("hex"):"(empty)",n=t.map(r);console.log("Stack:",n.length?n:["(empty)"]),e.length&&console.log("AltStack:",e.map(r))}async function c(e,r,n=!0){const s=new o.Script.Interpreter;s.script=e,s.tx=r,s.nIn=0,s.flags=o.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID;const c=e.chunks;let u=null;i&&void 0!==t&&t.stdin&&(u=i.createInterface({input:t.stdin,output:t.stdout})),console.log("==========================================="),console.log("🔍 SCRIPT INTERPRETER DEBUGGER (STEP MODE)"),console.log("===========================================\n"),console.log("Script:",e.toASM()),console.log("-------------------------------------------");for(let t=0;t<c.length;t++){const e=c[t],r=o.Opcode.reverseMap[e.opcodenum]||"PUSH";n&&u?await new Promise(e=>u.question(`\n[${t+1}/${c.length}] Step (${r}) — press Enter to execute...`,e)):n&&console.log(`\n[${t+1}/${c.length}] Step (${r})`);try{if("function"!=typeof s.step){console.log("⚠️ Step-by-step execution not supported in this BSV version"),console.log("💡 Consider using runFullEvaluation instead");break}s.step(),console.log("🧩 Executed: "+r),a(s.stack,s.altstack)}catch(t){console.log(`⚠️ Error executing ${r}: ${t.message}`);break}}u&&u.close(),console.log("\n==========================================="),console.log("✅ Final Stack State:"),a(s.stack||[],s.altstack||[]),console.log("===========================================")}function u(t,e,r){console.log("==========================================="),console.log("🔍 SCRIPT INTERPRETER DEBUGGER (FULL RUN)"),console.log("===========================================\n");const n=new o.Script.Interpreter,i=new o.crypto.BN(1e5),s=n.verify(t,e,r,0,o.Script.Interpreter.SCRIPT_ENABLE_SIGHASH_FORKID,i);console.log("🔐 Locking Script:",e.toASM()),console.log("🔓 Unlocking Script:",t.toASM()),console.log("-------------------------------------------"),console.log("✅ Result:",s?"TRUE (Success)":"❌ FALSE (Failure)"),console.log("Final Stack:",n.stack.map(t=>t.toString("hex"))),console.log("AltStack:",n.altstack.map(t=>t.toString("hex"))),console.log("===========================================")}async function f(){if(void 0===t||!t.argv)return void console.log("⚙️ CLI mode not available in browser environment");const r=t.argv.slice(2),n=t=>{const e=r.indexOf(t);return-1!==e&&r[e+1]?r[e+1]:null},i=n("--unlocking"),a=n("--locking"),f=n("--combined"),h=r.includes("--step"),d=r.includes("--truth");let p,l,g;if(f)g=s(f);else{p=s(i),l=s(a);const t=e.concat([p.toBuffer(),l.toBuffer()]);g=o.Script.fromBuffer(t)}const m=new o.Transaction,b=new o.Transaction.Input({prevTxId:"0".repeat(64),outputIndex:0,script:o.Script.empty(),satoshis:1e5,output:new o.Transaction.Output({satoshis:1e5,script:o.Script.empty()})});m.addInput(b),m.addOutput(new o.Transaction.Output({satoshis:1e5,script:o.Script.empty()})),h?await c(g,m,!0):d?u(p||o.Script.empty(),l||o.Script.empty(),m):console.log("⚙️ No mode specified. Use --step or --truth")}n.exports={parseScript:s,printStack:a,stepThroughScript:c,runFullEvaluation:u,main:f},r.c[r.s]===n&&f()}).call(this,r(18),r(0).Buffer,r(25)(t))}])}));