Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ldk

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ldk - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

2

dist/ldk.cjs.production.min.js

@@ -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=require("bip32"),n=require("bip39"),i=t(require("bs58check")),o=require("slip77"),s=t(require("axios"));function u(t){this.wrapped=t}function a(t){var e,r;function n(e,r){try{var o=t[e](r),s=o.value,a=s instanceof u;Promise.resolve(a?s.wrapped:s).then((function(t){a?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,s){var u={key:t,arg:i,resolve:o,reject:s,next:null};r?r=r.next=u:(e=r=u,n(t,i))}))},"function"!=typeof t.return&&(this.return=void 0)}function c(t){return function(){return new a(t.apply(this,arguments))}}function p(t){return new u(t)}function f(t,e,r,n,i,o,s){try{var u=t[o](s),a=u.value}catch(t){return void r(t)}u.done?e(a):Promise.resolve(a).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 s(t){f(o,n,i,s,u,"next",t)}function u(t){f(o,n,i,s,u,"throw",t)}s(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 g(t,e,r){return(g=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 b(t){var e="function"==typeof Map?new Map:void 0;return(b=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 g(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 m(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 w(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 m(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)?m(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.")}a.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},a.prototype.next=function(t){return this._invoke("next",t)},a.prototype.throw=function(t){return this._invoke("throw",t)},a.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",s=n.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function a(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 s=r.delegate;if(s){var u=m(s,r);if(u){if(u===p)continue;return u}}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 a=c(t,e,r);if("normal"===a.type){if(n=r.done?"completed":"suspendedYield",a.arg===p)continue;return{value:a.arg,done:r.done}}"throw"===a.type&&(n="completed",r.method="throw",r.arg=a.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=a;var p={};function f(){}function d(){}function l(){}var h={};u(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 g(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){var n;this._invoke=function(i,o){function s(){return new e((function(n,s){!function n(i,o,s,u){var a=c(t[i],t,o);if("throw"!==a.type){var p=a.arg,f=p.value;return f&&"object"==typeof f&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,s,u)}),(function(t){n("throw",t,s,u)})):e.resolve(f).then((function(t){p.value=t,s(p)}),(function(t){return n("throw",t,s,u)}))}u(a.arg)}(i,o,n,s)}))}return n=n?n.then(s,s):s()}}function m(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,m(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 w(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(w,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=l,u(x,"constructor",l),u(l,"constructor",d),d.displayName=u(l,s,"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,u(t,s,"GeneratorFunction")),t.prototype=Object.create(x),t},t.awrap=function(t){return{__await:t}},g(b.prototype),u(b.prototype,o,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var s=new b(a(e,r,n,i),o);return t.isGeneratorFunction(r)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},g(x),u(x,s,"Generator"),u(x,i,(function(){return this})),u(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 s.type="throw",s.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],s=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var u=r.call(o,"catchLoc"),a=r.call(o,"finallyLoc");if(u&&a){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!a)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 s=o?o.completion:{};return s.type=t,s.arg=e,o?(this.method="next",this.next=o.finallyLoc,p):this.complete(s)},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){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}}(P={exports:{}}),P.exports),K=Buffer.alloc(32),A=Buffer.from("0x00","hex");function E(t){return null!=t&&t.length>0}function I(t){var e=t.surjectionProof,r=t.nonce;return E(t.rangeProof)&&E(e)&&r!==A}var T,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}(),B=new Map([["xpub","0488b21e"],["ypub","049d7cb2"],["Ypub","0295b43f"],["zpub","04b24746"],["Zpub","02aa7ed3"],["tpub","043587cf"],["upub","044a5262"],["Upub","024289ef"],["vpub","045f1cf6"],["Vpub","02575483"]]);function N(t,e){if(!B.has(e))return"Invalid target version";t=t.trim();try{var r=i.decode(t);return r=r.slice(4),r=Buffer.concat([Buffer.from(B.get(e),"hex"),r]),i.encode(r)}catch(t){throw new Error("Invalid extended public key! Please double check that you didn't accidentally paste extra data.")}}function O(t,e){return N(t,"regtest"===e?"vpub":"zpub")}function _(t){return N(t,"xpub")}function M(t,e){try{r.fromBase58(t,e)}catch(t){return!1}return!0}function L(t){try{o.fromMasterBlindingKey(t)}catch(t){return!1}return!0}function U(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 j(t){return t?e.networks[t]:e.networks.liquid}function F(t,e){return C.apply(this,arguments)}function C(){return(C=d(k.mark((function t(r,n){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(I(r.prevout)){t.next=2;break}return t.abrupt("return",l({},r,{unblindData:{asset:r.prevout.asset.slice(1),value:e.confidential.confidentialValueToSatoshi(r.prevout.value).toString(10),assetBlindingFactor:K,valueBlindingFactor:K}}));case 2:return t.next=4,e.confidential.unblindOutputWithKey(r.prevout,Buffer.from(n,"hex"));case 4:return t.abrupt("return",l({},r,{unblindData:t.sent}));case 6:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function D(t,e){if(t!==e)throw new Error("Incorrect Identity type: need "+e+" and get "+t+".")}function R(t,e){if(e&&n.setDefaultWordlist(e),!n.validateMnemonic(t))throw new Error("Mnemonic is not valid.")}function W(t){try{r.fromBase58(t)}catch(e){throw new Error("invalid master public key: "+t)}}function H(t){var r;try{r=e.Psbt.fromBase64(t)}catch(t){throw new Error("Invalid pset")}return r}function X(t,e){return t.reduce((function(t,r){var n,i=e(r),o=null!=(n=t[i])?n:[];return t[i]=[].concat(o,[r]),t}),{})}function q(t){return void 0!==t.unblindData}function G(t){if(q(t))return parseInt(t.unblindData.value,10);if(!I(t.prevout))return e.confidential.confidentialValueToSatoshi(t.prevout.value);throw new Error("cannot get value for confidential output, need unblinded one")}function V(t){if(q(t))return Buffer.from(t.unblindData.asset).reverse().toString("hex");if(!I(t.prevout))return Buffer.from(t.prevout.asset).slice(1).reverse().toString("hex");throw new Error("cannot get asset for confidential output, need unblinded one")}(T=exports.IdentityType||(exports.IdentityType={}))[T.PrivateKey=1]="PrivateKey",T[T.Mnemonic=2]="Mnemonic",T[T.MasterPublicKey=3]="MasterPublicKey",T[T.Inject=4]="Inject",T[T.Ledger=5]="Ledger",T[T.Trezor=6]="Trezor",T[T.MultisigWatchOnly=7]="MultisigWatchOnly",T[T.Multisig=8]="Multisig";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,s){var u,a,c,p,f,d,l,h,v,y,x,g,b,m,P;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:u=new Map,a=new Map,c=H(n),p=e.Transaction.fromHex(U(n)),f=w(i);case 5:if((d=f()).done){t.next=16;break}if(l=d.value,null==o||!o.has(l)){t.next=11;break}return h=Buffer.from(o.get(l),"hex"),a.set(l,h),t.abrupt("continue",14);case 11:v=r(p.outs[l].script).publicKey,a.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(g=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:g=x.witnessUtxo.script;case 24:if(!x.nonWitnessUtxo){t.next=30;break}if(b=p.ins[y].index,I(m=e.Transaction.fromBuffer(x.nonWitnessUtxo).outs[b])){t.next=29;break}return t.abrupt("continue",40);case 29:g=m.script;case 30:if(null==s||!s.has(y)){t.next=33;break}return u.set(y,s.get(y)),t.abrupt("continue",40);case 33:if(g){t.next=35;break}throw new Error("no witness script for input #"+y);case 35:return P=r(g).privateKey,t.next=38,e.confidential.unblindOutputWithKey(x.witnessUtxo,P);case 38:u.set(y,t.sent);case 40:y++,t.next=17;break;case 43:return t.next=45,c.blindOutputsByIndex(u,a);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}(),Y=function(t){function n(e){var i;(i=t.call(this,e)||this).index=n.INITIAL_INDEX,i.changeIndex=n.INITIAL_INDEX,i.scriptToAddressCache={};var s=_(e.opts.masterPublicKey);if(D(e.type,exports.IdentityType.MasterPublicKey),!M(s))throw new Error("Master public key is not valid");if(!L(e.opts.masterBlindingKey))throw new Error("Master blinding key is not valid");return i.masterPublicKeyNode=r.fromBase58(s),i.masterBlindingKeyNode=o.fromMasterBlindingKey(e.opts.masterBlindingKey),i.baseDerivationPath=e.opts.baseDerivationPath||n.INITIAL_BASE_PATH,i}h(n,t);var i=n.prototype;return i.blindPset=function(){var e=d(k.mark((function e(r,n,i,o){var s=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 s.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)}}(),i.isAbleToSign=function(){return!1},i.derivePublicKeyWithIndex=function(t,e){return this.masterPublicKeyNode.derive(t?1:0).derive(e).publicKey},i.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}},i.scriptFromPublicKey=function(t){return e.payments.p2wpkh({pubkey:t,network:this.network}).output.toString("hex")},i.createConfidentialAddress=function(t,r){return e.payments.p2wpkh({pubkey:t,blindkey:r,network:this.network}).confidentialAddress},i.persistAddressToCache=function(t){var e=Buffer.from(t.publicKey,"hex"),r=this.scriptFromPublicKey(e);this.scriptToAddressCache[r]=t},i.getAddress=function(t,e){var r=this.derivePublicKeyWithIndex(t,e),n=this.scriptFromPublicKey(r),i=this.getBlindingKeyPair(n),o=this.createConfidentialAddress(r,i.publicKey),s=this.baseDerivationPath+"/"+(t?1:0)+"/"+e;return{address:{confidentialAddress:o,blindingPrivateKey:i.privateKey.toString("hex"),derivationPath:s},publicKey:r.toString("hex")}},i.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)}}(),i.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)}}(),i.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)}}(),i.signPset=function(t){throw new Error("MasterPublicKey is a watch only identity. Use Mnemonic to sign transactions")},i.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)}}(),i.getXPub=function(){return this.masterPublicKeyNode.toBase58()},n}(z);Y.INITIAL_BASE_PATH="m/84'/0'/0'",Y.INITIAL_INDEX=0;var Z=function(t){function i(i){var s;D(i.type,exports.IdentityType.Mnemonic),n.setDefaultWordlist(i.opts.language||"english"),R(i.opts.mnemonic);var u=n.mnemonicToSeedSync(i.opts.mnemonic),a=r.fromSeed(u,e.networks[i.chain]),c=a.derivePath(Y.INITIAL_BASE_PATH),p=O(e.bip32.fromPublicKey(c.publicKey,c.chainCode,c.network).toBase58(),i.chain),f=o.fromSeed(u),d=f.masterKey.toString("hex");return(s=t.call(this,l({},i,{type:exports.IdentityType.MasterPublicKey,opts:{masterPublicKey:p,masterBlindingKey:d,baseDerivationPath:i.opts.baseDerivationPath}}))||this).masterBlindingKey=d,s.masterBlindingKeyNode=f,s.masterPublicKey=p,s.masterPrivateKeyNode=a,s.mnemonic=i.opts.mnemonic,s}h(i,t);var s=i.prototype;return s.blindPset=function(){var e=d(k.mark((function e(r,n,i,o){var s=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(s,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)}}(),s.isAbleToSign=function(){return!0},s.derivePath=function(t){var r=this.masterPrivateKeyNode.derivePath(t).toWIF(),n=e.ECPair.fromWIF(r,this.network);return{publicKey:n.publicKey,privateKey:n.privateKey}},s.signPset=function(){var t=d(k.mark((function t(r){var n,i,o,s,u,a,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++)(s=n.data.inputs[o]).witnessUtxo&&(u=this.scriptToAddressCache[s.witnessUtxo.script.toString("hex")])&&(a=this.derivePath(u.address.derivationPath).privateKey,c=e.ECPair.fromPrivateKey(a),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)}}(),i.Random=function(t,e){var r=n.generateMnemonic();return new i({chain:t,type:exports.IdentityType.Mnemonic,opts:{mnemonic:r,baseDerivationPath:e}})},i}(Y),$=function(t){function r(r){var n;n=t.call(this,r)||this,D(r.type,exports.IdentityType.PrivateKey),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 s=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 s.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,s,u=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++)(s=n.data.inputs[o]).witnessUtxo?s.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,u.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),J=function(t){function e(e){var r;if(r=t.call(this,e)||this,D(e.type,exports.IdentityType.Inject),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);function Q(t,e){if(t.length!==e.length)throw new Error("a.length !== b.length (xor)");for(var r=Buffer.alloc(t.length),n=0;n<t.length;n++)r[n]=t[n]^e[n];return r}function tt(t){return t.sort(et)}function et(t,e){return t.toString("hex")<e.toString("hex")?-1:1}var rt=function(t){function i(i){var s;(s=t.call(this,i)||this).nextIndex=0,s.nextChangeIndex=0,D(i.type,exports.IdentityType.MultisigWatchOnly),function(t,e){if(t<=0||t>e)throw new Error("number of required signatures must be > 0 and <= "+e)}(i.opts.requiredSignatures,i.opts.cosigners.length);var u,a=i.opts.cosigners.map((function(t){return function(t,e){if("string"==typeof t)return t;var i=n.mnemonicToSeedSync(t.mnemonic),o=r.fromSeed(i,e).derivePath(t.baseDerivationPath||"m/48'/0'/0'/2'");return _(r.fromPublicKey(o.publicKey,o.chainCode,e).toBase58())}(t,s.network)}));return a.forEach(W),s.cosigners=a.sort().map((function(t){return r.fromBase58(t)})),s.blindingKeyMasterNode=(u=function(t){for(var r,n=Buffer.from("blinding_key"),i=Buffer.alloc(32),o=w(t);!(r=o()).done;)i=Q(i,r.value);return e.crypto.sha256(Buffer.concat([n,i]))}(s.cosigners.map((function(t){return t.chainCode}))),o.fromSeed(u)),s.requiredSignatures=i.opts.requiredSignatures,s}h(i,t);var s=i.prototype;return s.getNextAddress=function(){var t=this.getMultisigAddress(i.EXTERNAL_INDEX,this.nextIndex);return this.nextIndex++,Promise.resolve(t)},s.getNextChangeAddress=function(){var t=this.getMultisigAddress(i.INTERNAL_INDEX,this.nextChangeIndex);return this.nextChangeIndex++,Promise.resolve(t)},s.getAddresses=function(){var t=this,e=Array.from(Array(this.nextIndex).keys()).map((function(e){return t.getMultisigAddress(i.EXTERNAL_INDEX,e)})),r=Array.from(Array(this.nextChangeIndex).keys()).map((function(e){return t.getMultisigAddress(i.INTERNAL_INDEX,e)}));return Promise.resolve(e.concat(r))},s.getBlindingPrivateKey=function(t){var e=this.getBlindingKeyPair(t).privateKey;return Promise.resolve(e.toString("hex"))},s.getBlindingKeyPair=function(t){var e=this.blindingKeyMasterNode.derive(t);if(!e.publicKey||!e.privateKey)throw new Error("unable to generate blinding key pair");return{publicKey:e.publicKey,privateKey:e.privateKey}},s.isAbleToSign=function(){return!1},s.signPset=function(t){throw new Error("WatchOnly Multisig Identity is not able to sign pset")},s.blindPset=function(e,r,n,i){var o=this;return t.prototype.blindPsetWithBlindKeysGetter.call(this,(function(t){return o.getBlindingKeyPair(t.toString("hex"))}),e,r,n,i)},s.getMultisigAddress=function(t,r){return l({},function(t,r,n,i){var o=e.payments.p2wsh({redeem:e.payments.p2ms({m:parseInt(n.toString()),pubkeys:tt(t.map((function(t){return t.publicKey}))),network:i}),network:i});if(!o.address)throw new Error("Invalid payment");var s=r.derive(e.address.toOutputScript(o.address,i)),u=s.publicKey,a=s.privateKey;if(!u||!a)throw new Error("something went wrong while generating blinding key pair");if(!(o=e.payments.p2wsh({redeem:e.payments.p2ms({m:parseInt(n.toString()),pubkeys:tt(t.map((function(t){return t.publicKey}))),network:i}),blindkey:u,network:i})).confidentialAddress||!o.redeem||!o.redeem.output)throw new Error("invalid payment");return{blindingPrivateKey:a.toString("hex"),confidentialAddress:o.confidentialAddress,witnessScript:o.redeem.output.toString("hex")}}(this.cosigners.map((function(e){return e.derive(t).derive(r)})),this.blindingKeyMasterNode,this.requiredSignatures,this.network),{derivationPath:t+"/"+r})},i}(z);rt.EXTERNAL_INDEX=0,rt.INTERNAL_INDEX=1;var nt=function(t){function i(i){var o;D(i.type,exports.IdentityType.Multisig),R(i.opts.signer.mnemonic);var s=n.mnemonicToSeedSync(i.opts.signer.mnemonic),u=r.fromSeed(s,e.networks[i.chain]).derivePath(i.opts.signer.baseDerivationPath||"m/48'/0'/0'/2'");return(o=t.call(this,l({},i,{opts:l({},i.opts,{cosigners:i.opts.cosigners.concat([i.opts.signer])}),type:exports.IdentityType.MultisigWatchOnly}))||this).baseDerivationPath=i.opts.signer.baseDerivationPath||"m/48'/0'/0'/2'",o.baseNode=u,o.scriptToPath={},o}h(i,t);var o=i.prototype;return o.getNextAddress=function(){var e=d(k.mark((function e(){var r;return k.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.prototype.getNextAddress.call(this);case 2:if((r=e.sent).derivationPath){e.next=5;break}throw new Error("need derivation path to cache addresses");case 5:return this.scriptToPath[this.toScript(r.confidentialAddress)]=r.derivationPath,e.abrupt("return",r);case 7:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),o.getNextChangeAddress=function(){var e=d(k.mark((function e(){var r;return k.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.prototype.getNextChangeAddress.call(this);case 2:if((r=e.sent).derivationPath){e.next=5;break}throw new Error("need derivation path to cache addresses");case 5:return this.scriptToPath[this.toScript(r.confidentialAddress)]=r.derivationPath,e.abrupt("return",r);case 7:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),o.isAbleToSign=function(){return!0},o.signPset=function(){var t=d(k.mark((function t(r){var n,i,o,s,u,a,c;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=e.Psbt.fromBase64(r),i=[],o=0;case 3:if(!(o<n.data.inputs.length)){t.next=16;break}if(!(s=n.data.inputs[o]).witnessUtxo){t.next=13;break}if(!(u=this.scriptToPath[s.witnessUtxo.script.toString("hex")])){t.next=13;break}if(a=this.baseNode.derivePath(u).privateKey){t.next=11;break}throw new Error("signing private key is undefined");case 11:c=e.ECPair.fromPrivateKey(a),i.push(n.signInputAsync(o,c));case 13:o++,t.next=3;break;case 16:return t.next=18,Promise.all(i);case 18:return t.abrupt("return",n.toBase64());case 19:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),o.getXPub=function(){return _(r.fromPublicKey(this.baseNode.publicKey,this.baseNode.chainCode,this.network).toBase58())},o.toScript=function(t){return e.address.toOutputScript(t,this.network).toString("hex")},i}(rt),it=function(t,e,r){throw new Error("not enought funds to fill "+e+"sats of "+t+" (amount selected: "+r+")")};function ot(t,e){return t.set(e.asset,(t.get(e.asset)||0)+e.value),t}function st(t){return function(e){return V(e)===t}}var ut=function(t){return function(e){var r=e.map((function(t){return{value:G(t)||0,asset:V(t)||""}}));return at(r)(t)}},at=function(t){return function(e){var r=function(t){return t.reduce((function(t,e){return(t[e.asset]=t[e.asset]||[]).push(e),t}),{})},n=r(t),i=r(e),o=Object.keys(n).sort(),s=Object.keys(i).sort();if(!o.every((function(t){return s.includes(t)})))throw new Error("inputs and outputs don't have the same assets. Inputs assets = "+o+", Outputs assets = "+s);for(var u in n){var a=ct(n[u].map((function(t){return t.value}))),c=ct(i[u].map((function(t){return t.value})));if(a!==c)throw new Error("missing funds for asset "+u+" (inputs: "+a+", outputs: "+c+")")}}},ct=function(t){return t.reduce((function(t,e){return t+e}),0)},pt=function(t,e){return G(t)-G(e)};function ft(t,e){return dt.apply(this,arguments)}function dt(){return(dt=d(k.mark((function t(e,r){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,s.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 lt(){return(lt=d(k.mark((function t(e,r){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=xt,t.next=3,s.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 ht(t,e){return vt.apply(this,arguments)}function vt(){return(vt=d(k.mark((function t(e,r){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,s.get(r+"/address/"+e+"/utxo");case 2:return t.abrupt("return",Promise.all(t.sent.data.map(yt(r))));case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var yt=function(t){return function(){var r=d(k.mark((function r(n){var i;return k.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,ft(n.txid,t);case 2:return i=e.Transaction.fromHex(r.sent).outs[n.vout],r.abrupt("return",l({},n,{prevout:i}));case 5:case"end":return r.stop()}}),r)})));return function(t){return r.apply(this,arguments)}}()};function xt(t,e){return gt.apply(this,arguments)}function gt(){return(gt=d(k.mark((function t(r,n){var i,o,s,u,a,c,p,f,d,l;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(i=[],o=[],s=w(r.vin);!(u=s()).done;)i.push((a=u.value).txid),o.push(a.vout);return t.next=5,Promise.all(i.map((function(t,e){return r.vin[e].is_pegin?Promise.resolve(void 0):ft(t,n)})));case 5:return c=t.sent.map((function(t,r){if(t)return bt({txid:i[r],vout:o[r]},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,ft(r.txid,n);case 10:return f=e.Transaction.fromHex(t.sent),d=function(t){return{txid:r.txid,vout:t}},l=f.outs.map((function(t,e){return bt(d(e),t)})),t.abrupt("return",{txid:r.txid,vin:p,vout:l,fee:r.fee,status:{confirmed:r.status.confirmed,blockHash:r.status.block_hash,blockHeight:r.status.block_height,blockTime:r.status.block_time}});case 17:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function bt(t,e){return l({},t,{prevout:e})}function mt(t,e,r){return t+"/tx/"+e+"#blinded="+r.map((function(t){return t.value+","+t.asset+","+t.valueBlinder+","+t.assetBlinder})).join(",")}var wt=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}(b(Error));function Pt(t,e,r,n){return kt.apply(this,arguments)}function kt(){return(kt=c(k.mark((function t(e,r,n,i){var o,s,u,a,c,f,d,l,h,v;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o=[],s=[],u=w(e);case 3:if((a=u()).done){t.next=40;break}return c=a.value,t.prev=5,f=At(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(It(l,r));case 19:return v=(h=t.sent).unblindedTx,s.push.apply(s,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=38;break;case 33:t.prev=33,t.t0=t.catch(5),t.t0 instanceof Error&&s.push(t.t0),"string"==typeof t.t0&&s.push(new Error(t.t0)),s.push(new Error("unknown error"));case 38:t.next=3;break;case 40:return t.abrupt("return",{txIDs:o,errors:s});case 41:case"end":return t.stop()}}),t,null,[[5,33]])})))).apply(this,arguments)}function Kt(){return(Kt=d(k.mark((function t(e,r,n,i){var o,s,u;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=Pt(e,r,n,i),s=[],t.next=4,o.next();case 4:u=t.sent;case 5:if(u.done){t.next=12;break}return s.push(u.value),t.next=9,o.next();case 9:u=t.sent,t.next=5;break;case 12:return t.abrupt("return",s);case 13:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function At(t,e,r){return Et.apply(this,arguments)}function Et(){return(Et=c(k.mark((function t(e,r,n){var i,o,s,u,a,c,f,d;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:i=void 0,o=[],s=0;case 3:return t.next=5,p(St(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,s+=o.length,u=o.map((function(t){return xt(t,r)})),a=w(u);case 12:if((c=a()).done){t.next=23;break}return f=c.value,t.next=16,p(f);case 16:if(d=t.sent,null==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",s);case 25:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function It(t,e){return Tt.apply(this,arguments)}function Tt(){return(Tt=d(k.mark((function t(e,r){var n,i,o,s,u,a;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&&!q(o)&&n.push(function(){var n=d(k.mark((function n(){var s;return k.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(s=r(o.prevout.script.toString("hex")))){n.next=12;break}return n.prev=2,n.next=5,F(o,s);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 wt(e.vin[t].txid,e.vin[t].vout,s));case 12:case"end":return n.stop()}}),n,null,[[2,9]])})));return function(){return n.apply(this,arguments)}}()())},s=0;s<e.vin.length;s++)o(s);for(u=function(t){var o=e.vout[t];q(o)||n.push(function(){var n=d(k.mark((function n(){var s;return k.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(s=r(o.prevout.script.toString("hex")))){n.next=12;break}return n.prev=2,n.next=5,F(o,s);case 5:e.vout[t]=n.sent,n.next=12;break;case 9:n.prev=9,n.t0=n.catch(2),i.push(new wt(e.txid,t,s));case 12:case"end":return n.stop()}}),n,null,[[2,9]])})));return function(){return n.apply(this,arguments)}}()())},a=0;a<e.vout.length;a++)u(a);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 St(t,e,r){return Bt.apply(this,arguments)}function Bt(){return(Bt=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,s.get(i);case 4:return t.abrupt("return",t.sent.data);case 6:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Nt(t,e,r){return Ot.apply(this,arguments)}function Ot(){return(Ot=c(k.mark((function t(r,n,i){var o,s,u,a,c,f,d,l,h,v,y,x;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o=0,s=[],u=w(r);case 3:if((a=u()).done){t.next=33;break}if(f=(c=a.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(ht(f,n));case 13:v=w(t.sent);case 15:if((y=v()).done){t.next=24;break}if(x=y.value,null==i||!i(x)){t.next=19;break}return t.abrupt("continue",22);case 19:return t.next=21,Lt(x,d);case 21:o++;case 22:t.next=15;break;case 24:t.next=31;break;case 26:t.prev=26,t.t0=t.catch(5),t.t0 instanceof Error&&s.push(t.t0),"string"==typeof t.t0&&s.push(new Error(t.t0)),s.push(new Error("unknow error"));case 31:t.next=3;break;case 33:return t.abrupt("return",{numberOfUtxos:o,errors:s});case 34:case"end":return t.stop()}}),t,null,[[5,26]])})))).apply(this,arguments)}function _t(t,e,r){return Mt.apply(this,arguments)}function Mt(){return(Mt=d(k.mark((function t(e,r,n){var i,o,s;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=Nt(e,r,n),o=[],t.next=4,i.next();case 4:s=t.sent;case 5:if(s.done){t.next=12;break}return o.push(s.value),t.next=9,i.next();case 9:s=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 Lt(t,e){return Ut.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.prev=0,t.abrupt("return",F(e,r));case 4:throw t.prev=4,t.t0=t.catch(0),new wt(e.txid,e.vout,r);case 7:case"end":return t.stop()}}),t,null,[[0,4]])})))).apply(this,arguments)}function jt(t,r,n,i,o,s){void 0===o&&(o=!1),void 0===s&&(s=Ft);var u=e.address.getNetwork(r.address),a=o&&r.asset===u.assetHash,c=Dt(n(it)(t,[r],(function(){return i})).selectedUtxos.length,2,s,u.assetHash),p=it;a&&(p=function(t,e,n){t!==r.asset?it(t,e,n):r.value=n-c.value});var f=n(p)(t,[r,c],(function(){return i})),d=f.selectedUtxos,l=[r].concat(f.changeOutputs,[c]);return ut(l)(d),Rt(new e.Psbt({network:u}).toBase64(),d,l)}var Ft=.1;function Ct(t){var r=function(t){if(t.satsPerByte||(t.satsPerByte=Ft),t.errorHandler||(t.errorHandler=it),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,s=r.recipients,u=r.unspents,a=r.addFee,c=r.satsPerByte,p=r.errorHandler,f=i(p)(u,s,n);if(!a){var d=s.concat(f.changeOutputs);return ut(d)(f.selectedUtxos),Rt(o,f.selectedUtxos,d)}var l=function(t,r,n,i){var o=H(t);return Dt(o.data.inputs.length+r.selectedUtxos.length+1,o.data.outputs.length+n.length+r.changeOutputs.length+1,i,e.address.getNetwork(n[0].address).assetHash)}(o,f,s,c),h=i(p)(u,[].concat(s,[l]),n),v=h.selectedUtxos,y=[].concat(s,h.changeOutputs,[l]);return ut(y)(v),Rt(o,v,y)}function Dt(t,e,r,n){var i=Wt(t,e);return{asset:n,value:Math.ceil(i*r),address:""}}function Rt(t,r,n){for(var i,o=H(t),s=Buffer.from("00","hex"),u=w(n);!(i=u()).done;){var a=i.value,c=a.asset,p=a.value,f=a.address,d=""===f?"":e.address.toOutputScript(f);o.addOutput({asset:c,value:p,script:d,nonce:s})}for(var l,h=w(r);!(l=h()).done;){var v=l.value;o.addInput({hash:v.txid,index:v.vout,witnessUtxo:v.prevout})}return o.toBase64()}function Wt(t,e){return(3*Ht(!1,t,e,!1)+Ht(!0,t,e,!0)+3)/4}function Ht(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+Xt(r)+Xt(e)+i+o}function Xt(t){return t<253?1:t<=65535?3:t<=4294967295?5:9}var qt=function(){function t(t,e){this.network=e,this.unspents=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 Ct({psetBase64:t,recipients:e,coinSelector:r,changeAddressByAsset:n,addFee:i,satsPerByte:o,unspents:this.unspents})},r.sendTx=function(t,e,r,n,i){return void 0===n&&(n=!1),void 0===i&&(i=Ft),jt(this.unspents,t,e,r,n,i)},t}();function Gt(){return(Gt=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,_t(e,r);case 2:return t.abrupt("return",Vt(t.sent,n));case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Vt(t,e){return new qt(t,j(e))}function zt(t){return t.reduce((function(t,e){return t+G(e)}),0)}function Yt(t,e){return function(){var r=d(k.mark((function r(n){var i,o,s,u,a,c,p,f,l,h;return k.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return o=void 0===(i=n.esploraURL)?"https://blockstream.info/liquid/api":i,u=void 0===(s=n.gapLimit)?20:s,c=(a=function(){var t=d(k.mark((function t(e){var r,n,i,s,a;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=0,n=0,i=void 0,s=k.mark((function t(){var s,a,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(u).keys()).map((function(t){return t+s})).map(e));case 3:return a=t.sent,t.next=6,Promise.all(a.map((function(t){return Zt(t,o)})));case 6:c=0,p=w(t.sent);case 9:if((f=p()).done){t.next=22;break}if(!f.value){t.next=16;break}i=c+n,r=0,t.next=19;break;case 16:if(++r!==u){t.next=19;break}return t.abrupt("return",{v:i});case 19:c++;case 20:t.next=9;break;case 22:n+=u;case 23:case"end":return t.stop()}}),t)}));case 4:if(!(r<u)){t.next=11;break}return t.delegateYield(s(),"t0",6);case 6:if("object"!=typeof(a=t.t0)){t.next=9;break}return t.abrupt("return",a.v);case 9:t.next=4;break;case 11:return t.abrupt("return",i);case 12:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}())((function(t){return Promise.resolve(e(!1,t))})),p=a((function(t){return Promise.resolve(e(!0,t))})),r.next=6,Promise.all([c,p]);case 6:return l=(f=r.sent)[0],h=f[1],r.abrupt("return",Jt(t)({lastUsedExternalIndex:l,lastUsedInternalIndex:h}));case 10:case"end":return r.stop()}}),r)})));return function(t){return r.apply(this,arguments)}}()}function Zt(t,e){return $t.apply(this,arguments)}function $t(){return($t=d(k.mark((function t(e,r){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,s.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 Jt(t){return function(){var e=d(k.mark((function e(r){var n,i,o,s,u,a,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(s=0;s<=n;s++)u=t.getNextAddress(),o.push(u);if(void 0!==i)for(a=0;a<=i;a++)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=J,exports.BufferMap=S,exports.DEFAULT_BASE_DERIVATION_PATH="m/48'/0'/0'/2'",exports.DEFAULT_SATS_PER_BYTE=Ft,exports.Identity=z,exports.MasterPublicKey=Y,exports.Mnemonic=Z,exports.Multisig=nt,exports.MultisigWatchOnly=rt,exports.PrivateKey=$,exports.Wallet=qt,exports.addToTx=Rt,exports.balances=function(t){for(var e=X(t,V),r={},n=0,i=Object.entries(e);n<i.length;n++){var o=i[n];r[o[0]]=zt(o[1])}return r},exports.checkIdentityType=D,exports.checkMasterPublicKey=W,exports.checkMnemonic=R,exports.craftMultipleRecipientsPset=Ct,exports.craftSingleRecipientPset=jt,exports.createFeeOutput=Dt,exports.decodePset=H,exports.esploraTxToTxInterface=xt,exports.estimateTxSize=Wt,exports.fetchAndUnblindTxs=function(t,e,r,n){return Kt.apply(this,arguments)},exports.fetchAndUnblindTxsGenerator=Pt,exports.fetchAndUnblindUtxos=_t,exports.fetchAndUnblindUtxosGenerator=Nt,exports.fetchTx=function(t,e){return lt.apply(this,arguments)},exports.fetchTxHex=ft,exports.fetchUtxos=ht,exports.fromAssetHash=function(t){return Buffer.concat([Buffer.from("01","hex"),Buffer.from(t,"hex").reverse()])},exports.fromXpub=O,exports.getAsset=V,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=j,exports.getSats=G,exports.getScripts=function(t){return new Set(t.map((function(t){return e.address.toOutputScript(t.confidentialAddress).toString("hex")})))},exports.getUnblindURLFromTx=function(t,e){for(var r,n=[],i=function(t){return Buffer.from(t,"hex").reverse().toString("hex")},o=w(t.vout);!(r=o()).done;){var s=r.value;s.prevout.script.length>0&&q(s)&&n.push({value:G(s),asset:V(s),assetBlinder:i(s.unblindData.assetBlindingFactor.toString("hex")),valueBlinder:i(s.unblindData.valueBlindingFactor.toString("hex"))})}return mt(e,t.txid,n)},exports.greedyCoinSelector=function(t){return void 0===t&&(t=pt),function(e){void 0===e&&(e=it);var r,n=(r=t,function(t){return function(e){return function(n){var i=[],o=function(t){return function(e){return function(r){return function(n){return function(i){var o=0,s=i.filter(st(r)).sort(t).reduce((function(t,e){return o<=n&&(t.push(e),o+=G(e)),t}),[]);return o<n&&e(r,n,o),s}}}}}(r)(t);return n.forEach((function(t,e){i.push(o(e)(t))})),i.flatMap((function(t){return t(e)}))}}})(e);return function(t,e,r){var i=function(t){return function(e){return function(r){var n=[];return e.forEach((function(e,i){var o,s=(o=r,function(t){var e=function(t){return function(e){return e.filter(st(t)).reduce((function(t,e){return t+G(e)}),0)}}(t)(o);return function(t){return e-t}})(i)(e);s>0&&n.push({address:t(i),asset:i,value:s})})),n}}}(r),o=function(t){return t.reduce(ot,new Map)}(e),s=n(t)(o);return{selectedUtxos:s,changeOutputs:i(o)(s)}}}},exports.groupBy=X,exports.isConfidentialOutput=I,exports.isUnblindedOutput=q,exports.isValidAmount=function(t){return!(t<=0||!Number.isSafeInteger(t))},exports.isValidExtendedBlindKey=L,exports.isValidXpub=M,exports.makeUnblindURL=mt,exports.masterPubKeyRestorerFromEsplora=function(t){return Yt(t,(function(e,r){return t.getAddress(e,r).address.confidentialAddress}))},exports.masterPubKeyRestorerFromState=function(t){return Jt(t)},exports.mnemonicRestorerFromEsplora=function(t){return Yt(t,(function(e,r){return t.getAddress(e,r).address.confidentialAddress}))},exports.mnemonicRestorerFromState=function(t){return Jt(t)},exports.multisigFromEsplora=function(t){return Yt(t,(function(e,r){return t.getMultisigAddress(e?rt.INTERNAL_INDEX:rt.EXTERNAL_INDEX,r).confidentialAddress}))},exports.multisigWatchOnlyFromEsplora=function(t){return Yt(t,(function(e,r){return t.getMultisigAddress(e?rt.INTERNAL_INDEX:rt.EXTERNAL_INDEX,r).confidentialAddress}))},exports.psetToUnsignedHex=U,exports.psetToUnsignedTx=function(t){return e.Transaction.fromHex(U(t))},exports.restorerFromState=Jt,exports.toAssetHash=function(t){return t.slice(1).reverse().toString("hex")},exports.toNumber=function(t){return e.confidential.confidentialValueToSatoshi(t)},exports.toOutpoint=function(t){return{txid:t.txid,vout:t.vout}},exports.toXpub=_,exports.unblindOutput=F,exports.unblindTransaction=It,exports.utxosFromTransactions=function(t,e,r){void 0===r&&(r=[]);var n=function(t){return t||Infinity};return t.sort((function(t,e){return function(t,e){return n(t.status.blockHeight)-n(e.status.blockHeight)||0}(t,e)||function(t,e){return t.vin.map((function(t){return t.txid})).includes(e.txid)?1:-1}(t,e)})).reduce((function(t,r,n){return function(t,e,r){var n=e.vout.filter((function(t){return r.has(t.prevout.script.toString("hex"))}));return t.concat(n)}(function(t,e){for(var r,n=t,i=function(){var t=r.value;n=n.filter((function(e){return!(e.txid===t.txid&&e.vout===t.vout)}))},o=w(e);!(r=o()).done;)i();return n}(t,r.vin),r,e)}),r)},exports.walletFromAddresses=function(t,e,r){return Gt.apply(this,arguments)},exports.walletFromCoins=Vt;
"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=require("bip32"),n=require("bip39"),i=t(require("bs58check")),o=require("slip77"),s=t(require("axios"));function u(t){this.wrapped=t}function a(t){var e,r;function n(e,r){try{var o=t[e](r),s=o.value,a=s instanceof u;Promise.resolve(a?s.wrapped:s).then((function(t){a?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,s){var u={key:t,arg:i,resolve:o,reject:s,next:null};r?r=r.next=u:(e=r=u,n(t,i))}))},"function"!=typeof t.return&&(this.return=void 0)}function c(t){return function(){return new a(t.apply(this,arguments))}}function p(t){return new u(t)}function f(t,e,r,n,i,o,s){try{var u=t[o](s),a=u.value}catch(t){return void r(t)}u.done?e(a):Promise.resolve(a).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 s(t){f(o,n,i,s,u,"next",t)}function u(t){f(o,n,i,s,u,"throw",t)}s(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 g(t,e,r){return(g=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 b(t){var e="function"==typeof Map?new Map:void 0;return(b=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 g(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 m(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 w(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 m(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)?m(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.")}a.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},a.prototype.next=function(t){return this._invoke("next",t)},a.prototype.throw=function(t){return this._invoke("throw",t)},a.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",s=n.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function a(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 s=r.delegate;if(s){var u=m(s,r);if(u){if(u===p)continue;return u}}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 a=c(t,e,r);if("normal"===a.type){if(n=r.done?"completed":"suspendedYield",a.arg===p)continue;return{value:a.arg,done:r.done}}"throw"===a.type&&(n="completed",r.method="throw",r.arg=a.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=a;var p={};function f(){}function d(){}function l(){}var h={};u(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 g(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){var n;this._invoke=function(i,o){function s(){return new e((function(n,s){!function n(i,o,s,u){var a=c(t[i],t,o);if("throw"!==a.type){var p=a.arg,f=p.value;return f&&"object"==typeof f&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,s,u)}),(function(t){n("throw",t,s,u)})):e.resolve(f).then((function(t){p.value=t,s(p)}),(function(t){return n("throw",t,s,u)}))}u(a.arg)}(i,o,n,s)}))}return n=n?n.then(s,s):s()}}function m(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,m(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 w(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(w,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=l,u(x,"constructor",l),u(l,"constructor",d),d.displayName=u(l,s,"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,u(t,s,"GeneratorFunction")),t.prototype=Object.create(x),t},t.awrap=function(t){return{__await:t}},g(b.prototype),u(b.prototype,o,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var s=new b(a(e,r,n,i),o);return t.isGeneratorFunction(r)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},g(x),u(x,s,"Generator"),u(x,i,(function(){return this})),u(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 s.type="throw",s.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],s=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var u=r.call(o,"catchLoc"),a=r.call(o,"finallyLoc");if(u&&a){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!a)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 s=o?o.completion:{};return s.type=t,s.arg=e,o?(this.method="next",this.next=o.finallyLoc,p):this.complete(s)},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){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}}(P={exports:{}}),P.exports),K=Buffer.alloc(32),A=Buffer.from("0x00","hex");function E(t){return null!=t&&t.length>0}function I(t){var e=t.surjectionProof,r=t.nonce;return E(t.rangeProof)&&E(e)&&r!==A}var T,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}(),B=new Map([["xpub","0488b21e"],["ypub","049d7cb2"],["Ypub","0295b43f"],["zpub","04b24746"],["Zpub","02aa7ed3"],["tpub","043587cf"],["upub","044a5262"],["Upub","024289ef"],["vpub","045f1cf6"],["Vpub","02575483"]]);function N(t,e){if(!B.has(e))return"Invalid target version";t=t.trim();try{var r=i.decode(t);return r=r.slice(4),r=Buffer.concat([Buffer.from(B.get(e),"hex"),r]),i.encode(r)}catch(t){throw new Error("Invalid extended public key! Please double check that you didn't accidentally paste extra data.")}}function O(t,e){return N(t,"liquid"===e?"zpub":"vpub")}function _(t){return N(t,"xpub")}function M(t,e){try{r.fromBase58(t,e)}catch(t){return!1}return!0}function L(t){try{o.fromMasterBlindingKey(t)}catch(t){return!1}return!0}function U(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 j(t){return t?e.networks[t]:e.networks.liquid}function F(t,e){return C.apply(this,arguments)}function C(){return(C=d(k.mark((function t(r,n){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(I(r.prevout)){t.next=2;break}return t.abrupt("return",l({},r,{unblindData:{asset:r.prevout.asset.slice(1),value:e.confidential.confidentialValueToSatoshi(r.prevout.value).toString(10),assetBlindingFactor:K,valueBlindingFactor:K}}));case 2:return t.next=4,e.confidential.unblindOutputWithKey(r.prevout,Buffer.from(n,"hex"));case 4:return t.abrupt("return",l({},r,{unblindData:t.sent}));case 6:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function D(t,e){if(t!==e)throw new Error("Incorrect Identity type: need "+e+" and get "+t+".")}function R(t,e){if(e&&n.setDefaultWordlist(e),!n.validateMnemonic(t))throw new Error("Mnemonic is not valid.")}function W(t){try{r.fromBase58(t)}catch(e){throw new Error("invalid master public key: "+t)}}function H(t){var r;try{r=e.Psbt.fromBase64(t)}catch(t){throw new Error("Invalid pset")}return r}function X(t,e){return t.reduce((function(t,r){var n,i=e(r),o=null!=(n=t[i])?n:[];return t[i]=[].concat(o,[r]),t}),{})}function q(t){return void 0!==t.unblindData}function G(t){if(q(t))return parseInt(t.unblindData.value,10);if(!I(t.prevout))return e.confidential.confidentialValueToSatoshi(t.prevout.value);throw new Error("cannot get value for confidential output, need unblinded one")}function V(t){if(q(t))return Buffer.from(t.unblindData.asset).reverse().toString("hex");if(!I(t.prevout))return Buffer.from(t.prevout.asset).slice(1).reverse().toString("hex");throw new Error("cannot get asset for confidential output, need unblinded one")}(T=exports.IdentityType||(exports.IdentityType={}))[T.PrivateKey=1]="PrivateKey",T[T.Mnemonic=2]="Mnemonic",T[T.MasterPublicKey=3]="MasterPublicKey",T[T.Inject=4]="Inject",T[T.Ledger=5]="Ledger",T[T.Trezor=6]="Trezor",T[T.MultisigWatchOnly=7]="MultisigWatchOnly",T[T.Multisig=8]="Multisig";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,s){var u,a,c,p,f,d,l,h,v,y,x,g,b,m,P;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:u=new Map,a=new Map,c=H(n),p=e.Transaction.fromHex(U(n)),f=w(i);case 5:if((d=f()).done){t.next=16;break}if(l=d.value,null==o||!o.has(l)){t.next=11;break}return h=Buffer.from(o.get(l),"hex"),a.set(l,h),t.abrupt("continue",14);case 11:v=r(p.outs[l].script).publicKey,a.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(g=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:g=x.witnessUtxo.script;case 24:if(!x.nonWitnessUtxo){t.next=30;break}if(b=p.ins[y].index,I(m=e.Transaction.fromBuffer(x.nonWitnessUtxo).outs[b])){t.next=29;break}return t.abrupt("continue",40);case 29:g=m.script;case 30:if(null==s||!s.has(y)){t.next=33;break}return u.set(y,s.get(y)),t.abrupt("continue",40);case 33:if(g){t.next=35;break}throw new Error("no witness script for input #"+y);case 35:return P=r(g).privateKey,t.next=38,e.confidential.unblindOutputWithKey(x.witnessUtxo,P);case 38:u.set(y,t.sent);case 40:y++,t.next=17;break;case 43:return t.next=45,c.blindOutputsByIndex(u,a);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}(),Y=function(t){function n(e){var i;(i=t.call(this,e)||this).index=n.INITIAL_INDEX,i.changeIndex=n.INITIAL_INDEX,i.scriptToAddressCache={};var s=_(e.opts.masterPublicKey);if(D(e.type,exports.IdentityType.MasterPublicKey),!M(s))throw new Error("Master public key is not valid");if(!L(e.opts.masterBlindingKey))throw new Error("Master blinding key is not valid");return i.masterPublicKeyNode=r.fromBase58(s),i.masterBlindingKeyNode=o.fromMasterBlindingKey(e.opts.masterBlindingKey),i.baseDerivationPath=e.opts.baseDerivationPath||n.INITIAL_BASE_PATH,i}h(n,t);var i=n.prototype;return i.blindPset=function(){var e=d(k.mark((function e(r,n,i,o){var s=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 s.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)}}(),i.isAbleToSign=function(){return!1},i.derivePublicKeyWithIndex=function(t,e){return this.masterPublicKeyNode.derive(t?1:0).derive(e).publicKey},i.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}},i.scriptFromPublicKey=function(t){return e.payments.p2wpkh({pubkey:t,network:this.network}).output.toString("hex")},i.createConfidentialAddress=function(t,r){return e.payments.p2wpkh({pubkey:t,blindkey:r,network:this.network}).confidentialAddress},i.persistAddressToCache=function(t){var e=Buffer.from(t.publicKey,"hex"),r=this.scriptFromPublicKey(e);this.scriptToAddressCache[r]=t},i.getAddress=function(t,e){var r=this.derivePublicKeyWithIndex(t,e),n=this.scriptFromPublicKey(r),i=this.getBlindingKeyPair(n),o=this.createConfidentialAddress(r,i.publicKey),s=this.baseDerivationPath+"/"+(t?1:0)+"/"+e;return{address:{confidentialAddress:o,blindingPrivateKey:i.privateKey.toString("hex"),derivationPath:s},publicKey:r.toString("hex")}},i.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)}}(),i.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)}}(),i.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)}}(),i.signPset=function(t){throw new Error("MasterPublicKey is a watch only identity. Use Mnemonic to sign transactions")},i.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)}}(),i.getXPub=function(){return this.masterPublicKeyNode.toBase58()},n}(z);Y.INITIAL_BASE_PATH="m/84'/0'/0'",Y.INITIAL_INDEX=0;var Z=function(t){function i(i){var s;D(i.type,exports.IdentityType.Mnemonic),n.setDefaultWordlist(i.opts.language||"english"),R(i.opts.mnemonic);var u=n.mnemonicToSeedSync(i.opts.mnemonic),a=r.fromSeed(u,e.networks[i.chain]),c=a.derivePath(Y.INITIAL_BASE_PATH),p=O(e.bip32.fromPublicKey(c.publicKey,c.chainCode,c.network).toBase58(),i.chain),f=o.fromSeed(u),d=f.masterKey.toString("hex");return(s=t.call(this,l({},i,{type:exports.IdentityType.MasterPublicKey,opts:{masterPublicKey:p,masterBlindingKey:d,baseDerivationPath:i.opts.baseDerivationPath}}))||this).masterBlindingKey=d,s.masterBlindingKeyNode=f,s.masterPublicKey=p,s.masterPrivateKeyNode=a,s.mnemonic=i.opts.mnemonic,s}h(i,t);var s=i.prototype;return s.blindPset=function(){var e=d(k.mark((function e(r,n,i,o){var s=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(s,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)}}(),s.isAbleToSign=function(){return!0},s.derivePath=function(t){var r=this.masterPrivateKeyNode.derivePath(t).toWIF(),n=e.ECPair.fromWIF(r,this.network);return{publicKey:n.publicKey,privateKey:n.privateKey}},s.signPset=function(){var t=d(k.mark((function t(r){var n,i,o,s,u,a,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++)(s=n.data.inputs[o]).witnessUtxo&&(u=this.scriptToAddressCache[s.witnessUtxo.script.toString("hex")])&&(a=this.derivePath(u.address.derivationPath).privateKey,c=e.ECPair.fromPrivateKey(a),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)}}(),i.Random=function(t,e){var r=n.generateMnemonic();return new i({chain:t,type:exports.IdentityType.Mnemonic,opts:{mnemonic:r,baseDerivationPath:e}})},i}(Y),$=function(t){function r(r){var n;n=t.call(this,r)||this,D(r.type,exports.IdentityType.PrivateKey),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 s=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 s.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,s,u=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++)(s=n.data.inputs[o]).witnessUtxo?s.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,u.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),J=function(t){function e(e){var r;if(r=t.call(this,e)||this,D(e.type,exports.IdentityType.Inject),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);function Q(t,e){if(t.length!==e.length)throw new Error("a.length !== b.length (xor)");for(var r=Buffer.alloc(t.length),n=0;n<t.length;n++)r[n]=t[n]^e[n];return r}function tt(t){return t.sort(et)}function et(t,e){return t.toString("hex")<e.toString("hex")?-1:1}var rt=function(t){function i(i){var s;(s=t.call(this,i)||this).nextIndex=0,s.nextChangeIndex=0,D(i.type,exports.IdentityType.MultisigWatchOnly),function(t,e){if(t<=0||t>e)throw new Error("number of required signatures must be > 0 and <= "+e)}(i.opts.requiredSignatures,i.opts.cosigners.length);var u,a=i.opts.cosigners.map((function(t){return function(t,e){if("string"==typeof t)return t;var i=n.mnemonicToSeedSync(t.mnemonic),o=r.fromSeed(i,e).derivePath(t.baseDerivationPath||"m/48'/0'/0'/2'");return _(r.fromPublicKey(o.publicKey,o.chainCode,e).toBase58())}(t,s.network)}));return a.forEach(W),s.cosigners=a.sort().map((function(t){return r.fromBase58(t)})),s.blindingKeyMasterNode=(u=function(t){for(var r,n=Buffer.from("blinding_key"),i=Buffer.alloc(32),o=w(t);!(r=o()).done;)i=Q(i,r.value);return e.crypto.sha256(Buffer.concat([n,i]))}(s.cosigners.map((function(t){return t.chainCode}))),o.fromSeed(u)),s.requiredSignatures=i.opts.requiredSignatures,s}h(i,t);var s=i.prototype;return s.getNextAddress=function(){var t=this.getMultisigAddress(i.EXTERNAL_INDEX,this.nextIndex);return this.nextIndex++,Promise.resolve(t)},s.getNextChangeAddress=function(){var t=this.getMultisigAddress(i.INTERNAL_INDEX,this.nextChangeIndex);return this.nextChangeIndex++,Promise.resolve(t)},s.getAddresses=function(){var t=this,e=Array.from(Array(this.nextIndex).keys()).map((function(e){return t.getMultisigAddress(i.EXTERNAL_INDEX,e)})),r=Array.from(Array(this.nextChangeIndex).keys()).map((function(e){return t.getMultisigAddress(i.INTERNAL_INDEX,e)}));return Promise.resolve(e.concat(r))},s.getBlindingPrivateKey=function(t){var e=this.getBlindingKeyPair(t).privateKey;return Promise.resolve(e.toString("hex"))},s.getBlindingKeyPair=function(t){var e=this.blindingKeyMasterNode.derive(t);if(!e.publicKey||!e.privateKey)throw new Error("unable to generate blinding key pair");return{publicKey:e.publicKey,privateKey:e.privateKey}},s.isAbleToSign=function(){return!1},s.signPset=function(t){throw new Error("WatchOnly Multisig Identity is not able to sign pset")},s.blindPset=function(e,r,n,i){var o=this;return t.prototype.blindPsetWithBlindKeysGetter.call(this,(function(t){return o.getBlindingKeyPair(t.toString("hex"))}),e,r,n,i)},s.getMultisigAddress=function(t,r){return l({},function(t,r,n,i){var o=e.payments.p2wsh({redeem:e.payments.p2ms({m:parseInt(n.toString()),pubkeys:tt(t.map((function(t){return t.publicKey}))),network:i}),network:i});if(!o.address)throw new Error("Invalid payment");var s=r.derive(e.address.toOutputScript(o.address,i)),u=s.publicKey,a=s.privateKey;if(!u||!a)throw new Error("something went wrong while generating blinding key pair");if(!(o=e.payments.p2wsh({redeem:e.payments.p2ms({m:parseInt(n.toString()),pubkeys:tt(t.map((function(t){return t.publicKey}))),network:i}),blindkey:u,network:i})).confidentialAddress||!o.redeem||!o.redeem.output)throw new Error("invalid payment");return{blindingPrivateKey:a.toString("hex"),confidentialAddress:o.confidentialAddress,witnessScript:o.redeem.output.toString("hex")}}(this.cosigners.map((function(e){return e.derive(t).derive(r)})),this.blindingKeyMasterNode,this.requiredSignatures,this.network),{derivationPath:t+"/"+r})},i}(z);rt.EXTERNAL_INDEX=0,rt.INTERNAL_INDEX=1;var nt=function(t){function i(i){var o;D(i.type,exports.IdentityType.Multisig),R(i.opts.signer.mnemonic);var s=n.mnemonicToSeedSync(i.opts.signer.mnemonic),u=r.fromSeed(s,e.networks[i.chain]).derivePath(i.opts.signer.baseDerivationPath||"m/48'/0'/0'/2'");return(o=t.call(this,l({},i,{opts:l({},i.opts,{cosigners:i.opts.cosigners.concat([i.opts.signer])}),type:exports.IdentityType.MultisigWatchOnly}))||this).baseDerivationPath=i.opts.signer.baseDerivationPath||"m/48'/0'/0'/2'",o.baseNode=u,o.scriptToPath={},o}h(i,t);var o=i.prototype;return o.getNextAddress=function(){var e=d(k.mark((function e(){var r;return k.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.prototype.getNextAddress.call(this);case 2:if((r=e.sent).derivationPath){e.next=5;break}throw new Error("need derivation path to cache addresses");case 5:return this.scriptToPath[this.toScript(r.confidentialAddress)]=r.derivationPath,e.abrupt("return",r);case 7:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),o.getNextChangeAddress=function(){var e=d(k.mark((function e(){var r;return k.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.prototype.getNextChangeAddress.call(this);case 2:if((r=e.sent).derivationPath){e.next=5;break}throw new Error("need derivation path to cache addresses");case 5:return this.scriptToPath[this.toScript(r.confidentialAddress)]=r.derivationPath,e.abrupt("return",r);case 7:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),o.isAbleToSign=function(){return!0},o.signPset=function(){var t=d(k.mark((function t(r){var n,i,o,s,u,a,c;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=e.Psbt.fromBase64(r),i=[],o=0;case 3:if(!(o<n.data.inputs.length)){t.next=16;break}if(!(s=n.data.inputs[o]).witnessUtxo){t.next=13;break}if(!(u=this.scriptToPath[s.witnessUtxo.script.toString("hex")])){t.next=13;break}if(a=this.baseNode.derivePath(u).privateKey){t.next=11;break}throw new Error("signing private key is undefined");case 11:c=e.ECPair.fromPrivateKey(a),i.push(n.signInputAsync(o,c));case 13:o++,t.next=3;break;case 16:return t.next=18,Promise.all(i);case 18:return t.abrupt("return",n.toBase64());case 19:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),o.getXPub=function(){return _(r.fromPublicKey(this.baseNode.publicKey,this.baseNode.chainCode,this.network).toBase58())},o.toScript=function(t){return e.address.toOutputScript(t,this.network).toString("hex")},i}(rt),it=function(t,e,r){throw new Error("not enought funds to fill "+e+"sats of "+t+" (amount selected: "+r+")")};function ot(t,e){return t.set(e.asset,(t.get(e.asset)||0)+e.value),t}function st(t){return function(e){return V(e)===t}}var ut=function(t){return function(e){var r=e.map((function(t){return{value:G(t)||0,asset:V(t)||""}}));return at(r)(t)}},at=function(t){return function(e){var r=function(t){return t.reduce((function(t,e){return(t[e.asset]=t[e.asset]||[]).push(e),t}),{})},n=r(t),i=r(e),o=Object.keys(n).sort(),s=Object.keys(i).sort();if(!o.every((function(t){return s.includes(t)})))throw new Error("inputs and outputs don't have the same assets. Inputs assets = "+o+", Outputs assets = "+s);for(var u in n){var a=ct(n[u].map((function(t){return t.value}))),c=ct(i[u].map((function(t){return t.value})));if(a!==c)throw new Error("missing funds for asset "+u+" (inputs: "+a+", outputs: "+c+")")}}},ct=function(t){return t.reduce((function(t,e){return t+e}),0)},pt=function(t,e){return G(t)-G(e)};function ft(t,e){return dt.apply(this,arguments)}function dt(){return(dt=d(k.mark((function t(e,r){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,s.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 lt(){return(lt=d(k.mark((function t(e,r){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=xt,t.next=3,s.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 ht(t,e){return vt.apply(this,arguments)}function vt(){return(vt=d(k.mark((function t(e,r){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,s.get(r+"/address/"+e+"/utxo");case 2:return t.abrupt("return",Promise.all(t.sent.data.map(yt(r))));case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var yt=function(t){return function(){var r=d(k.mark((function r(n){var i;return k.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,ft(n.txid,t);case 2:return i=e.Transaction.fromHex(r.sent).outs[n.vout],r.abrupt("return",l({},n,{prevout:i}));case 5:case"end":return r.stop()}}),r)})));return function(t){return r.apply(this,arguments)}}()};function xt(t,e){return gt.apply(this,arguments)}function gt(){return(gt=d(k.mark((function t(r,n){var i,o,s,u,a,c,p,f,d,l;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(i=[],o=[],s=w(r.vin);!(u=s()).done;)i.push((a=u.value).txid),o.push(a.vout);return t.next=5,Promise.all(i.map((function(t,e){return r.vin[e].is_pegin?Promise.resolve(void 0):ft(t,n)})));case 5:return c=t.sent.map((function(t,r){if(t)return bt({txid:i[r],vout:o[r]},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,ft(r.txid,n);case 10:return f=e.Transaction.fromHex(t.sent),d=function(t){return{txid:r.txid,vout:t}},l=f.outs.map((function(t,e){return bt(d(e),t)})),t.abrupt("return",{txid:r.txid,vin:p,vout:l,fee:r.fee,status:{confirmed:r.status.confirmed,blockHash:r.status.block_hash,blockHeight:r.status.block_height,blockTime:r.status.block_time}});case 17:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function bt(t,e){return l({},t,{prevout:e})}function mt(t,e,r){return t+"/tx/"+e+"#blinded="+r.map((function(t){return t.value+","+t.asset+","+t.valueBlinder+","+t.assetBlinder})).join(",")}var wt=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}(b(Error));function Pt(t,e,r,n){return kt.apply(this,arguments)}function kt(){return(kt=c(k.mark((function t(e,r,n,i){var o,s,u,a,c,f,d,l,h,v;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o=[],s=[],u=w(e);case 3:if((a=u()).done){t.next=40;break}return c=a.value,t.prev=5,f=At(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(It(l,r));case 19:return v=(h=t.sent).unblindedTx,s.push.apply(s,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=38;break;case 33:t.prev=33,t.t0=t.catch(5),t.t0 instanceof Error&&s.push(t.t0),"string"==typeof t.t0&&s.push(new Error(t.t0)),s.push(new Error("unknown error"));case 38:t.next=3;break;case 40:return t.abrupt("return",{txIDs:o,errors:s});case 41:case"end":return t.stop()}}),t,null,[[5,33]])})))).apply(this,arguments)}function Kt(){return(Kt=d(k.mark((function t(e,r,n,i){var o,s,u;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=Pt(e,r,n,i),s=[],t.next=4,o.next();case 4:u=t.sent;case 5:if(u.done){t.next=12;break}return s.push(u.value),t.next=9,o.next();case 9:u=t.sent,t.next=5;break;case 12:return t.abrupt("return",s);case 13:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function At(t,e,r){return Et.apply(this,arguments)}function Et(){return(Et=c(k.mark((function t(e,r,n){var i,o,s,u,a,c,f,d;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:i=void 0,o=[],s=0;case 3:return t.next=5,p(St(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,s+=o.length,u=o.map((function(t){return xt(t,r)})),a=w(u);case 12:if((c=a()).done){t.next=23;break}return f=c.value,t.next=16,p(f);case 16:if(d=t.sent,null==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",s);case 25:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function It(t,e){return Tt.apply(this,arguments)}function Tt(){return(Tt=d(k.mark((function t(e,r){var n,i,o,s,u,a;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&&!q(o)&&n.push(function(){var n=d(k.mark((function n(){var s;return k.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(s=r(o.prevout.script.toString("hex")))){n.next=12;break}return n.prev=2,n.next=5,F(o,s);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 wt(e.vin[t].txid,e.vin[t].vout,s));case 12:case"end":return n.stop()}}),n,null,[[2,9]])})));return function(){return n.apply(this,arguments)}}()())},s=0;s<e.vin.length;s++)o(s);for(u=function(t){var o=e.vout[t];q(o)||n.push(function(){var n=d(k.mark((function n(){var s;return k.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(s=r(o.prevout.script.toString("hex")))){n.next=12;break}return n.prev=2,n.next=5,F(o,s);case 5:e.vout[t]=n.sent,n.next=12;break;case 9:n.prev=9,n.t0=n.catch(2),i.push(new wt(e.txid,t,s));case 12:case"end":return n.stop()}}),n,null,[[2,9]])})));return function(){return n.apply(this,arguments)}}()())},a=0;a<e.vout.length;a++)u(a);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 St(t,e,r){return Bt.apply(this,arguments)}function Bt(){return(Bt=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,s.get(i);case 4:return t.abrupt("return",t.sent.data);case 6:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Nt(t,e,r){return Ot.apply(this,arguments)}function Ot(){return(Ot=c(k.mark((function t(r,n,i){var o,s,u,a,c,f,d,l,h,v,y,x;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o=0,s=[],u=w(r);case 3:if((a=u()).done){t.next=33;break}if(f=(c=a.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(ht(f,n));case 13:v=w(t.sent);case 15:if((y=v()).done){t.next=24;break}if(x=y.value,null==i||!i(x)){t.next=19;break}return t.abrupt("continue",22);case 19:return t.next=21,Lt(x,d);case 21:o++;case 22:t.next=15;break;case 24:t.next=31;break;case 26:t.prev=26,t.t0=t.catch(5),t.t0 instanceof Error&&s.push(t.t0),"string"==typeof t.t0&&s.push(new Error(t.t0)),s.push(new Error("unknow error"));case 31:t.next=3;break;case 33:return t.abrupt("return",{numberOfUtxos:o,errors:s});case 34:case"end":return t.stop()}}),t,null,[[5,26]])})))).apply(this,arguments)}function _t(t,e,r){return Mt.apply(this,arguments)}function Mt(){return(Mt=d(k.mark((function t(e,r,n){var i,o,s;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=Nt(e,r,n),o=[],t.next=4,i.next();case 4:s=t.sent;case 5:if(s.done){t.next=12;break}return o.push(s.value),t.next=9,i.next();case 9:s=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 Lt(t,e){return Ut.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.prev=0,t.abrupt("return",F(e,r));case 4:throw t.prev=4,t.t0=t.catch(0),new wt(e.txid,e.vout,r);case 7:case"end":return t.stop()}}),t,null,[[0,4]])})))).apply(this,arguments)}function jt(t,r,n,i,o,s){void 0===o&&(o=!1),void 0===s&&(s=Ft);var u=e.address.getNetwork(r.address),a=o&&r.asset===u.assetHash,c=n(it)(t,[r],(function(){return i})),p=Dt(c.selectedUtxos.length,c.changeOutputs.length+2,s,u.assetHash),f=it;a&&(f=function(t,e,n){t!==r.asset?it(t,e,n):r.value=n-p.value});var d=n(f)(t,[r,p],(function(){return i})),l=d.selectedUtxos,h=[r].concat(d.changeOutputs,[p]);return ut(h)(l),Rt(new e.Psbt({network:u}).toBase64(),l,h)}var Ft=.1;function Ct(t){var r=function(t){if(t.satsPerByte||(t.satsPerByte=Ft),t.errorHandler||(t.errorHandler=it),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,s=r.recipients,u=r.unspents,a=r.addFee,c=r.satsPerByte,p=r.errorHandler,f=i(p)(u,s,n);if(!a){var d=s.concat(f.changeOutputs);return ut(d)(f.selectedUtxos),Rt(o,f.selectedUtxos,d)}var l=function(t,r,n,i){var o=H(t);return Dt(o.data.inputs.length+r.selectedUtxos.length+1,o.data.outputs.length+n.length+r.changeOutputs.length+1,i,e.address.getNetwork(n[0].address).assetHash)}(o,f,s,c),h=i(p)(u,[].concat(s,[l]),n),v=h.selectedUtxos,y=[].concat(s,h.changeOutputs,[l]);return ut(y)(v),Rt(o,v,y)}function Dt(t,e,r,n){var i=Wt(t,e);return{asset:n,value:Math.ceil(i*r),address:""}}function Rt(t,r,n){for(var i,o=H(t),s=Buffer.from("00","hex"),u=w(n);!(i=u()).done;){var a=i.value,c=a.asset,p=a.value,f=a.address,d=""===f?"":e.address.toOutputScript(f);o.addOutput({asset:c,value:p,script:d,nonce:s})}for(var l,h=w(r);!(l=h()).done;){var v=l.value;o.addInput({hash:v.txid,index:v.vout,witnessUtxo:v.prevout})}return o.toBase64()}function Wt(t,e){return(3*Ht(!1,t,e,!1)+Ht(!0,t,e,!0)+3)/4}function Ht(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+Xt(r)+Xt(e)+i+o}function Xt(t){return t<253?1:t<=65535?3:t<=4294967295?5:9}var qt=function(){function t(t,e){this.network=e,this.unspents=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 Ct({psetBase64:t,recipients:e,coinSelector:r,changeAddressByAsset:n,addFee:i,satsPerByte:o,unspents:this.unspents})},r.sendTx=function(t,e,r,n,i){return void 0===n&&(n=!1),void 0===i&&(i=Ft),jt(this.unspents,t,e,r,n,i)},t}();function Gt(){return(Gt=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,_t(e,r);case 2:return t.abrupt("return",Vt(t.sent,n));case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function Vt(t,e){return new qt(t,j(e))}function zt(t){return t.reduce((function(t,e){return t+G(e)}),0)}function Yt(t,e){return function(){var r=d(k.mark((function r(n){var i,o,s,u,a,c,p,f,l,h;return k.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return o=void 0===(i=n.esploraURL)?"https://blockstream.info/liquid/api":i,u=void 0===(s=n.gapLimit)?20:s,c=(a=function(){var t=d(k.mark((function t(e){var r,n,i,s,a;return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=0,n=0,i=void 0,s=k.mark((function t(){var s,a,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(u).keys()).map((function(t){return t+s})).map(e));case 3:return a=t.sent,t.next=6,Promise.all(a.map((function(t){return Zt(t,o)})));case 6:c=0,p=w(t.sent);case 9:if((f=p()).done){t.next=22;break}if(!f.value){t.next=16;break}i=c+n,r=0,t.next=19;break;case 16:if(++r!==u){t.next=19;break}return t.abrupt("return",{v:i});case 19:c++;case 20:t.next=9;break;case 22:n+=u;case 23:case"end":return t.stop()}}),t)}));case 4:if(!(r<u)){t.next=11;break}return t.delegateYield(s(),"t0",6);case 6:if("object"!=typeof(a=t.t0)){t.next=9;break}return t.abrupt("return",a.v);case 9:t.next=4;break;case 11:return t.abrupt("return",i);case 12:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}())((function(t){return Promise.resolve(e(!1,t))})),p=a((function(t){return Promise.resolve(e(!0,t))})),r.next=6,Promise.all([c,p]);case 6:return l=(f=r.sent)[0],h=f[1],r.abrupt("return",Jt(t)({lastUsedExternalIndex:l,lastUsedInternalIndex:h}));case 10:case"end":return r.stop()}}),r)})));return function(t){return r.apply(this,arguments)}}()}function Zt(t,e){return $t.apply(this,arguments)}function $t(){return($t=d(k.mark((function t(e,r){return k.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,s.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 Jt(t){return function(){var e=d(k.mark((function e(r){var n,i,o,s,u,a,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(s=0;s<=n;s++)u=t.getNextAddress(),o.push(u);if(void 0!==i)for(a=0;a<=i;a++)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=J,exports.BufferMap=S,exports.DEFAULT_BASE_DERIVATION_PATH="m/48'/0'/0'/2'",exports.DEFAULT_SATS_PER_BYTE=Ft,exports.Identity=z,exports.MasterPublicKey=Y,exports.Mnemonic=Z,exports.Multisig=nt,exports.MultisigWatchOnly=rt,exports.PrivateKey=$,exports.Wallet=qt,exports.addToTx=Rt,exports.balances=function(t){for(var e=X(t,V),r={},n=0,i=Object.entries(e);n<i.length;n++){var o=i[n];r[o[0]]=zt(o[1])}return r},exports.checkIdentityType=D,exports.checkMasterPublicKey=W,exports.checkMnemonic=R,exports.craftMultipleRecipientsPset=Ct,exports.craftSingleRecipientPset=jt,exports.createFeeOutput=Dt,exports.decodePset=H,exports.esploraTxToTxInterface=xt,exports.estimateTxSize=Wt,exports.fetchAndUnblindTxs=function(t,e,r,n){return Kt.apply(this,arguments)},exports.fetchAndUnblindTxsGenerator=Pt,exports.fetchAndUnblindUtxos=_t,exports.fetchAndUnblindUtxosGenerator=Nt,exports.fetchTx=function(t,e){return lt.apply(this,arguments)},exports.fetchTxHex=ft,exports.fetchUtxos=ht,exports.fromAssetHash=function(t){return Buffer.concat([Buffer.from("01","hex"),Buffer.from(t,"hex").reverse()])},exports.fromXpub=O,exports.getAsset=V,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=j,exports.getSats=G,exports.getScripts=function(t){return new Set(t.map((function(t){return e.address.toOutputScript(t.confidentialAddress).toString("hex")})))},exports.getUnblindURLFromTx=function(t,e){for(var r,n=[],i=function(t){return Buffer.from(t,"hex").reverse().toString("hex")},o=w(t.vout);!(r=o()).done;){var s=r.value;s.prevout.script.length>0&&q(s)&&n.push({value:G(s),asset:V(s),assetBlinder:i(s.unblindData.assetBlindingFactor.toString("hex")),valueBlinder:i(s.unblindData.valueBlindingFactor.toString("hex"))})}return mt(e,t.txid,n)},exports.greedyCoinSelector=function(t){return void 0===t&&(t=pt),function(e){void 0===e&&(e=it);var r,n=(r=t,function(t){return function(e){return function(n){var i=[],o=function(t){return function(e){return function(r){return function(n){return function(i){var o=0,s=i.filter(st(r)).sort(t).reduce((function(t,e){return o<=n&&(t.push(e),o+=G(e)),t}),[]);return o<n&&e(r,n,o),s}}}}}(r)(t);return n.forEach((function(t,e){i.push(o(e)(t))})),i.flatMap((function(t){return t(e)}))}}})(e);return function(t,e,r){var i=function(t){return function(e){return function(r){var n=[];return e.forEach((function(e,i){var o,s=(o=r,function(t){var e=function(t){return function(e){return e.filter(st(t)).reduce((function(t,e){return t+G(e)}),0)}}(t)(o);return function(t){return e-t}})(i)(e);s>0&&n.push({address:t(i),asset:i,value:s})})),n}}}(r),o=function(t){return t.reduce(ot,new Map)}(e),s=n(t)(o);return{selectedUtxos:s,changeOutputs:i(o)(s)}}}},exports.groupBy=X,exports.isConfidentialOutput=I,exports.isUnblindedOutput=q,exports.isValidAmount=function(t){return!(t<=0||!Number.isSafeInteger(t))},exports.isValidExtendedBlindKey=L,exports.isValidXpub=M,exports.makeUnblindURL=mt,exports.masterPubKeyRestorerFromEsplora=function(t){return Yt(t,(function(e,r){return t.getAddress(e,r).address.confidentialAddress}))},exports.masterPubKeyRestorerFromState=function(t){return Jt(t)},exports.mnemonicRestorerFromEsplora=function(t){return Yt(t,(function(e,r){return t.getAddress(e,r).address.confidentialAddress}))},exports.mnemonicRestorerFromState=function(t){return Jt(t)},exports.multisigFromEsplora=function(t){return Yt(t,(function(e,r){return t.getMultisigAddress(e?rt.INTERNAL_INDEX:rt.EXTERNAL_INDEX,r).confidentialAddress}))},exports.multisigWatchOnlyFromEsplora=function(t){return Yt(t,(function(e,r){return t.getMultisigAddress(e?rt.INTERNAL_INDEX:rt.EXTERNAL_INDEX,r).confidentialAddress}))},exports.psetToUnsignedHex=U,exports.psetToUnsignedTx=function(t){return e.Transaction.fromHex(U(t))},exports.restorerFromState=Jt,exports.toAssetHash=function(t){return t.slice(1).reverse().toString("hex")},exports.toNumber=function(t){return e.confidential.confidentialValueToSatoshi(t)},exports.toOutpoint=function(t){return{txid:t.txid,vout:t.vout}},exports.toXpub=_,exports.unblindOutput=F,exports.unblindTransaction=It,exports.utxosFromTransactions=function(t,e,r){void 0===r&&(r=[]);var n=function(t){return t||Infinity};return t.sort((function(t,e){return function(t,e){return n(t.status.blockHeight)-n(e.status.blockHeight)||0}(t,e)||function(t,e){return t.vin.map((function(t){return t.txid})).includes(e.txid)?1:-1}(t,e)})).reduce((function(t,r,n){return function(t,e,r){var n=e.vout.filter((function(t){return r.has(t.prevout.script.toString("hex"))}));return t.concat(n)}(function(t,e){for(var r,n=t,i=function(){var t=r.value;n=n.filter((function(e){return!(e.txid===t.txid&&e.vout===t.vout)}))},o=w(e);!(r=o()).done;)i();return n}(t,r.vin),r,e)}),r)},exports.walletFromAddresses=function(t,e,r){return Gt.apply(this,arguments)},exports.walletFromCoins=Vt;
//# sourceMappingURL=ldk.cjs.production.min.js.map

@@ -28,3 +28,3 @@ /// <reference types="node" />

}
export declare function fromXpub(xub: string, chain: string): string;
export declare function fromXpub(xub: string, chain: NetworkString): string;
export declare function toXpub(anyPub: string): string;

@@ -31,0 +31,0 @@ export declare function isValidXpub(xpub: string, network?: Network): boolean;

{
"version": "0.4.1",
"version": "0.4.2",
"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

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