Comparing version 0.3.11 to 0.3.12
@@ -1,2 +0,2 @@ | ||
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=require("liquidjs-lib"),r=t(require("bs58check")),n=require("bip32"),i=require("slip77"),o=require("bip39"),a=t(require("axios"));function s(t){this.wrapped=t}function u(t){var e,r;function n(e,r){try{var o=t[e](r),a=o.value,u=a instanceof s;Promise.resolve(u?a.wrapped:a).then((function(t){u?n("return"===e?"return":"next",t):i(o.done?"return":"normal",t)}),(function(t){n("throw",t)}))}catch(t){i("throw",t)}}function i(t,i){switch(t){case"return":e.resolve({value:i,done:!0});break;case"throw":e.reject(i);break;default:e.resolve({value:i,done:!1})}(e=e.next)?n(e.key,e.arg):r=null}this._invoke=function(t,i){return new Promise((function(o,a){var s={key:t,arg:i,resolve:o,reject:a,next:null};r?r=r.next=s:(e=r=s,n(t,i))}))},"function"!=typeof t.return&&(this.return=void 0)}function c(t){return function(){return new u(t.apply(this,arguments))}}function p(t){return new s(t)}function f(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function d(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){f(o,n,i,a,s,"next",t)}function s(t){f(o,n,i,a,s,"throw",t)}a(void 0)}))}}function l(){return(l=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function h(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,y(t,e)}function v(t){return(v=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function y(t,e){return(y=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function x(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function b(t,e,r){return(b=x()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var i=new(Function.bind.apply(t,n));return r&&y(i,r.prototype),i}).apply(null,arguments)}function g(t){var e="function"==typeof Map?new Map:void 0;return(g=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return b(t,arguments,v(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),y(r,t)})(t)}function w(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function m(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return w(t,void 0);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?w(t,void 0):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}u.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},u.prototype.next=function(t){return this._invoke("next",t)},u.prototype.throw=function(t){return this._invoke("throw",t)},u.prototype.return=function(t){return this._invoke("return",t)};var P,k=(function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var i=Object.create((e&&e.prototype instanceof f?e:f).prototype),o=new k(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return{value:void 0,done:!0}}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=w(a,r);if(s){if(s===p)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===p)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,o),i}function c(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var p={};function f(){}function d(){}function l(){}var h={};h[i]=function(){return this};var v=Object.getPrototypeOf,y=v&&v(v(K([])));y&&y!==e&&r.call(y,i)&&(h=y);var x=l.prototype=f.prototype=Object.create(h);function b(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function g(t,e){var n;this._invoke=function(i,o){function a(){return new e((function(n,a){!function n(i,o,a,s){var u=c(t[i],t,o);if("throw"!==u.type){var p=u.arg,f=p.value;return f&&"object"==typeof f&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(f).then((function(t){p.value=t,a(p)}),(function(t){return n("throw",t,a,s)}))}s(u.arg)}(i,o,n,a)}))}return n=n?n.then(a,a):a()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return p;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var n=c(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,p;var i=n.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function m(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(m,this),this.reset(!0)}function K(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:A}}function A(){return{value:void 0,done:!0}}return d.prototype=x.constructor=l,l.constructor=d,d.displayName=s(l,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,s(t,a,"GeneratorFunction")),t.prototype=Object.create(x),t},t.awrap=function(t){return{__await:t}},b(g.prototype),g.prototype[o]=function(){return this},t.AsyncIterator=g,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var a=new g(u(e,r,n,i),o);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},b(x),s(x,a,"Generator"),x[i]=function(){return this},x.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=K,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(P),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,p):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),p},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),P(r),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;P(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:K(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}(P={exports:{}}),P.exports);function K(t){return t.slice(1).reverse().toString("hex")}function A(t){return e.confidential.confidentialValueToSatoshi(t)}var B=Buffer.from("0x00","hex");function T(t){return null!=t&&t.length>0}function I(t){var e=t.surjectionProof,r=t.nonce;return T(t.rangeProof)&&T(e)&&r!==B}var E,S=function(){function t(){this.map=new Map}var e=t.prototype;return e.bufferToStringPrimitive=function(t){return t.toString("hex").valueOf()},e.get=function(t){return this.map.get(this.bufferToStringPrimitive(t))},e.set=function(t,e){return this.map.set(this.bufferToStringPrimitive(t),e),this},e.values=function(){return Array.from(this.map.values())},t}(),O=new Map([["xpub","0488b21e"],["ypub","049d7cb2"],["Ypub","0295b43f"],["zpub","04b24746"],["Zpub","02aa7ed3"],["tpub","043587cf"],["upub","044a5262"],["Upub","024289ef"],["vpub","045f1cf6"],["Vpub","02575483"]]);function j(t,e){if(!O.has(e))return"Invalid target version";t=t.trim();try{var n=r.decode(t);return n=n.slice(4),n=Buffer.concat([Buffer.from(O.get(e),"hex"),n]),r.encode(n)}catch(t){throw new Error("Invalid extended public key! Please double check that you didn't accidentally paste extra data.")}}function U(t,e){return j(t,"regtest"===e?"vpub":"zpub")}function _(t){return j(t,"xpub")}function L(t,e){try{n.fromBase58(t,e)}catch(t){return!1}return!0}function N(t){try{i.fromMasterBlindingKey(t)}catch(t){return!1}return!0}function M(t){var r;try{r=e.Psbt.fromBase64(t)}catch(t){throw new Error("Invalid pset")}return r.data.globalMap.unsignedTx.toBuffer().toString("hex")}function F(t){return{txid:t.txid,vout:t.vout}}function C(t){return!t.asset||!t.value}function W(t){return t?e.networks[t]:e.networks.liquid}function R(t,e){return H.apply(this,arguments)}function H(){return(H=d(k.mark((function t(r,n){var i,o,a,s;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i={asset:r.blindedAsset,value:r.blindedValue,rangeProof:r.rangeProof,surjectionProof:r.surjectionProof,nonce:r.nonce,script:Buffer.from(r.script,"hex")},o=Buffer.from(n,"hex"),t.next=4,e.confidential.unblindOutputWithKey(i,o);case 4:return a=t.sent,s={asset:Buffer.from(a.asset.reverse()).toString("hex"),value:parseInt(a.value,10),script:r.script,assetBlinder:a.assetBlindingFactor.toString("hex"),valueBlinder:a.valueBlindingFactor.toString("hex")},t.abrupt("return",s);case 7:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function q(t){var r=function(t){if(t.satsPerByte||(t.satsPerByte=.1),t.addFee||(t.addFee=!1),t.addFee&&t.satsPerByte<.1)throw new Error("satsPerByte minimum value is 0.1");if(0===t.recipients.length)throw new Error("need a least one recipient output to build the transaction");if(0===t.unspents.length)throw new Error("need at least one unspent to fund the transaction");return t}(t),n=r.changeAddressByAsset,i=r.coinSelector,o=r.psetBase64,a=r.recipients,s=r.unspents,u=r.addFee,c=r.satsPerByte,p=i(s,a,n),f=p.selectedUtxos,d=p.changeOutputs,l=f;if(!u)return D(o,l,a.concat(d));var h=V(o),v=h.data.inputs.length+l.length,y=h.data.outputs.length+a.length+d.length,x=e.address.getNetwork(a[0].address).assetHash,b=G(v,y,c,x),g=d.findIndex((function(t){return t.asset===x})),w=-1===g?0-b.value:d[g].value-b.value;if(w>0)return d[g].value=w,D(o,l,a.concat(d).concat(b));if(0===w)return D(o,l,a.concat(b));for(var P,k=[],K=m(s);!(P=K()).done;){var A=P.value;f.includes(A)||k.push(A)}var B=G(v+1,y+1,c,x),T=i(k,[B],n);return D(o,l.concat(T.selectedUtxos),a.concat(d).concat(T.changeOutputs).concat(B))}function G(t,e,r,n){var i=X(t,e);return{asset:n,value:Math.ceil(i*r),address:""}}function D(t,r,n){for(var i,o=V(t),a=Buffer.from("00","hex"),s=m(n);!(i=s()).done;){var u=i.value,c=u.asset,p=u.value,f=u.address,d=""===f?"":e.address.toOutputScript(f);o.addOutput({asset:c,value:p,script:d,nonce:a})}for(var l,h=m(r);!(l=h()).done;){var v=l.value;o.addInput({hash:v.txid,index:v.vout,witnessUtxo:v.prevout})}return o.toBase64()}function V(t){var r;try{r=e.Psbt.fromBase64(t)}catch(t){throw new Error("Invalid pset")}return r}function X(t,e){return(3*z(!1,t,e,!1)+z(!0,t,e,!0)+3)/4}function z(t,e,r,n){var i=function(t,e){var r=40*e;return t&&(r+=105*e),r}(t,e),o=function(t,e){var r=67*e;return t&&(r+=4273*e),r+43}(n,r);return 9+Y(r)+Y(e)+i+o}function Y(t){return t<253?1:t<=65535?3:t<=4294967295?5:9}(E=exports.IdentityType||(exports.IdentityType={}))[E.PrivateKey=1]="PrivateKey",E[E.Mnemonic=2]="Mnemonic",E[E.MasterPublicKey=3]="MasterPublicKey",E[E.Inject=4]="Inject",E[E.Ledger=5]="Ledger",E[E.Trezor=6]="Trezor";var Z=function(){function t(t){if(!t.chain||!e.networks.hasOwnProperty(t.chain))throw new Error("Network is missing or not valid");if(!t.type||!(t.type in exports.IdentityType))throw new Error("Type is missing or not valid");this.network=e.networks[t.chain],this.type=t.type}return t.prototype.blindPsetWithBlindKeysGetter=function(){var t=d(k.mark((function t(r,n,i,o,a){var s,u,c,p,f,d,l,h,v,y,x,b,g,w,P;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:s=new Map,u=new Map,c=V(n),p=e.Transaction.fromHex(M(n)),f=m(i);case 5:if((d=f()).done){t.next=16;break}if(l=d.value,!o||!o.has(l)){t.next=11;break}return h=Buffer.from(o.get(l),"hex"),u.set(l,h),t.abrupt("continue",14);case 11:v=r(p.outs[l].script).publicKey,u.set(l,v);case 14:t.next=5;break;case 16:y=0;case 17:if(!(y<c.data.inputs.length)){t.next=43;break}if(b=void 0,!(x=c.data.inputs[y]).witnessUtxo){t.next=24;break}if(I(x.witnessUtxo)){t.next=23;break}return t.abrupt("continue",40);case 23:b=x.witnessUtxo.script;case 24:if(!x.nonWitnessUtxo){t.next=30;break}if(g=p.ins[y].index,I(w=e.Transaction.fromBuffer(x.nonWitnessUtxo).outs[g])){t.next=29;break}return t.abrupt("continue",40);case 29:b=w.script;case 30:if(!a||!a.has(y)){t.next=33;break}return s.set(y,a.get(y)),t.abrupt("continue",40);case 33:if(b){t.next=35;break}throw new Error("no witness script for input #"+y);case 35:return P=r(b).privateKey,t.next=38,e.confidential.unblindOutputWithKey(x.witnessUtxo,P);case 38:s.set(y,t.sent);case 40:y++,t.next=17;break;case 43:return t.next=45,c.blindOutputsByIndex(s,u);case 45:return t.abrupt("return",t.sent.toBase64());case 47:case"end":return t.stop()}}),t)})));return function(e,r,n,i,o){return t.apply(this,arguments)}}(),t}(),$=function(t){function r(e){var o;(o=t.call(this,e)||this).index=r.INITIAL_INDEX,o.changeIndex=r.INITIAL_INDEX,o.scriptToAddressCache={},o.baseDerivationPath=r.INITIAL_BASE_PATH;var a=_(e.opts.masterPublicKey);if(e.type!==exports.IdentityType.MasterPublicKey)throw new Error("The identity arguments have not the MasterPublicKey type.");if(!L(a))throw new Error("Master public key is not valid");if(!N(e.opts.masterBlindingKey))throw new Error("Master blinding key is not valid");return o.masterPublicKeyNode=n.fromBase58(a),o.masterBlindingKeyNode=i.fromMasterBlindingKey(e.opts.masterBlindingKey),o}h(r,t);var o=r.prototype;return o.blindPset=function(){var e=d(k.mark((function e(r,n,i,o){var a=this;return k.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t.prototype.blindPsetWithBlindKeysGetter.call(this,(function(t){return a.getBlindingKeyPair(t.toString("hex"),!0)}),r,n,i,o));case 1:case"end":return e.stop()}}),e,this)})));return function(t,r,n,i){return e.apply(this,arguments)}}(),o.isAbleToSign=function(){return!1},o.derivePublicKeyWithIndex=function(t,e){return this.masterPublicKeyNode.derive(t?1:0).derive(e).publicKey},o.getBlindingKeyPair=function(t,e){if(void 0===e&&(e=!1),e&&!this.scriptToAddressCache[t])throw new Error("unknow blinding key for script "+t);var r=this.masterBlindingKeyNode.derive(t);return{publicKey:r.publicKey,privateKey:r.privateKey}},o.scriptFromPublicKey=function(t){return e.payments.p2wpkh({pubkey:t,network:this.network}).output.toString("hex")},o.createConfidentialAddress=function(t,r){return e.payments.p2wpkh({pubkey:t,blindkey:r,network:this.network}).confidentialAddress},o.persistAddressToCache=function(t){var e=Buffer.from(t.publicKey,"hex"),r=this.scriptFromPublicKey(e);this.scriptToAddressCache[r]=t},o.getAddress=function(t,e){var r=this.derivePublicKeyWithIndex(t,e),n=this.scriptFromPublicKey(r),i=this.getBlindingKeyPair(n),o=this.createConfidentialAddress(r,i.publicKey),a=this.baseDerivationPath+"/"+(t?1:0)+"/"+e;return{address:{confidentialAddress:o,blindingPrivateKey:i.privateKey.toString("hex"),derivationPath:a},publicKey:r.toString("hex")}},o.getNextAddress=function(){var t=d(k.mark((function t(){var e;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.getAddress(!1,this.index),this.persistAddressToCache(e),this.index=this.index+1,t.abrupt("return",e.address);case 4:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),o.getNextChangeAddress=function(){var t=d(k.mark((function t(){var e;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.getAddress(!0,this.changeIndex),this.persistAddressToCache(e),this.changeIndex=this.changeIndex+1,t.abrupt("return",e.address);case 4:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),o.getBlindingPrivateKey=function(){var t=d(k.mark((function t(e){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getBlindingKeyPair(e).privateKey.toString("hex"));case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),o.signPset=function(t){throw new Error("MasterPublicKey is a watch only identity. Use Mnemonic to sign transactions")},o.getAddresses=function(){var t=d(k.mark((function t(){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",Object.values(this.scriptToAddressCache).map((function(t){return t.address})));case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r}(Z);$.INITIAL_BASE_PATH="m/84'/0'/0'",$.INITIAL_INDEX=0;var J=function(t){function r(r){var a;if(r.type!==exports.IdentityType.Mnemonic)throw new Error("The identity arguments have not the Mnemonic type.");if(o.setDefaultWordlist(r.opts.language||"english"),!o.validateMnemonic(r.opts.mnemonic))throw new Error("Mnemonic is not valid.");var s=o.mnemonicToSeedSync(r.opts.mnemonic),u=n.fromSeed(s,e.networks[r.chain]),c=u.derivePath($.INITIAL_BASE_PATH),p=U(e.bip32.fromPublicKey(c.publicKey,c.chainCode,c.network).toBase58(),r.chain),f=i.fromSeed(s),d=f.masterKey.toString("hex");return(a=t.call(this,l({},r,{type:exports.IdentityType.MasterPublicKey,opts:{masterPublicKey:p,masterBlindingKey:d}}))||this).masterBlindingKey=d,a.masterBlindingKeyNode=f,a.masterPublicKey=p,a.masterPrivateKeyNode=u,a}h(r,t);var a=r.prototype;return a.blindPset=function(){var e=d(k.mark((function e(r,n,i,o){var a=this;return k.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t.prototype.blindPsetWithBlindKeysGetter.call(this,(function(e){return t.prototype.getBlindingKeyPair.call(a,e.toString("hex"),!0)}),r,n,i,o));case 1:case"end":return e.stop()}}),e,this)})));return function(t,r,n,i){return e.apply(this,arguments)}}(),a.isAbleToSign=function(){return!0},a.derivePath=function(t){var r=this.masterPrivateKeyNode.derivePath(t).toWIF(),n=e.ECPair.fromWIF(r,this.network);return{publicKey:n.publicKey,privateKey:n.privateKey}},a.signPset=function(){var t=d(k.mark((function t(r){var n,i,o,a,s,u,c;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(n=e.Psbt.fromBase64(r),i=[],o=0;o<n.data.inputs.length;o++)(a=n.data.inputs[o]).witnessUtxo&&(s=this.scriptToAddressCache[a.witnessUtxo.script.toString("hex")])&&(u=this.derivePath(s.address.derivationPath).privateKey,c=e.ECPair.fromPrivateKey(u),i.push(n.signInputAsync(o,c)));return t.next=5,Promise.all(i);case 5:return t.abrupt("return",n.toBase64());case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),a.getAddresses=function(){var e=d(k.mark((function e(){return k.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t.prototype.getAddresses.call(this));case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r}($),Q=function(t){function r(r){var n;if(n=t.call(this,r)||this,r.type!==exports.IdentityType.PrivateKey)throw new Error("The identity arguments have not the PrivateKey type.");n.signingKeyPair=n.decodeFromWif(r.opts.signingKeyWIF),n.blindingKeyPair=n.decodeFromWif(r.opts.blindingKeyWIF);var i=e.payments.p2wpkh({pubkey:n.signingKeyPair.publicKey,blindkey:n.blindingKeyPair.publicKey,network:n.network});return n.confidentialAddress=i.confidentialAddress,n.blindingPrivateKey=n.blindingKeyPair.privateKey.toString("hex"),n.scriptPubKey=i.output,n}h(r,t);var n=r.prototype;return n.blindPset=function(){var e=d(k.mark((function e(r,n,i,o){var a=this;return k.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t.prototype.blindPsetWithBlindKeysGetter.call(this,(function(t){return a.getBlindingKeyPair(t)}),r,n,i,o));case 1:case"end":return e.stop()}}),e,this)})));return function(t,r,n,i){return e.apply(this,arguments)}}(),n.getBlindingKeyPair=function(t){if(!t.equals(this.scriptPubKey))throw new Error(t+" is unknown by the PrivateKey Identity");return{publicKey:this.blindingKeyPair.publicKey,privateKey:this.blindingKeyPair.privateKey}},n.isAbleToSign=function(){return!0},n.decodeFromWif=function(t){return e.ECPair.fromWIF(t,this.network)},n.getAddress=function(){return{confidentialAddress:this.confidentialAddress,blindingPrivateKey:this.blindingPrivateKey,derivationPath:void 0}},n.getNextAddress=function(){var t=d(k.mark((function t(){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getAddress());case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.getNextChangeAddress=function(){var t=d(k.mark((function t(){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getAddress());case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.getBlindingPrivateKey=function(){var t=d(k.mark((function t(e){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Buffer.from(e,"hex").equals(this.scriptPubKey)){t.next=3;break}throw new Error("The script is not PrivateKey.scriptPubKey.");case 3:return t.abrupt("return",this.blindingPrivateKey);case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),n.signPset=function(){var t=d(k.mark((function t(r){var n,i,o,a,s=this;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(n=e.Psbt.fromBase64(r),i=[],o=0;o<n.data.inputs.length;o++)(a=n.data.inputs[o]).witnessUtxo?a.witnessUtxo.script.equals(this.scriptPubKey)&&i.push(o):i.push(o);return t.next=5,Promise.all(i.map((function(t){return n.signInputAsync(t,s.signingKeyPair)})));case 5:return t.abrupt("return",n.toBase64());case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),n.getAddresses=function(){var t=d(k.mark((function t(){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",[{confidentialAddress:this.confidentialAddress,blindingPrivateKey:this.blindingPrivateKey,derivationPath:void 0}]);case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r}(Z),tt=function(t){function e(e){var r;if(r=t.call(this,e)||this,e.type!==exports.IdentityType.Inject)throw new Error("The identity arguments have not the Inject type.");if(void 0===window||void 0===window[e.opts.windowProvider])throw new Error("The value.windowProvider of IdentityOpts is not valid or the script is to injected in the window");return r.provider=window[e.opts.windowProvider],r}h(e,t);var r=e.prototype;return r.getNextAddress=function(){return this.provider.getNextAddress()},r.getNextChangeAddress=function(){return this.provider.getNextChangeAddress()},r.signPset=function(t){return this.provider.signTransaction(t)},r.getAddresses=function(){return this.provider.getAddresses()},r.getBlindingPrivateKey=function(t){throw new Error("Method not implemented.")},r.isAbleToSign=function(){return!0},r.blindPset=function(t,e,r,n){throw new Error("Method not implemented.")},e}(Z),et=function(t,e){return t.value-e.value};function rt(t,e,r){for(var n,i=[],o=0,a=m(t=t.sort(r));!(n=a()).done;){var s=n.value;if(C(s)||(i.push(s),o+=s.value),o>=e)return{selected:i,changeAmount:o-e}}throw new Error("not enough utxos in wallet to fund: "+e)}function nt(t,e){return t.reduce((function(t,r){return(t[r[e]]=t[r[e]]||[]).push(r),t}),{})}function it(t){return"surjectionProof"in t&&"rangeProof"in t}var ot=Buffer.alloc(32).toString("hex");function at(t,e){return st.apply(this,arguments)}function st(){return(st=d(k.mark((function t(e,r){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,a.get(r+"/tx/"+e+"/hex");case 2:return t.abrupt("return",t.sent.data);case 3:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function ut(){return(ut=d(k.mark((function t(e,r){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=ft,t.next=3,a.get(r+"/tx/"+e);case 3:return t.t1=t.sent.data,t.t2=r,t.abrupt("return",(0,t.t0)(t.t1,t.t2));case 6:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function ct(t,e){return pt.apply(this,arguments)}function pt(){return(pt=d(k.mark((function t(e,r){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,a.get(r+"/address/"+e+"/utxo");case 2:return t.abrupt("return",t.sent.data);case 3:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function ft(t,e){return dt.apply(this,arguments)}function dt(){return(dt=d(k.mark((function t(r,n){var i,o,a,s,u,c,p,f,d;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(i=[],o=[],a=m(r.vin);!(s=a()).done;)i.push((u=s.value).txid),o.push(u.vout);return t.next=5,Promise.all(i.map((function(t,e){return r.vin[e].is_pegin?Promise.resolve(void 0):at(t,n)})));case 5:return c=t.sent.map((function(t,r){if(t)return lt(e.Transaction.fromHex(t).outs[o[r]])})),p=i.map((function(t,e){return{prevout:c[e],txid:t,vout:o[e],isPegin:r.vin[e].is_pegin}})),t.next=10,at(r.txid,n);case 10:return f=e.Transaction.fromHex(t.sent),d=f.outs.map(lt),t.abrupt("return",{txid:r.txid,vin:p,vout:d,fee:r.fee,status:{confirmed:r.status.confirmed,blockHash:r.status.block_hash,blockHeight:r.status.block_height,blockTime:r.status.block_time}});case 15:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function lt(t){return I(t)?{blindedAsset:t.asset,blindedValue:t.value,nonce:t.nonce,rangeProof:t.rangeProof,surjectionProof:t.surjectionProof,script:t.script.toString("hex")}:{asset:K(t.asset),value:A(t.value),script:t.script.toString("hex"),assetBlinder:ot,valueBlinder:ot}}function ht(t,e,r){return t+"/tx/"+e+"#blinded="+r.map((function(t){return t.value+","+t.asset+","+t.valueBlinder+","+t.assetBlinder})).join(",")}var vt=function(t){function e(e,r,n){return t.call(this,"UnblindError output ("+e+":"+r+") with blind key "+n)||this}return h(e,t),e}(g(Error));function yt(t,e,r,n){return xt.apply(this,arguments)}function xt(){return(xt=c(k.mark((function t(e,r,n,i){var o,a,s,u,c,f,d,l,h,v;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o=[],a=[],s=m(e);case 3:if((u=s()).done){t.next=38;break}return c=u.value,t.prev=5,f=gt(c,n,i),t.next=9,p(f.next());case 9:d=t.sent;case 10:if(d.done){t.next=31;break}if(!o.includes((l=d.value).txid)){t.next=17;break}return t.next=15,p(f.next());case 15:return d=t.sent,t.abrupt("continue",10);case 17:return t.next=19,p(mt(l,r));case 19:return v=(h=t.sent).unblindedTx,a.push.apply(a,h.errors),t.next=25,v;case 25:return o.push(l.txid),t.next=28,p(f.next());case 28:d=t.sent,t.next=10;break;case 31:t.next=36;break;case 33:t.prev=33,t.t0=t.catch(5),a.push(t.t0);case 36:t.next=3;break;case 38:return t.abrupt("return",{txIDs:o,errors:a});case 39:case"end":return t.stop()}}),t,null,[[5,33]])})))).apply(this,arguments)}function bt(){return(bt=d(k.mark((function t(e,r,n,i){var o,a,s;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=yt(e,r,n,i),a=[],t.next=4,o.next();case 4:s=t.sent;case 5:if(s.done){t.next=12;break}return a.push(s.value),t.next=9,o.next();case 9:s=t.sent,t.next=5;break;case 12:return t.abrupt("return",a);case 13:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function gt(t,e,r){return wt.apply(this,arguments)}function wt(){return(wt=c(k.mark((function t(e,r,n){var i,o,a,s,u,c,f,d;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:i=void 0,o=[],a=0;case 3:return t.next=5,p(kt(e,r,i));case 5:if(0!==(o=t.sent).length){t.next=8;break}return t.abrupt("break",24);case 8:i=o[o.length-1].txid,a+=o.length,s=o.map((function(t){return ft(t,r)})),u=m(s);case 12:if((c=u()).done){t.next=23;break}return f=c.value,t.next=16,p(f);case 16:if(d=t.sent,!n||!n(d)){t.next=19;break}return t.abrupt("continue",21);case 19:return t.next=21,d;case 21:t.next=12;break;case 23:if(i){t.next=3;break}case 24:return t.abrupt("return",a);case 25:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function mt(t,e){return Pt.apply(this,arguments)}function Pt(){return(Pt=d(k.mark((function t(e,r){var n,i,o,a,s,u;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(n=[],i=[],o=function(t){var o=e.vin[t].prevout;it(o)&&n.push(function(){var n=d(k.mark((function n(){var a;return k.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(a=r(o.script))){n.next=12;break}return n.prev=2,n.next=5,R(o,a);case 5:e.vin[t].prevout=n.sent,n.next=12;break;case 9:n.prev=9,n.t0=n.catch(2),i.push(new vt(e.vin[t].txid,e.vin[t].vout,a));case 12:case"end":return n.stop()}}),n,null,[[2,9]])})));return function(){return n.apply(this,arguments)}}()())},a=0;a<e.vin.length;a++)o(a);for(s=function(t){var o=e.vout[t];it(o)&&n.push(function(){var n=d(k.mark((function n(){var a;return k.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(a=r(o.script))){n.next=12;break}return n.prev=2,n.next=5,R(o,a);case 5:e.vout[t]=n.sent,n.next=12;break;case 9:n.prev=9,n.t0=n.catch(2),i.push(new vt(e.txid,t,a));case 12:case"end":return n.stop()}}),n,null,[[2,9]])})));return function(){return n.apply(this,arguments)}}()())},u=0;u<e.vout.length;u++)s(u);return t.next=8,Promise.all(n);case 8:return t.abrupt("return",{unblindedTx:e,errors:i});case 9:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function kt(t,e,r){return Kt.apply(this,arguments)}function Kt(){return(Kt=d(k.mark((function t(e,r,n){var i;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=r+"/address/"+e+"/txs/chain",n&&(i+="/"+n),t.next=4,a.get(i);case 4:return t.abrupt("return",t.sent.data);case 6:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function At(){return(At=d(k.mark((function t(e,r,n){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,It([{confidentialAddress:e,blindingPrivateKey:r}],n);case 2:return t.abrupt("return",t.sent.reduce((function(t,e){var r=e.asset;return t[r]=t[r]||0,t[r]+=e.value,t}),{}));case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Bt(t,e,r){return Tt.apply(this,arguments)}function Tt(){return(Tt=c(k.mark((function t(r,n,i){var o,a,s,u,c,f,d,l,h,v,y,x,b,g,w;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o=0,a=[],s=m(r);case 3:if((u=s()).done){t.next=39;break}if(f=(c=u.value).confidentialAddress,d=c.blindingPrivateKey,t.prev=5,!(d.length>0)){t.next=11;break}if(l=e.ECPair.fromPrivateKey(Buffer.from(d,"hex")),h=e.address.fromConfidential(f).blindingKey,l.publicKey.equals(h)){t.next=11;break}throw new Error("wrong blinding private key");case 11:return t.next=13,p(ct(f,n));case 13:v=m(t.sent);case 15:if((y=v()).done){t.next=32;break}if(x=y.value,!i||!i(x)){t.next=21;break}return t.next=20,x;case 20:return t.abrupt("continue",30);case 21:return t.next=23,p(jt(x,d,n));case 23:return g=(b=t.sent).unblindedUtxo,(w=b.error)&&a.push(w),t.next=29,g;case 29:o++;case 30:t.next=15;break;case 32:t.next=37;break;case 34:t.prev=34,t.t0=t.catch(5),a.push(t.t0);case 37:t.next=3;break;case 39:return t.abrupt("return",{numberOfUtxos:o,errors:a});case 40:case"end":return t.stop()}}),t,null,[[5,34]])})))).apply(this,arguments)}function It(t,e,r){return Et.apply(this,arguments)}function Et(){return(Et=d(k.mark((function t(e,r,n){var i,o,a;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=Bt(e,r,n),o=[],t.next=4,i.next();case 4:a=t.sent;case 5:if(a.done){t.next=12;break}return o.push(a.value),t.next=9,i.next();case 9:a=t.sent,t.next=5;break;case 12:return t.abrupt("return",o);case 13:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function St(t,e){return Ot.apply(this,arguments)}function Ot(){return(Ot=d(k.mark((function t(r,n){var i;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,at(r.txid,n);case 2:return i=e.Transaction.fromHex(t.sent).outs[r.vout],t.abrupt("return",l({},r,{prevout:i}));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function jt(t,e,r){return Ut.apply(this,arguments)}function Ut(){return(Ut=d(k.mark((function t(e,r,n){var i;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.prevout){t.next=4;break}return t.next=3,St(e,n);case 3:e=t.sent;case 4:return t.prev=4,t.next=7,_t(e,r);case 7:return t.abrupt("return",{unblindedUtxo:t.sent});case 11:return t.prev=11,t.t0=t.catch(4),i=new vt(e.txid,e.vout,r),t.abrupt("return",{unblindedUtxo:e,error:i});case 15:case"end":return t.stop()}}),t,null,[[4,11]])})))).apply(this,arguments)}function _t(t,e){return Lt.apply(this,arguments)}function Lt(){return(Lt=d(k.mark((function t(r,n){var i,o;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r.prevout){t.next=2;break}throw new Error("utxo need utxo.prevout to be defined. Use utxoWithPrevout.");case 2:if(I(r.prevout)){t.next=4;break}return t.abrupt("return",r);case 4:return t.next=6,e.confidential.unblindOutputWithKey(r.prevout,Buffer.from(n,"hex"));case 6:return i=t.sent,o=Buffer.alloc(32),i.asset.copy(o),t.abrupt("return",l({},r,{asset:o.reverse().toString("hex"),value:parseInt(i.value,10),unblindData:i}));case 10:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Nt=function(){function t(t,e){this.network=e,this.cache=t}var r=t.prototype;return r.createTx=function(){return new e.Psbt({network:this.network}).toBase64()},r.buildTx=function(t,e,r,n,i,o){return q({psetBase64:t,recipients:e,coinSelector:r,changeAddressByAsset:n,addFee:i,satsPerByte:o,unspents:this.cache.getAll()})},t}();function Mt(){return(Mt=d(k.mark((function t(e,r,n){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,It(e,r);case 2:return t.abrupt("return",Ft(t.sent,n));case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Ft(t,e){return new Nt(new Ct(t),W(e))}var Ct=function(){function t(t){this.utxoMap=new Map,t&&this.push(t)}var e=t.prototype;return e.push=function(t){for(var e,r=m(t);!(e=r()).done;){var n=e.value;this.utxoMap.set(F(n),n)}},e.delete=function(t){return this.utxoMap.delete(t)},e.getAll=function(){return Array.from(this.utxoMap.values())},t}();function Wt(t){return function(){var e=d(k.mark((function e(r){var n,i,o,a,s,u,c,p,f,l;return k.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=void 0===(n=r.esploraURL)?"https://blockstream.info/liquid/api":n,a=void 0===(o=r.gapLimit)?20:o,u=(s=function(){var t=d(k.mark((function t(e){var r,n,o,s,u;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=0,n=0,o=void 0,s=k.mark((function t(){var s,u,c,p,f;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=n,t.next=3,Promise.all(Array.from(Array(a).keys()).map((function(t){return t+s})).map(e));case 3:return u=t.sent,t.next=6,Promise.all(u.map((function(t){return Rt(t,i)})));case 6:c=0,p=m(t.sent);case 9:if((f=p()).done){t.next=22;break}if(!f.value){t.next=16;break}o=c+n,r=0,t.next=19;break;case 16:if(++r!==a){t.next=19;break}return t.abrupt("return",{v:o});case 19:c++;case 20:t.next=9;break;case 22:n+=a;case 23:case"end":return t.stop()}}),t)}));case 4:if(!(r<a)){t.next=11;break}return t.delegateYield(s(),"t0",6);case 6:if("object"!=typeof(u=t.t0)){t.next=9;break}return t.abrupt("return",u.v);case 9:t.next=4;break;case 11:return t.abrupt("return",o);case 12:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}())((function(e){return Promise.resolve(t.getAddress(!1,e).address.confidentialAddress)})),c=s((function(e){return Promise.resolve(t.getAddress(!0,e).address.confidentialAddress)})),e.next=6,Promise.all([u,c]);case 6:return f=(p=e.sent)[0],l=p[1],e.abrupt("return",qt(t)({lastUsedExternalIndex:f,lastUsedInternalIndex:l}));case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()}function Rt(t,e){return Ht.apply(this,arguments)}function Ht(){return(Ht=d(k.mark((function t(e,r){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,a.get(r+"/address/"+e+"/txs");case 2:return t.abrupt("return",t.sent.data.length>0);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function qt(t){return function(){var e=d(k.mark((function e(r){var n,i,o,a,s,u,c;return k.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=r.lastUsedInternalIndex,o=[],void 0!==(n=r.lastUsedExternalIndex))for(a=0;a<=n;a++)s=t.getNextAddress(),o.push(s);if(void 0!==i)for(u=0;u<=i;u++)c=t.getNextChangeAddress(),o.push(c);return e.next=6,Promise.all(o);case 6:return e.abrupt("return",t);case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()}Object.defineProperty(exports,"ECPair",{enumerable:!0,get:function(){return e.ECPair}}),Object.defineProperty(exports,"address",{enumerable:!0,get:function(){return e.address}}),Object.defineProperty(exports,"networks",{enumerable:!0,get:function(){return e.networks}}),Object.defineProperty(exports,"payments",{enumerable:!0,get:function(){return e.payments}}),exports.BLOCKSTREAM_ESPLORA_ENDPOINT="https://blockstream.info/liquid/api",exports.BrowserInject=tt,exports.BufferMap=S,exports.MasterPublicKey=$,exports.Mnemonic=J,exports.PrivateKey=Q,exports.UtxoCache=Ct,exports.Wallet=Nt,exports.addToTx=D,exports.buildTx=q,exports.createFeeOutput=G,exports.decodePset=V,exports.esploraTxToTxInterface=ft,exports.estimateTxSize=X,exports.fetchAndUnblindTxs=function(t,e,r,n){return bt.apply(this,arguments)},exports.fetchAndUnblindTxsGenerator=yt,exports.fetchAndUnblindUtxos=It,exports.fetchAndUnblindUtxosGenerator=Bt,exports.fetchBalances=function(t,e,r){return At.apply(this,arguments)},exports.fetchPrevoutAndTryToUnblindUtxo=jt,exports.fetchTx=function(t,e){return ut.apply(this,arguments)},exports.fetchTxHex=at,exports.fetchUtxos=ct,exports.fromAssetHash=function(t){return Buffer.concat([Buffer.from("01","hex"),Buffer.from(t,"hex").reverse()])},exports.fromXpub=U,exports.getIndexFromAddress=function(t){if(!t.derivationPath)throw new Error("need derivation path to be defined");var e=t.derivationPath.split("/");return parseInt(e[e.length-1])},exports.getNetwork=W,exports.getUnblindURLFromTx=function(t,e){for(var r,n=[],i=function(t){return Buffer.from(t,"hex").reverse().toString("hex")},o=m(t.vout);!(r=o()).done;){var a=r.value;a.script.length>0&&!it(a)&&n.push(l({},a,{assetBlinder:i(a.assetBlinder),valueBlinder:i(a.valueBlinder)}))}return ht(e,t.txid,n)},exports.greedyCoinSelector=function(t){return void 0===t&&(t=et),function(e,r,n){return function(t,e,r,n){for(var i={selectedUtxos:[],changeOutputs:[]},o=nt(t=t.filter((function(t){return!C(t)})),"asset"),a=nt(e,"asset"),s=0,u=Object.entries(a);s<u.length;s++){var c,p=u[s],f=p[0],d=p[1],l=o[f];if(!l)throw new Error("need unspents for the asset: "+f);var h=rt(l,d.reduce((function(t,e){return t+e.value}),0),n),v=h.changeAmount;if((c=i.selectedUtxos).push.apply(c,h.selected),v>0){var y=r(f);if(!y)throw new Error("need change address for asset: "+f);i.changeOutputs.push({asset:f,value:v,address:y})}}return i}(e,r,n,t)}},exports.isBlindedOutputInterface=it,exports.isBlindedUtxo=C,exports.isConfidentialOutput=I,exports.isValidAmount=function(t){return!(t<=0||!Number.isSafeInteger(t))},exports.isValidExtendedBlindKey=N,exports.isValidXpub=L,exports.makeUnblindURL=ht,exports.masterPubKeyRestorerFromEsplora=function(t){return Wt(t)},exports.masterPubKeyRestorerFromState=function(t){return qt(t)},exports.mnemonicRestorerFromEsplora=function(t){return Wt(t)},exports.mnemonicRestorerFromState=function(t){return qt(t)},exports.psetToUnsignedHex=M,exports.psetToUnsignedTx=function(t){return e.Transaction.fromHex(M(t))},exports.toAssetHash=K,exports.toNumber=A,exports.toOutpoint=F,exports.toXpub=_,exports.unblindOutput=R,exports.unblindTransaction=mt,exports.unblindUtxo=_t,exports.utxoWithPrevout=St,exports.walletFromAddresses=function(t,e,r){return Mt.apply(this,arguments)},exports.walletFromCoins=Ft; | ||
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=require("liquidjs-lib"),r=t(require("bs58check")),n=require("bip32"),i=require("slip77"),o=require("bip39"),a=t(require("axios"));function s(t){this.wrapped=t}function u(t){var e,r;function n(e,r){try{var o=t[e](r),a=o.value,u=a instanceof s;Promise.resolve(u?a.wrapped:a).then((function(t){u?n("return"===e?"return":"next",t):i(o.done?"return":"normal",t)}),(function(t){n("throw",t)}))}catch(t){i("throw",t)}}function i(t,i){switch(t){case"return":e.resolve({value:i,done:!0});break;case"throw":e.reject(i);break;default:e.resolve({value:i,done:!1})}(e=e.next)?n(e.key,e.arg):r=null}this._invoke=function(t,i){return new Promise((function(o,a){var s={key:t,arg:i,resolve:o,reject:a,next:null};r?r=r.next=s:(e=r=s,n(t,i))}))},"function"!=typeof t.return&&(this.return=void 0)}function c(t){return function(){return new u(t.apply(this,arguments))}}function p(t){return new s(t)}function f(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function d(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){f(o,n,i,a,s,"next",t)}function s(t){f(o,n,i,a,s,"throw",t)}a(void 0)}))}}function l(){return(l=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function h(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,y(t,e)}function v(t){return(v=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function y(t,e){return(y=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function x(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function b(t,e,r){return(b=x()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var i=new(Function.bind.apply(t,n));return r&&y(i,r.prototype),i}).apply(null,arguments)}function g(t){var e="function"==typeof Map?new Map:void 0;return(g=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return b(t,arguments,v(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),y(r,t)})(t)}function w(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function m(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return w(t,void 0);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?w(t,void 0):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}u.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},u.prototype.next=function(t){return this._invoke("next",t)},u.prototype.throw=function(t){return this._invoke("throw",t)},u.prototype.return=function(t){return this._invoke("return",t)};var P,k=(function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var i=Object.create((e&&e.prototype instanceof f?e:f).prototype),o=new k(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return{value:void 0,done:!0}}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=w(a,r);if(s){if(s===p)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===p)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,o),i}function c(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var p={};function f(){}function d(){}function l(){}var h={};h[i]=function(){return this};var v=Object.getPrototypeOf,y=v&&v(v(K([])));y&&y!==e&&r.call(y,i)&&(h=y);var x=l.prototype=f.prototype=Object.create(h);function b(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function g(t,e){var n;this._invoke=function(i,o){function a(){return new e((function(n,a){!function n(i,o,a,s){var u=c(t[i],t,o);if("throw"!==u.type){var p=u.arg,f=p.value;return f&&"object"==typeof f&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,a,s)}),(function(t){n("throw",t,a,s)})):e.resolve(f).then((function(t){p.value=t,a(p)}),(function(t){return n("throw",t,a,s)}))}s(u.arg)}(i,o,n,a)}))}return n=n?n.then(a,a):a()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return p;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var n=c(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,p;var i=n.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function m(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(m,this),this.reset(!0)}function K(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:A}}function A(){return{value:void 0,done:!0}}return d.prototype=x.constructor=l,l.constructor=d,d.displayName=s(l,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,s(t,a,"GeneratorFunction")),t.prototype=Object.create(x),t},t.awrap=function(t){return{__await:t}},b(g.prototype),g.prototype[o]=function(){return this},t.AsyncIterator=g,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var a=new g(u(e,r,n,i),o);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},b(x),s(x,a,"Generator"),x[i]=function(){return this},x.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=K,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(P),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,p):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),p},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),P(r),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;P(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:K(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}(P={exports:{}}),P.exports);function K(t){return t.slice(1).reverse().toString("hex")}function A(t){return e.confidential.confidentialValueToSatoshi(t)}var B=Buffer.from("0x00","hex");function T(t){return null!=t&&t.length>0}function I(t){var e=t.surjectionProof,r=t.nonce;return T(t.rangeProof)&&T(e)&&r!==B}var E,S=function(){function t(){this.map=new Map}var e=t.prototype;return e.bufferToStringPrimitive=function(t){return t.toString("hex").valueOf()},e.get=function(t){return this.map.get(this.bufferToStringPrimitive(t))},e.set=function(t,e){return this.map.set(this.bufferToStringPrimitive(t),e),this},e.values=function(){return Array.from(this.map.values())},t}(),O=new Map([["xpub","0488b21e"],["ypub","049d7cb2"],["Ypub","0295b43f"],["zpub","04b24746"],["Zpub","02aa7ed3"],["tpub","043587cf"],["upub","044a5262"],["Upub","024289ef"],["vpub","045f1cf6"],["Vpub","02575483"]]);function j(t,e){if(!O.has(e))return"Invalid target version";t=t.trim();try{var n=r.decode(t);return n=n.slice(4),n=Buffer.concat([Buffer.from(O.get(e),"hex"),n]),r.encode(n)}catch(t){throw new Error("Invalid extended public key! Please double check that you didn't accidentally paste extra data.")}}function U(t,e){return j(t,"regtest"===e?"vpub":"zpub")}function _(t){return j(t,"xpub")}function L(t,e){try{n.fromBase58(t,e)}catch(t){return!1}return!0}function N(t){try{i.fromMasterBlindingKey(t)}catch(t){return!1}return!0}function M(t){var r;try{r=e.Psbt.fromBase64(t)}catch(t){throw new Error("Invalid pset")}return r.data.globalMap.unsignedTx.toBuffer().toString("hex")}function F(t){return{txid:t.txid,vout:t.vout}}function C(t){return!t.asset||!t.value}function W(t){return t?e.networks[t]:e.networks.liquid}function R(t,e){return H.apply(this,arguments)}function H(){return(H=d(k.mark((function t(r,n){var i,o,a,s;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i={asset:r.blindedAsset,value:r.blindedValue,rangeProof:r.rangeProof,surjectionProof:r.surjectionProof,nonce:r.nonce,script:Buffer.from(r.script,"hex")},o=Buffer.from(n,"hex"),t.next=4,e.confidential.unblindOutputWithKey(i,o);case 4:return a=t.sent,s={asset:Buffer.from(a.asset.reverse()).toString("hex"),value:parseInt(a.value,10),script:r.script,assetBlinder:a.assetBlindingFactor.toString("hex"),valueBlinder:a.valueBlindingFactor.toString("hex")},t.abrupt("return",s);case 7:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function q(t){var r=function(t){if(t.satsPerByte||(t.satsPerByte=.1),t.addFee||(t.addFee=!1),t.addFee&&t.satsPerByte<.1)throw new Error("satsPerByte minimum value is 0.1");if(0===t.recipients.length)throw new Error("need a least one recipient output to build the transaction");if(0===t.unspents.length)throw new Error("need at least one unspent to fund the transaction");return t}(t),n=r.changeAddressByAsset,i=r.coinSelector,o=r.psetBase64,a=r.recipients,s=r.unspents,u=r.addFee,c=r.satsPerByte,p=i(s,a,n),f=p.selectedUtxos,d=p.changeOutputs,l=f;if(!u)return D(o,l,a.concat(d));var h=V(o),v=h.data.inputs.length+l.length,y=h.data.outputs.length+a.length+d.length,x=e.address.getNetwork(a[0].address).assetHash,b=G(v,y,c,x),g=d.findIndex((function(t){return t.asset===x})),w=-1===g?0-b.value:d[g].value-b.value;if(w>0)return d[g].value=w,D(o,l,a.concat(d).concat(b));if(0===w)return D(o,l,a.concat(b));for(var P,k=[],K=m(s);!(P=K()).done;){var A=P.value;f.includes(A)||k.push(A)}var B=G(v+1,y+1,c,x),T=i(k,[B],n);return D(o,l.concat(T.selectedUtxos),a.concat(d).concat(T.changeOutputs).concat(B))}function G(t,e,r,n){var i=X(t,e);return{asset:n,value:Math.ceil(i*r),address:""}}function D(t,r,n){for(var i,o=V(t),a=Buffer.from("00","hex"),s=m(n);!(i=s()).done;){var u=i.value,c=u.asset,p=u.value,f=u.address,d=""===f?"":e.address.toOutputScript(f);o.addOutput({asset:c,value:p,script:d,nonce:a})}for(var l,h=m(r);!(l=h()).done;){var v=l.value;o.addInput({hash:v.txid,index:v.vout,witnessUtxo:v.prevout})}return o.toBase64()}function V(t){var r;try{r=e.Psbt.fromBase64(t)}catch(t){throw new Error("Invalid pset")}return r}function X(t,e){return(3*z(!1,t,e,!1)+z(!0,t,e,!0)+3)/4}function z(t,e,r,n){var i=function(t,e){var r=40*e;return t&&(r+=105*e),r}(t,e),o=function(t,e){var r=67*e;return t&&(r+=4273*e),r+43}(n,r);return 9+Y(r)+Y(e)+i+o}function Y(t){return t<253?1:t<=65535?3:t<=4294967295?5:9}(E=exports.IdentityType||(exports.IdentityType={}))[E.PrivateKey=1]="PrivateKey",E[E.Mnemonic=2]="Mnemonic",E[E.MasterPublicKey=3]="MasterPublicKey",E[E.Inject=4]="Inject",E[E.Ledger=5]="Ledger",E[E.Trezor=6]="Trezor";var Z=function(){function t(t){if(!t.chain||!e.networks.hasOwnProperty(t.chain))throw new Error("Network is missing or not valid");if(!t.type||!(t.type in exports.IdentityType))throw new Error("Type is missing or not valid");this.network=e.networks[t.chain],this.type=t.type}return t.prototype.blindPsetWithBlindKeysGetter=function(){var t=d(k.mark((function t(r,n,i,o,a){var s,u,c,p,f,d,l,h,v,y,x,b,g,w,P;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:s=new Map,u=new Map,c=V(n),p=e.Transaction.fromHex(M(n)),f=m(i);case 5:if((d=f()).done){t.next=16;break}if(l=d.value,!o||!o.has(l)){t.next=11;break}return h=Buffer.from(o.get(l),"hex"),u.set(l,h),t.abrupt("continue",14);case 11:v=r(p.outs[l].script).publicKey,u.set(l,v);case 14:t.next=5;break;case 16:y=0;case 17:if(!(y<c.data.inputs.length)){t.next=43;break}if(b=void 0,!(x=c.data.inputs[y]).witnessUtxo){t.next=24;break}if(I(x.witnessUtxo)){t.next=23;break}return t.abrupt("continue",40);case 23:b=x.witnessUtxo.script;case 24:if(!x.nonWitnessUtxo){t.next=30;break}if(g=p.ins[y].index,I(w=e.Transaction.fromBuffer(x.nonWitnessUtxo).outs[g])){t.next=29;break}return t.abrupt("continue",40);case 29:b=w.script;case 30:if(!a||!a.has(y)){t.next=33;break}return s.set(y,a.get(y)),t.abrupt("continue",40);case 33:if(b){t.next=35;break}throw new Error("no witness script for input #"+y);case 35:return P=r(b).privateKey,t.next=38,e.confidential.unblindOutputWithKey(x.witnessUtxo,P);case 38:s.set(y,t.sent);case 40:y++,t.next=17;break;case 43:return t.next=45,c.blindOutputsByIndex(s,u);case 45:return t.abrupt("return",t.sent.toBase64());case 47:case"end":return t.stop()}}),t)})));return function(e,r,n,i,o){return t.apply(this,arguments)}}(),t}(),$=function(t){function r(e){var o;(o=t.call(this,e)||this).index=r.INITIAL_INDEX,o.changeIndex=r.INITIAL_INDEX,o.scriptToAddressCache={},o.baseDerivationPath=r.INITIAL_BASE_PATH;var a=_(e.opts.masterPublicKey);if(e.type!==exports.IdentityType.MasterPublicKey)throw new Error("The identity arguments have not the MasterPublicKey type.");if(!L(a))throw new Error("Master public key is not valid");if(!N(e.opts.masterBlindingKey))throw new Error("Master blinding key is not valid");return o.masterPublicKeyNode=n.fromBase58(a),o.masterBlindingKeyNode=i.fromMasterBlindingKey(e.opts.masterBlindingKey),o}h(r,t);var o=r.prototype;return o.blindPset=function(){var e=d(k.mark((function e(r,n,i,o){var a=this;return k.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t.prototype.blindPsetWithBlindKeysGetter.call(this,(function(t){return a.getBlindingKeyPair(t.toString("hex"),!0)}),r,n,i,o));case 1:case"end":return e.stop()}}),e,this)})));return function(t,r,n,i){return e.apply(this,arguments)}}(),o.isAbleToSign=function(){return!1},o.derivePublicKeyWithIndex=function(t,e){return this.masterPublicKeyNode.derive(t?1:0).derive(e).publicKey},o.getBlindingKeyPair=function(t,e){if(void 0===e&&(e=!1),e&&!this.scriptToAddressCache[t])throw new Error("unknow blinding key for script "+t);var r=this.masterBlindingKeyNode.derive(t);return{publicKey:r.publicKey,privateKey:r.privateKey}},o.scriptFromPublicKey=function(t){return e.payments.p2wpkh({pubkey:t,network:this.network}).output.toString("hex")},o.createConfidentialAddress=function(t,r){return e.payments.p2wpkh({pubkey:t,blindkey:r,network:this.network}).confidentialAddress},o.persistAddressToCache=function(t){var e=Buffer.from(t.publicKey,"hex"),r=this.scriptFromPublicKey(e);this.scriptToAddressCache[r]=t},o.getAddress=function(t,e){var r=this.derivePublicKeyWithIndex(t,e),n=this.scriptFromPublicKey(r),i=this.getBlindingKeyPair(n),o=this.createConfidentialAddress(r,i.publicKey),a=this.baseDerivationPath+"/"+(t?1:0)+"/"+e;return{address:{confidentialAddress:o,blindingPrivateKey:i.privateKey.toString("hex"),derivationPath:a},publicKey:r.toString("hex")}},o.getNextAddress=function(){var t=d(k.mark((function t(){var e;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.getAddress(!1,this.index),this.persistAddressToCache(e),this.index=this.index+1,t.abrupt("return",e.address);case 4:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),o.getNextChangeAddress=function(){var t=d(k.mark((function t(){var e;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.getAddress(!0,this.changeIndex),this.persistAddressToCache(e),this.changeIndex=this.changeIndex+1,t.abrupt("return",e.address);case 4:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),o.getBlindingPrivateKey=function(){var t=d(k.mark((function t(e){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getBlindingKeyPair(e).privateKey.toString("hex"));case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),o.signPset=function(t){throw new Error("MasterPublicKey is a watch only identity. Use Mnemonic to sign transactions")},o.getAddresses=function(){var t=d(k.mark((function t(){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",Object.values(this.scriptToAddressCache).map((function(t){return t.address})));case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r}(Z);$.INITIAL_BASE_PATH="m/84'/0'/0'",$.INITIAL_INDEX=0;var J=function(t){function r(r){var a;if(r.type!==exports.IdentityType.Mnemonic)throw new Error("The identity arguments have not the Mnemonic type.");if(o.setDefaultWordlist(r.opts.language||"english"),!o.validateMnemonic(r.opts.mnemonic))throw new Error("Mnemonic is not valid.");var s=o.mnemonicToSeedSync(r.opts.mnemonic),u=n.fromSeed(s,e.networks[r.chain]),c=u.derivePath($.INITIAL_BASE_PATH),p=U(e.bip32.fromPublicKey(c.publicKey,c.chainCode,c.network).toBase58(),r.chain),f=i.fromSeed(s),d=f.masterKey.toString("hex");return(a=t.call(this,l({},r,{type:exports.IdentityType.MasterPublicKey,opts:{masterPublicKey:p,masterBlindingKey:d}}))||this).masterBlindingKey=d,a.masterBlindingKeyNode=f,a.masterPublicKey=p,a.masterPrivateKeyNode=u,a}h(r,t);var a=r.prototype;return a.blindPset=function(){var e=d(k.mark((function e(r,n,i,o){var a=this;return k.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t.prototype.blindPsetWithBlindKeysGetter.call(this,(function(e){return t.prototype.getBlindingKeyPair.call(a,e.toString("hex"),!0)}),r,n,i,o));case 1:case"end":return e.stop()}}),e,this)})));return function(t,r,n,i){return e.apply(this,arguments)}}(),a.isAbleToSign=function(){return!0},a.derivePath=function(t){var r=this.masterPrivateKeyNode.derivePath(t).toWIF(),n=e.ECPair.fromWIF(r,this.network);return{publicKey:n.publicKey,privateKey:n.privateKey}},a.signPset=function(){var t=d(k.mark((function t(r){var n,i,o,a,s,u,c;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(n=e.Psbt.fromBase64(r),i=[],o=0;o<n.data.inputs.length;o++)(a=n.data.inputs[o]).witnessUtxo&&(s=this.scriptToAddressCache[a.witnessUtxo.script.toString("hex")])&&(u=this.derivePath(s.address.derivationPath).privateKey,c=e.ECPair.fromPrivateKey(u),i.push(n.signInputAsync(o,c)));return t.next=5,Promise.all(i);case 5:return t.abrupt("return",n.toBase64());case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),a.getAddresses=function(){var e=d(k.mark((function e(){return k.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t.prototype.getAddresses.call(this));case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r}($),Q=function(t){function r(r){var n;if(n=t.call(this,r)||this,r.type!==exports.IdentityType.PrivateKey)throw new Error("The identity arguments have not the PrivateKey type.");n.signingKeyPair=n.decodeFromWif(r.opts.signingKeyWIF),n.blindingKeyPair=n.decodeFromWif(r.opts.blindingKeyWIF);var i=e.payments.p2wpkh({pubkey:n.signingKeyPair.publicKey,blindkey:n.blindingKeyPair.publicKey,network:n.network});return n.confidentialAddress=i.confidentialAddress,n.blindingPrivateKey=n.blindingKeyPair.privateKey.toString("hex"),n.scriptPubKey=i.output,n}h(r,t);var n=r.prototype;return n.blindPset=function(){var e=d(k.mark((function e(r,n,i,o){var a=this;return k.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t.prototype.blindPsetWithBlindKeysGetter.call(this,(function(t){return a.getBlindingKeyPair(t)}),r,n,i,o));case 1:case"end":return e.stop()}}),e,this)})));return function(t,r,n,i){return e.apply(this,arguments)}}(),n.getBlindingKeyPair=function(t){if(!t.equals(this.scriptPubKey))throw new Error(t+" is unknown by the PrivateKey Identity");return{publicKey:this.blindingKeyPair.publicKey,privateKey:this.blindingKeyPair.privateKey}},n.isAbleToSign=function(){return!0},n.decodeFromWif=function(t){return e.ECPair.fromWIF(t,this.network)},n.getAddress=function(){return{confidentialAddress:this.confidentialAddress,blindingPrivateKey:this.blindingPrivateKey,derivationPath:void 0}},n.getNextAddress=function(){var t=d(k.mark((function t(){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getAddress());case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.getNextChangeAddress=function(){var t=d(k.mark((function t(){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.getAddress());case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),n.getBlindingPrivateKey=function(){var t=d(k.mark((function t(e){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Buffer.from(e,"hex").equals(this.scriptPubKey)){t.next=3;break}throw new Error("The script is not PrivateKey.scriptPubKey.");case 3:return t.abrupt("return",this.blindingPrivateKey);case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),n.signPset=function(){var t=d(k.mark((function t(r){var n,i,o,a,s=this;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(n=e.Psbt.fromBase64(r),i=[],o=0;o<n.data.inputs.length;o++)(a=n.data.inputs[o]).witnessUtxo?a.witnessUtxo.script.equals(this.scriptPubKey)&&i.push(o):i.push(o);return t.next=5,Promise.all(i.map((function(t){return n.signInputAsync(t,s.signingKeyPair)})));case 5:return t.abrupt("return",n.toBase64());case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),n.getAddresses=function(){var t=d(k.mark((function t(){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",[{confidentialAddress:this.confidentialAddress,blindingPrivateKey:this.blindingPrivateKey,derivationPath:void 0}]);case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r}(Z),tt=function(t){function e(e){var r;if(r=t.call(this,e)||this,e.type!==exports.IdentityType.Inject)throw new Error("The identity arguments have not the Inject type.");if(void 0===window||void 0===window[e.opts.windowProvider])throw new Error("The value.windowProvider of IdentityOpts is not valid or the script is to injected in the window");return r.provider=window[e.opts.windowProvider],r}h(e,t);var r=e.prototype;return r.getNextAddress=function(){return this.provider.getNextAddress()},r.getNextChangeAddress=function(){return this.provider.getNextChangeAddress()},r.signPset=function(t){return this.provider.signTransaction(t)},r.getAddresses=function(){return this.provider.getAddresses()},r.getBlindingPrivateKey=function(t){throw new Error("Method not implemented.")},r.isAbleToSign=function(){return!0},r.blindPset=function(t,e,r,n){throw new Error("Method not implemented.")},e}(Z),et=function(t,e){return t.value-e.value};function rt(t,e,r){for(var n,i=[],o=0,a=m(t=t.sort(r));!(n=a()).done;){var s=n.value;if(C(s)||(i.push(s),o+=s.value),o>=e)return{selected:i,changeAmount:o-e}}throw new Error("not enough utxos in wallet to fund: "+e)}function nt(t,e){return t.reduce((function(t,r){return(t[r[e]]=t[r[e]]||[]).push(r),t}),{})}function it(t){return"surjectionProof"in t&&"rangeProof"in t}var ot=Buffer.alloc(32).toString("hex");function at(t,e){return st.apply(this,arguments)}function st(){return(st=d(k.mark((function t(e,r){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,a.get(r+"/tx/"+e+"/hex");case 2:return t.abrupt("return",t.sent.data);case 3:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function ut(){return(ut=d(k.mark((function t(e,r){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=ft,t.next=3,a.get(r+"/tx/"+e);case 3:return t.t1=t.sent.data,t.t2=r,t.abrupt("return",(0,t.t0)(t.t1,t.t2));case 6:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function ct(t,e){return pt.apply(this,arguments)}function pt(){return(pt=d(k.mark((function t(e,r){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,a.get(r+"/address/"+e+"/utxo");case 2:return t.abrupt("return",t.sent.data);case 3:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function ft(t,e){return dt.apply(this,arguments)}function dt(){return(dt=d(k.mark((function t(r,n){var i,o,a,s,u,c,p,f,d;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(i=[],o=[],a=m(r.vin);!(s=a()).done;)i.push((u=s.value).txid),o.push(u.vout);return t.next=5,Promise.all(i.map((function(t,e){return r.vin[e].is_pegin?Promise.resolve(void 0):at(t,n)})));case 5:return c=t.sent.map((function(t,r){if(t)return lt(e.Transaction.fromHex(t).outs[o[r]])})),p=i.map((function(t,e){return{prevout:c[e],txid:t,vout:o[e],isPegin:r.vin[e].is_pegin}})),t.next=10,at(r.txid,n);case 10:return f=e.Transaction.fromHex(t.sent),d=f.outs.map(lt),t.abrupt("return",{txid:r.txid,vin:p,vout:d,fee:r.fee,status:{confirmed:r.status.confirmed,blockHash:r.status.block_hash,blockHeight:r.status.block_height,blockTime:r.status.block_time}});case 15:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function lt(t){return I(t)?{blindedAsset:t.asset,blindedValue:t.value,nonce:t.nonce,rangeProof:t.rangeProof,surjectionProof:t.surjectionProof,script:t.script.toString("hex")}:{asset:K(t.asset),value:A(t.value),script:t.script.toString("hex"),assetBlinder:ot,valueBlinder:ot}}function ht(t,e,r){return t+"/tx/"+e+"#blinded="+r.map((function(t){return t.value+","+t.asset+","+t.valueBlinder+","+t.assetBlinder})).join(",")}var vt=function(t){function e(e,r,n){return t.call(this,"UnblindError output ("+e+":"+r+") with blind key "+n)||this}return h(e,t),e}(g(Error));function yt(t,e,r,n){return xt.apply(this,arguments)}function xt(){return(xt=c(k.mark((function t(e,r,n,i){var o,a,s,u,c,f,d,l,h,v;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o=[],a=[],s=m(e);case 3:if((u=s()).done){t.next=38;break}return c=u.value,t.prev=5,f=gt(c,n,i),t.next=9,p(f.next());case 9:d=t.sent;case 10:if(d.done){t.next=31;break}if(!o.includes((l=d.value).txid)){t.next=17;break}return t.next=15,p(f.next());case 15:return d=t.sent,t.abrupt("continue",10);case 17:return t.next=19,p(mt(l,r));case 19:return v=(h=t.sent).unblindedTx,a.push.apply(a,h.errors),t.next=25,v;case 25:return o.push(l.txid),t.next=28,p(f.next());case 28:d=t.sent,t.next=10;break;case 31:t.next=36;break;case 33:t.prev=33,t.t0=t.catch(5),a.push(t.t0);case 36:t.next=3;break;case 38:return t.abrupt("return",{txIDs:o,errors:a});case 39:case"end":return t.stop()}}),t,null,[[5,33]])})))).apply(this,arguments)}function bt(){return(bt=d(k.mark((function t(e,r,n,i){var o,a,s;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=yt(e,r,n,i),a=[],t.next=4,o.next();case 4:s=t.sent;case 5:if(s.done){t.next=12;break}return a.push(s.value),t.next=9,o.next();case 9:s=t.sent,t.next=5;break;case 12:return t.abrupt("return",a);case 13:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function gt(t,e,r){return wt.apply(this,arguments)}function wt(){return(wt=c(k.mark((function t(e,r,n){var i,o,a,s,u,c,f,d;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:i=void 0,o=[],a=0;case 3:return t.next=5,p(kt(e,r,i));case 5:if(0!==(o=t.sent).length){t.next=8;break}return t.abrupt("break",24);case 8:i=o[o.length-1].txid,a+=o.length,s=o.map((function(t){return ft(t,r)})),u=m(s);case 12:if((c=u()).done){t.next=23;break}return f=c.value,t.next=16,p(f);case 16:if(d=t.sent,!n||!n(d)){t.next=19;break}return t.abrupt("continue",21);case 19:return t.next=21,d;case 21:t.next=12;break;case 23:if(i){t.next=3;break}case 24:return t.abrupt("return",a);case 25:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function mt(t,e){return Pt.apply(this,arguments)}function Pt(){return(Pt=d(k.mark((function t(e,r){var n,i,o,a,s,u;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(n=[],i=[],o=function(t){var o=e.vin[t].prevout;o&&it(o)&&n.push(function(){var n=d(k.mark((function n(){var a;return k.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(a=r(o.script))){n.next=12;break}return n.prev=2,n.next=5,R(o,a);case 5:e.vin[t].prevout=n.sent,n.next=12;break;case 9:n.prev=9,n.t0=n.catch(2),i.push(new vt(e.vin[t].txid,e.vin[t].vout,a));case 12:case"end":return n.stop()}}),n,null,[[2,9]])})));return function(){return n.apply(this,arguments)}}()())},a=0;a<e.vin.length;a++)o(a);for(s=function(t){var o=e.vout[t];it(o)&&n.push(function(){var n=d(k.mark((function n(){var a;return k.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(a=r(o.script))){n.next=12;break}return n.prev=2,n.next=5,R(o,a);case 5:e.vout[t]=n.sent,n.next=12;break;case 9:n.prev=9,n.t0=n.catch(2),i.push(new vt(e.txid,t,a));case 12:case"end":return n.stop()}}),n,null,[[2,9]])})));return function(){return n.apply(this,arguments)}}()())},u=0;u<e.vout.length;u++)s(u);return t.next=8,Promise.all(n);case 8:return t.abrupt("return",{unblindedTx:e,errors:i});case 9:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function kt(t,e,r){return Kt.apply(this,arguments)}function Kt(){return(Kt=d(k.mark((function t(e,r,n){var i;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=r+"/address/"+e+"/txs/chain",n&&(i+="/"+n),t.next=4,a.get(i);case 4:return t.abrupt("return",t.sent.data);case 6:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function At(){return(At=d(k.mark((function t(e,r,n){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,It([{confidentialAddress:e,blindingPrivateKey:r}],n);case 2:return t.abrupt("return",t.sent.reduce((function(t,e){var r=e.asset;return t[r]=t[r]||0,t[r]+=e.value,t}),{}));case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Bt(t,e,r){return Tt.apply(this,arguments)}function Tt(){return(Tt=c(k.mark((function t(r,n,i){var o,a,s,u,c,f,d,l,h,v,y,x,b,g,w;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o=0,a=[],s=m(r);case 3:if((u=s()).done){t.next=39;break}if(f=(c=u.value).confidentialAddress,d=c.blindingPrivateKey,t.prev=5,!(d.length>0)){t.next=11;break}if(l=e.ECPair.fromPrivateKey(Buffer.from(d,"hex")),h=e.address.fromConfidential(f).blindingKey,l.publicKey.equals(h)){t.next=11;break}throw new Error("wrong blinding private key");case 11:return t.next=13,p(ct(f,n));case 13:v=m(t.sent);case 15:if((y=v()).done){t.next=32;break}if(x=y.value,!i||!i(x)){t.next=21;break}return t.next=20,x;case 20:return t.abrupt("continue",30);case 21:return t.next=23,p(jt(x,d,n));case 23:return g=(b=t.sent).unblindedUtxo,(w=b.error)&&a.push(w),t.next=29,g;case 29:o++;case 30:t.next=15;break;case 32:t.next=37;break;case 34:t.prev=34,t.t0=t.catch(5),a.push(t.t0);case 37:t.next=3;break;case 39:return t.abrupt("return",{numberOfUtxos:o,errors:a});case 40:case"end":return t.stop()}}),t,null,[[5,34]])})))).apply(this,arguments)}function It(t,e,r){return Et.apply(this,arguments)}function Et(){return(Et=d(k.mark((function t(e,r,n){var i,o,a;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=Bt(e,r,n),o=[],t.next=4,i.next();case 4:a=t.sent;case 5:if(a.done){t.next=12;break}return o.push(a.value),t.next=9,i.next();case 9:a=t.sent,t.next=5;break;case 12:return t.abrupt("return",o);case 13:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function St(t,e){return Ot.apply(this,arguments)}function Ot(){return(Ot=d(k.mark((function t(r,n){var i;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,at(r.txid,n);case 2:return i=e.Transaction.fromHex(t.sent).outs[r.vout],t.abrupt("return",l({},r,{prevout:i}));case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function jt(t,e,r){return Ut.apply(this,arguments)}function Ut(){return(Ut=d(k.mark((function t(e,r,n){var i;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.prevout){t.next=4;break}return t.next=3,St(e,n);case 3:e=t.sent;case 4:return t.prev=4,t.next=7,_t(e,r);case 7:return t.abrupt("return",{unblindedUtxo:t.sent});case 11:return t.prev=11,t.t0=t.catch(4),i=new vt(e.txid,e.vout,r),t.abrupt("return",{unblindedUtxo:e,error:i});case 15:case"end":return t.stop()}}),t,null,[[4,11]])})))).apply(this,arguments)}function _t(t,e){return Lt.apply(this,arguments)}function Lt(){return(Lt=d(k.mark((function t(r,n){var i,o;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r.prevout){t.next=2;break}throw new Error("utxo need utxo.prevout to be defined. Use utxoWithPrevout.");case 2:if(I(r.prevout)){t.next=4;break}return t.abrupt("return",r);case 4:return t.next=6,e.confidential.unblindOutputWithKey(r.prevout,Buffer.from(n,"hex"));case 6:return i=t.sent,o=Buffer.alloc(32),i.asset.copy(o),t.abrupt("return",l({},r,{asset:o.reverse().toString("hex"),value:parseInt(i.value,10),unblindData:i}));case 10:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var Nt=function(){function t(t,e){this.network=e,this.cache=t}var r=t.prototype;return r.createTx=function(){return new e.Psbt({network:this.network}).toBase64()},r.buildTx=function(t,e,r,n,i,o){return q({psetBase64:t,recipients:e,coinSelector:r,changeAddressByAsset:n,addFee:i,satsPerByte:o,unspents:this.cache.getAll()})},t}();function Mt(){return(Mt=d(k.mark((function t(e,r,n){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,It(e,r);case 2:return t.abrupt("return",Ft(t.sent,n));case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Ft(t,e){return new Nt(new Ct(t),W(e))}var Ct=function(){function t(t){this.utxoMap=new Map,t&&this.push(t)}var e=t.prototype;return e.push=function(t){for(var e,r=m(t);!(e=r()).done;){var n=e.value;this.utxoMap.set(F(n),n)}},e.delete=function(t){return this.utxoMap.delete(t)},e.getAll=function(){return Array.from(this.utxoMap.values())},t}();function Wt(t){return function(){var e=d(k.mark((function e(r){var n,i,o,a,s,u,c,p,f,l;return k.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=void 0===(n=r.esploraURL)?"https://blockstream.info/liquid/api":n,a=void 0===(o=r.gapLimit)?20:o,u=(s=function(){var t=d(k.mark((function t(e){var r,n,o,s,u;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=0,n=0,o=void 0,s=k.mark((function t(){var s,u,c,p,f;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=n,t.next=3,Promise.all(Array.from(Array(a).keys()).map((function(t){return t+s})).map(e));case 3:return u=t.sent,t.next=6,Promise.all(u.map((function(t){return Rt(t,i)})));case 6:c=0,p=m(t.sent);case 9:if((f=p()).done){t.next=22;break}if(!f.value){t.next=16;break}o=c+n,r=0,t.next=19;break;case 16:if(++r!==a){t.next=19;break}return t.abrupt("return",{v:o});case 19:c++;case 20:t.next=9;break;case 22:n+=a;case 23:case"end":return t.stop()}}),t)}));case 4:if(!(r<a)){t.next=11;break}return t.delegateYield(s(),"t0",6);case 6:if("object"!=typeof(u=t.t0)){t.next=9;break}return t.abrupt("return",u.v);case 9:t.next=4;break;case 11:return t.abrupt("return",o);case 12:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}())((function(e){return Promise.resolve(t.getAddress(!1,e).address.confidentialAddress)})),c=s((function(e){return Promise.resolve(t.getAddress(!0,e).address.confidentialAddress)})),e.next=6,Promise.all([u,c]);case 6:return f=(p=e.sent)[0],l=p[1],e.abrupt("return",qt(t)({lastUsedExternalIndex:f,lastUsedInternalIndex:l}));case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()}function Rt(t,e){return Ht.apply(this,arguments)}function Ht(){return(Ht=d(k.mark((function t(e,r){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,a.get(r+"/address/"+e+"/txs");case 2:return t.abrupt("return",t.sent.data.length>0);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function qt(t){return function(){var e=d(k.mark((function e(r){var n,i,o,a,s,u,c;return k.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=r.lastUsedInternalIndex,o=[],void 0!==(n=r.lastUsedExternalIndex))for(a=0;a<=n;a++)s=t.getNextAddress(),o.push(s);if(void 0!==i)for(u=0;u<=i;u++)c=t.getNextChangeAddress(),o.push(c);return e.next=6,Promise.all(o);case 6:return e.abrupt("return",t);case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()}Object.defineProperty(exports,"ECPair",{enumerable:!0,get:function(){return e.ECPair}}),Object.defineProperty(exports,"address",{enumerable:!0,get:function(){return e.address}}),Object.defineProperty(exports,"networks",{enumerable:!0,get:function(){return e.networks}}),Object.defineProperty(exports,"payments",{enumerable:!0,get:function(){return e.payments}}),exports.BLOCKSTREAM_ESPLORA_ENDPOINT="https://blockstream.info/liquid/api",exports.BrowserInject=tt,exports.BufferMap=S,exports.MasterPublicKey=$,exports.Mnemonic=J,exports.PrivateKey=Q,exports.UtxoCache=Ct,exports.Wallet=Nt,exports.addToTx=D,exports.buildTx=q,exports.createFeeOutput=G,exports.decodePset=V,exports.esploraTxToTxInterface=ft,exports.estimateTxSize=X,exports.fetchAndUnblindTxs=function(t,e,r,n){return bt.apply(this,arguments)},exports.fetchAndUnblindTxsGenerator=yt,exports.fetchAndUnblindUtxos=It,exports.fetchAndUnblindUtxosGenerator=Bt,exports.fetchBalances=function(t,e,r){return At.apply(this,arguments)},exports.fetchPrevoutAndTryToUnblindUtxo=jt,exports.fetchTx=function(t,e){return ut.apply(this,arguments)},exports.fetchTxHex=at,exports.fetchUtxos=ct,exports.fromAssetHash=function(t){return Buffer.concat([Buffer.from("01","hex"),Buffer.from(t,"hex").reverse()])},exports.fromXpub=U,exports.getIndexFromAddress=function(t){if(!t.derivationPath)throw new Error("need derivation path to be defined");var e=t.derivationPath.split("/");return parseInt(e[e.length-1])},exports.getNetwork=W,exports.getUnblindURLFromTx=function(t,e){for(var r,n=[],i=function(t){return Buffer.from(t,"hex").reverse().toString("hex")},o=m(t.vout);!(r=o()).done;){var a=r.value;a.script.length>0&&!it(a)&&n.push(l({},a,{assetBlinder:i(a.assetBlinder),valueBlinder:i(a.valueBlinder)}))}return ht(e,t.txid,n)},exports.greedyCoinSelector=function(t){return void 0===t&&(t=et),function(e,r,n){return function(t,e,r,n){for(var i={selectedUtxos:[],changeOutputs:[]},o=nt(t=t.filter((function(t){return!C(t)})),"asset"),a=nt(e,"asset"),s=0,u=Object.entries(a);s<u.length;s++){var c,p=u[s],f=p[0],d=p[1],l=o[f];if(!l)throw new Error("need unspents for the asset: "+f);var h=rt(l,d.reduce((function(t,e){return t+e.value}),0),n),v=h.changeAmount;if((c=i.selectedUtxos).push.apply(c,h.selected),v>0){var y=r(f);if(!y)throw new Error("need change address for asset: "+f);i.changeOutputs.push({asset:f,value:v,address:y})}}return i}(e,r,n,t)}},exports.isBlindedOutputInterface=it,exports.isBlindedUtxo=C,exports.isConfidentialOutput=I,exports.isValidAmount=function(t){return!(t<=0||!Number.isSafeInteger(t))},exports.isValidExtendedBlindKey=N,exports.isValidXpub=L,exports.makeUnblindURL=ht,exports.masterPubKeyRestorerFromEsplora=function(t){return Wt(t)},exports.masterPubKeyRestorerFromState=function(t){return qt(t)},exports.mnemonicRestorerFromEsplora=function(t){return Wt(t)},exports.mnemonicRestorerFromState=function(t){return qt(t)},exports.psetToUnsignedHex=M,exports.psetToUnsignedTx=function(t){return e.Transaction.fromHex(M(t))},exports.toAssetHash=K,exports.toNumber=A,exports.toOutpoint=F,exports.toXpub=_,exports.unblindOutput=R,exports.unblindTransaction=mt,exports.unblindUtxo=_t,exports.utxoWithPrevout=St,exports.walletFromAddresses=function(t,e,r){return Mt.apply(this,arguments)},exports.walletFromCoins=Ft; | ||
//# sourceMappingURL=ldk.cjs.production.min.js.map |
{ | ||
"version": "0.3.11", | ||
"version": "0.3.12", | ||
"license": "MIT", | ||
@@ -4,0 +4,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
787688