New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@trezor/blockchain-link

Package Overview
Dependencies
Maintainers
5
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@trezor/blockchain-link - npm Package Compare versions

Comparing version 1.0.8 to 1.0.9

2

build/web/blockbook-worker.js

@@ -1,1 +0,1 @@

!function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="./",n(n.s=463)}({19:function(e,t,n){"use strict";var r,i="object"==typeof Reflect?Reflect:null,o=i&&"function"==typeof i.apply?i.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};r=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function u(){u.init.call(this)}e.exports=u,u.EventEmitter=u,u.prototype._events=void 0,u.prototype._eventsCount=0,u.prototype._maxListeners=void 0;var c=10;function a(e){return void 0===e._maxListeners?u.defaultMaxListeners:e._maxListeners}function f(e,t,n,r){var i,o,s,u;if("function"!=typeof n)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n);if(void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),s=o[t]),void 0===s)s=o[t]=n,++e._eventsCount;else if("function"==typeof s?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),(i=a(e))>0&&s.length>i&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,u=c,console&&console.warn&&console.warn(u)}return e}function l(){for(var e=[],t=0;t<arguments.length;t++)e.push(arguments[t]);this.fired||(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,o(this.listener,this.target,e))}function d(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=l.bind(r);return i.listener=n,r.wrapFn=i,i}function p(e,t,n){var r=e._events;if(void 0===r)return[];var i=r[t];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(i):v(i,i.length)}function h(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function v(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}Object.defineProperty(u,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");c=e}}),u.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},u.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||s(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},u.prototype.getMaxListeners=function(){return a(this)},u.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var r="error"===e,i=this._events;if(void 0!==i)r=r&&void 0===i.error;else if(!r)return!1;if(r){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var u=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw u.context=s,u}var c=i[e];if(void 0===c)return!1;if("function"==typeof c)o(c,this,t);else{var a=c.length,f=v(c,a);for(n=0;n<a;++n)o(f[n],this,t)}return!0},u.prototype.addListener=function(e,t){return f(this,e,t,!1)},u.prototype.on=u.prototype.addListener,u.prototype.prependListener=function(e,t){return f(this,e,t,!0)},u.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);return this.on(e,d(this,e,t)),this},u.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);return this.prependListener(e,d(this,e,t)),this},u.prototype.removeListener=function(e,t){var n,r,i,o,s;if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);if(void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,o=n.length-1;o>=0;o--)if(n[o]===t||n[o].listener===t){s=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,i),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,s||t)}return this},u.prototype.off=u.prototype.removeListener,u.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var i,o=Object.keys(n);for(r=0;r<o.length;++r)"removeListener"!==(i=o[r])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},u.prototype.listeners=function(e){return p(this,e,!0)},u.prototype.rawListeners=function(e){return p(this,e,!1)},u.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):h.call(e,t)},u.prototype.listenerCount=h,u.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}},29:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var o="blockchain_link/",s={worker_not_found:"Worker not found",worker_invalid:"Invalid worker object",worker_timeout:"Worker timeout",worker_unknown_request:"Unknown message type:",worker_runtime:void 0,invalid_param:"Invalid parameter:",websocket_not_initialized:"WebSocket not initialized",websocket_no_url:"Cannot connect because no server was specified",websocket_timeout:"Websocket timeout",websocket_error_message:void 0,websocket_runtime_error:void 0},u=function(e){function t(t,n){void 0===n&&(n="");var r=e.call(this,n)||this;if(r.message="",r.message=n,"string"==typeof t){var i=0===t.indexOf(o)?t.substring(o.length,t.length):t;r.code=""+o+i;var u=s[i];"string"==typeof u&&(""===r.message?r.message=u:0===n.indexOf("+")&&(r.message=u+" "+n.substr(1,n.length)))}return"string"==typeof r.message&&""!==r.message||(r.message="Message not set"),r}return i(t,e),t}(Error);t.CustomError=u},46:function(e,t,n){"use strict";var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});var i=r(n(85));t.MESSAGES=i;var o=r(n(86));t.RESPONSES=o,t.NETWORKS={RIPPLE:"ripple",BLOCKBOOK:"blockbook"}},463:function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},i=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function u(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,u)}c((r=r.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},u=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});var c,a=n(29),f=n(46),l=s(n(464)),d=u(n(466)),p=new(s(n(87)).default)(postMessage),h=[],v=function(){c&&(c.dispose(),c.removeAllListeners(),c=void 0),h=[],p.removeAccounts(p.getAccounts()),p.removeAddresses(p.getAddresses()),p.clearSubscriptions()},y=function(){return i(void 0,void 0,void 0,function(){var e,t,n,r,i,s;return o(this,function(o){switch(o.label){case 0:if(c&&c.isConnected())return[2,c];if(e=p.getSettings(),t=e.server,n=e.timeout,r=e.pingTimeout,i=e.keepAlive,!t||!Array.isArray(t)||t.length<1)throw new a.CustomError("connect","Endpoint not set");h.length<1&&(h=p.shuffleEndpoints(t.slice(0))),p.debug("Connecting to",h[0]),s=new l.default({url:h[0],timeout:n,pingTimeout:r,keepAlive:i}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,s.connect()];case 2:return o.sent(),c=s,[3,4];case 3:if(o.sent(),p.debug("Websocket connection failed"),c=void 0,h.splice(0,1),h.length<1)throw new a.CustomError("connect","All backends are down");return[2,y()];case 4:return s.on("disconnected",function(){p.response({id:-1,type:f.RESPONSES.DISCONNECTED,payload:!0}),v()}),p.response({id:-1,type:f.RESPONSES.CONNECTED}),p.debug("Connected"),[2,s]}})})},g=function(e){p.response({id:-1,type:f.RESPONSES.NOTIFICATION,payload:{type:"block",payload:{blockHeight:e.height,blockHash:e.hash}}})},m=function(e){if(e.tx){var t=e.address,n=p.getAccount(t);p.response({id:-1,type:f.RESPONSES.NOTIFICATION,payload:{type:"notification",payload:{descriptor:n?n.descriptor:t,tx:n?d.transformTransaction(n.descriptor,n.addresses,e.tx):d.transformTransaction(t,void 0,e.tx)}}})}};onmessage=function(e){if(e.data){var t=e.data,n=t.id,s=t.type;switch(p.debug("onmessage",t),t.type){case f.MESSAGES.HANDSHAKE:p.setSettings(t.settings);break;case f.MESSAGES.CONNECT:y().then(function(){return i(void 0,void 0,void 0,function(){return o(this,function(e){return p.response({id:n,type:f.RESPONSES.CONNECT,payload:!0}),[2]})})}).catch(function(e){return p.errorHandler({id:n,error:e})});break;case f.MESSAGES.GET_INFO:!function(e){i(void 0,void 0,void 0,function(){var t,n,i;return o(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,y()];case 1:return[4,(t=o.sent()).getServerInfo()];case 2:return n=o.sent(),p.response({id:e.id,type:f.RESPONSES.GET_INFO,payload:r({url:t.options.url},d.transformServerInfo(n))}),[3,4];case 3:return i=o.sent(),p.errorHandler({id:e.id,error:i}),[3,4];case 4:return[2]}})})}(t);break;case f.MESSAGES.GET_BLOCK_HASH:!function(e){i(void 0,void 0,void 0,function(){var t,n;return o(this,function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),[4,y()];case 1:return[4,r.sent().getBlockHash(e.payload)];case 2:return t=r.sent(),p.response({id:e.id,type:f.RESPONSES.GET_BLOCK_HASH,payload:t.hash}),[3,4];case 3:return n=r.sent(),p.errorHandler({id:e.id,error:n}),[3,4];case 4:return[2]}})})}(t);break;case f.MESSAGES.GET_ACCOUNT_INFO:!function(e){i(void 0,void 0,void 0,function(){var t,n,r;return o(this,function(i){switch(i.label){case 0:t=e.payload,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,y()];case 2:return[4,i.sent().getAccountInfo(t)];case 3:return n=i.sent(),p.response({id:e.id,type:f.RESPONSES.GET_ACCOUNT_INFO,payload:d.transformAccountInfo(n)}),[3,5];case 4:return r=i.sent(),p.errorHandler({id:e.id,error:r}),[3,5];case 5:return[2]}})})}(t);break;case f.MESSAGES.GET_ACCOUNT_UTXO:!function(e){i(void 0,void 0,void 0,function(){var t,n,r;return o(this,function(i){switch(i.label){case 0:t=e.payload,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,y()];case 2:return[4,i.sent().getAccountUtxo(t)];case 3:return n=i.sent(),p.response({id:e.id,type:f.RESPONSES.GET_ACCOUNT_UTXO,payload:d.transformAccountUtxo(n)}),[3,5];case 4:return r=i.sent(),p.errorHandler({id:e.id,error:r}),[3,5];case 5:return[2]}})})}(t);break;case f.MESSAGES.GET_TRANSACTION:!function(e){i(void 0,void 0,void 0,function(){var t,n,r;return o(this,function(i){switch(i.label){case 0:t=e.payload,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,y()];case 2:return[4,i.sent().getTransaction(t)];case 3:return n=i.sent(),p.response({id:e.id,type:f.RESPONSES.GET_TRANSACTION,payload:{type:"blockbook",tx:n}}),[3,5];case 4:return r=i.sent(),p.errorHandler({id:e.id,error:r}),[3,5];case 5:return[2]}})})}(t);break;case f.MESSAGES.ESTIMATE_FEE:!function(e){i(void 0,void 0,void 0,function(){var t,n;return o(this,function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),[4,y()];case 1:return[4,r.sent().estimateFee(e.payload)];case 2:return t=r.sent(),p.response({id:e.id,type:f.RESPONSES.ESTIMATE_FEE,payload:t}),[3,4];case 3:return n=r.sent(),p.errorHandler({id:e.id,error:n}),[3,4];case 4:return[2]}})})}(t);break;case f.MESSAGES.PUSH_TRANSACTION:!function(e){i(void 0,void 0,void 0,function(){var t,n;return o(this,function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),[4,y()];case 1:return[4,r.sent().pushTransaction(e.payload)];case 2:return t=r.sent(),p.response({id:e.id,type:f.RESPONSES.PUSH_TRANSACTION,payload:t.result}),[3,4];case 3:return n=r.sent(),p.errorHandler({id:e.id,error:n}),[3,4];case 4:return[2]}})})}(t);break;case f.MESSAGES.SUBSCRIBE:!function(e){i(void 0,void 0,void 0,function(){var t,n,r;return o(this,function(s){switch(s.label){case 0:t=e.payload,s.label=1;case 1:return s.trys.push([1,9,,10]),n=void 0,"accounts"!==t.type?[3,3]:[4,(c=t.accounts,i(void 0,void 0,void 0,function(){var e;return o(this,function(t){switch(t.label){case 0:return p.addAccounts(c),[4,y()];case 1:return e=t.sent(),p.getSubscription("notification")||(e.on("notification",m),p.addSubscription("notification")),[2,e.subscribeAddresses(p.getAddresses())]}})}))];case 2:return n=s.sent(),[3,8];case 3:return"addresses"!==t.type?[3,5]:[4,(u=t.addresses,i(void 0,void 0,void 0,function(){var e;return o(this,function(t){switch(t.label){case 0:return p.addAddresses(u),[4,y()];case 1:return e=t.sent(),p.getSubscription("notification")||(e.on("notification",m),p.addSubscription("notification")),[2,e.subscribeAddresses(p.getAddresses())]}})}))];case 4:return n=s.sent(),[3,8];case 5:return"block"!==t.type?[3,7]:[4,i(void 0,void 0,void 0,function(){var e;return o(this,function(t){switch(t.label){case 0:return p.getSubscription("block")?[2,{subscribed:!0}]:[4,y()];case 1:return e=t.sent(),p.addSubscription("block"),e.on("block",g),[2,e.subscribeBlock()]}})})];case 6:return n=s.sent(),[3,8];case 7:throw new a.CustomError("invalid_param","+type");case 8:return p.response({id:e.id,type:f.RESPONSES.SUBSCRIBE,payload:n}),[3,10];case 9:return r=s.sent(),p.errorHandler({id:e.id,error:r}),[3,10];case 10:return[2]}var u,c})})}(t);break;case f.MESSAGES.UNSUBSCRIBE:!function(e){i(void 0,void 0,void 0,function(){var t,n,r;return o(this,function(s){switch(s.label){case 0:t=e.payload,s.label=1;case 1:return s.trys.push([1,9,,10]),n=void 0,"accounts"!==t.type?[3,3]:[4,(c=t.accounts,i(void 0,void 0,void 0,function(){var e,t;return o(this,function(n){switch(n.label){case 0:return p.removeAccounts(c||p.getAccounts()),[4,y()];case 1:return e=n.sent(),(t=p.getAddresses()).length<1?(e.removeListener("notification",m),p.removeSubscription("notification"),[2,e.unsubscribeAddresses()]):[2,e.subscribeAddresses(t)]}})}))];case 2:return n=s.sent(),[3,8];case 3:return"addresses"!==t.type?[3,5]:[4,(u=t.addresses,i(void 0,void 0,void 0,function(){var e,t;return o(this,function(n){switch(n.label){case 0:return[4,y()];case 1:return e=n.sent(),u||p.removeAccounts(p.getAccounts()),(t=p.removeAddresses(u||p.getAddresses())).length<1?(e.removeListener("notification",m),p.removeSubscription("notification"),[2,e.unsubscribeAddresses()]):[2,e.subscribeAddresses(t)]}})}))];case 4:return n=s.sent(),[3,8];case 5:return"block"!==t.type?[3,7]:[4,i(void 0,void 0,void 0,function(){var e;return o(this,function(t){switch(t.label){case 0:return p.getSubscription("block")?[4,y()]:[2,{subscribed:!1}];case 1:return(e=t.sent()).removeListener("block",g),p.removeSubscription("block"),[2,e.unsubscribeBlock()]}})})];case 6:return n=s.sent(),[3,8];case 7:throw new a.CustomError("invalid_param","+type");case 8:return p.response({id:e.id,type:f.RESPONSES.UNSUBSCRIBE,payload:n}),[3,10];case 9:return r=s.sent(),p.errorHandler({id:e.id,error:r}),[3,10];case 10:return[2]}var u,c})})}(t);break;case f.MESSAGES.DISCONNECT:!function(e){i(void 0,void 0,void 0,function(){var t;return o(this,function(n){switch(n.label){case 0:if(!c)return p.response({id:e.id,type:f.RESPONSES.DISCONNECTED,payload:!0}),[2];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,c.disconnect()];case 2:return n.sent(),p.response({id:e.id,type:f.RESPONSES.DISCONNECTED,payload:!0}),[3,4];case 3:return t=n.sent(),p.errorHandler({id:e.id,error:t}),[3,4];case 4:return[2]}})})}(t);break;case"terminate":v();break;default:p.errorHandler({id:n,error:new a.CustomError("worker_unknown_request","+"+s)})}}},p.handshake()},464:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function u(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,u)}c((r=r.apply(e,t||[])).next())})},s=this&&this.__generator||function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var c=u(n(68)),a=n(19),f=n(29),l=n(465),d=new f.CustomError("websocket_not_initialized"),p=function(e){function t(t){var n=e.call(this)||this;return n.messageID=0,n.messages=[],n.subscriptions=[],n.send=function(e,t){var r=n.ws;if(!r)throw d;var i=n.messageID.toString(),o=l.create(i),s={id:i,method:e,params:t};return n.messageID++,n.messages.push(o),n.setConnectionTimeout(),n.setPingTimeout(),r.send(JSON.stringify(s)),o.promise},n.setMaxListeners(1/0),n.options=t,n}return i(t,e),t.prototype.setConnectionTimeout=function(){this.clearConnectionTimeout(),this.connectionTimeout=setTimeout(this.onTimeout.bind(this),this.options.timeout||2e4)},t.prototype.clearConnectionTimeout=function(){this.connectionTimeout&&(clearTimeout(this.connectionTimeout),this.connectionTimeout=void 0)},t.prototype.setPingTimeout=function(){this.pingTimeout&&clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(this.onPing.bind(this),this.options.pingTimeout||5e4)},t.prototype.onTimeout=function(){var e=this.ws;if(e)if(e.listenerCount("open")>0){e.emit("error","Websocket timeout");try{e.close()}catch(e){}}else this.messages.forEach(function(e){return e.reject(new f.CustomError("websocket_timeout"))}),e.close()},t.prototype.onPing=function(){return o(this,void 0,void 0,function(){return s(this,function(e){switch(e.label){case 0:return this.ws&&this.isConnected()?this.subscriptions.length>0||this.options.keepAlive?[4,this.getBlockHash(0)]:[3,2]:[3,3];case 1:return e.sent(),[3,3];case 2:try{this.ws.close()}catch(e){}e.label=3;case 3:return[2]}})})},t.prototype.onError=function(){this.dispose()},t.prototype.onmessage=function(e){try{var t=JSON.parse(e),n=t.id,r=t.data,i=this.messages.find(function(e){return e.id===n});if(i)r.error?i.reject(new f.CustomError("websocket_error_message",r.error.message)):i.resolve(r),this.messages.splice(this.messages.indexOf(i),1);else{var o=this.subscriptions.find(function(e){return e&&e.id===n});o&&o.callback(r)}}catch(e){}0===this.messages.length&&this.clearConnectionTimeout(),this.setPingTimeout()},t.prototype.connect=function(){var e=this,t=this.options.url;if("string"!=typeof t)throw new f.CustomError("websocket_no_url");if(t.startsWith("https")&&(t=t.replace("https","wss")),t.startsWith("http")&&(t=t.replace("http","ws")),!t.endsWith("/websocket")){var n=t.endsWith("/")?"websocket":"/websocket";t+=n}this.setConnectionTimeout();var r=l.create(-1),i=new c.default(t);return"function"==typeof i.setMaxListeners&&i.setMaxListeners(1/0),i.once("error",function(t){e.dispose(),r.reject(new f.CustomError("websocket_runtime_error",t.message))}),i.on("open",function(){e.init(),r.resolve()}),this.ws=i,r.promise},t.prototype.init=function(){var e=this,t=this.ws;if(!t||!this.isConnected())throw Error("Blockbook websocket init cannot be called");this.clearConnectionTimeout(),t.removeAllListeners(),t.on("error",this.onError.bind(this)),t.on("message",this.onmessage.bind(this)),t.on("close",function(){e.emit("disconnected"),e.dispose()})},t.prototype.disconnect=function(){this.ws&&this.ws.close()},t.prototype.isConnected=function(){var e=this.ws;return e&&e.readyState===c.default.OPEN},t.prototype.getServerInfo=function(){return this.send("getInfo",{})},t.prototype.getBlockHash=function(e){return this.send("getBlockHash",{height:e})},t.prototype.getAccountInfo=function(e){return this.send("getAccountInfo",e)},t.prototype.getAccountUtxo=function(e){return this.send("getAccountUtxo",{descriptor:e})},t.prototype.getTransaction=function(e){return this.send("getTransaction",{txid:e})},t.prototype.pushTransaction=function(e){return this.send("sendTransaction",{hex:e})},t.prototype.estimateFee=function(e){return this.send("estimateFee",e)},t.prototype.subscribeAddresses=function(e){var t=this,n=this.subscriptions.findIndex(function(e){return"notification"===e.type});n>=0&&this.subscriptions.splice(n,1);var r=this.messageID.toString();return this.subscriptions.push({id:r,type:"notification",callback:function(e){t.emit("notification",e)}}),this.send("subscribeAddresses",{addresses:e})},t.prototype.unsubscribeAddresses=function(){var e=this.subscriptions.findIndex(function(e){return"notification"===e.type});return e>=0?(this.subscriptions.splice(e,1),this.send("unsubscribeAddresses",{})):{subscribed:!1}},t.prototype.subscribeBlock=function(){var e=this,t=this.subscriptions.findIndex(function(e){return"block"===e.type});t>=0&&this.subscriptions.splice(t,1);var n=this.messageID.toString();return this.subscriptions.push({id:n,type:"block",callback:function(t){e.emit("block",t)}}),this.send("subscribeNewBlock",{})},t.prototype.unsubscribeBlock=function(){var e=this.subscriptions.findIndex(function(e){return"block"===e.type});return e>=0?(this.subscriptions.splice(e,1),this.send("unsubscribeNewBlock",{})):{subscribed:!1}},t.prototype.dispose=function(){this.pingTimeout&&clearTimeout(this.pingTimeout),this.connectionTimeout&&clearTimeout(this.connectionTimeout);var e=this.ws;this.isConnected()&&this.disconnect(),e&&e.removeAllListeners(),this.removeAllListeners()},t}(a.EventEmitter);t.default=p},465:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.create=function(e){var t=function(){},n=function(){},r=new Promise(function(e,r){t=e,n=r});return{id:e,resolve:t,reject:n,promise:r}}},466:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var i=r(n(7));t.transformServerInfo=function(e){return{name:e.name,shortcut:e.shortcut,testnet:e.testnet,version:e.version,decimals:e.decimals,blockHeight:e.bestHeight,blockHash:e.bestHash}},t.filterTargets=function(e,t){if("string"==typeof e&&(e=[e]),!(e&&Array.isArray(e)&&t&&Array.isArray(t)))return[];var n=e.map(function(e){return"string"==typeof e?e:"object"==typeof e&&"string"==typeof e.address?e.address:null});return t.filter(function(e){return!(!e||!Array.isArray(e.addresses))&&e.addresses.filter(function(e){return n.indexOf(e)>=0}).length>0})},t.filterTokenTransfers=function(e,t){if("string"==typeof e&&(e=[e]),!(e&&Array.isArray(e)&&t&&Array.isArray(t)))return[];var n=e.map(function(e){return"string"==typeof e?e:"object"==typeof e&&"string"==typeof e.address?e.address:null});return t.filter(function(e){return!(!e||"object"!=typeof e)&&(e.from&&n.indexOf(e.from)>=0||e.to&&n.indexOf(e.to)>=0)}).map(function(e){var t=e.from&&n.indexOf(e.from)>=0,r=e.to&&n.indexOf(e.to)>=0,i="unknown";return t&&r?i="self":(t&&(i="sent"),r&&(i="recv")),{type:i,name:e.name,symbol:e.symbol,address:e.token,decimals:e.decimals||0,amount:e.value,from:e.from,to:e.to}})};t.transformTransaction=function(e,n,r){var o,s,u=n?n.change.concat(n.used,n.unused):[e],c=Array.isArray(r.vin)?r.vin.length:0,a=Array.isArray(r.vout)?r.vout.length:0,f=t.filterTargets(u,r.vin),l=t.filterTargets(u,r.vout),d=n?t.filterTargets(n.change,r.vout):[],p=t.filterTokenTransfers(u,r.tokenTransfers),h=[],v=r.value;if(0===f.length&&0===l.length&&0===p.length)o="unknown";else if(c>0&&a>0&&f.length===c&&l.length===a)o="self",v=r.fees;else if(0===f.length&&(l.length>0||p.length>0))o="recv",v="0",l.length>0&&(Array.isArray(r.vin)&&(h=r.vin),v=l.reduce(function(e,t){return"string"!=typeof t.value?e:new i.default(e).plus(t.value).toString()},v));else if(o="sent",0===p.length&&Array.isArray(r.vout)&&(h=r.vout.filter(function(e){return l.indexOf(e)<0&&d.indexOf(e)<0})),r.ethereumSpecific)v=p.length>0||0===r.ethereumSpecific.status?r.fees:r.value;else if(Array.isArray(r.vout)){var y=f.reduce(function(e,t){return"string"!=typeof t.value?e:new i.default(e).plus(t.value).toString()},"0");v=l.reduce(function(e,t){return"string"!=typeof t.value?e:new i.default(e).minus(t.value).toString()},y)}return Array.isArray(r.vin)&&r.vin.forEach(function(e){"number"==typeof e.sequence&&e.sequence<4294967294&&(s=!0)}),{type:o,txid:r.txid,blockTime:r.blockTime,blockHeight:r.blockHeight,blockHash:r.blockHash,amount:v,fee:r.fees,targets:h.filter(function(e){return"object"==typeof e}).map(function(e){return{addresses:(t=e).addresses,isAddress:t.isAddress,amount:t.value,coinbase:t.coinbase};var t}),tokens:p,rbf:s,ethereumSpecific:r.ethereumSpecific}},t.transformTokenInfo=function(e){if(e&&Array.isArray(e)){var t=e.reduce(function(e,t){return"ERC20"!==t.type?e:e.concat([{type:t.type,name:t.name,symbol:t.symbol,address:t.contract,balance:t.balance,decimals:t.decimals||0}])},[]);return t.length>0?t:void 0}},t.transformAddresses=function(e){if(e&&Array.isArray(e)){var t=e.reduce(function(e,t){return"XPUBAddress"!==t.type?e:e.concat([{address:t.name,path:t.path,transfers:t.transfers,balance:t.balance,sent:t.totalSent,received:t.totalReceived}])},[]);if(!(t.length<1)){var n=t.filter(function(e){return"1"===e.path.split("/")[4]}),r=t.filter(function(e){return n.indexOf(e)<0});return{change:n,used:r.filter(function(e){return e.transfers>0}),unused:r.filter(function(e){return 0===e.transfers})}}}},t.transformAccountInfo=function(e){var n,r;"number"==typeof e.page&&(n={index:e.page,size:e.itemsOnPage,total:e.totalPages}),"string"==typeof e.nonce&&(r={nonce:e.nonce});var o=e.address,s=t.transformAddresses(e.tokens),u=t.transformTokenInfo(e.tokens),c=0===e.txs&&0===e.unconfirmedTxs,a=new i.default(e.unconfirmedBalance),f=a.isNaN()||a.isZero()?e.balance:a.plus(e.balance).toString();return{descriptor:o,balance:e.balance,availableBalance:f,empty:c,tokens:u,addresses:s,history:{total:e.txs,tokens:"number"==typeof e.nonTokenTxs?e.txs-e.nonTokenTxs:void 0,unconfirmed:e.unconfirmedTxs,transactions:e.transactions?e.transactions.map(function(e){return t.transformTransaction(o,s,e)}):void 0},misc:r,page:n}},t.transformAccountUtxo=function(e){return e.map(function(e){return{txid:e.txid,vout:e.vout,amount:e.value,blockHeight:e.height,address:e.address,path:e.path,confirmations:e.confirmations,coinbase:e.coinbase}})}},68:function(e,t,n){var r=n(69),i=n(70),o=n(71),s=n(72),u=function(e){"use strict";function t(t){var n;return n=e.call(this)||this,s(i(n),"ws",void 0),n.setMaxListeners(1/0),n.ws=new WebSocket(t),n.ws.onclose=function(){n.emit("close")},n.ws.onopen=function(){n.emit("open")},n.ws.onerror=function(e){n.emit("error",e)},n.ws.onmessage=function(e){n.emit("message",e.data)},n}o(t,e);var n=t.prototype;return n.close=function(){1===this.readyState&&this.ws.close()},n.send=function(e){this.ws.send(e)},r(t,[{key:"readyState",get:function(){return this.ws.readyState}}]),t}(n(19).EventEmitter);u.CONNECTING=0,u.OPEN=1,u.CLOSING=2,u.CLOSED=3,e.exports=u},69:function(e,t){function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}e.exports=function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}},7:function(e,t,n){var r;!function(i){"use strict";var o,s=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,u=Math.ceil,c=Math.floor,a="[BigNumber Error] ",f=a+"Number primitive has more than 15 significant digits: ",l=1e14,d=14,p=9007199254740991,h=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],v=1e7,y=1e9;function g(e){var t=0|e;return e>0||e===t?t:t-1}function m(e){for(var t,n,r=1,i=e.length,o=e[0]+"";r<i;){for(t=e[r++]+"",n=d-t.length;n--;t="0"+t);o+=t}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function b(e,t){var n,r,i=e.c,o=t.c,s=e.s,u=t.s,c=e.e,a=t.e;if(!s||!u)return null;if(n=i&&!i[0],r=o&&!o[0],n||r)return n?r?0:-u:s;if(s!=u)return s;if(n=s<0,r=c==a,!i||!o)return r?0:!i^n?1:-1;if(!r)return c>a^n?1:-1;for(u=(c=i.length)<(a=o.length)?c:a,s=0;s<u;s++)if(i[s]!=o[s])return i[s]>o[s]^n?1:-1;return c==a?0:c>a^n?1:-1}function w(e,t,n,r){if(e<t||e>n||e!==c(e))throw Error(a+(r||"Argument")+("number"==typeof e?e<t||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function _(e){var t=e.c.length-1;return g(e.e/d)==t&&e.c[t]%2!=0}function E(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function S(e,t,n){var r,i;if(t<0){for(i=n+".";++t;i+=n);e=i+e}else if(++t>(r=e.length)){for(i=n,t-=r;--t;i+=n);e+=i}else t<r&&(e=e.slice(0,t)+"."+e.slice(t));return e}(o=function e(t){var n,r,i,o,O,A,T,N,k,C=F.prototype={constructor:F,toString:null,valueOf:null},x=new F(1),P=20,I=4,R=-7,L=21,M=-1e7,j=1e7,B=!1,U=1,G=0,H={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},D="0123456789abcdefghijklmnopqrstuvwxyz";function F(e,t){var n,o,u,a,l,h,v,y,g=this;if(!(g instanceof F))return new F(e,t);if(null==t){if(e&&!0===e._isBigNumber)return g.s=e.s,void(!e.c||e.e>j?g.c=g.e=null:e.e<M?g.c=[g.e=0]:(g.e=e.e,g.c=e.c.slice()));if((h="number"==typeof e)&&0*e==0){if(g.s=1/e<0?(e=-e,-1):1,e===~~e){for(a=0,l=e;l>=10;l/=10,a++);return void(a>j?g.c=g.e=null:(g.e=a,g.c=[e]))}y=String(e)}else{if(!s.test(y=String(e)))return i(g,y,h);g.s=45==y.charCodeAt(0)?(y=y.slice(1),-1):1}(a=y.indexOf("."))>-1&&(y=y.replace(".","")),(l=y.search(/e/i))>0?(a<0&&(a=l),a+=+y.slice(l+1),y=y.substring(0,l)):a<0&&(a=y.length)}else{if(w(t,2,D.length,"Base"),10==t)return K(g=new F(e),P+g.e+1,I);if(y=String(e),h="number"==typeof e){if(0*e!=0)return i(g,y,h,t);if(g.s=1/e<0?(y=y.slice(1),-1):1,F.DEBUG&&y.replace(/^0\.0*|\./,"").length>15)throw Error(f+e)}else g.s=45===y.charCodeAt(0)?(y=y.slice(1),-1):1;for(n=D.slice(0,t),a=l=0,v=y.length;l<v;l++)if(n.indexOf(o=y.charAt(l))<0){if("."==o){if(l>a){a=v;continue}}else if(!u&&(y==y.toUpperCase()&&(y=y.toLowerCase())||y==y.toLowerCase()&&(y=y.toUpperCase()))){u=!0,l=-1,a=0;continue}return i(g,String(e),h,t)}h=!1,(a=(y=r(y,t,10,g.s)).indexOf("."))>-1?y=y.replace(".",""):a=y.length}for(l=0;48===y.charCodeAt(l);l++);for(v=y.length;48===y.charCodeAt(--v););if(y=y.slice(l,++v)){if(v-=l,h&&F.DEBUG&&v>15&&(e>p||e!==c(e)))throw Error(f+g.s*e);if((a=a-l-1)>j)g.c=g.e=null;else if(a<M)g.c=[g.e=0];else{if(g.e=a,g.c=[],l=(a+1)%d,a<0&&(l+=d),l<v){for(l&&g.c.push(+y.slice(0,l)),v-=d;l<v;)g.c.push(+y.slice(l,l+=d));l=d-(y=y.slice(l)).length}else l-=v;for(;l--;y+="0");g.c.push(+y)}}else g.c=[g.e=0]}function W(e,t,n,r){var i,o,s,u,c;if(null==n?n=I:w(n,0,8),!e.c)return e.toString();if(i=e.c[0],s=e.e,null==t)c=m(e.c),c=1==r||2==r&&(s<=R||s>=L)?E(c,s):S(c,s,"0");else if(o=(e=K(new F(e),t,n)).e,u=(c=m(e.c)).length,1==r||2==r&&(t<=o||o<=R)){for(;u<t;c+="0",u++);c=E(c,o)}else if(t-=s,c=S(c,o,"0"),o+1>u){if(--t>0)for(c+=".";t--;c+="0");}else if((t+=o-u)>0)for(o+1==u&&(c+=".");t--;c+="0");return e.s<0&&i?"-"+c:c}function q(e,t){for(var n,r=1,i=new F(e[0]);r<e.length;r++){if(!(n=new F(e[r])).s){i=n;break}t.call(i,n)&&(i=n)}return i}function z(e,t,n){for(var r=1,i=t.length;!t[--i];t.pop());for(i=t[0];i>=10;i/=10,r++);return(n=r+n*d-1)>j?e.c=e.e=null:n<M?e.c=[e.e=0]:(e.e=n,e.c=t),e}function K(e,t,n,r){var i,o,s,a,f,p,v,y=e.c,g=h;if(y){e:{for(i=1,a=y[0];a>=10;a/=10,i++);if((o=t-i)<0)o+=d,s=t,v=(f=y[p=0])/g[i-s-1]%10|0;else if((p=u((o+1)/d))>=y.length){if(!r)break e;for(;y.length<=p;y.push(0));f=v=0,i=1,s=(o%=d)-d+1}else{for(f=a=y[p],i=1;a>=10;a/=10,i++);v=(s=(o%=d)-d+i)<0?0:f/g[i-s-1]%10|0}if(r=r||t<0||null!=y[p+1]||(s<0?f:f%g[i-s-1]),r=n<4?(v||r)&&(0==n||n==(e.s<0?3:2)):v>5||5==v&&(4==n||r||6==n&&(o>0?s>0?f/g[i-s]:0:y[p-1])%10&1||n==(e.s<0?8:7)),t<1||!y[0])return y.length=0,r?(t-=e.e+1,y[0]=g[(d-t%d)%d],e.e=-t||0):y[0]=e.e=0,e;if(0==o?(y.length=p,a=1,p--):(y.length=p+1,a=g[d-o],y[p]=s>0?c(f/g[i-s]%g[s])*a:0),r)for(;;){if(0==p){for(o=1,s=y[0];s>=10;s/=10,o++);for(s=y[0]+=a,a=1;s>=10;s/=10,a++);o!=a&&(e.e++,y[0]==l&&(y[0]=1));break}if(y[p]+=a,y[p]!=l)break;y[p--]=0,a=1}for(o=y.length;0===y[--o];y.pop());}e.e>j?e.c=e.e=null:e.e<M&&(e.c=[e.e=0])}return e}function $(e){var t,n=e.e;return null===n?e.toString():(t=m(e.c),t=n<=R||n>=L?E(t,n):S(t,n,"0"),e.s<0?"-"+t:t)}return F.clone=e,F.ROUND_UP=0,F.ROUND_DOWN=1,F.ROUND_CEIL=2,F.ROUND_FLOOR=3,F.ROUND_HALF_UP=4,F.ROUND_HALF_DOWN=5,F.ROUND_HALF_EVEN=6,F.ROUND_HALF_CEIL=7,F.ROUND_HALF_FLOOR=8,F.EUCLID=9,F.config=F.set=function(e){var t,n;if(null!=e){if("object"!=typeof e)throw Error(a+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(w(n=e[t],0,y,t),P=n),e.hasOwnProperty(t="ROUNDING_MODE")&&(w(n=e[t],0,8,t),I=n),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((n=e[t])&&n.pop?(w(n[0],-y,0,t),w(n[1],0,y,t),R=n[0],L=n[1]):(w(n,-y,y,t),R=-(L=n<0?-n:n))),e.hasOwnProperty(t="RANGE"))if((n=e[t])&&n.pop)w(n[0],-y,-1,t),w(n[1],1,y,t),M=n[0],j=n[1];else{if(w(n,-y,y,t),!n)throw Error(a+t+" cannot be zero: "+n);M=-(j=n<0?-n:n)}if(e.hasOwnProperty(t="CRYPTO")){if((n=e[t])!==!!n)throw Error(a+t+" not true or false: "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw B=!n,Error(a+"crypto unavailable");B=n}else B=n}if(e.hasOwnProperty(t="MODULO_MODE")&&(w(n=e[t],0,9,t),U=n),e.hasOwnProperty(t="POW_PRECISION")&&(w(n=e[t],0,y,t),G=n),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(n=e[t]))throw Error(a+t+" not an object: "+n);H=n}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(n=e[t])||/^.$|[+-.\s]|(.).*\1/.test(n))throw Error(a+t+" invalid: "+n);D=n}}return{DECIMAL_PLACES:P,ROUNDING_MODE:I,EXPONENTIAL_AT:[R,L],RANGE:[M,j],CRYPTO:B,MODULO_MODE:U,POW_PRECISION:G,FORMAT:H,ALPHABET:D}},F.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!F.DEBUG)return!0;var t,n,r=e.c,i=e.e,o=e.s;e:if("[object Array]"=={}.toString.call(r)){if((1===o||-1===o)&&i>=-y&&i<=y&&i===c(i)){if(0===r[0]){if(0===i&&1===r.length)return!0;break e}if((t=(i+1)%d)<1&&(t+=d),String(r[0]).length==t){for(t=0;t<r.length;t++)if((n=r[t])<0||n>=l||n!==c(n))break e;if(0!==n)return!0}}}else if(null===r&&null===i&&(null===o||1===o||-1===o))return!0;throw Error(a+"Invalid BigNumber: "+e)},F.maximum=F.max=function(){return q(arguments,C.lt)},F.minimum=F.min=function(){return q(arguments,C.gt)},F.random=(o=9007199254740992*Math.random()&2097151?function(){return c(9007199254740992*Math.random())}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,n,r,i,s,f=0,l=[],p=new F(x);if(null==e?e=P:w(e,0,y),i=u(e/d),B)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(i*=2));f<i;)(s=131072*t[f]+(t[f+1]>>>11))>=9e15?(n=crypto.getRandomValues(new Uint32Array(2)),t[f]=n[0],t[f+1]=n[1]):(l.push(s%1e14),f+=2);f=i/2}else{if(!crypto.randomBytes)throw B=!1,Error(a+"crypto unavailable");for(t=crypto.randomBytes(i*=7);f<i;)(s=281474976710656*(31&t[f])+1099511627776*t[f+1]+4294967296*t[f+2]+16777216*t[f+3]+(t[f+4]<<16)+(t[f+5]<<8)+t[f+6])>=9e15?crypto.randomBytes(7).copy(t,f):(l.push(s%1e14),f+=7);f=i/7}if(!B)for(;f<i;)(s=o())<9e15&&(l[f++]=s%1e14);for(i=l[--f],e%=d,i&&e&&(s=h[d-e],l[f]=c(i/s)*s);0===l[f];l.pop(),f--);if(f<0)l=[r=0];else{for(r=-1;0===l[0];l.splice(0,1),r-=d);for(f=1,s=l[0];s>=10;s/=10,f++);f<d&&(r-=d-f)}return p.e=r,p.c=l,p}),F.sum=function(){for(var e=1,t=arguments,n=new F(t[0]);e<t.length;)n=n.plus(t[e++]);return n},r=function(){function e(e,t,n,r){for(var i,o,s=[0],u=0,c=e.length;u<c;){for(o=s.length;o--;s[o]*=t);for(s[0]+=r.indexOf(e.charAt(u++)),i=0;i<s.length;i++)s[i]>n-1&&(null==s[i+1]&&(s[i+1]=0),s[i+1]+=s[i]/n|0,s[i]%=n)}return s.reverse()}return function(t,r,i,o,s){var u,c,a,f,l,d,p,h,v=t.indexOf("."),y=P,g=I;for(v>=0&&(f=G,G=0,t=t.replace(".",""),d=(h=new F(r)).pow(t.length-v),G=f,h.c=e(S(m(d.c),d.e,"0"),10,i,"0123456789"),h.e=h.c.length),a=f=(p=e(t,r,i,s?(u=D,"0123456789"):(u="0123456789",D))).length;0==p[--f];p.pop());if(!p[0])return u.charAt(0);if(v<0?--a:(d.c=p,d.e=a,d.s=o,p=(d=n(d,h,y,g,i)).c,l=d.r,a=d.e),v=p[c=a+y+1],f=i/2,l=l||c<0||null!=p[c+1],l=g<4?(null!=v||l)&&(0==g||g==(d.s<0?3:2)):v>f||v==f&&(4==g||l||6==g&&1&p[c-1]||g==(d.s<0?8:7)),c<1||!p[0])t=l?S(u.charAt(1),-y,u.charAt(0)):u.charAt(0);else{if(p.length=c,l)for(--i;++p[--c]>i;)p[c]=0,c||(++a,p=[1].concat(p));for(f=p.length;!p[--f];);for(v=0,t="";v<=f;t+=u.charAt(p[v++]));t=S(t,a,u.charAt(0))}return t}}(),n=function(){function e(e,t,n){var r,i,o,s,u=0,c=e.length,a=t%v,f=t/v|0;for(e=e.slice();c--;)u=((i=a*(o=e[c]%v)+(r=f*o+(s=e[c]/v|0)*a)%v*v+u)/n|0)+(r/v|0)+f*s,e[c]=i%n;return u&&(e=[u].concat(e)),e}function t(e,t,n,r){var i,o;if(n!=r)o=n>r?1:-1;else for(i=o=0;i<n;i++)if(e[i]!=t[i]){o=e[i]>t[i]?1:-1;break}return o}function n(e,t,n,r){for(var i=0;n--;)e[n]-=i,i=e[n]<t[n]?1:0,e[n]=i*r+e[n]-t[n];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(r,i,o,s,u){var a,f,p,h,v,y,m,b,w,_,E,S,O,A,T,N,k,C=r.s==i.s?1:-1,x=r.c,P=i.c;if(!(x&&x[0]&&P&&P[0]))return new F(r.s&&i.s&&(x?!P||x[0]!=P[0]:P)?x&&0==x[0]||!P?0*C:C/0:NaN);for(w=(b=new F(C)).c=[],C=o+(f=r.e-i.e)+1,u||(u=l,f=g(r.e/d)-g(i.e/d),C=C/d|0),p=0;P[p]==(x[p]||0);p++);if(P[p]>(x[p]||0)&&f--,C<0)w.push(1),h=!0;else{for(A=x.length,N=P.length,p=0,C+=2,(v=c(u/(P[0]+1)))>1&&(P=e(P,v,u),x=e(x,v,u),N=P.length,A=x.length),O=N,E=(_=x.slice(0,N)).length;E<N;_[E++]=0);k=P.slice(),k=[0].concat(k),T=P[0],P[1]>=u/2&&T++;do{if(v=0,(a=t(P,_,N,E))<0){if(S=_[0],N!=E&&(S=S*u+(_[1]||0)),(v=c(S/T))>1)for(v>=u&&(v=u-1),m=(y=e(P,v,u)).length,E=_.length;1==t(y,_,m,E);)v--,n(y,N<m?k:P,m,u),m=y.length,a=1;else 0==v&&(a=v=1),m=(y=P.slice()).length;if(m<E&&(y=[0].concat(y)),n(_,y,E,u),E=_.length,-1==a)for(;t(P,_,N,E)<1;)v++,n(_,N<E?k:P,E,u),E=_.length}else 0===a&&(v++,_=[0]);w[p++]=v,_[0]?_[E++]=x[O]||0:(_=[x[O]],E=1)}while((O++<A||null!=_[0])&&C--);h=null!=_[0],w[0]||w.splice(0,1)}if(u==l){for(p=1,C=w[0];C>=10;C/=10,p++);K(b,o+(b.e=p+f*d-1)+1,s,h)}else b.e=f,b.r=+h;return b}}(),O=/^(-?)0([xbo])(?=\w[\w.]*$)/i,A=/^([^.]+)\.$/,T=/^\.([^.]+)$/,N=/^-?(Infinity|NaN)$/,k=/^\s*\+(?=[\w.])|^\s+|\s+$/g,i=function(e,t,n,r){var i,o=n?t:t.replace(k,"");if(N.test(o))e.s=isNaN(o)?null:o<0?-1:1;else{if(!n&&(o=o.replace(O,function(e,t,n){return i="x"==(n=n.toLowerCase())?16:"b"==n?2:8,r&&r!=i?e:t}),r&&(i=r,o=o.replace(A,"$1").replace(T,"0.$1")),t!=o))return new F(o,i);if(F.DEBUG)throw Error(a+"Not a"+(r?" base "+r:"")+" number: "+t);e.s=null}e.c=e.e=null},C.absoluteValue=C.abs=function(){var e=new F(this);return e.s<0&&(e.s=1),e},C.comparedTo=function(e,t){return b(this,new F(e,t))},C.decimalPlaces=C.dp=function(e,t){var n,r,i,o=this;if(null!=e)return w(e,0,y),null==t?t=I:w(t,0,8),K(new F(o),e+o.e+1,t);if(!(n=o.c))return null;if(r=((i=n.length-1)-g(this.e/d))*d,i=n[i])for(;i%10==0;i/=10,r--);return r<0&&(r=0),r},C.dividedBy=C.div=function(e,t){return n(this,new F(e,t),P,I)},C.dividedToIntegerBy=C.idiv=function(e,t){return n(this,new F(e,t),0,1)},C.exponentiatedBy=C.pow=function(e,t){var n,r,i,o,s,f,l,p,h=this;if((e=new F(e)).c&&!e.isInteger())throw Error(a+"Exponent not an integer: "+$(e));if(null!=t&&(t=new F(t)),s=e.e>14,!h.c||!h.c[0]||1==h.c[0]&&!h.e&&1==h.c.length||!e.c||!e.c[0])return p=new F(Math.pow(+$(h),s?2-_(e):+$(e))),t?p.mod(t):p;if(f=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new F(NaN);(r=!f&&h.isInteger()&&t.isInteger())&&(h=h.mod(t))}else{if(e.e>9&&(h.e>0||h.e<-1||(0==h.e?h.c[0]>1||s&&h.c[1]>=24e7:h.c[0]<8e13||s&&h.c[0]<=9999975e7)))return o=h.s<0&&_(e)?-0:0,h.e>-1&&(o=1/o),new F(f?1/o:o);G&&(o=u(G/d+2))}for(s?(n=new F(.5),f&&(e.s=1),l=_(e)):l=(i=Math.abs(+$(e)))%2,p=new F(x);;){if(l){if(!(p=p.times(h)).c)break;o?p.c.length>o&&(p.c.length=o):r&&(p=p.mod(t))}if(i){if(0===(i=c(i/2)))break;l=i%2}else if(K(e=e.times(n),e.e+1,1),e.e>14)l=_(e);else{if(0===(i=+$(e)))break;l=i%2}h=h.times(h),o?h.c&&h.c.length>o&&(h.c.length=o):r&&(h=h.mod(t))}return r?p:(f&&(p=x.div(p)),t?p.mod(t):o?K(p,G,I,void 0):p)},C.integerValue=function(e){var t=new F(this);return null==e?e=I:w(e,0,8),K(t,t.e+1,e)},C.isEqualTo=C.eq=function(e,t){return 0===b(this,new F(e,t))},C.isFinite=function(){return!!this.c},C.isGreaterThan=C.gt=function(e,t){return b(this,new F(e,t))>0},C.isGreaterThanOrEqualTo=C.gte=function(e,t){return 1===(t=b(this,new F(e,t)))||0===t},C.isInteger=function(){return!!this.c&&g(this.e/d)>this.c.length-2},C.isLessThan=C.lt=function(e,t){return b(this,new F(e,t))<0},C.isLessThanOrEqualTo=C.lte=function(e,t){return-1===(t=b(this,new F(e,t)))||0===t},C.isNaN=function(){return!this.s},C.isNegative=function(){return this.s<0},C.isPositive=function(){return this.s>0},C.isZero=function(){return!!this.c&&0==this.c[0]},C.minus=function(e,t){var n,r,i,o,s=this,u=s.s;if(t=(e=new F(e,t)).s,!u||!t)return new F(NaN);if(u!=t)return e.s=-t,s.plus(e);var c=s.e/d,a=e.e/d,f=s.c,p=e.c;if(!c||!a){if(!f||!p)return f?(e.s=-t,e):new F(p?s:NaN);if(!f[0]||!p[0])return p[0]?(e.s=-t,e):new F(f[0]?s:3==I?-0:0)}if(c=g(c),a=g(a),f=f.slice(),u=c-a){for((o=u<0)?(u=-u,i=f):(a=c,i=p),i.reverse(),t=u;t--;i.push(0));i.reverse()}else for(r=(o=(u=f.length)<(t=p.length))?u:t,u=t=0;t<r;t++)if(f[t]!=p[t]){o=f[t]<p[t];break}if(o&&(i=f,f=p,p=i,e.s=-e.s),(t=(r=p.length)-(n=f.length))>0)for(;t--;f[n++]=0);for(t=l-1;r>u;){if(f[--r]<p[r]){for(n=r;n&&!f[--n];f[n]=t);--f[n],f[r]+=l}f[r]-=p[r]}for(;0==f[0];f.splice(0,1),--a);return f[0]?z(e,f,a):(e.s=3==I?-1:1,e.c=[e.e=0],e)},C.modulo=C.mod=function(e,t){var r,i,o=this;return e=new F(e,t),!o.c||!e.s||e.c&&!e.c[0]?new F(NaN):!e.c||o.c&&!o.c[0]?new F(o):(9==U?(i=e.s,e.s=1,r=n(o,e,0,3),e.s=i,r.s*=i):r=n(o,e,0,U),(e=o.minus(r.times(e))).c[0]||1!=U||(e.s=o.s),e)},C.multipliedBy=C.times=function(e,t){var n,r,i,o,s,u,c,a,f,p,h,y,m,b,w,_=this,E=_.c,S=(e=new F(e,t)).c;if(!(E&&S&&E[0]&&S[0]))return!_.s||!e.s||E&&!E[0]&&!S||S&&!S[0]&&!E?e.c=e.e=e.s=null:(e.s*=_.s,E&&S?(e.c=[0],e.e=0):e.c=e.e=null),e;for(r=g(_.e/d)+g(e.e/d),e.s*=_.s,(c=E.length)<(p=S.length)&&(m=E,E=S,S=m,i=c,c=p,p=i),i=c+p,m=[];i--;m.push(0));for(b=l,w=v,i=p;--i>=0;){for(n=0,h=S[i]%w,y=S[i]/w|0,o=i+(s=c);o>i;)n=((a=h*(a=E[--s]%w)+(u=y*a+(f=E[s]/w|0)*h)%w*w+m[o]+n)/b|0)+(u/w|0)+y*f,m[o--]=a%b;m[o]=n}return n?++r:m.splice(0,1),z(e,m,r)},C.negated=function(){var e=new F(this);return e.s=-e.s||null,e},C.plus=function(e,t){var n,r=this,i=r.s;if(t=(e=new F(e,t)).s,!i||!t)return new F(NaN);if(i!=t)return e.s=-t,r.minus(e);var o=r.e/d,s=e.e/d,u=r.c,c=e.c;if(!o||!s){if(!u||!c)return new F(i/0);if(!u[0]||!c[0])return c[0]?e:new F(u[0]?r:0*i)}if(o=g(o),s=g(s),u=u.slice(),i=o-s){for(i>0?(s=o,n=c):(i=-i,n=u),n.reverse();i--;n.push(0));n.reverse()}for((i=u.length)-(t=c.length)<0&&(n=c,c=u,u=n,t=i),i=0;t;)i=(u[--t]=u[t]+c[t]+i)/l|0,u[t]=l===u[t]?0:u[t]%l;return i&&(u=[i].concat(u),++s),z(e,u,s)},C.precision=C.sd=function(e,t){var n,r,i,o=this;if(null!=e&&e!==!!e)return w(e,1,y),null==t?t=I:w(t,0,8),K(new F(o),e,t);if(!(n=o.c))return null;if(r=(i=n.length-1)*d+1,i=n[i]){for(;i%10==0;i/=10,r--);for(i=n[0];i>=10;i/=10,r++);}return e&&o.e+1>r&&(r=o.e+1),r},C.shiftedBy=function(e){return w(e,-p,p),this.times("1e"+e)},C.squareRoot=C.sqrt=function(){var e,t,r,i,o,s=this,u=s.c,c=s.s,a=s.e,f=P+4,l=new F("0.5");if(1!==c||!u||!u[0])return new F(!c||c<0&&(!u||u[0])?NaN:u?s:1/0);if(0==(c=Math.sqrt(+$(s)))||c==1/0?(((t=m(u)).length+a)%2==0&&(t+="0"),c=Math.sqrt(+t),a=g((a+1)/2)-(a<0||a%2),r=new F(t=c==1/0?"1e"+a:(t=c.toExponential()).slice(0,t.indexOf("e")+1)+a)):r=new F(c+""),r.c[0])for((c=(a=r.e)+f)<3&&(c=0);;)if(o=r,r=l.times(o.plus(n(s,o,f,1))),m(o.c).slice(0,c)===(t=m(r.c)).slice(0,c)){if(r.e<a&&--c,"9999"!=(t=t.slice(c-3,c+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(K(r,r.e+P+2,1),e=!r.times(r).eq(s));break}if(!i&&(K(o,o.e+P+2,0),o.times(o).eq(s))){r=o;break}f+=4,c+=4,i=1}return K(r,r.e+P+1,I,e)},C.toExponential=function(e,t){return null!=e&&(w(e,0,y),e++),W(this,e,t,1)},C.toFixed=function(e,t){return null!=e&&(w(e,0,y),e=e+this.e+1),W(this,e,t)},C.toFormat=function(e,t,n){var r,i=this;if(null==n)null!=e&&t&&"object"==typeof t?(n=t,t=null):e&&"object"==typeof e?(n=e,e=t=null):n=H;else if("object"!=typeof n)throw Error(a+"Argument not an object: "+n);if(r=i.toFixed(e,t),i.c){var o,s=r.split("."),u=+n.groupSize,c=+n.secondaryGroupSize,f=n.groupSeparator||"",l=s[0],d=s[1],p=i.s<0,h=p?l.slice(1):l,v=h.length;if(c&&(o=u,u=c,c=o,v-=o),u>0&&v>0){for(o=v%u||u,l=h.substr(0,o);o<v;o+=u)l+=f+h.substr(o,u);c>0&&(l+=f+h.slice(o)),p&&(l="-"+l)}r=d?l+(n.decimalSeparator||"")+((c=+n.fractionGroupSize)?d.replace(new RegExp("\\d{"+c+"}\\B","g"),"$&"+(n.fractionGroupSeparator||"")):d):l}return(n.prefix||"")+r+(n.suffix||"")},C.toFraction=function(e){var t,r,i,o,s,u,c,f,l,p,v,y,g=this,b=g.c;if(null!=e&&(!(c=new F(e)).isInteger()&&(c.c||1!==c.s)||c.lt(x)))throw Error(a+"Argument "+(c.isInteger()?"out of range: ":"not an integer: ")+$(c));if(!b)return new F(g);for(t=new F(x),l=r=new F(x),i=f=new F(x),y=m(b),s=t.e=y.length-g.e-1,t.c[0]=h[(u=s%d)<0?d+u:u],e=!e||c.comparedTo(t)>0?s>0?t:l:c,u=j,j=1/0,c=new F(y),f.c[0]=0;p=n(c,t,0,1),1!=(o=r.plus(p.times(i))).comparedTo(e);)r=i,i=o,l=f.plus(p.times(o=l)),f=o,t=c.minus(p.times(o=t)),c=o;return o=n(e.minus(r),i,0,1),f=f.plus(o.times(l)),r=r.plus(o.times(i)),f.s=l.s=g.s,v=n(l,i,s*=2,I).minus(g).abs().comparedTo(n(f,r,s,I).minus(g).abs())<1?[l,i]:[f,r],j=u,v},C.toNumber=function(){return+$(this)},C.toPrecision=function(e,t){return null!=e&&w(e,1,y),W(this,e,t,2)},C.toString=function(e){var t,n=this,i=n.s,o=n.e;return null===o?i?(t="Infinity",i<0&&(t="-"+t)):t="NaN":(null==e?t=o<=R||o>=L?E(m(n.c),o):S(m(n.c),o,"0"):10===e?t=S(m((n=K(new F(n),P+o+1,I)).c),n.e,"0"):(w(e,2,D.length,"Base"),t=r(S(m(n.c),o,"0"),10,e,i,!0)),i<0&&n.c[0]&&(t="-"+t)),t},C.valueOf=C.toJSON=function(){return $(this)},C._isBigNumber=!0,null!=t&&F.set(t),F}()).default=o.BigNumber=o,void 0===(r=function(){return o}.call(t,n,t,e))||(e.exports=r)}()},70:function(e,t){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}},71:function(e,t){e.exports=function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}},72:function(e,t){e.exports=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}},85:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HANDSHAKE="m_handshake",t.INIT="m_init",t.CONNECT="m_connect",t.DISCONNECT="m_disconnect",t.GET_INFO="m_get_info",t.GET_BLOCK_HASH="m_get_block_hash",t.GET_ACCOUNT_INFO="m_get_account_info",t.GET_ACCOUNT_UTXO="m_get_account_utxo",t.GET_TRANSACTION="m_get_transaction",t.ESTIMATE_FEE="m_estimate_fee",t.SUBSCRIBE="m_subscribe",t.UNSUBSCRIBE="m_unsubscribe",t.PUSH_TRANSACTION="m_push_tx"},86:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ERROR="r_error",t.CONNECT="r_connect",t.GET_INFO="r_info",t.GET_BLOCK_HASH="r_get_block_hash",t.GET_ACCOUNT_INFO="r_account_info",t.GET_ACCOUNT_UTXO="r_get_account_utxo",t.GET_TRANSACTION="r_get_transaction",t.ESTIMATE_FEE="r_estimate_fee",t.SUBSCRIBE="r_subscribe",t.UNSUBSCRIBE="r_unsubscribe",t.PUSH_TRANSACTION="r_push_tx",t.CONNECTED="r_connected",t.DISCONNECTED="r_disconnected",t.NOTIFICATION="r_notification"},87:function(e,t,n){"use strict";var r=this&&this.__spreadArrays||function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),i=0;for(t=0;t<n;t++)for(var o=arguments[t],s=0,u=o.length;s<u;s++,i++)r[i]=o[s];return r};Object.defineProperty(t,"__esModule",{value:!0});var i=n(46),o=n(29),s=function(){function e(e){this.addresses=[],this.accounts=[],this.subscription={},this.settings={name:"unknown",worker:"unknown",server:[]},this.debugPrefix="[UnknownWorker]",this.post=function(){return console.warn("BlockchainLink:workers.common: postMessage method is not set")},void 0!==e&&(this.post=e)}return e.prototype.handshake=function(){this.post.call(null,{id:-1,type:i.MESSAGES.HANDSHAKE})},e.prototype.setSettings=function(e){this.settings=e,this.debugPrefix='[Worker "'+e.name+'"]:'},e.prototype.getSettings=function(){return this.settings},e.prototype.errorHandler=function(e){var t=e.id,n=e.error,r="blockchain_link/unknown",o=n.message;n.code&&(r=n.code),this.post.call(null,{id:t,type:i.RESPONSES.ERROR,payload:{code:r,message:o}})},e.prototype.response=function(e){this.post.call(null,this.removeEmpty(e))},e.prototype.validateAddresses=function(e){if(!Array.isArray(e))throw new o.CustomError("invalid_param","+addresses");var t=[];return e.filter(function(e){return"string"==typeof e&&(!(t.indexOf(e)>=0)&&(t.push(e),!0))})},e.prototype.addAddresses=function(e){var t=this,n=this.validateAddresses(e).filter(function(e){return t.addresses.indexOf(e)<0});return this.addresses=this.addresses.concat(n),n},e.prototype.getAddresses=function(){return this.addresses},e.prototype.removeAddresses=function(e){var t=this.validateAddresses(e);return this.addresses=this.addresses.filter(function(e){return t.indexOf(e)<0}),this.addresses},e.prototype.validateAccounts=function(e){if(!Array.isArray(e))throw new o.CustomError("invalid_param","+accounts");var t=[];return e.filter(function(e){return!(!e||"object"!=typeof e||"string"!=typeof e.descriptor)&&(!(t.indexOf(e.descriptor)>=0)&&(t.push(e.descriptor),!0))})},e.prototype.getAccountAddresses=function(e){if(e.addresses){var t=e.addresses,n=t.change,r=t.used,i=t.unused;return n.concat(r,i).map(function(e){return e.address})}return[e.descriptor]},e.prototype.addAccounts=function(e){var t=this,n=this.validateAccounts(e),r=this.accounts.filter(function(e){return!n.find(function(t){return t.descriptor===e.descriptor})});this.accounts=r.concat(n);var i=this.accounts.reduce(function(e,n){return e.concat(t.getAccountAddresses(n))},[]);return this.addAddresses(i),n},e.prototype.getAccount=function(e){return this.accounts.find(function(t){if(t.descriptor===e)return!0;if(t.addresses){var n=t.addresses,r=n.change,i=n.used,o=n.unused;if(r.find(function(t){return t.address===e}))return!0;if(i.find(function(t){return t.address===e}))return!0;if(o.find(function(t){return t.address===e}))return!0}return!1})},e.prototype.getAccounts=function(){return this.accounts},e.prototype.removeAccounts=function(e){var t=this,n=this.validateAccounts(e),r=this.accounts.filter(function(e){return n.find(function(t){return t.descriptor===e.descriptor})}),i=r.reduce(function(e,n){return e.concat(t.getAccountAddresses(n))},[]);return this.accounts=this.accounts.filter(function(e){return r.indexOf(e)<0}),this.removeAddresses(i),this.accounts},e.prototype.addSubscription=function(e){this.subscription[e]=!0},e.prototype.getSubscription=function(e){return this.subscription[e]},e.prototype.hasSubscriptions=function(){return Object.keys(this.subscription).length>0},e.prototype.removeSubscription=function(e){delete this.subscription[e]},e.prototype.clearSubscriptions=function(){var e=this;Object.keys(this.subscription).forEach(function(t){delete e.subscription[t]})},e.prototype.shuffleEndpoints=function(e){for(var t,n=e.length-1;n>0;n--){var r=Math.floor(Math.random()*(n+1));t=[e[r],e[n]],e[n]=t[0],e[r]=t[1]}return e},e.prototype.removeEmpty=function(e){var t=this;return Object.keys(e).forEach(function(n){e[n]&&"object"==typeof e[n]?t.removeEmpty(e[n]):void 0===e[n]&&delete e[n]}),e},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.settings&&this.settings.debug&&("warn"===e[0]||"error"===e[0]?console[e[0]].apply(console,r([this.debugPrefix],e.slice(1))):console.log.apply(console,r([this.debugPrefix],e)))},e}();t.default=s}});
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="./",r(r.s=463)}({19:function(e,t,r){"use strict";var n,i="object"==typeof Reflect?Reflect:null,s=i&&"function"==typeof i.apply?i.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};n=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var o=Number.isNaN||function(e){return e!=e};function c(){c.init.call(this)}e.exports=c,c.EventEmitter=c,c.prototype._events=void 0,c.prototype._eventsCount=0,c.prototype._maxListeners=void 0;var u=10;function a(e){return void 0===e._maxListeners?c.defaultMaxListeners:e._maxListeners}function f(e,t,r,n){var i,s,o,c;if("function"!=typeof r)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r);if(void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),o=s[t]),void 0===o)o=s[t]=r,++e._eventsCount;else if("function"==typeof o?o=s[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),(i=a(e))>0&&o.length>i&&!o.warned){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=o.length,c=u,console&&console.warn&&console.warn(c)}return e}function l(){for(var e=[],t=0;t<arguments.length;t++)e.push(arguments[t]);this.fired||(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,s(this.listener,this.target,e))}function d(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=l.bind(n);return i.listener=r,n.wrapFn=i,i}function p(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(i):v(i,i.length)}function h(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function v(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}Object.defineProperty(c,"defaultMaxListeners",{enumerable:!0,get:function(){return u},set:function(e){if("number"!=typeof e||e<0||o(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");u=e}}),c.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},c.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||o(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},c.prototype.getMaxListeners=function(){return a(this)},c.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var n="error"===e,i=this._events;if(void 0!==i)n=n&&void 0===i.error;else if(!n)return!1;if(n){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var c=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw c.context=o,c}var u=i[e];if(void 0===u)return!1;if("function"==typeof u)s(u,this,t);else{var a=u.length,f=v(u,a);for(r=0;r<a;++r)s(f[r],this,t)}return!0},c.prototype.addListener=function(e,t){return f(this,e,t,!1)},c.prototype.on=c.prototype.addListener,c.prototype.prependListener=function(e,t){return f(this,e,t,!0)},c.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);return this.on(e,d(this,e,t)),this},c.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);return this.prependListener(e,d(this,e,t)),this},c.prototype.removeListener=function(e,t){var r,n,i,s,o;if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);if(void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,s=r.length-1;s>=0;s--)if(r[s]===t||r[s].listener===t){o=r[s].listener,i=s;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,i),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,o||t)}return this},c.prototype.off=c.prototype.removeListener,c.prototype.removeAllListeners=function(e){var t,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var i,s=Object.keys(r);for(n=0;n<s.length;++n)"removeListener"!==(i=s[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},c.prototype.listeners=function(e){return p(this,e,!0)},c.prototype.rawListeners=function(e){return p(this,e,!1)},c.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):h.call(e,t)},c.prototype.listenerCount=h,c.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},29:function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(t,"__esModule",{value:!0});var s="blockchain_link/",o={worker_not_found:"Worker not found",worker_invalid:"Invalid worker object",worker_timeout:"Worker timeout",worker_unknown_request:"Unknown message type:",worker_runtime:void 0,invalid_param:"Invalid parameter:",websocket_not_initialized:"WebSocket not initialized",websocket_no_url:"Cannot connect because no server was specified",websocket_timeout:"Websocket timeout",websocket_error_message:void 0,websocket_runtime_error:void 0},c=function(e){function t(t,r){void 0===r&&(r="");var n=e.call(this,r)||this;if(n.message="",n.message=r,"string"==typeof t){var i=0===t.indexOf(s)?t.substring(s.length,t.length):t;n.code=""+s+i;var c=o[i];"string"==typeof c&&(""===n.message?n.message=c:0===r.indexOf("+")&&(n.message=c+" "+r.substr(1,r.length)))}return"string"==typeof n.message&&""!==n.message||(n.message="Message not set"),n}return i(t,e),t}(Error);t.CustomError=c},46:function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});var i=n(r(85));t.MESSAGES=i;var s=n(r(86));t.RESPONSES=s,t.NETWORKS={RIPPLE:"ripple",BLOCKBOOK:"blockbook"}},463:function(e,t,r){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},i=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,s){function o(e){try{u(n.next(e))}catch(e){s(e)}}function c(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,c)}u((n=n.apply(e,t||[])).next())})},s=this&&this.__generator||function(e,t){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function c(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=(i=o.trys).length>0&&i[i.length-1])&&(6===s[0]||2===s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},c=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(t,"__esModule",{value:!0});var u,a=r(29),f=r(46),l=o(r(464)),d=c(r(466)),p=new(o(r(87)).default)(postMessage),h=[],v=function(){u&&(u.dispose(),u.removeAllListeners(),u=void 0),h=[],p.removeAccounts(p.getAccounts()),p.removeAddresses(p.getAddresses()),p.clearSubscriptions()},y=function(){return i(void 0,void 0,void 0,function(){var e,t,r,n,i,o;return s(this,function(s){switch(s.label){case 0:if(u&&u.isConnected())return[2,u];if(e=p.getSettings(),t=e.server,r=e.timeout,n=e.pingTimeout,i=e.keepAlive,!t||!Array.isArray(t)||t.length<1)throw new a.CustomError("connect","Endpoint not set");h.length<1&&(h=p.shuffleEndpoints(t.slice(0))),p.debug("Connecting to",h[0]),o=new l.default({url:h[0],timeout:r,pingTimeout:n,keepAlive:i}),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,o.connect()];case 2:return s.sent(),u=o,[3,4];case 3:if(s.sent(),p.debug("Websocket connection failed"),u=void 0,h.splice(0,1),h.length<1)throw new a.CustomError("connect","All backends are down");return[2,y()];case 4:return o.on("disconnected",function(){p.response({id:-1,type:f.RESPONSES.DISCONNECTED,payload:!0}),v()}),p.response({id:-1,type:f.RESPONSES.CONNECTED}),p.debug("Connected"),[2,o]}})})},b=function(e){p.response({id:-1,type:f.RESPONSES.NOTIFICATION,payload:{type:"block",payload:{blockHeight:e.height,blockHash:e.hash}}})},g=function(e){if(e.tx){var t=e.address,r=p.getAccount(t);p.response({id:-1,type:f.RESPONSES.NOTIFICATION,payload:{type:"notification",payload:{descriptor:r?r.descriptor:t,tx:r?d.transformTransaction(r.descriptor,r.addresses,e.tx):d.transformTransaction(t,void 0,e.tx)}}})}},m=function(e){p.response({id:-1,type:f.RESPONSES.NOTIFICATION,payload:{type:"fiatRates",payload:{rates:e.rates}}})};onmessage=function(e){if(e.data){var t=e.data,r=t.id,o=t.type;switch(p.debug("onmessage",t),t.type){case f.MESSAGES.HANDSHAKE:p.setSettings(t.settings);break;case f.MESSAGES.CONNECT:y().then(function(){return i(void 0,void 0,void 0,function(){return s(this,function(e){return p.response({id:r,type:f.RESPONSES.CONNECT,payload:!0}),[2]})})}).catch(function(e){return p.errorHandler({id:r,error:e})});break;case f.MESSAGES.GET_INFO:!function(e){i(void 0,void 0,void 0,function(){var t,r,i;return s(this,function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),[4,y()];case 1:return[4,(t=s.sent()).getServerInfo()];case 2:return r=s.sent(),p.response({id:e.id,type:f.RESPONSES.GET_INFO,payload:n({url:t.options.url},d.transformServerInfo(r))}),[3,4];case 3:return i=s.sent(),p.errorHandler({id:e.id,error:i}),[3,4];case 4:return[2]}})})}(t);break;case f.MESSAGES.GET_BLOCK_HASH:!function(e){i(void 0,void 0,void 0,function(){var t,r;return s(this,function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),[4,y()];case 1:return[4,n.sent().getBlockHash(e.payload)];case 2:return t=n.sent(),p.response({id:e.id,type:f.RESPONSES.GET_BLOCK_HASH,payload:t.hash}),[3,4];case 3:return r=n.sent(),p.errorHandler({id:e.id,error:r}),[3,4];case 4:return[2]}})})}(t);break;case f.MESSAGES.GET_ACCOUNT_INFO:!function(e){i(void 0,void 0,void 0,function(){var t,r,n;return s(this,function(i){switch(i.label){case 0:t=e.payload,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,y()];case 2:return[4,i.sent().getAccountInfo(t)];case 3:return r=i.sent(),p.response({id:e.id,type:f.RESPONSES.GET_ACCOUNT_INFO,payload:d.transformAccountInfo(r)}),[3,5];case 4:return n=i.sent(),p.errorHandler({id:e.id,error:n}),[3,5];case 5:return[2]}})})}(t);break;case f.MESSAGES.GET_ACCOUNT_UTXO:!function(e){i(void 0,void 0,void 0,function(){var t,r,n;return s(this,function(i){switch(i.label){case 0:t=e.payload,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,y()];case 2:return[4,i.sent().getAccountUtxo(t)];case 3:return r=i.sent(),p.response({id:e.id,type:f.RESPONSES.GET_ACCOUNT_UTXO,payload:d.transformAccountUtxo(r)}),[3,5];case 4:return n=i.sent(),p.errorHandler({id:e.id,error:n}),[3,5];case 5:return[2]}})})}(t);break;case f.MESSAGES.GET_TRANSACTION:!function(e){i(void 0,void 0,void 0,function(){var t,r,n;return s(this,function(i){switch(i.label){case 0:t=e.payload,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,y()];case 2:return[4,i.sent().getTransaction(t)];case 3:return r=i.sent(),p.response({id:e.id,type:f.RESPONSES.GET_TRANSACTION,payload:{type:"blockbook",tx:r}}),[3,5];case 4:return n=i.sent(),p.errorHandler({id:e.id,error:n}),[3,5];case 5:return[2]}})})}(t);break;case f.MESSAGES.GET_ACCOUNT_BALANCE_HISTORY:!function(e){i(void 0,void 0,void 0,function(){var t,r,n;return s(this,function(i){switch(i.label){case 0:t=e.payload,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,y()];case 2:return[4,i.sent().getAccountBalanceHistory(t)];case 3:return r=i.sent(),p.response({id:e.id,type:f.RESPONSES.GET_ACCOUNT_BALANCE_HISTORY,payload:r}),[3,5];case 4:return n=i.sent(),p.errorHandler({id:e.id,error:n}),[3,5];case 5:return[2]}})})}(t);break;case f.MESSAGES.GET_CURRENT_FIAT_RATES:!function(e){i(void 0,void 0,void 0,function(){var t,r,n;return s(this,function(i){switch(i.label){case 0:t=e.payload,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,y()];case 2:return[4,i.sent().getCurrentFiatRates(t)];case 3:return r=i.sent(),p.response({id:e.id,type:f.RESPONSES.GET_CURRENT_FIAT_RATES,payload:r}),[3,5];case 4:return n=i.sent(),p.errorHandler({id:e.id,error:n}),[3,5];case 5:return[2]}})})}(t);break;case f.MESSAGES.GET_FIAT_RATES_FOR_TIMESTAMPS:!function(e){i(void 0,void 0,void 0,function(){var t,r,n;return s(this,function(i){switch(i.label){case 0:t=e.payload,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,y()];case 2:return[4,i.sent().getFiatRatesForTimestamps(t)];case 3:return r=i.sent().tickers,p.response({id:e.id,type:f.RESPONSES.GET_FIAT_RATES_FOR_TIMESTAMPS,payload:{tickers:r}}),[3,5];case 4:return n=i.sent(),p.errorHandler({id:e.id,error:n}),[3,5];case 5:return[2]}})})}(t);break;case f.MESSAGES.GET_FIAT_RATES_TICKERS_LIST:!function(e){i(void 0,void 0,void 0,function(){var t,r,n;return s(this,function(i){switch(i.label){case 0:t=e.payload,i.label=1;case 1:return i.trys.push([1,4,,5]),[4,y()];case 2:return[4,i.sent().getFiatRatesTickersList(t)];case 3:return r=i.sent(),p.response({id:e.id,type:f.RESPONSES.GET_FIAT_RATES_TICKERS_LIST,payload:{ts:r.ts,availableCurrencies:r.available_currencies}}),[3,5];case 4:return n=i.sent(),p.errorHandler({id:e.id,error:n}),[3,5];case 5:return[2]}})})}(t);break;case f.MESSAGES.ESTIMATE_FEE:!function(e){i(void 0,void 0,void 0,function(){var t,r;return s(this,function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),[4,y()];case 1:return[4,n.sent().estimateFee(e.payload)];case 2:return t=n.sent(),p.response({id:e.id,type:f.RESPONSES.ESTIMATE_FEE,payload:t}),[3,4];case 3:return r=n.sent(),p.errorHandler({id:e.id,error:r}),[3,4];case 4:return[2]}})})}(t);break;case f.MESSAGES.PUSH_TRANSACTION:!function(e){i(void 0,void 0,void 0,function(){var t,r;return s(this,function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),[4,y()];case 1:return[4,n.sent().pushTransaction(e.payload)];case 2:return t=n.sent(),p.response({id:e.id,type:f.RESPONSES.PUSH_TRANSACTION,payload:t.result}),[3,4];case 3:return r=n.sent(),p.errorHandler({id:e.id,error:r}),[3,4];case 4:return[2]}})})}(t);break;case f.MESSAGES.SUBSCRIBE:!function(e){i(void 0,void 0,void 0,function(){var t,r,n;return s(this,function(o){switch(o.label){case 0:t=e.payload,o.label=1;case 1:return o.trys.push([1,11,,12]),r=void 0,"accounts"!==t.type?[3,3]:[4,(l=t.accounts,i(void 0,void 0,void 0,function(){var e;return s(this,function(t){switch(t.label){case 0:return p.addAccounts(l),[4,y()];case 1:return e=t.sent(),p.getSubscription("notification")||(e.on("notification",g),p.addSubscription("notification")),[2,e.subscribeAddresses(p.getAddresses())]}})}))];case 2:return r=o.sent(),[3,10];case 3:return"addresses"!==t.type?[3,5]:[4,(u=t.addresses,i(void 0,void 0,void 0,function(){var e;return s(this,function(t){switch(t.label){case 0:return p.addAddresses(u),[4,y()];case 1:return e=t.sent(),p.getSubscription("notification")||(e.on("notification",g),p.addSubscription("notification")),[2,e.subscribeAddresses(p.getAddresses())]}})}))];case 4:return r=o.sent(),[3,10];case 5:return"block"!==t.type?[3,7]:[4,i(void 0,void 0,void 0,function(){var e;return s(this,function(t){switch(t.label){case 0:return p.getSubscription("block")?[2,{subscribed:!0}]:[4,y()];case 1:return e=t.sent(),p.addSubscription("block"),e.on("block",b),[2,e.subscribeBlock()]}})})];case 6:return r=o.sent(),[3,10];case 7:return"fiatRates"!==t.type?[3,9]:[4,(c=t.currency,i(void 0,void 0,void 0,function(){var e;return s(this,function(t){switch(t.label){case 0:return[4,y()];case 1:return e=t.sent(),p.getSubscription("fiatRates")||(p.addSubscription("fiatRates"),e.on("fiatRates",m)),[2,e.subscribeFiatRates(c)]}})}))];case 8:return r=o.sent(),[3,10];case 9:throw new a.CustomError("invalid_param","+type");case 10:return p.response({id:e.id,type:f.RESPONSES.SUBSCRIBE,payload:r}),[3,12];case 11:return n=o.sent(),p.errorHandler({id:e.id,error:n}),[3,12];case 12:return[2]}var c,u,l})})}(t);break;case f.MESSAGES.UNSUBSCRIBE:!function(e){i(void 0,void 0,void 0,function(){var t,r,n;return s(this,function(o){switch(o.label){case 0:t=e.payload,o.label=1;case 1:return o.trys.push([1,11,,12]),r=void 0,"accounts"!==t.type?[3,3]:[4,(u=t.accounts,i(void 0,void 0,void 0,function(){var e,t;return s(this,function(r){switch(r.label){case 0:return p.removeAccounts(u||p.getAccounts()),[4,y()];case 1:return e=r.sent(),(t=p.getAddresses()).length<1?(e.removeListener("notification",g),p.removeSubscription("notification"),[2,e.unsubscribeAddresses()]):[2,e.subscribeAddresses(t)]}})}))];case 2:return r=o.sent(),[3,10];case 3:return"addresses"!==t.type?[3,5]:[4,(c=t.addresses,i(void 0,void 0,void 0,function(){var e,t;return s(this,function(r){switch(r.label){case 0:return[4,y()];case 1:return e=r.sent(),c||p.removeAccounts(p.getAccounts()),(t=p.removeAddresses(c||p.getAddresses())).length<1?(e.removeListener("notification",g),p.removeSubscription("notification"),[2,e.unsubscribeAddresses()]):[2,e.subscribeAddresses(t)]}})}))];case 4:return r=o.sent(),[3,10];case 5:return"block"!==t.type?[3,7]:[4,i(void 0,void 0,void 0,function(){var e;return s(this,function(t){switch(t.label){case 0:return p.getSubscription("block")?[4,y()]:[2,{subscribed:!1}];case 1:return(e=t.sent()).removeListener("block",b),p.removeSubscription("block"),[2,e.unsubscribeBlock()]}})})];case 6:return r=o.sent(),[3,10];case 7:return"fiatRates"!==t.type?[3,9]:[4,i(void 0,void 0,void 0,function(){var e;return s(this,function(t){switch(t.label){case 0:return p.getSubscription("fiatRates")?[4,y()]:[2,{subscribed:!1}];case 1:return(e=t.sent()).removeListener("fiatRates",b),p.removeSubscription("fiatRates"),[2,e.unsubscribeFiatRates()]}})})];case 8:return r=o.sent(),[3,10];case 9:throw new a.CustomError("invalid_param","+type");case 10:return p.response({id:e.id,type:f.RESPONSES.UNSUBSCRIBE,payload:r}),[3,12];case 11:return n=o.sent(),p.errorHandler({id:e.id,error:n}),[3,12];case 12:return[2]}var c,u})})}(t);break;case f.MESSAGES.DISCONNECT:!function(e){i(void 0,void 0,void 0,function(){var t;return s(this,function(r){switch(r.label){case 0:if(!u)return p.response({id:e.id,type:f.RESPONSES.DISCONNECTED,payload:!0}),[2];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,u.disconnect()];case 2:return r.sent(),p.response({id:e.id,type:f.RESPONSES.DISCONNECTED,payload:!0}),[3,4];case 3:return t=r.sent(),p.errorHandler({id:e.id,error:t}),[3,4];case 4:return[2]}})})}(t);break;case"terminate":v();break;default:p.errorHandler({id:r,error:new a.CustomError("worker_unknown_request","+"+o)})}}},p.handshake()},464:function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),s=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(i,s){function o(e){try{u(n.next(e))}catch(e){s(e)}}function c(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,c)}u((n=n.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function c(s){return function(c){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=(i=o.trys).length>0&&i[i.length-1])&&(6===s[0]||2===s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},c=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var u=c(r(68)),a=r(19),f=r(29),l=r(465),d=new f.CustomError("websocket_not_initialized"),p=function(e){function t(t){var r=e.call(this)||this;return r.messageID=0,r.messages=[],r.subscriptions=[],r.send=function(e,t){var n=r.ws;if(!n)throw d;var i=r.messageID.toString(),s=l.create(i),o={id:i,method:e,params:t};return r.messageID++,r.messages.push(s),r.setConnectionTimeout(),r.setPingTimeout(),n.send(JSON.stringify(o)),s.promise},r.setMaxListeners(1/0),r.options=t,r}return i(t,e),t.prototype.setConnectionTimeout=function(){this.clearConnectionTimeout(),this.connectionTimeout=setTimeout(this.onTimeout.bind(this),this.options.timeout||2e4)},t.prototype.clearConnectionTimeout=function(){this.connectionTimeout&&(clearTimeout(this.connectionTimeout),this.connectionTimeout=void 0)},t.prototype.setPingTimeout=function(){this.pingTimeout&&clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(this.onPing.bind(this),this.options.pingTimeout||5e4)},t.prototype.onTimeout=function(){var e=this.ws;if(e)if(e.listenerCount("open")>0){e.emit("error","Websocket timeout");try{e.close()}catch(e){}}else this.messages.forEach(function(e){return e.reject(new f.CustomError("websocket_timeout"))}),e.close()},t.prototype.onPing=function(){return s(this,void 0,void 0,function(){return o(this,function(e){switch(e.label){case 0:return this.ws&&this.isConnected()?this.subscriptions.length>0||this.options.keepAlive?[4,this.getBlockHash(0)]:[3,2]:[3,3];case 1:return e.sent(),[3,3];case 2:try{this.ws.close()}catch(e){}e.label=3;case 3:return[2]}})})},t.prototype.onError=function(){this.dispose()},t.prototype.onmessage=function(e){try{var t=JSON.parse(e),r=t.id,n=t.data,i=this.messages.find(function(e){return e.id===r});if(i)n.error?i.reject(new f.CustomError("websocket_error_message",n.error.message)):i.resolve(n),this.messages.splice(this.messages.indexOf(i),1);else{var s=this.subscriptions.find(function(e){return e&&e.id===r});s&&s.callback(n)}}catch(e){}0===this.messages.length&&this.clearConnectionTimeout(),this.setPingTimeout()},t.prototype.connect=function(){var e=this,t=this.options.url;if("string"!=typeof t)throw new f.CustomError("websocket_no_url");if(t.startsWith("https")&&(t=t.replace("https","wss")),t.startsWith("http")&&(t=t.replace("http","ws")),!t.endsWith("/websocket")){var r=t.endsWith("/")?"websocket":"/websocket";t+=r}this.setConnectionTimeout();var n=l.create(-1),i=new u.default(t);return"function"==typeof i.setMaxListeners&&i.setMaxListeners(1/0),i.once("error",function(t){e.dispose(),n.reject(new f.CustomError("websocket_runtime_error",t.message))}),i.on("open",function(){e.init(),n.resolve()}),this.ws=i,n.promise},t.prototype.init=function(){var e=this,t=this.ws;if(!t||!this.isConnected())throw Error("Blockbook websocket init cannot be called");this.clearConnectionTimeout(),t.removeAllListeners(),t.on("error",this.onError.bind(this)),t.on("message",this.onmessage.bind(this)),t.on("close",function(){e.emit("disconnected"),e.dispose()})},t.prototype.disconnect=function(){this.ws&&this.ws.close()},t.prototype.isConnected=function(){var e=this.ws;return e&&e.readyState===u.default.OPEN},t.prototype.getServerInfo=function(){return this.send("getInfo",{})},t.prototype.getBlockHash=function(e){return this.send("getBlockHash",{height:e})},t.prototype.getAccountInfo=function(e){return this.send("getAccountInfo",e)},t.prototype.getAccountUtxo=function(e){return this.send("getAccountUtxo",{descriptor:e})},t.prototype.getTransaction=function(e){return this.send("getTransaction",{txid:e})},t.prototype.pushTransaction=function(e){return this.send("sendTransaction",{hex:e})},t.prototype.estimateFee=function(e){return this.send("estimateFee",e)},t.prototype.getCurrentFiatRates=function(e){return this.send("getCurrentFiatRates",e)},t.prototype.getAccountBalanceHistory=function(e){return this.send("getBalanceHistory",e)},t.prototype.getFiatRatesForTimestamps=function(e){return this.send("getFiatRatesForTimestamps",e)},t.prototype.getFiatRatesTickersList=function(e){return this.send("getFiatRatesTickersList",e)},t.prototype.subscribeAddresses=function(e){var t=this,r=this.subscriptions.findIndex(function(e){return"notification"===e.type});r>=0&&this.subscriptions.splice(r,1);var n=this.messageID.toString();return this.subscriptions.push({id:n,type:"notification",callback:function(e){t.emit("notification",e)}}),this.send("subscribeAddresses",{addresses:e})},t.prototype.unsubscribeAddresses=function(){var e=this.subscriptions.findIndex(function(e){return"notification"===e.type});return e>=0?(this.subscriptions.splice(e,1),this.send("unsubscribeAddresses",{})):{subscribed:!1}},t.prototype.subscribeBlock=function(){var e=this,t=this.subscriptions.findIndex(function(e){return"block"===e.type});t>=0&&this.subscriptions.splice(t,1);var r=this.messageID.toString();return this.subscriptions.push({id:r,type:"block",callback:function(t){e.emit("block",t)}}),this.send("subscribeNewBlock",{})},t.prototype.unsubscribeBlock=function(){var e=this.subscriptions.findIndex(function(e){return"block"===e.type});return e>=0?(this.subscriptions.splice(e,1),this.send("unsubscribeNewBlock",{})):{subscribed:!1}},t.prototype.subscribeFiatRates=function(e){var t=this,r=this.subscriptions.findIndex(function(e){return"fiatRates"===e.type});r>=0&&this.subscriptions.splice(r,1);var n=this.messageID.toString();return this.subscriptions.push({id:n,type:"fiatRates",callback:function(e){t.emit("fiatRates",e)}}),this.send("subscribeFiatRates",{currency:e})},t.prototype.unsubscribeFiatRates=function(){var e=this.subscriptions.findIndex(function(e){return"fiatRates"===e.type});return e>=0?(this.subscriptions.splice(e,1),this.send("unsubscribeFiatRates",{})):{subscribed:!1}},t.prototype.dispose=function(){this.pingTimeout&&clearTimeout(this.pingTimeout),this.connectionTimeout&&clearTimeout(this.connectionTimeout);var e=this.ws;this.isConnected()&&this.disconnect(),e&&e.removeAllListeners(),this.removeAllListeners()},t}(a.EventEmitter);t.default=p},465:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.create=function(e){var t=function(){},r=function(){},n=new Promise(function(e,n){t=e,r=n});return{id:e,resolve:t,reject:r,promise:n}}},466:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var i=n(r(7));t.transformServerInfo=function(e){return{name:e.name,shortcut:e.shortcut,testnet:e.testnet,version:e.version,decimals:e.decimals,blockHeight:e.bestHeight,blockHash:e.bestHash}},t.filterTargets=function(e,t){if("string"==typeof e&&(e=[e]),!(e&&Array.isArray(e)&&t&&Array.isArray(t)))return[];var r=e.map(function(e){return"string"==typeof e?e:"object"==typeof e&&"string"==typeof e.address?e.address:null});return t.filter(function(e){return!(!e||!Array.isArray(e.addresses))&&e.addresses.filter(function(e){return r.indexOf(e)>=0}).length>0})},t.filterTokenTransfers=function(e,t){if("string"==typeof e&&(e=[e]),!(e&&Array.isArray(e)&&t&&Array.isArray(t)))return[];var r=e.map(function(e){return"string"==typeof e?e:"object"==typeof e&&"string"==typeof e.address?e.address:null});return t.filter(function(e){return!(!e||"object"!=typeof e)&&(e.from&&r.indexOf(e.from)>=0||e.to&&r.indexOf(e.to)>=0)}).map(function(e){var t=e.from&&r.indexOf(e.from)>=0,n=e.to&&r.indexOf(e.to)>=0,i="unknown";return t&&n?i="self":(t&&(i="sent"),n&&(i="recv")),{type:i,name:e.name,symbol:e.symbol,address:e.token,decimals:e.decimals||0,amount:e.value,from:e.from,to:e.to}})};t.transformTransaction=function(e,r,n){var s,o,c=r?r.change.concat(r.used,r.unused):[e],u=Array.isArray(n.vin)?n.vin.length:0,a=Array.isArray(n.vout)?n.vout.length:0,f=t.filterTargets(c,n.vin),l=t.filterTargets(c,n.vout),d=r?t.filterTargets(r.change,n.vout):[],p=t.filterTokenTransfers(c,n.tokenTransfers),h=[],v=n.value;if(0===f.length&&0===l.length&&0===p.length)s="unknown";else if(u>0&&a>0&&f.length===u&&l.length===a)s="self",v=n.fees;else if(0===f.length&&(l.length>0||p.length>0))s="recv",v="0",l.length>0&&(Array.isArray(n.vin)&&(h=n.vin),v=l.reduce(function(e,t){return"string"!=typeof t.value?e:new i.default(e).plus(t.value).toString()},v));else if(s="sent",0===p.length&&Array.isArray(n.vout)&&(h=n.vout.filter(function(e){return l.indexOf(e)<0&&d.indexOf(e)<0})),n.ethereumSpecific)v=p.length>0||0===n.ethereumSpecific.status?n.fees:n.value;else if(Array.isArray(n.vout)){var y=f.reduce(function(e,t){return"string"!=typeof t.value?e:new i.default(e).plus(t.value).toString()},"0");v=l.reduce(function(e,t){return"string"!=typeof t.value?e:new i.default(e).minus(t.value).toString()},y)}return Array.isArray(n.vin)&&n.vin.forEach(function(e){"number"==typeof e.sequence&&e.sequence<4294967294&&(o=!0)}),{type:s,txid:n.txid,blockTime:n.blockTime,blockHeight:n.blockHeight,blockHash:n.blockHash,amount:v,fee:n.fees,targets:h.filter(function(e){return"object"==typeof e}).map(function(e){return{addresses:(t=e).addresses,isAddress:t.isAddress,amount:t.value,coinbase:t.coinbase};var t}),tokens:p,rbf:o,ethereumSpecific:n.ethereumSpecific}},t.transformTokenInfo=function(e){if(e&&Array.isArray(e)){var t=e.reduce(function(e,t){return"ERC20"!==t.type?e:e.concat([{type:t.type,name:t.name,symbol:t.symbol,address:t.contract,balance:t.balance,decimals:t.decimals||0}])},[]);return t.length>0?t:void 0}},t.transformAddresses=function(e){if(e&&Array.isArray(e)){var t=e.reduce(function(e,t){return"XPUBAddress"!==t.type?e:e.concat([{address:t.name,path:t.path,transfers:t.transfers,balance:t.balance,sent:t.totalSent,received:t.totalReceived}])},[]);if(!(t.length<1)){var r=t.filter(function(e){return"1"===e.path.split("/")[4]}),n=t.filter(function(e){return r.indexOf(e)<0});return{change:r,used:n.filter(function(e){return e.transfers>0}),unused:n.filter(function(e){return 0===e.transfers})}}}},t.transformAccountInfo=function(e){var r,n;"number"==typeof e.page&&(r={index:e.page,size:e.itemsOnPage,total:e.totalPages}),"string"==typeof e.nonce&&(n={nonce:e.nonce});var s=e.address,o=t.transformAddresses(e.tokens),c=t.transformTokenInfo(e.tokens),u=0===e.txs&&0===e.unconfirmedTxs,a=new i.default(e.unconfirmedBalance),f=a.isNaN()||a.isZero()?e.balance:a.plus(e.balance).toString();return{descriptor:s,balance:e.balance,availableBalance:f,empty:u,tokens:c,addresses:o,history:{total:e.txs,tokens:"number"==typeof e.nonTokenTxs?e.txs-e.nonTokenTxs:void 0,unconfirmed:e.unconfirmedTxs,transactions:e.transactions?e.transactions.map(function(e){return t.transformTransaction(s,o,e)}):void 0},misc:n,page:r}},t.transformAccountUtxo=function(e){return e.map(function(e){return{txid:e.txid,vout:e.vout,amount:e.value,blockHeight:e.height,address:e.address,path:e.path,confirmations:e.confirmations,coinbase:e.coinbase}})}},68:function(e,t,r){var n=r(69),i=r(70),s=r(71),o=r(72),c=function(e){"use strict";function t(t){var r;return r=e.call(this)||this,o(i(r),"ws",void 0),r.setMaxListeners(1/0),r.ws=new WebSocket(t),r.ws.onclose=function(){r.emit("close")},r.ws.onopen=function(){r.emit("open")},r.ws.onerror=function(e){r.emit("error",e)},r.ws.onmessage=function(e){r.emit("message",e.data)},r}s(t,e);var r=t.prototype;return r.close=function(){1===this.readyState&&this.ws.close()},r.send=function(e){this.ws.send(e)},n(t,[{key:"readyState",get:function(){return this.ws.readyState}}]),t}(r(19).EventEmitter);c.CONNECTING=0,c.OPEN=1,c.CLOSING=2,c.CLOSED=3,e.exports=c},69:function(e,t){function r(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}e.exports=function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}},7:function(e,t,r){var n;!function(i){"use strict";var s,o=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,c=Math.ceil,u=Math.floor,a="[BigNumber Error] ",f=a+"Number primitive has more than 15 significant digits: ",l=1e14,d=14,p=9007199254740991,h=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],v=1e7,y=1e9;function b(e){var t=0|e;return e>0||e===t?t:t-1}function g(e){for(var t,r,n=1,i=e.length,s=e[0]+"";n<i;){for(t=e[n++]+"",r=d-t.length;r--;t="0"+t);s+=t}for(i=s.length;48===s.charCodeAt(--i););return s.slice(0,i+1||1)}function m(e,t){var r,n,i=e.c,s=t.c,o=e.s,c=t.s,u=e.e,a=t.e;if(!o||!c)return null;if(r=i&&!i[0],n=s&&!s[0],r||n)return r?n?0:-c:o;if(o!=c)return o;if(r=o<0,n=u==a,!i||!s)return n?0:!i^r?1:-1;if(!n)return u>a^r?1:-1;for(c=(u=i.length)<(a=s.length)?u:a,o=0;o<c;o++)if(i[o]!=s[o])return i[o]>s[o]^r?1:-1;return u==a?0:u>a^r?1:-1}function _(e,t,r,n){if(e<t||e>r||e!==u(e))throw Error(a+(n||"Argument")+("number"==typeof e?e<t||e>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function E(e){var t=e.c.length-1;return b(e.e/d)==t&&e.c[t]%2!=0}function S(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function w(e,t,r){var n,i;if(t<0){for(i=r+".";++t;i+=r);e=i+e}else if(++t>(n=e.length)){for(i=r,t-=n;--t;i+=r);e+=i}else t<n&&(e=e.slice(0,t)+"."+e.slice(t));return e}(s=function e(t){var r,n,i,s,A,T,O,N,k,C=D.prototype={constructor:D,toString:null,valueOf:null},R=new D(1),I=20,x=4,P=-7,L=21,M=-1e7,F=1e7,G=!1,U=1,B=0,j={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},H="0123456789abcdefghijklmnopqrstuvwxyz";function D(e,t){var r,s,c,a,l,h,v,y,b=this;if(!(b instanceof D))return new D(e,t);if(null==t){if(e&&!0===e._isBigNumber)return b.s=e.s,void(!e.c||e.e>F?b.c=b.e=null:e.e<M?b.c=[b.e=0]:(b.e=e.e,b.c=e.c.slice()));if((h="number"==typeof e)&&0*e==0){if(b.s=1/e<0?(e=-e,-1):1,e===~~e){for(a=0,l=e;l>=10;l/=10,a++);return void(a>F?b.c=b.e=null:(b.e=a,b.c=[e]))}y=String(e)}else{if(!o.test(y=String(e)))return i(b,y,h);b.s=45==y.charCodeAt(0)?(y=y.slice(1),-1):1}(a=y.indexOf("."))>-1&&(y=y.replace(".","")),(l=y.search(/e/i))>0?(a<0&&(a=l),a+=+y.slice(l+1),y=y.substring(0,l)):a<0&&(a=y.length)}else{if(_(t,2,H.length,"Base"),10==t)return z(b=new D(e),I+b.e+1,x);if(y=String(e),h="number"==typeof e){if(0*e!=0)return i(b,y,h,t);if(b.s=1/e<0?(y=y.slice(1),-1):1,D.DEBUG&&y.replace(/^0\.0*|\./,"").length>15)throw Error(f+e)}else b.s=45===y.charCodeAt(0)?(y=y.slice(1),-1):1;for(r=H.slice(0,t),a=l=0,v=y.length;l<v;l++)if(r.indexOf(s=y.charAt(l))<0){if("."==s){if(l>a){a=v;continue}}else if(!c&&(y==y.toUpperCase()&&(y=y.toLowerCase())||y==y.toLowerCase()&&(y=y.toUpperCase()))){c=!0,l=-1,a=0;continue}return i(b,String(e),h,t)}h=!1,(a=(y=n(y,t,10,b.s)).indexOf("."))>-1?y=y.replace(".",""):a=y.length}for(l=0;48===y.charCodeAt(l);l++);for(v=y.length;48===y.charCodeAt(--v););if(y=y.slice(l,++v)){if(v-=l,h&&D.DEBUG&&v>15&&(e>p||e!==u(e)))throw Error(f+b.s*e);if((a=a-l-1)>F)b.c=b.e=null;else if(a<M)b.c=[b.e=0];else{if(b.e=a,b.c=[],l=(a+1)%d,a<0&&(l+=d),l<v){for(l&&b.c.push(+y.slice(0,l)),v-=d;l<v;)b.c.push(+y.slice(l,l+=d));l=d-(y=y.slice(l)).length}else l-=v;for(;l--;y+="0");b.c.push(+y)}}else b.c=[b.e=0]}function W(e,t,r,n){var i,s,o,c,u;if(null==r?r=x:_(r,0,8),!e.c)return e.toString();if(i=e.c[0],o=e.e,null==t)u=g(e.c),u=1==n||2==n&&(o<=P||o>=L)?S(u,o):w(u,o,"0");else if(s=(e=z(new D(e),t,r)).e,c=(u=g(e.c)).length,1==n||2==n&&(t<=s||s<=P)){for(;c<t;u+="0",c++);u=S(u,s)}else if(t-=o,u=w(u,s,"0"),s+1>c){if(--t>0)for(u+=".";t--;u+="0");}else if((t+=s-c)>0)for(s+1==c&&(u+=".");t--;u+="0");return e.s<0&&i?"-"+u:u}function K(e,t){for(var r,n=1,i=new D(e[0]);n<e.length;n++){if(!(r=new D(e[n])).s){i=r;break}t.call(i,r)&&(i=r)}return i}function q(e,t,r){for(var n=1,i=t.length;!t[--i];t.pop());for(i=t[0];i>=10;i/=10,n++);return(r=n+r*d-1)>F?e.c=e.e=null:r<M?e.c=[e.e=0]:(e.e=r,e.c=t),e}function z(e,t,r,n){var i,s,o,a,f,p,v,y=e.c,b=h;if(y){e:{for(i=1,a=y[0];a>=10;a/=10,i++);if((s=t-i)<0)s+=d,o=t,v=(f=y[p=0])/b[i-o-1]%10|0;else if((p=c((s+1)/d))>=y.length){if(!n)break e;for(;y.length<=p;y.push(0));f=v=0,i=1,o=(s%=d)-d+1}else{for(f=a=y[p],i=1;a>=10;a/=10,i++);v=(o=(s%=d)-d+i)<0?0:f/b[i-o-1]%10|0}if(n=n||t<0||null!=y[p+1]||(o<0?f:f%b[i-o-1]),n=r<4?(v||n)&&(0==r||r==(e.s<0?3:2)):v>5||5==v&&(4==r||n||6==r&&(s>0?o>0?f/b[i-o]:0:y[p-1])%10&1||r==(e.s<0?8:7)),t<1||!y[0])return y.length=0,n?(t-=e.e+1,y[0]=b[(d-t%d)%d],e.e=-t||0):y[0]=e.e=0,e;if(0==s?(y.length=p,a=1,p--):(y.length=p+1,a=b[d-s],y[p]=o>0?u(f/b[i-o]%b[o])*a:0),n)for(;;){if(0==p){for(s=1,o=y[0];o>=10;o/=10,s++);for(o=y[0]+=a,a=1;o>=10;o/=10,a++);s!=a&&(e.e++,y[0]==l&&(y[0]=1));break}if(y[p]+=a,y[p]!=l)break;y[p--]=0,a=1}for(s=y.length;0===y[--s];y.pop());}e.e>F?e.c=e.e=null:e.e<M&&(e.c=[e.e=0])}return e}function $(e){var t,r=e.e;return null===r?e.toString():(t=g(e.c),t=r<=P||r>=L?S(t,r):w(t,r,"0"),e.s<0?"-"+t:t)}return D.clone=e,D.ROUND_UP=0,D.ROUND_DOWN=1,D.ROUND_CEIL=2,D.ROUND_FLOOR=3,D.ROUND_HALF_UP=4,D.ROUND_HALF_DOWN=5,D.ROUND_HALF_EVEN=6,D.ROUND_HALF_CEIL=7,D.ROUND_HALF_FLOOR=8,D.EUCLID=9,D.config=D.set=function(e){var t,r;if(null!=e){if("object"!=typeof e)throw Error(a+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(_(r=e[t],0,y,t),I=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(_(r=e[t],0,8,t),x=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((r=e[t])&&r.pop?(_(r[0],-y,0,t),_(r[1],0,y,t),P=r[0],L=r[1]):(_(r,-y,y,t),P=-(L=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if((r=e[t])&&r.pop)_(r[0],-y,-1,t),_(r[1],1,y,t),M=r[0],F=r[1];else{if(_(r,-y,y,t),!r)throw Error(a+t+" cannot be zero: "+r);M=-(F=r<0?-r:r)}if(e.hasOwnProperty(t="CRYPTO")){if((r=e[t])!==!!r)throw Error(a+t+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw G=!r,Error(a+"crypto unavailable");G=r}else G=r}if(e.hasOwnProperty(t="MODULO_MODE")&&(_(r=e[t],0,9,t),U=r),e.hasOwnProperty(t="POW_PRECISION")&&(_(r=e[t],0,y,t),B=r),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(r=e[t]))throw Error(a+t+" not an object: "+r);j=r}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(r=e[t])||/^.$|[+-.\s]|(.).*\1/.test(r))throw Error(a+t+" invalid: "+r);H=r}}return{DECIMAL_PLACES:I,ROUNDING_MODE:x,EXPONENTIAL_AT:[P,L],RANGE:[M,F],CRYPTO:G,MODULO_MODE:U,POW_PRECISION:B,FORMAT:j,ALPHABET:H}},D.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!D.DEBUG)return!0;var t,r,n=e.c,i=e.e,s=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===s||-1===s)&&i>=-y&&i<=y&&i===u(i)){if(0===n[0]){if(0===i&&1===n.length)return!0;break e}if((t=(i+1)%d)<1&&(t+=d),String(n[0]).length==t){for(t=0;t<n.length;t++)if((r=n[t])<0||r>=l||r!==u(r))break e;if(0!==r)return!0}}}else if(null===n&&null===i&&(null===s||1===s||-1===s))return!0;throw Error(a+"Invalid BigNumber: "+e)},D.maximum=D.max=function(){return K(arguments,C.lt)},D.minimum=D.min=function(){return K(arguments,C.gt)},D.random=(s=9007199254740992*Math.random()&2097151?function(){return u(9007199254740992*Math.random())}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,r,n,i,o,f=0,l=[],p=new D(R);if(null==e?e=I:_(e,0,y),i=c(e/d),G)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(i*=2));f<i;)(o=131072*t[f]+(t[f+1]>>>11))>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),t[f]=r[0],t[f+1]=r[1]):(l.push(o%1e14),f+=2);f=i/2}else{if(!crypto.randomBytes)throw G=!1,Error(a+"crypto unavailable");for(t=crypto.randomBytes(i*=7);f<i;)(o=281474976710656*(31&t[f])+1099511627776*t[f+1]+4294967296*t[f+2]+16777216*t[f+3]+(t[f+4]<<16)+(t[f+5]<<8)+t[f+6])>=9e15?crypto.randomBytes(7).copy(t,f):(l.push(o%1e14),f+=7);f=i/7}if(!G)for(;f<i;)(o=s())<9e15&&(l[f++]=o%1e14);for(i=l[--f],e%=d,i&&e&&(o=h[d-e],l[f]=u(i/o)*o);0===l[f];l.pop(),f--);if(f<0)l=[n=0];else{for(n=-1;0===l[0];l.splice(0,1),n-=d);for(f=1,o=l[0];o>=10;o/=10,f++);f<d&&(n-=d-f)}return p.e=n,p.c=l,p}),D.sum=function(){for(var e=1,t=arguments,r=new D(t[0]);e<t.length;)r=r.plus(t[e++]);return r},n=function(){function e(e,t,r,n){for(var i,s,o=[0],c=0,u=e.length;c<u;){for(s=o.length;s--;o[s]*=t);for(o[0]+=n.indexOf(e.charAt(c++)),i=0;i<o.length;i++)o[i]>r-1&&(null==o[i+1]&&(o[i+1]=0),o[i+1]+=o[i]/r|0,o[i]%=r)}return o.reverse()}return function(t,n,i,s,o){var c,u,a,f,l,d,p,h,v=t.indexOf("."),y=I,b=x;for(v>=0&&(f=B,B=0,t=t.replace(".",""),d=(h=new D(n)).pow(t.length-v),B=f,h.c=e(w(g(d.c),d.e,"0"),10,i,"0123456789"),h.e=h.c.length),a=f=(p=e(t,n,i,o?(c=H,"0123456789"):(c="0123456789",H))).length;0==p[--f];p.pop());if(!p[0])return c.charAt(0);if(v<0?--a:(d.c=p,d.e=a,d.s=s,p=(d=r(d,h,y,b,i)).c,l=d.r,a=d.e),v=p[u=a+y+1],f=i/2,l=l||u<0||null!=p[u+1],l=b<4?(null!=v||l)&&(0==b||b==(d.s<0?3:2)):v>f||v==f&&(4==b||l||6==b&&1&p[u-1]||b==(d.s<0?8:7)),u<1||!p[0])t=l?w(c.charAt(1),-y,c.charAt(0)):c.charAt(0);else{if(p.length=u,l)for(--i;++p[--u]>i;)p[u]=0,u||(++a,p=[1].concat(p));for(f=p.length;!p[--f];);for(v=0,t="";v<=f;t+=c.charAt(p[v++]));t=w(t,a,c.charAt(0))}return t}}(),r=function(){function e(e,t,r){var n,i,s,o,c=0,u=e.length,a=t%v,f=t/v|0;for(e=e.slice();u--;)c=((i=a*(s=e[u]%v)+(n=f*s+(o=e[u]/v|0)*a)%v*v+c)/r|0)+(n/v|0)+f*o,e[u]=i%r;return c&&(e=[c].concat(e)),e}function t(e,t,r,n){var i,s;if(r!=n)s=r>n?1:-1;else for(i=s=0;i<r;i++)if(e[i]!=t[i]){s=e[i]>t[i]?1:-1;break}return s}function r(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]<t[r]?1:0,e[r]=i*n+e[r]-t[r];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(n,i,s,o,c){var a,f,p,h,v,y,g,m,_,E,S,w,A,T,O,N,k,C=n.s==i.s?1:-1,R=n.c,I=i.c;if(!(R&&R[0]&&I&&I[0]))return new D(n.s&&i.s&&(R?!I||R[0]!=I[0]:I)?R&&0==R[0]||!I?0*C:C/0:NaN);for(_=(m=new D(C)).c=[],C=s+(f=n.e-i.e)+1,c||(c=l,f=b(n.e/d)-b(i.e/d),C=C/d|0),p=0;I[p]==(R[p]||0);p++);if(I[p]>(R[p]||0)&&f--,C<0)_.push(1),h=!0;else{for(T=R.length,N=I.length,p=0,C+=2,(v=u(c/(I[0]+1)))>1&&(I=e(I,v,c),R=e(R,v,c),N=I.length,T=R.length),A=N,S=(E=R.slice(0,N)).length;S<N;E[S++]=0);k=I.slice(),k=[0].concat(k),O=I[0],I[1]>=c/2&&O++;do{if(v=0,(a=t(I,E,N,S))<0){if(w=E[0],N!=S&&(w=w*c+(E[1]||0)),(v=u(w/O))>1)for(v>=c&&(v=c-1),g=(y=e(I,v,c)).length,S=E.length;1==t(y,E,g,S);)v--,r(y,N<g?k:I,g,c),g=y.length,a=1;else 0==v&&(a=v=1),g=(y=I.slice()).length;if(g<S&&(y=[0].concat(y)),r(E,y,S,c),S=E.length,-1==a)for(;t(I,E,N,S)<1;)v++,r(E,N<S?k:I,S,c),S=E.length}else 0===a&&(v++,E=[0]);_[p++]=v,E[0]?E[S++]=R[A]||0:(E=[R[A]],S=1)}while((A++<T||null!=E[0])&&C--);h=null!=E[0],_[0]||_.splice(0,1)}if(c==l){for(p=1,C=_[0];C>=10;C/=10,p++);z(m,s+(m.e=p+f*d-1)+1,o,h)}else m.e=f,m.r=+h;return m}}(),A=/^(-?)0([xbo])(?=\w[\w.]*$)/i,T=/^([^.]+)\.$/,O=/^\.([^.]+)$/,N=/^-?(Infinity|NaN)$/,k=/^\s*\+(?=[\w.])|^\s+|\s+$/g,i=function(e,t,r,n){var i,s=r?t:t.replace(k,"");if(N.test(s))e.s=isNaN(s)?null:s<0?-1:1;else{if(!r&&(s=s.replace(A,function(e,t,r){return i="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=i?e:t}),n&&(i=n,s=s.replace(T,"$1").replace(O,"0.$1")),t!=s))return new D(s,i);if(D.DEBUG)throw Error(a+"Not a"+(n?" base "+n:"")+" number: "+t);e.s=null}e.c=e.e=null},C.absoluteValue=C.abs=function(){var e=new D(this);return e.s<0&&(e.s=1),e},C.comparedTo=function(e,t){return m(this,new D(e,t))},C.decimalPlaces=C.dp=function(e,t){var r,n,i,s=this;if(null!=e)return _(e,0,y),null==t?t=x:_(t,0,8),z(new D(s),e+s.e+1,t);if(!(r=s.c))return null;if(n=((i=r.length-1)-b(this.e/d))*d,i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},C.dividedBy=C.div=function(e,t){return r(this,new D(e,t),I,x)},C.dividedToIntegerBy=C.idiv=function(e,t){return r(this,new D(e,t),0,1)},C.exponentiatedBy=C.pow=function(e,t){var r,n,i,s,o,f,l,p,h=this;if((e=new D(e)).c&&!e.isInteger())throw Error(a+"Exponent not an integer: "+$(e));if(null!=t&&(t=new D(t)),o=e.e>14,!h.c||!h.c[0]||1==h.c[0]&&!h.e&&1==h.c.length||!e.c||!e.c[0])return p=new D(Math.pow(+$(h),o?2-E(e):+$(e))),t?p.mod(t):p;if(f=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new D(NaN);(n=!f&&h.isInteger()&&t.isInteger())&&(h=h.mod(t))}else{if(e.e>9&&(h.e>0||h.e<-1||(0==h.e?h.c[0]>1||o&&h.c[1]>=24e7:h.c[0]<8e13||o&&h.c[0]<=9999975e7)))return s=h.s<0&&E(e)?-0:0,h.e>-1&&(s=1/s),new D(f?1/s:s);B&&(s=c(B/d+2))}for(o?(r=new D(.5),f&&(e.s=1),l=E(e)):l=(i=Math.abs(+$(e)))%2,p=new D(R);;){if(l){if(!(p=p.times(h)).c)break;s?p.c.length>s&&(p.c.length=s):n&&(p=p.mod(t))}if(i){if(0===(i=u(i/2)))break;l=i%2}else if(z(e=e.times(r),e.e+1,1),e.e>14)l=E(e);else{if(0===(i=+$(e)))break;l=i%2}h=h.times(h),s?h.c&&h.c.length>s&&(h.c.length=s):n&&(h=h.mod(t))}return n?p:(f&&(p=R.div(p)),t?p.mod(t):s?z(p,B,x,void 0):p)},C.integerValue=function(e){var t=new D(this);return null==e?e=x:_(e,0,8),z(t,t.e+1,e)},C.isEqualTo=C.eq=function(e,t){return 0===m(this,new D(e,t))},C.isFinite=function(){return!!this.c},C.isGreaterThan=C.gt=function(e,t){return m(this,new D(e,t))>0},C.isGreaterThanOrEqualTo=C.gte=function(e,t){return 1===(t=m(this,new D(e,t)))||0===t},C.isInteger=function(){return!!this.c&&b(this.e/d)>this.c.length-2},C.isLessThan=C.lt=function(e,t){return m(this,new D(e,t))<0},C.isLessThanOrEqualTo=C.lte=function(e,t){return-1===(t=m(this,new D(e,t)))||0===t},C.isNaN=function(){return!this.s},C.isNegative=function(){return this.s<0},C.isPositive=function(){return this.s>0},C.isZero=function(){return!!this.c&&0==this.c[0]},C.minus=function(e,t){var r,n,i,s,o=this,c=o.s;if(t=(e=new D(e,t)).s,!c||!t)return new D(NaN);if(c!=t)return e.s=-t,o.plus(e);var u=o.e/d,a=e.e/d,f=o.c,p=e.c;if(!u||!a){if(!f||!p)return f?(e.s=-t,e):new D(p?o:NaN);if(!f[0]||!p[0])return p[0]?(e.s=-t,e):new D(f[0]?o:3==x?-0:0)}if(u=b(u),a=b(a),f=f.slice(),c=u-a){for((s=c<0)?(c=-c,i=f):(a=u,i=p),i.reverse(),t=c;t--;i.push(0));i.reverse()}else for(n=(s=(c=f.length)<(t=p.length))?c:t,c=t=0;t<n;t++)if(f[t]!=p[t]){s=f[t]<p[t];break}if(s&&(i=f,f=p,p=i,e.s=-e.s),(t=(n=p.length)-(r=f.length))>0)for(;t--;f[r++]=0);for(t=l-1;n>c;){if(f[--n]<p[n]){for(r=n;r&&!f[--r];f[r]=t);--f[r],f[n]+=l}f[n]-=p[n]}for(;0==f[0];f.splice(0,1),--a);return f[0]?q(e,f,a):(e.s=3==x?-1:1,e.c=[e.e=0],e)},C.modulo=C.mod=function(e,t){var n,i,s=this;return e=new D(e,t),!s.c||!e.s||e.c&&!e.c[0]?new D(NaN):!e.c||s.c&&!s.c[0]?new D(s):(9==U?(i=e.s,e.s=1,n=r(s,e,0,3),e.s=i,n.s*=i):n=r(s,e,0,U),(e=s.minus(n.times(e))).c[0]||1!=U||(e.s=s.s),e)},C.multipliedBy=C.times=function(e,t){var r,n,i,s,o,c,u,a,f,p,h,y,g,m,_,E=this,S=E.c,w=(e=new D(e,t)).c;if(!(S&&w&&S[0]&&w[0]))return!E.s||!e.s||S&&!S[0]&&!w||w&&!w[0]&&!S?e.c=e.e=e.s=null:(e.s*=E.s,S&&w?(e.c=[0],e.e=0):e.c=e.e=null),e;for(n=b(E.e/d)+b(e.e/d),e.s*=E.s,(u=S.length)<(p=w.length)&&(g=S,S=w,w=g,i=u,u=p,p=i),i=u+p,g=[];i--;g.push(0));for(m=l,_=v,i=p;--i>=0;){for(r=0,h=w[i]%_,y=w[i]/_|0,s=i+(o=u);s>i;)r=((a=h*(a=S[--o]%_)+(c=y*a+(f=S[o]/_|0)*h)%_*_+g[s]+r)/m|0)+(c/_|0)+y*f,g[s--]=a%m;g[s]=r}return r?++n:g.splice(0,1),q(e,g,n)},C.negated=function(){var e=new D(this);return e.s=-e.s||null,e},C.plus=function(e,t){var r,n=this,i=n.s;if(t=(e=new D(e,t)).s,!i||!t)return new D(NaN);if(i!=t)return e.s=-t,n.minus(e);var s=n.e/d,o=e.e/d,c=n.c,u=e.c;if(!s||!o){if(!c||!u)return new D(i/0);if(!c[0]||!u[0])return u[0]?e:new D(c[0]?n:0*i)}if(s=b(s),o=b(o),c=c.slice(),i=s-o){for(i>0?(o=s,r=u):(i=-i,r=c),r.reverse();i--;r.push(0));r.reverse()}for((i=c.length)-(t=u.length)<0&&(r=u,u=c,c=r,t=i),i=0;t;)i=(c[--t]=c[t]+u[t]+i)/l|0,c[t]=l===c[t]?0:c[t]%l;return i&&(c=[i].concat(c),++o),q(e,c,o)},C.precision=C.sd=function(e,t){var r,n,i,s=this;if(null!=e&&e!==!!e)return _(e,1,y),null==t?t=x:_(t,0,8),z(new D(s),e,t);if(!(r=s.c))return null;if(n=(i=r.length-1)*d+1,i=r[i]){for(;i%10==0;i/=10,n--);for(i=r[0];i>=10;i/=10,n++);}return e&&s.e+1>n&&(n=s.e+1),n},C.shiftedBy=function(e){return _(e,-p,p),this.times("1e"+e)},C.squareRoot=C.sqrt=function(){var e,t,n,i,s,o=this,c=o.c,u=o.s,a=o.e,f=I+4,l=new D("0.5");if(1!==u||!c||!c[0])return new D(!u||u<0&&(!c||c[0])?NaN:c?o:1/0);if(0==(u=Math.sqrt(+$(o)))||u==1/0?(((t=g(c)).length+a)%2==0&&(t+="0"),u=Math.sqrt(+t),a=b((a+1)/2)-(a<0||a%2),n=new D(t=u==1/0?"1e"+a:(t=u.toExponential()).slice(0,t.indexOf("e")+1)+a)):n=new D(u+""),n.c[0])for((u=(a=n.e)+f)<3&&(u=0);;)if(s=n,n=l.times(s.plus(r(o,s,f,1))),g(s.c).slice(0,u)===(t=g(n.c)).slice(0,u)){if(n.e<a&&--u,"9999"!=(t=t.slice(u-3,u+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(z(n,n.e+I+2,1),e=!n.times(n).eq(o));break}if(!i&&(z(s,s.e+I+2,0),s.times(s).eq(o))){n=s;break}f+=4,u+=4,i=1}return z(n,n.e+I+1,x,e)},C.toExponential=function(e,t){return null!=e&&(_(e,0,y),e++),W(this,e,t,1)},C.toFixed=function(e,t){return null!=e&&(_(e,0,y),e=e+this.e+1),W(this,e,t)},C.toFormat=function(e,t,r){var n,i=this;if(null==r)null!=e&&t&&"object"==typeof t?(r=t,t=null):e&&"object"==typeof e?(r=e,e=t=null):r=j;else if("object"!=typeof r)throw Error(a+"Argument not an object: "+r);if(n=i.toFixed(e,t),i.c){var s,o=n.split("."),c=+r.groupSize,u=+r.secondaryGroupSize,f=r.groupSeparator||"",l=o[0],d=o[1],p=i.s<0,h=p?l.slice(1):l,v=h.length;if(u&&(s=c,c=u,u=s,v-=s),c>0&&v>0){for(s=v%c||c,l=h.substr(0,s);s<v;s+=c)l+=f+h.substr(s,c);u>0&&(l+=f+h.slice(s)),p&&(l="-"+l)}n=d?l+(r.decimalSeparator||"")+((u=+r.fractionGroupSize)?d.replace(new RegExp("\\d{"+u+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):d):l}return(r.prefix||"")+n+(r.suffix||"")},C.toFraction=function(e){var t,n,i,s,o,c,u,f,l,p,v,y,b=this,m=b.c;if(null!=e&&(!(u=new D(e)).isInteger()&&(u.c||1!==u.s)||u.lt(R)))throw Error(a+"Argument "+(u.isInteger()?"out of range: ":"not an integer: ")+$(u));if(!m)return new D(b);for(t=new D(R),l=n=new D(R),i=f=new D(R),y=g(m),o=t.e=y.length-b.e-1,t.c[0]=h[(c=o%d)<0?d+c:c],e=!e||u.comparedTo(t)>0?o>0?t:l:u,c=F,F=1/0,u=new D(y),f.c[0]=0;p=r(u,t,0,1),1!=(s=n.plus(p.times(i))).comparedTo(e);)n=i,i=s,l=f.plus(p.times(s=l)),f=s,t=u.minus(p.times(s=t)),u=s;return s=r(e.minus(n),i,0,1),f=f.plus(s.times(l)),n=n.plus(s.times(i)),f.s=l.s=b.s,v=r(l,i,o*=2,x).minus(b).abs().comparedTo(r(f,n,o,x).minus(b).abs())<1?[l,i]:[f,n],F=c,v},C.toNumber=function(){return+$(this)},C.toPrecision=function(e,t){return null!=e&&_(e,1,y),W(this,e,t,2)},C.toString=function(e){var t,r=this,i=r.s,s=r.e;return null===s?i?(t="Infinity",i<0&&(t="-"+t)):t="NaN":(null==e?t=s<=P||s>=L?S(g(r.c),s):w(g(r.c),s,"0"):10===e?t=w(g((r=z(new D(r),I+s+1,x)).c),r.e,"0"):(_(e,2,H.length,"Base"),t=n(w(g(r.c),s,"0"),10,e,i,!0)),i<0&&r.c[0]&&(t="-"+t)),t},C.valueOf=C.toJSON=function(){return $(this)},C._isBigNumber=!0,null!=t&&D.set(t),D}()).default=s.BigNumber=s,void 0===(n=function(){return s}.call(t,r,t,e))||(e.exports=n)}()},70:function(e,t){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}},71:function(e,t){e.exports=function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}},72:function(e,t){e.exports=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}},85:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.HANDSHAKE="m_handshake",t.INIT="m_init",t.CONNECT="m_connect",t.DISCONNECT="m_disconnect",t.GET_INFO="m_get_info",t.GET_CURRENT_FIAT_RATES="m_get_current_fiat_rates",t.GET_FIAT_RATES_FOR_TIMESTAMPS="m_get_fiat_rates_for_timestamps",t.GET_ACCOUNT_BALANCE_HISTORY="m_get_account_balance_history",t.GET_FIAT_RATES_TICKERS_LIST="m_get_fiat_rates_tickers_list",t.GET_BLOCK_HASH="m_get_block_hash",t.GET_ACCOUNT_INFO="m_get_account_info",t.GET_ACCOUNT_UTXO="m_get_account_utxo",t.GET_TRANSACTION="m_get_transaction",t.ESTIMATE_FEE="m_estimate_fee",t.SUBSCRIBE="m_subscribe",t.UNSUBSCRIBE="m_unsubscribe",t.PUSH_TRANSACTION="m_push_tx"},86:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ERROR="r_error",t.CONNECT="r_connect",t.GET_INFO="r_info",t.GET_BLOCK_HASH="r_get_block_hash",t.GET_CURRENT_FIAT_RATES="r_get_current_fiat_rates",t.GET_FIAT_RATES_FOR_TIMESTAMPS="r_get_fiat_rates_for_timestamps",t.GET_FIAT_RATES_TICKERS_LIST="r_GET_FIAT_RATES_TICKERS_LIST",t.GET_ACCOUNT_INFO="r_account_info",t.GET_ACCOUNT_UTXO="r_get_account_utxo",t.GET_ACCOUNT_BALANCE_HISTORY="r_get_account_balance_history",t.GET_TRANSACTION="r_get_transaction",t.ESTIMATE_FEE="r_estimate_fee",t.SUBSCRIBE="r_subscribe",t.UNSUBSCRIBE="r_unsubscribe",t.PUSH_TRANSACTION="r_push_tx",t.CONNECTED="r_connected",t.DISCONNECTED="r_disconnected",t.NOTIFICATION="r_notification"},87:function(e,t,r){"use strict";var n=this&&this.__spreadArrays||function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),i=0;for(t=0;t<r;t++)for(var s=arguments[t],o=0,c=s.length;o<c;o++,i++)n[i]=s[o];return n};Object.defineProperty(t,"__esModule",{value:!0});var i=r(46),s=r(29),o=function(){function e(e){this.addresses=[],this.accounts=[],this.subscription={},this.settings={name:"unknown",worker:"unknown",server:[]},this.debugPrefix="[UnknownWorker]",this.post=function(){return console.warn("BlockchainLink:workers.common: postMessage method is not set")},void 0!==e&&(this.post=e)}return e.prototype.handshake=function(){this.post.call(null,{id:-1,type:i.MESSAGES.HANDSHAKE})},e.prototype.setSettings=function(e){this.settings=e,this.debugPrefix='[Worker "'+e.name+'"]:'},e.prototype.getSettings=function(){return this.settings},e.prototype.errorHandler=function(e){var t=e.id,r=e.error,n="blockchain_link/unknown",s=r.message;r.code&&(n=r.code),this.post.call(null,{id:t,type:i.RESPONSES.ERROR,payload:{code:n,message:s}})},e.prototype.response=function(e){this.post.call(null,this.removeEmpty(e))},e.prototype.validateAddresses=function(e){if(!Array.isArray(e))throw new s.CustomError("invalid_param","+addresses");var t=[];return e.filter(function(e){return"string"==typeof e&&(!(t.indexOf(e)>=0)&&(t.push(e),!0))})},e.prototype.addAddresses=function(e){var t=this,r=this.validateAddresses(e).filter(function(e){return t.addresses.indexOf(e)<0});return this.addresses=this.addresses.concat(r),r},e.prototype.getAddresses=function(){return this.addresses},e.prototype.removeAddresses=function(e){var t=this.validateAddresses(e);return this.addresses=this.addresses.filter(function(e){return t.indexOf(e)<0}),this.addresses},e.prototype.validateAccounts=function(e){if(!Array.isArray(e))throw new s.CustomError("invalid_param","+accounts");var t=[];return e.filter(function(e){return!(!e||"object"!=typeof e||"string"!=typeof e.descriptor)&&(!(t.indexOf(e.descriptor)>=0)&&(t.push(e.descriptor),!0))})},e.prototype.getAccountAddresses=function(e){if(e.addresses){var t=e.addresses,r=t.change,n=t.used,i=t.unused;return r.concat(n,i).map(function(e){return e.address})}return[e.descriptor]},e.prototype.addAccounts=function(e){var t=this,r=this.validateAccounts(e),n=this.accounts.filter(function(e){return!r.find(function(t){return t.descriptor===e.descriptor})});this.accounts=n.concat(r);var i=this.accounts.reduce(function(e,r){return e.concat(t.getAccountAddresses(r))},[]);return this.addAddresses(i),r},e.prototype.getAccount=function(e){return this.accounts.find(function(t){if(t.descriptor===e)return!0;if(t.addresses){var r=t.addresses,n=r.change,i=r.used,s=r.unused;if(n.find(function(t){return t.address===e}))return!0;if(i.find(function(t){return t.address===e}))return!0;if(s.find(function(t){return t.address===e}))return!0}return!1})},e.prototype.getAccounts=function(){return this.accounts},e.prototype.removeAccounts=function(e){var t=this,r=this.validateAccounts(e),n=this.accounts.filter(function(e){return r.find(function(t){return t.descriptor===e.descriptor})}),i=n.reduce(function(e,r){return e.concat(t.getAccountAddresses(r))},[]);return this.accounts=this.accounts.filter(function(e){return n.indexOf(e)<0}),this.removeAddresses(i),this.accounts},e.prototype.addSubscription=function(e){this.subscription[e]=!0},e.prototype.getSubscription=function(e){return this.subscription[e]},e.prototype.hasSubscriptions=function(){return Object.keys(this.subscription).length>0},e.prototype.removeSubscription=function(e){delete this.subscription[e]},e.prototype.clearSubscriptions=function(){var e=this;Object.keys(this.subscription).forEach(function(t){delete e.subscription[t]})},e.prototype.shuffleEndpoints=function(e){for(var t,r=e.length-1;r>0;r--){var n=Math.floor(Math.random()*(r+1));t=[e[n],e[r]],e[r]=t[0],e[n]=t[1]}return e},e.prototype.removeEmpty=function(e){var t=this;return Object.keys(e).forEach(function(r){e[r]&&"object"==typeof e[r]?t.removeEmpty(e[r]):void 0===e[r]&&delete e[r]}),e},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.settings&&this.settings.debug&&("warn"===e[0]||"error"===e[0]?console[e[0]].apply(console,n([this.debugPrefix],e.slice(1))):console.log.apply(console,n([this.debugPrefix],e)))},e}();t.default=o}});

@@ -0,44 +1,69 @@

# 1.0.9
#### changes
- Added new Blockbook methods for fiat rates (`getAccountBalanceHistory`, `getCurrentFiatRates`, `getFiatRatesForTimestamps`, `getFiatRatesTickersList`)
# 1.0.8
#### changes
- Fix: Ripple notification dispatched for both, sender and receiver
- Fix: Ripple notification dispatched for both, sender and receiver
# 1.0.7
#### changes
- Update outdated node_modules
- Ripple worker: different reconnection schema since RippleApi@1.6.3
- Ripple worker: fixed bug with `minLedgerVersion` since RippleApi@1.6.3
- Update outdated node_modules
- Ripple worker: different reconnection schema since RippleApi@1.6.3
- Ripple worker: fixed bug with `minLedgerVersion` since RippleApi@1.6.3
# 1.0.6
#### changes
- Fix for react-native workers
- Update outdated node_modules
- Fix for react-native workers
- Update outdated node_modules
# 1.0.5
#### changes
- Fixed Ripple-lib transaction event transformation (missing ledger_index field in transaction object)
- Fixed Ripple-lib transaction event transformation (missing ledger_index field in transaction object)
# 1.0.4
#### changes
- Update dependencies (ripple-lib@1.4.0) and fix reconnection issue
- Update types for ERC20 tokens
- Update dependencies (ripple-lib@1.4.0) and fix reconnection issue
- Update types for ERC20 tokens
# 1.0.3
#### changes
- Add currently connected url to 'getInfo' response
- Fixed getAccountInfo 'blockbook' type: empty = (transactions === 0 && unconfirmedTransactions === 0)
- Add currently connected url to 'getInfo' response
- Fixed getAccountInfo 'blockbook' type: empty = (transactions === 0 && unconfirmedTransactions === 0)
# 1.0.2
#### changes
- Fixed getTransaction response
- Fixed getTransaction response
# 1.0.1
#### changes
- Fixed amount calculation in blockbook Transactions
- Fixed amount calculation in blockbook Transactions
# 1.0.0-rc3
#### changes
- Added possibility to export workers as a main thread module (using webpack build)
- ./src/workers/common.ts changed to class for multiple instance usage
- Added possibility to export workers as a main thread module (using webpack build)
- ./src/workers/common.ts changed to class for multiple instance usage
# 1.0.0-rc1
- First release
- First release

@@ -6,2 +6,6 @@ export declare const HANDSHAKE = "m_handshake";

export declare const GET_INFO = "m_get_info";
export declare const GET_CURRENT_FIAT_RATES = "m_get_current_fiat_rates";
export declare const GET_FIAT_RATES_FOR_TIMESTAMPS = "m_get_fiat_rates_for_timestamps";
export declare const GET_ACCOUNT_BALANCE_HISTORY = "m_get_account_balance_history";
export declare const GET_FIAT_RATES_TICKERS_LIST = "m_get_fiat_rates_tickers_list";
export declare const GET_BLOCK_HASH = "m_get_block_hash";

@@ -8,0 +12,0 @@ export declare const GET_ACCOUNT_INFO = "m_get_account_info";

@@ -8,2 +8,6 @@ "use strict";

exports.GET_INFO = 'm_get_info';
exports.GET_CURRENT_FIAT_RATES = 'm_get_current_fiat_rates';
exports.GET_FIAT_RATES_FOR_TIMESTAMPS = 'm_get_fiat_rates_for_timestamps';
exports.GET_ACCOUNT_BALANCE_HISTORY = 'm_get_account_balance_history';
exports.GET_FIAT_RATES_TICKERS_LIST = 'm_get_fiat_rates_tickers_list';
exports.GET_BLOCK_HASH = 'm_get_block_hash';

@@ -10,0 +14,0 @@ exports.GET_ACCOUNT_INFO = 'm_get_account_info';

@@ -5,4 +5,8 @@ export declare const ERROR = "r_error";

export declare const GET_BLOCK_HASH = "r_get_block_hash";
export declare const GET_CURRENT_FIAT_RATES = "r_get_current_fiat_rates";
export declare const GET_FIAT_RATES_FOR_TIMESTAMPS = "r_get_fiat_rates_for_timestamps";
export declare const GET_FIAT_RATES_TICKERS_LIST = "r_GET_FIAT_RATES_TICKERS_LIST";
export declare const GET_ACCOUNT_INFO = "r_account_info";
export declare const GET_ACCOUNT_UTXO = "r_get_account_utxo";
export declare const GET_ACCOUNT_BALANCE_HISTORY = "r_get_account_balance_history";
export declare const GET_TRANSACTION = "r_get_transaction";

@@ -9,0 +13,0 @@ export declare const ESTIMATE_FEE = "r_estimate_fee";

@@ -7,4 +7,8 @@ "use strict";

exports.GET_BLOCK_HASH = 'r_get_block_hash';
exports.GET_CURRENT_FIAT_RATES = 'r_get_current_fiat_rates';
exports.GET_FIAT_RATES_FOR_TIMESTAMPS = 'r_get_fiat_rates_for_timestamps';
exports.GET_FIAT_RATES_TICKERS_LIST = 'r_GET_FIAT_RATES_TICKERS_LIST';
exports.GET_ACCOUNT_INFO = 'r_account_info';
exports.GET_ACCOUNT_UTXO = 'r_get_account_utxo';
exports.GET_ACCOUNT_BALANCE_HISTORY = 'r_get_account_balance_history';
exports.GET_TRANSACTION = 'r_get_transaction';

@@ -11,0 +15,0 @@ exports.ESTIMATE_FEE = 'r_estimate_fee';

@@ -27,2 +27,6 @@ /// <reference types="node" />

getTransaction(payload: MessageTypes.GetTransaction['payload']): Promise<ResponseTypes.GetTransaction['payload']>;
getAccountBalanceHistory(payload: MessageTypes.GetAccountBalanceHistory['payload']): Promise<ResponseTypes.GetAccountBalanceHistory['payload']>;
getCurrentFiatRates(payload: MessageTypes.GetCurrentFiatRates['payload']): Promise<ResponseTypes.GetCurrentFiatRates['payload']>;
getFiatRatesForTimestamps(payload: MessageTypes.GetFiatRatesForTimestamps['payload']): Promise<ResponseTypes.GetFiatRatesForTimestamps['payload']>;
getFiatRatesTickersList(payload: MessageTypes.GetFiatRatesTickersList['payload']): Promise<ResponseTypes.GetFiatRatesTickersList['payload']>;
estimateFee(payload: MessageTypes.EstimateFee['payload']): Promise<ResponseTypes.EstimateFee['payload']>;

@@ -29,0 +33,0 @@ subscribe(payload: MessageTypes.Subscribe['payload']): Promise<ResponseTypes.Subscribe['payload']>;

@@ -260,2 +260,42 @@ "use strict";

};
BlockchainLink.prototype.getAccountBalanceHistory = function (payload) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2, this.sendMessage({
type: constants_1.MESSAGES.GET_ACCOUNT_BALANCE_HISTORY,
payload: payload,
})];
});
});
};
BlockchainLink.prototype.getCurrentFiatRates = function (payload) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2, this.sendMessage({
type: constants_1.MESSAGES.GET_CURRENT_FIAT_RATES,
payload: payload,
})];
});
});
};
BlockchainLink.prototype.getFiatRatesForTimestamps = function (payload) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2, this.sendMessage({
type: constants_1.MESSAGES.GET_FIAT_RATES_FOR_TIMESTAMPS,
payload: payload,
})];
});
});
};
BlockchainLink.prototype.getFiatRatesTickersList = function (payload) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2, this.sendMessage({
type: constants_1.MESSAGES.GET_FIAT_RATES_TICKERS_LIST,
payload: payload,
})];
});
});
};
BlockchainLink.prototype.estimateFee = function (payload) {

@@ -262,0 +302,0 @@ return __awaiter(this, void 0, void 0, function () {

@@ -0,1 +1,2 @@

import { AccountBalanceHistoryParams, GetCurrentFiatRates, GetFiatRatesForTimestamps, GetFiatRatesTickersList, AccountInfoParams, EstimateFeeParams } from './messages';
export interface Subscribe {

@@ -17,13 +18,2 @@ subscribed: boolean;

}
export interface AccountInfoParams {
descriptor: string;
details?: 'basic' | 'tokens' | 'tokenBalances' | 'txids' | 'txs';
tokens?: 'nonzero' | 'used' | 'derived';
page?: number;
pageSize?: number;
from?: number;
to?: number;
contractFilter?: string;
gap?: number;
}
export interface XPUBAddress {

@@ -119,12 +109,2 @@ type: 'XPUBAddress';

}
export interface EstimateFeeParams {
blocks?: number[];
specific?: {
conservative?: boolean;
txsize?: number;
from?: string;
to?: string;
data?: string;
};
}
export declare type Fee = {

@@ -135,2 +115,5 @@ feePerUnit: string;

}[];
export interface FiatRates {
[symbol: string]: number | undefined;
}
export interface BlockNotification {

@@ -144,2 +127,23 @@ height: number;

}
export interface FiatRatesNotification {
rates: FiatRates;
}
export interface TimestampedFiatRates {
ts: number;
rates: FiatRates;
}
export interface FiatRatesForTimestamp {
tickers: TimestampedFiatRates[];
}
export interface AccountBalanceHistory {
time: number;
txs: number;
received: string;
sent: string;
fiatRate: number;
}
export interface AvailableCurrencies {
ts: number;
available_currencies: string[];
}
declare function FSend(method: 'getInfo', params: {}): Promise<ServerInfo>;

@@ -157,2 +161,6 @@ declare function FSend(method: 'getBlockHash', params: {

}): Promise<Push>;
declare function FSend(method: 'getBalanceHistory', params: AccountBalanceHistoryParams): Promise<AccountBalanceHistory[]>;
declare function FSend(method: 'getCurrentFiatRates', params: GetCurrentFiatRates['payload']): Promise<TimestampedFiatRates>;
declare function FSend(method: 'getFiatRatesTickersList', params: GetFiatRatesTickersList['payload']): Promise<AvailableCurrencies>;
declare function FSend(method: 'getFiatRatesForTimestamps', params: GetFiatRatesForTimestamps['payload']): Promise<FiatRatesForTimestamp>;
declare function FSend(method: 'estimateFee', params: EstimateFeeParams): Promise<Fee>;

@@ -165,3 +173,7 @@ declare function FSend(method: 'subscribeAddresses', params: {

declare function FSend(method: 'unsubscribeNewBlock', params: {}): Promise<Subscribe>;
declare function FSend(method: 'subscribeFiatRates', params: {
currency?: string;
}): Promise<Subscribe>;
declare function FSend(method: 'unsubscribeFiatRates', params: {}): Promise<Subscribe>;
export declare type Send = typeof FSend;
export {};

@@ -16,19 +16,20 @@ import { SubscriptionAccountInfo, BlockchainSettings } from './common';

}
export interface AccountInfoParams {
descriptor: string;
details?: 'basic' | 'tokens' | 'tokenBalances' | 'txids' | 'txs';
tokens?: 'nonzero' | 'used' | 'derived';
page?: number;
pageSize?: number;
from?: number;
to?: number;
contractFilter?: string;
gap?: number;
marker?: {
ledger: number;
seq: number;
};
}
export interface GetAccountInfo {
type: typeof MESSAGES.GET_ACCOUNT_INFO;
payload: {
descriptor: string;
details?: 'basic' | 'tokens' | 'tokenBalances' | 'txids' | 'txs';
tokens?: 'nonzero' | 'used' | 'derived';
page?: number;
pageSize?: number;
from?: number;
to?: number;
contractFilter?: string;
gap?: number;
marker?: {
ledger: number;
seq: number;
};
};
payload: AccountInfoParams;
}

@@ -43,3 +44,33 @@ export interface GetAccountUtxo {

}
export interface EstimateFeeOptions {
export interface GetFiatRatesTickersList {
type: typeof MESSAGES.GET_FIAT_RATES_TICKERS_LIST;
payload: {
timestamp?: number;
};
}
export interface AccountBalanceHistoryParams {
descriptor: string;
from: number;
to: number;
currencies?: string[];
groupBy?: number;
}
export interface GetAccountBalanceHistory {
type: typeof MESSAGES.GET_ACCOUNT_BALANCE_HISTORY;
payload: AccountBalanceHistoryParams;
}
export interface GetCurrentFiatRates {
type: typeof MESSAGES.GET_CURRENT_FIAT_RATES;
payload: {
currencies?: string[];
};
}
export interface GetFiatRatesForTimestamps {
type: typeof MESSAGES.GET_FIAT_RATES_FOR_TIMESTAMPS;
payload: {
timestamps: number[];
currencies?: string[];
};
}
export interface EstimateFeeParams {
blocks?: number[];

@@ -56,3 +87,3 @@ specific?: {

type: typeof MESSAGES.ESTIMATE_FEE;
payload: EstimateFeeOptions;
payload: EstimateFeeParams;
}

@@ -69,2 +100,5 @@ export interface Subscribe {

accounts: SubscriptionAccountInfo[];
} | {
type: 'fiatRates';
currency?: string;
};

@@ -82,2 +116,4 @@ }

accounts?: SubscriptionAccountInfo[];
} | {
type: 'fiatRates';
};

@@ -109,2 +145,10 @@ }

id: number;
} & GetCurrentFiatRates) | ({
id: number;
} & GetFiatRatesForTimestamps) | ({
id: number;
} & GetAccountBalanceHistory) | ({
id: number;
} & GetFiatRatesTickersList) | ({
id: number;
} & EstimateFee) | ({

@@ -111,0 +155,0 @@ id: number;

import { FormattedTransactionType as RippleTransaction } from 'ripple-lib';
import { Transaction as BlockbookTransaction } from './blockbook';
import { Transaction as BlockbookTransaction, FiatRates, AccountBalanceHistory } from './blockbook';
import { HANDSHAKE } from '../constants/messages';

@@ -62,2 +62,29 @@ import * as RESPONSES from '../constants/responses';

}
export interface GetAccountBalanceHistory {
type: typeof RESPONSES.GET_ACCOUNT_BALANCE_HISTORY;
payload: AccountBalanceHistory[];
}
export interface GetCurrentFiatRates {
type: typeof RESPONSES.GET_CURRENT_FIAT_RATES;
payload: {
ts: number;
rates: FiatRates;
};
}
export interface GetFiatRatesForTimestamps {
type: typeof RESPONSES.GET_FIAT_RATES_FOR_TIMESTAMPS;
payload: {
tickers: {
ts: number;
rates: FiatRates;
}[];
};
}
export interface GetFiatRatesTickersList {
type: typeof RESPONSES.GET_FIAT_RATES_TICKERS_LIST;
payload: {
ts: number;
availableCurrencies: string[];
};
}
export interface EstimateFee {

@@ -97,5 +124,11 @@ type: typeof RESPONSES.ESTIMATE_FEE;

}
export interface FiatRatesEvent {
type: 'fiatRates';
payload: {
rates: FiatRates;
};
}
export interface Notification {
type: typeof RESPONSES.NOTIFICATION;
payload: BlockEvent | NotificationEvent;
payload: BlockEvent | NotificationEvent | FiatRatesEvent;
}

@@ -131,2 +164,10 @@ export interface PushTransaction {

id: number;
} & GetAccountBalanceHistory) | ({
id: number;
} & GetCurrentFiatRates) | ({
id: number;
} & GetFiatRatesForTimestamps) | ({
id: number;
} & GetFiatRatesTickersList) | ({
id: number;
} & EstimateFee) | ({

@@ -133,0 +174,0 @@ id: number;

@@ -241,4 +241,123 @@ "use strict";

}); };
var getAccountBalanceHistory = function (data) { return __awaiter(void 0, void 0, void 0, function () {
var payload, socket, history, error_6;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
payload = data.payload;
_a.label = 1;
case 1:
_a.trys.push([1, 4, , 5]);
return [4, connect()];
case 2:
socket = _a.sent();
return [4, socket.getAccountBalanceHistory(payload)];
case 3:
history = _a.sent();
common.response({
id: data.id,
type: constants_1.RESPONSES.GET_ACCOUNT_BALANCE_HISTORY,
payload: history,
});
return [3, 5];
case 4:
error_6 = _a.sent();
common.errorHandler({ id: data.id, error: error_6 });
return [3, 5];
case 5: return [2];
}
});
}); };
var getCurrentFiatRates = function (data) { return __awaiter(void 0, void 0, void 0, function () {
var payload, socket, fiatRates, error_7;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
payload = data.payload;
_a.label = 1;
case 1:
_a.trys.push([1, 4, , 5]);
return [4, connect()];
case 2:
socket = _a.sent();
return [4, socket.getCurrentFiatRates(payload)];
case 3:
fiatRates = _a.sent();
common.response({
id: data.id,
type: constants_1.RESPONSES.GET_CURRENT_FIAT_RATES,
payload: fiatRates,
});
return [3, 5];
case 4:
error_7 = _a.sent();
common.errorHandler({ id: data.id, error: error_7 });
return [3, 5];
case 5: return [2];
}
});
}); };
var getFiatRatesForTimestamps = function (data) { return __awaiter(void 0, void 0, void 0, function () {
var payload, socket, tickers, error_8;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
payload = data.payload;
_a.label = 1;
case 1:
_a.trys.push([1, 4, , 5]);
return [4, connect()];
case 2:
socket = _a.sent();
return [4, socket.getFiatRatesForTimestamps(payload)];
case 3:
tickers = (_a.sent()).tickers;
common.response({
id: data.id,
type: constants_1.RESPONSES.GET_FIAT_RATES_FOR_TIMESTAMPS,
payload: { tickers: tickers },
});
return [3, 5];
case 4:
error_8 = _a.sent();
common.errorHandler({ id: data.id, error: error_8 });
return [3, 5];
case 5: return [2];
}
});
}); };
var getFiatRatesTickersList = function (data) { return __awaiter(void 0, void 0, void 0, function () {
var payload, socket, tickers, error_9;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
payload = data.payload;
_a.label = 1;
case 1:
_a.trys.push([1, 4, , 5]);
return [4, connect()];
case 2:
socket = _a.sent();
return [4, socket.getFiatRatesTickersList(payload)];
case 3:
tickers = _a.sent();
common.response({
id: data.id,
type: constants_1.RESPONSES.GET_FIAT_RATES_TICKERS_LIST,
payload: {
ts: tickers.ts,
availableCurrencies: tickers.available_currencies,
},
});
return [3, 5];
case 4:
error_9 = _a.sent();
common.errorHandler({ id: data.id, error: error_9 });
return [3, 5];
case 5: return [2];
}
});
}); };
var getTransaction = function (data) { return __awaiter(void 0, void 0, void 0, function () {
var payload, socket, tx, error_6;
var payload, socket, tx, error_10;
return __generator(this, function (_a) {

@@ -267,4 +386,4 @@ switch (_a.label) {

case 4:
error_6 = _a.sent();
common.errorHandler({ id: data.id, error: error_6 });
error_10 = _a.sent();
common.errorHandler({ id: data.id, error: error_10 });
return [3, 5];

@@ -276,3 +395,3 @@ case 5: return [2];

var pushTransaction = function (data) { return __awaiter(void 0, void 0, void 0, function () {
var socket, resp, error_7;
var socket, resp, error_11;
return __generator(this, function (_a) {

@@ -295,4 +414,4 @@ switch (_a.label) {

case 3:
error_7 = _a.sent();
common.errorHandler({ id: data.id, error: error_7 });
error_11 = _a.sent();
common.errorHandler({ id: data.id, error: error_11 });
return [3, 4];

@@ -304,3 +423,3 @@ case 4: return [2];

var estimateFee = function (data) { return __awaiter(void 0, void 0, void 0, function () {
var socket, resp, error_8;
var socket, resp, error_12;
return __generator(this, function (_a) {

@@ -323,4 +442,4 @@ switch (_a.label) {

case 3:
error_8 = _a.sent();
common.errorHandler({ id: data.id, error: error_8 });
error_12 = _a.sent();
common.errorHandler({ id: data.id, error: error_12 });
return [3, 4];

@@ -363,2 +482,14 @@ case 4: return [2];

};
var onNewFiatRates = function (event) {
common.response({
id: -1,
type: constants_1.RESPONSES.NOTIFICATION,
payload: {
type: 'fiatRates',
payload: {
rates: event.rates,
},
},
});
};
var subscribeAccounts = function (accounts) { return __awaiter(void 0, void 0, void 0, function () {

@@ -414,4 +545,19 @@ var socket;

}); };
var subscribeFiatRates = function (currency) { return __awaiter(void 0, void 0, void 0, function () {
var socket;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4, connect()];
case 1:
socket = _a.sent();
if (!common.getSubscription('fiatRates')) {
common.addSubscription('fiatRates');
socket.on('fiatRates', onNewFiatRates);
}
return [2, socket.subscribeFiatRates(currency)];
}
});
}); };
var subscribe = function (data) { return __awaiter(void 0, void 0, void 0, function () {
var payload, response, error_9;
var payload, response, error_13;
return __generator(this, function (_a) {

@@ -423,3 +569,3 @@ switch (_a.label) {

case 1:
_a.trys.push([1, 9, , 10]);
_a.trys.push([1, 11, , 12]);
response = void 0;

@@ -430,3 +576,3 @@ if (!(payload.type === 'accounts')) return [3, 3];

response = _a.sent();
return [3, 8];
return [3, 10];
case 3:

@@ -437,3 +583,3 @@ if (!(payload.type === 'addresses')) return [3, 5];

response = _a.sent();
return [3, 8];
return [3, 10];
case 5:

@@ -444,5 +590,11 @@ if (!(payload.type === 'block')) return [3, 7];

response = _a.sent();
return [3, 8];
case 7: throw new errors_1.CustomError('invalid_param', '+type');
return [3, 10];
case 7:
if (!(payload.type === 'fiatRates')) return [3, 9];
return [4, subscribeFiatRates(payload.currency)];
case 8:
response = _a.sent();
return [3, 10];
case 9: throw new errors_1.CustomError('invalid_param', '+type');
case 10:
common.response({

@@ -453,8 +605,8 @@ id: data.id,

});
return [3, 10];
case 9:
error_9 = _a.sent();
common.errorHandler({ id: data.id, error: error_9 });
return [3, 10];
case 10: return [2];
return [3, 12];
case 11:
error_13 = _a.sent();
common.errorHandler({ id: data.id, error: error_13 });
return [3, 12];
case 12: return [2];
}

@@ -518,4 +670,20 @@ });

}); };
var unsubscribeFiatRates = function () { return __awaiter(void 0, void 0, void 0, function () {
var socket;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!common.getSubscription('fiatRates'))
return [2, { subscribed: false }];
return [4, connect()];
case 1:
socket = _a.sent();
socket.removeListener('fiatRates', onNewBlock);
common.removeSubscription('fiatRates');
return [2, socket.unsubscribeFiatRates()];
}
});
}); };
var unsubscribe = function (data) { return __awaiter(void 0, void 0, void 0, function () {
var payload, response, error_10;
var payload, response, error_14;
return __generator(this, function (_a) {

@@ -527,3 +695,3 @@ switch (_a.label) {

case 1:
_a.trys.push([1, 9, , 10]);
_a.trys.push([1, 11, , 12]);
response = void 0;

@@ -534,3 +702,3 @@ if (!(payload.type === 'accounts')) return [3, 3];

response = _a.sent();
return [3, 8];
return [3, 10];
case 3:

@@ -541,3 +709,3 @@ if (!(payload.type === 'addresses')) return [3, 5];

response = _a.sent();
return [3, 8];
return [3, 10];
case 5:

@@ -548,5 +716,11 @@ if (!(payload.type === 'block')) return [3, 7];

response = _a.sent();
return [3, 8];
case 7: throw new errors_1.CustomError('invalid_param', '+type');
return [3, 10];
case 7:
if (!(payload.type === 'fiatRates')) return [3, 9];
return [4, unsubscribeFiatRates()];
case 8:
response = _a.sent();
return [3, 10];
case 9: throw new errors_1.CustomError('invalid_param', '+type');
case 10:
common.response({

@@ -557,8 +731,8 @@ id: data.id,

});
return [3, 10];
case 9:
error_10 = _a.sent();
common.errorHandler({ id: data.id, error: error_10 });
return [3, 10];
case 10: return [2];
return [3, 12];
case 11:
error_14 = _a.sent();
common.errorHandler({ id: data.id, error: error_14 });
return [3, 12];
case 12: return [2];
}

@@ -568,3 +742,3 @@ });

var disconnect = function (data) { return __awaiter(void 0, void 0, void 0, function () {
var error_11;
var error_15;
return __generator(this, function (_a) {

@@ -586,4 +760,4 @@ switch (_a.label) {

case 3:
error_11 = _a.sent();
common.errorHandler({ id: data.id, error: error_11 });
error_15 = _a.sent();
common.errorHandler({ id: data.id, error: error_15 });
return [3, 4];

@@ -629,2 +803,14 @@ case 4: return [2];

break;
case constants_1.MESSAGES.GET_ACCOUNT_BALANCE_HISTORY:
getAccountBalanceHistory(data);
break;
case constants_1.MESSAGES.GET_CURRENT_FIAT_RATES:
getCurrentFiatRates(data);
break;
case constants_1.MESSAGES.GET_FIAT_RATES_FOR_TIMESTAMPS:
getFiatRatesForTimestamps(data);
break;
case constants_1.MESSAGES.GET_FIAT_RATES_TICKERS_LIST:
getFiatRatesTickersList(data);
break;
case constants_1.MESSAGES.ESTIMATE_FEE:

@@ -631,0 +817,0 @@ estimateFee(data);

@@ -5,6 +5,7 @@ /// <reference types="node" />

import { Deferred } from '../../utils/deferred';
import { AccountInfoParams, EstimateFeeParams, Send } from '../../types/blockbook';
import { Send } from '../../types/blockbook';
import { GetFiatRatesForTimestamps, GetFiatRatesTickersList, AccountInfoParams, EstimateFeeParams, AccountBalanceHistoryParams, GetCurrentFiatRates } from '../../types/messages';
interface Subscription {
id: string;
type: 'notification' | 'block';
type: 'notification' | 'block' | 'fiatRates';
callback: (result: any) => void;

@@ -46,2 +47,6 @@ }

estimateFee(payload: EstimateFeeParams): Promise<import("../../types/blockbook").Fee>;
getCurrentFiatRates(payload: GetCurrentFiatRates['payload']): Promise<import("../../types/blockbook").TimestampedFiatRates>;
getAccountBalanceHistory(payload: AccountBalanceHistoryParams): Promise<import("../../types/blockbook").AccountBalanceHistory[]>;
getFiatRatesForTimestamps(payload: GetFiatRatesForTimestamps['payload']): Promise<import("../../types/blockbook").FiatRatesForTimestamp>;
getFiatRatesTickersList(payload: GetFiatRatesTickersList['payload']): Promise<import("../../types/blockbook").AvailableCurrencies>;
subscribeAddresses(addresses: string[]): Promise<import("../../types/blockbook").Subscribe>;

@@ -55,4 +60,8 @@ unsubscribeAddresses(): Promise<import("../../types/blockbook").Subscribe> | {

};
subscribeFiatRates(currency?: string): Promise<import("../../types/blockbook").Subscribe>;
unsubscribeFiatRates(): Promise<import("../../types/blockbook").Subscribe> | {
subscribed: boolean;
};
dispose(): void;
}
export {};

@@ -256,2 +256,14 @@ "use strict";

};
Socket.prototype.getCurrentFiatRates = function (payload) {
return this.send('getCurrentFiatRates', payload);
};
Socket.prototype.getAccountBalanceHistory = function (payload) {
return this.send('getBalanceHistory', payload);
};
Socket.prototype.getFiatRatesForTimestamps = function (payload) {
return this.send('getFiatRatesForTimestamps', payload);
};
Socket.prototype.getFiatRatesTickersList = function (payload) {
return this.send('getFiatRatesTickersList', payload);
};
Socket.prototype.subscribeAddresses = function (addresses) {

@@ -305,2 +317,26 @@ var _this = this;

};
Socket.prototype.subscribeFiatRates = function (currency) {
var _this = this;
var index = this.subscriptions.findIndex(function (s) { return s.type === 'fiatRates'; });
if (index >= 0) {
this.subscriptions.splice(index, 1);
}
var id = this.messageID.toString();
this.subscriptions.push({
id: id,
type: 'fiatRates',
callback: function (result) {
_this.emit('fiatRates', result);
},
});
return this.send('subscribeFiatRates', { currency: currency });
};
Socket.prototype.unsubscribeFiatRates = function () {
var index = this.subscriptions.findIndex(function (s) { return s.type === 'fiatRates'; });
if (index >= 0) {
this.subscriptions.splice(index, 1);
return this.send('unsubscribeFiatRates', {});
}
return { subscribed: false };
};
Socket.prototype.dispose = function () {

@@ -307,0 +343,0 @@ if (this.pingTimeout) {

{
"name": "@trezor/blockchain-link",
"version": "1.0.8",
"author": "Trezor <info@trezor.io>",
"homepage": "https://github.com/trezor/trezor-suite/packages/blockchain-link",
"description": "High-level javascript interface for blockchain communication",
"license": "SEE LICENSE IN LICENSE.md",
"repository": {
"type": "git",
"url": "git://github.com/trezor/trezor-suite.git"
},
"bugs": {
"url": "https://github.com/trezor/trezor-suite/issues"
},
"keywords": [
"Trezor",
"blockchain",
"blockbook",
"javascript"
],
"main": "./lib/index.js",
"browser": {
"ws": "./lib/utils/ws.js"
},
"scripts": {
"dev": "npx webpack-dev-server --config ./webpack/dev.babel.js --mode development",
"build:lib": "yarn build && yarn build:workers",
"build:workers": "rimraf build && yarn build:workers-web && yarn build:workers-node && yarn build:workers-module",
"build:workers-web": "webpack --config ./webpack/workers.web.babel.js --mode production",
"build:workers-node": "webpack --config ./webpack/workers.node.babel.js --mode production",
"build:workers-module": "webpack --config ./webpack/workers.module.babel.js --mode production",
"lint": "eslint '**/*{.ts,.tsx}'",
"test:unit": "jest --verbose -c jest.config.unit.js",
"test:node": "jest -c jest.config.integration.js",
"build": "rimraf lib && tsc --p ./tsconfig.lib.json && tsc --p ./tsconfig.workers.json",
"type-check": "tsc --project tsconfig.json"
},
"devDependencies": {
"@babel/register": "^7.8.6",
"@babel/runtime": "7.8.7",
"babel-eslint": "^10.1.0",
"babel-jest": "^25.1.0",
"babel-loader": "^8.0.6",
"bignumber.js": "^9.0.0",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-loader": "^3.0.3",
"eslint-plugin-jest": "^23.8.2",
"html-webpack-plugin": "^3.2.0",
"ripple-lib": "1.6.4",
"tiny-worker": "^2.3.0",
"ts-loader": "^6.2.1",
"webpack": "^4.42.0",
"webpack-cli": "3.3.11",
"webpack-dev-server": "3.10.3",
"worker-loader": "^2.0.0",
"ws": "^7.2.1"
},
"dependencies": {
"es6-promise": "^4.2.8",
"events": "^3.1.0"
},
"workersDependencies": {
"bignumber.js": "^9.0.0",
"ripple-lib": "1.6.4",
"tiny-worker": "^2.3.0",
"ws": "^7.2.1"
}
"name": "@trezor/blockchain-link",
"version": "1.0.9",
"author": "Trezor <info@trezor.io>",
"homepage": "https://github.com/trezor/trezor-suite/packages/blockchain-link",
"description": "High-level javascript interface for blockchain communication",
"license": "SEE LICENSE IN LICENSE.md",
"repository": {
"type": "git",
"url": "git://github.com/trezor/trezor-suite.git"
},
"bugs": {
"url": "https://github.com/trezor/trezor-suite/issues"
},
"keywords": [
"Trezor",
"blockchain",
"blockbook",
"javascript"
],
"main": "./lib/index.js",
"browser": {
"ws": "./lib/utils/ws.js"
},
"scripts": {
"dev": "npx webpack-dev-server --config ./webpack/dev.babel.js --mode development",
"build:lib": "yarn build && yarn build:workers",
"build:workers": "rimraf build && yarn build:workers-web && yarn build:workers-node && yarn build:workers-module",
"build:workers-web": "webpack --config ./webpack/workers.web.babel.js --mode production",
"build:workers-node": "webpack --config ./webpack/workers.node.babel.js --mode production",
"build:workers-module": "webpack --config ./webpack/workers.module.babel.js --mode production",
"lint": "eslint '**/*{.ts,.tsx}'",
"test:unit": "jest --verbose -c jest.config.unit.js",
"test:node": "jest -c jest.config.integration.js",
"build": "rimraf lib && tsc --p ./tsconfig.lib.json && tsc --p ./tsconfig.workers.json",
"type-check": "tsc --project tsconfig.json"
},
"devDependencies": {
"@babel/register": "^7.8.6",
"@babel/runtime": "^7.8.7",
"babel-eslint": "^10.1.0",
"babel-jest": "^25.1.0",
"babel-loader": "^8.0.6",
"bignumber.js": "^9.0.0",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-loader": "^3.0.3",
"eslint-plugin-jest": "^23.8.2",
"html-webpack-plugin": "^3.2.0",
"ripple-lib": "1.6.4",
"tiny-worker": "^2.3.0",
"ts-loader": "^6.2.1",
"webpack": "^4.42.0",
"webpack-cli": "3.3.11",
"webpack-dev-server": "3.10.3",
"worker-loader": "^2.0.0",
"ws": "^7.2.3"
},
"dependencies": {
"es6-promise": "^4.2.8",
"events": "^3.1.0"
},
"workersDependencies": {
"bignumber.js": "^9.0.0",
"ripple-lib": "1.6.4",
"tiny-worker": "^2.3.0",
"ws": "^7.2.1"
}
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc