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.1.6 to 0.1.7

1

dist/identity/masterpubkey.d.ts

@@ -45,3 +45,2 @@ import { AddressInterface } from '../types';

private generateSetOfAddresses;
private addressToChangeAddressAsync;
private checkAddressesWithRestorer;

@@ -48,0 +47,0 @@ private restoreAddresses;

@@ -59,3 +59,2 @@ import { Slip77Interface } from 'slip77';

private generateSetOfAddresses;
private addressToChangeAddressAsync;
private checkAddressesWithRestorer;

@@ -62,0 +61,0 @@ private restoreAddresses;

2

dist/ldk.cjs.production.min.js

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

"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("liquidjs-lib"),r=e(require("axios")),n=e(require("bs58check")),i=require("bip32"),s=require("slip77"),o=require("bip39");function a(e){this.wrapped=e}function u(e){var t,r;function n(t,r){try{var s=e[t](r),o=s.value,u=o instanceof a;Promise.resolve(u?o.wrapped:o).then((function(e){u?n("return"===t?"return":"next",e):i(s.done?"return":"normal",e)}),(function(e){n("throw",e)}))}catch(e){i("throw",e)}}function i(e,i){switch(e){case"return":t.resolve({value:i,done:!0});break;case"throw":t.reject(i);break;default:t.resolve({value:i,done:!1})}(t=t.next)?n(t.key,t.arg):r=null}this._invoke=function(e,i){return new Promise((function(s,o){var a={key:e,arg:i,resolve:s,reject:o,next:null};r?r=r.next=a:(t=r=a,n(e,i))}))},"function"!=typeof e.return&&(this.return=void 0)}function c(e){return function(){return new u(e.apply(this,arguments))}}function p(e){return new a(e)}function f(e,t,r,n,i,s,o){try{var a=e[s](o),u=a.value}catch(e){return void r(e)}a.done?t(u):Promise.resolve(u).then(n,i)}function d(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var s=e.apply(t,r);function o(e){f(s,n,i,o,a,"next",e)}function a(e){f(s,n,i,o,a,"throw",e)}o(void 0)}))}}function h(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,(Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function v(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return l(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?l(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[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.")}return(r=e[Symbol.iterator]()).next.bind(r)}"function"==typeof Symbol&&Symbol.asyncIterator&&(u.prototype[Symbol.asyncIterator]=function(){return this}),u.prototype.next=function(e){return this._invoke("next",e)},u.prototype.throw=function(e){return this._invoke("throw",e)},u.prototype.return=function(e){return this._invoke("return",e)};var y,x=(function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",s=n.asyncIterator||"@@asyncIterator",o=n.toStringTag||"@@toStringTag";function a(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{a({},"")}catch(e){a=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var i=Object.create((t&&t.prototype instanceof f?t:f).prototype),s=new k(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(i,s){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw s;return{value:void 0,done:!0}}for(r.method=i,r.arg=s;;){var o=r.delegate;if(o){var a=b(o,r);if(a){if(a===p)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===p)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,s),i}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var p={};function f(){}function d(){}function h(){}var l={};l[i]=function(){return this};var v=Object.getPrototypeOf,y=v&&v(v(A([])));y&&y!==t&&r.call(y,i)&&(l=y);var x=h.prototype=f.prototype=Object.create(l);function g(e){["next","throw","return"].forEach((function(t){a(e,t,(function(e){return this._invoke(t,e)}))}))}function m(e,t){var n;this._invoke=function(i,s){function o(){return new t((function(n,o){!function n(i,s,o,a){var u=c(e[i],e,s);if("throw"!==u.type){var p=u.arg,f=p.value;return f&&"object"==typeof f&&r.call(f,"__await")?t.resolve(f.__await).then((function(e){n("next",e,o,a)}),(function(e){n("throw",e,o,a)})):t.resolve(f).then((function(e){p.value=e,o(p)}),(function(e){return n("throw",e,o,a)}))}a(u.arg)}(i,s,n,o)}))}return n=n?n.then(o,o):o()}}function b(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method))return p;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,p;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,p):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,p)}function w(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function P(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(w,this),this.reset(!0)}function A(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,s=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return s.next=s}}return{next:K}}function K(){return{value:void 0,done:!0}}return d.prototype=x.constructor=h,h.constructor=d,d.displayName=a(h,o,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,a(e,o,"GeneratorFunction")),e.prototype=Object.create(x),e},e.awrap=function(e){return{__await:e}},g(m.prototype),m.prototype[s]=function(){return this},e.AsyncIterator=m,e.async=function(t,r,n,i,s){void 0===s&&(s=Promise);var o=new m(u(t,r,n,i),s);return e.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},g(x),a(x,o,"Generator"),x[i]=function(){return this},x.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=A,k.prototype={constructor:k,reset:function(e){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),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return o.type="throw",o.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i],o=s.completion;if("root"===s.tryLoc)return n("end");if(s.tryLoc<=this.prev){var a=r.call(s,"catchLoc"),u=r.call(s,"finallyLoc");if(a&&u){if(this.prev<s.catchLoc)return n(s.catchLoc,!0);if(this.prev<s.finallyLoc)return n(s.finallyLoc)}else if(a){if(this.prev<s.catchLoc)return n(s.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return n(s.finallyLoc)}}}},abrupt:function(e,t){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 s=i;break}}s&&("break"===e||"continue"===e)&&s.tryLoc<=t&&t<=s.finallyLoc&&(s=null);var o=s?s.completion:{};return o.type=e,o.arg=t,s?(this.method="next",this.next=s.finallyLoc,p):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),p},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),P(r),p}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;P(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:A(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}}(y={exports:{}}),y.exports),g=function e(t){var n=this;this.esploraEndpoint=e.DEFAULT_ESPLORA_ENDPOINT,this.addressesHaveBeenUsed=function(){var e=d(x.mark((function e(t){return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",r.all(t.map(n.addressHasBeenUsed)));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),this.addressHasBeenUsed=function(){var e=d(x.mark((function e(t){return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",r.get(n.esploraEndpoint+"/address/"+t+"/txs").then((function(e){return e.data.length>0}),(function(e){return!1})).catch((function(){return!1})));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),t&&(this.esploraEndpoint=t)};function m(e){var r=function(e){if(e.satsPerByte||(e.satsPerByte=.1),e.addFee||(e.addFee=!1),e.addFee&&e.satsPerByte<.1)throw new Error("satsPerByte minimum value is 0.1");if(0===e.recipients.length)throw new Error("need a least one recipient output to build the transaction");if(0===e.unspents.length)throw new Error("need at least one unspent to fund the transaction");return e}(e),n=r.changeAddressByAsset,i=r.coinSelector,s=r.psetBase64,o=r.recipients,a=r.unspents,u=r.addFee,c=r.satsPerByte,p=i(a,o,n),f=p.selectedUtxos,d=p.changeOutputs,h=f;if(!u)return w(s,h,o.concat(d));var l=P(s),y=l.data.inputs.length+h.length,x=l.data.outputs.length+o.length+d.length,g=t.address.getNetwork(o[0].address).assetHash,m=b(y,x,c,g),k=d.findIndex((function(e){return e.asset===g})),A=-1===k?0-m.value:d[k].value-m.value;if(A>0)return d[k].value=A,w(s,h,o.concat(d).concat(m));if(0===A)return w(s,h,o.concat(m));for(var K,I=[],T=v(a);!(K=T()).done;){var E=K.value;f.includes(E)||I.push(E)}var B=b(y+1,x+1,c,g),S=i(I,[B],n);return w(s,h.concat(S.selectedUtxos),o.concat(d).concat(S.changeOutputs).concat(B))}function b(e,t,r,n){var i=k(e,t);return{asset:n,value:Math.ceil(i*r),address:""}}function w(e,r,n){for(var i,s=P(e),o=Buffer.from("00","hex"),a=v(n);!(i=a()).done;){var u=i.value,c=u.asset,p=u.value,f=u.address,d=""===f?"":t.address.toOutputScript(f);s.addOutput({asset:c,value:p,script:d,nonce:o})}for(var h,l=v(r);!(h=l()).done;){var y=h.value;s.addInput({hash:y.txid,index:y.vout,witnessUtxo:y.prevout})}return s.toBase64()}function P(e){var r;try{r=t.Psbt.fromBase64(e)}catch(e){throw new Error("Invalid pset")}return r}function k(e,t){return(3*A(!1,e,t,!1)+A(!0,e,t,!0)+3)/4}function A(e,t,r,n){var i=function(e,t){var r=40*t;return e&&(r+=105*t),r}(e,t),s=function(e,t){var r=67*t;return e&&(r+=4273*t),r+43}(n,r);return 9+K(r)+K(t)+i+s}function K(e){return e<253?1:e<=65535?3:e<=4294967295?5:9}function I(e){return e.slice(1).reverse().toString("hex")}function T(e){return t.confidential.confidentialValueToSatoshi(e)}g.DEFAULT_ESPLORA_ENDPOINT="https://blockstream.info/liquid/api";var E=Buffer.from("0x00","hex");function B(e){return null!=e&&e.length>0}function S(e){var t=e.surjectionProof,r=e.nonce;return B(e.rangeProof)&&B(t)&&r!==E}var N,O=function(){function e(){this.map=new Map}var t=e.prototype;return t.bufferToStringPrimitive=function(e){return e.toString("hex").valueOf()},t.get=function(e){return this.map.get(this.bufferToStringPrimitive(e))},t.set=function(e,t){return this.map.set(this.bufferToStringPrimitive(e),t),this},t.values=function(){return Array.from(this.map.values())},e}(),L=new Map([["xpub","0488b21e"],["ypub","049d7cb2"],["Ypub","0295b43f"],["zpub","04b24746"],["Zpub","02aa7ed3"],["tpub","043587cf"],["upub","044a5262"],["Upub","024289ef"],["vpub","045f1cf6"],["Vpub","02575483"]]);function _(e,t){if(!L.has(t))return"Invalid target version";e=e.trim();try{var r=n.decode(e);return r=r.slice(4),r=Buffer.concat([Buffer.from(L.get(t),"hex"),r]),n.encode(r)}catch(e){throw new Error("Invalid extended public key! Please double check that you didn't accidentally paste extra data.")}}function M(e,t){return _(e,"regtest"===t?"vpub":"zpub")}function U(e){return _(e,"xpub")}function C(e,t){try{i.fromBase58(e,t)}catch(e){return!1}return!0}function F(e){try{s.fromMasterBlindingKey(e)}catch(e){return!1}return!0}function j(e){var r;try{r=t.Psbt.fromBase64(e)}catch(e){throw new Error("Invalid pset")}return r.data.globalMap.unsignedTx.toBuffer().toString("hex")}function W(e){return{txid:e.txid,vout:e.vout}}function R(e){return!e.asset||!e.value}function D(e){return e?t.networks[e]:t.networks.liquid}(N=exports.IdentityType||(exports.IdentityType={}))[N.PrivateKey=1]="PrivateKey",N[N.Mnemonic=2]="Mnemonic",N[N.MasterPublicKey=3]="MasterPublicKey",N[N.Inject=4]="Inject",N[N.Ledger=5]="Ledger",N[N.Trezor=6]="Trezor";var H=function(){function e(r){if(!r.chain||!t.networks.hasOwnProperty(r.chain))throw new Error("Network is missing or not valid");if(!r.type||!(r.type in exports.IdentityType))throw new Error("Type is missing or not valid");this.network=t.networks[r.chain],this.type=r.type,this.restorer=r.restorer?r.restorer:e.DEFAULT_RESTORER}return e.prototype.blindPsetWithBlindKeysGetter=function(){var e=d(x.mark((function e(r,n,i,s,o){var a,u,c,p,f,d,h,l,y,g,m,b,w,k,A,K;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Map,u=new Map,c=P(n),p=t.Transaction.fromHex(j(n)),f=v(i);case 5:if((d=f()).done){e.next=16;break}if(h=d.value,!s||!s.has(h)){e.next=11;break}return l=Buffer.from(s.get(h),"hex"),u.set(h,l),e.abrupt("continue",14);case 11:y=r(p.outs[h].script).publicKey,u.set(h,y);case 14:e.next=5;break;case 16:g=0;case 17:if(!(g<c.data.inputs.length)){e.next=41;break}if(b=void 0,!(m=c.data.inputs[g]).witnessUtxo){e.next=24;break}if(S(m.witnessUtxo)){e.next=23;break}return e.abrupt("continue",38);case 23:b=m.witnessUtxo.script;case 24:if(!m.nonWitnessUtxo){e.next=30;break}if(w=p.ins[g].index,S(k=t.Transaction.fromBuffer(m.nonWitnessUtxo).outs[w])){e.next=29;break}return e.abrupt("continue",38);case 29:b=k.script;case 30:if(!o||!o.has(g)){e.next=34;break}return A=Buffer.from(o.get(g),"hex"),a.set(g,A),e.abrupt("continue",38);case 34:if(b){e.next=36;break}throw new Error("no witness script for input #"+g);case 36:K=r(b).privateKey,a.set(g,K);case 38:g++,e.next=17;break;case 41:return e.abrupt("return",c.blindOutputsByIndex(a,u).toBase64());case 42:case"end":return e.stop()}}),e)})));return function(t,r,n,i,s){return e.apply(this,arguments)}}(),e}();function G(e){var t=e.derivationPath.split("/");return parseInt(t[t.length-1])}H.DEFAULT_RESTORER=new g;var X=function(e){function r(n){var a;if((a=e.call(this,n)||this).baseDerivationPath=r.INITIAL_BASE_PATH,a.index=r.INITIAL_INDEX,a.changeIndex=r.INITIAL_INDEX,a.scriptToAddressCache=new O,n.type!==exports.IdentityType.Mnemonic)throw new Error("The identity arguments have not the Mnemonic type.");if(!("mnemonic"in n.value))throw new Error("The value of IdentityOpts is not valid for Mnemonic Identity.");if(o.setDefaultWordlist(n.value.language?n.value.language:"english"),!o.validateMnemonic(n.value.mnemonic))throw new Error("Mnemonic is not valid.");var u=o.mnemonicToSeedSync(n.value.mnemonic);a.masterPrivateKeyNode=i.fromSeed(u,a.network);var c=a.masterPrivateKeyNode.derivePath(a.baseDerivationPath),p=t.bip32.fromPublicKey(c.publicKey,c.chainCode,c.network).toBase58();return a.masterPublicKey=M(p,n.chain),a.masterBlindingKeyNode=s.fromSeed(u),a.masterBlindingKey=a.masterBlindingKeyNode.masterKey.toString("hex"),a.isRestored=new Promise((function(){return!0})),n.initializeFromRestorer&&(a.isRestored=a.restore().catch((function(e){throw new Error("Error during restoration step: "+e)}))),a}h(r,e);var n=r.prototype;return n.blindPset=function(){var t=d(x.mark((function t(r,n,i,s){var o=this;return x.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e.prototype.blindPsetWithBlindKeysGetter.call(this,(function(e){return o.getBlindingKeyPair(e)}),r,n,i,s));case 1:case"end":return t.stop()}}),t,this)})));return function(e,r,n,i){return t.apply(this,arguments)}}(),n.isAbleToSign=function(){return!0},n.getCurrentDerivationPath=function(e){return this.baseDerivationPath+"/"+(e?1:0)},n.deriveKeyWithIndex=function(e,r){var n=this.masterPrivateKeyNode.derivePath(this.getCurrentDerivationPath(e)).derive(r).toWIF(),i=t.ECPair.fromWIF(n,this.network);return{publicKey:i.publicKey,privateKey:i.privateKey}},n.getBlindingKeyPair=function(e){var t=this.masterBlindingKeyNode.derive(e);return{publicKey:t.publicKey,privateKey:t.privateKey}},n.scriptFromPublicKey=function(e){return t.payments.p2wpkh({pubkey:e,network:this.network}).output},n.createConfidentialAddress=function(e,r){return t.payments.p2wpkh({pubkey:e,blindkey:r,network:this.network}).confidentialAddress},n.persistAddressToCache=function(e){var r=Buffer.from(e.signingPrivateKey,"hex"),n=t.ECPair.fromPrivateKey(r,{network:this.network}).publicKey,i=this.scriptFromPublicKey(n);this.scriptToAddressCache.set(i,e)},n.getAddress=function(e,t){var r=this.deriveKeyWithIndex(e,t),n=this.scriptFromPublicKey(r.publicKey),i=this.getBlindingKeyPair(n);return{address:{confidentialAddress:this.createConfidentialAddress(r.publicKey,i.publicKey),blindingPrivateKey:i.privateKey.toString("hex")},derivationPath:this.baseDerivationPath+"/"+t,signingPrivateKey:r.privateKey.toString("hex")}},n.getNextAddress=function(){var e=this.getAddress(!1,this.index);return this.persistAddressToCache(e),this.index+=1,e.address},n.getNextChangeAddress=function(){var e=this.getAddress(!0,this.changeIndex);return this.persistAddressToCache(e),this.changeIndex+=1,e.address},n.getBlindingPrivateKey=function(e){var t=Buffer.from(e,"hex");return this.getBlindingKeyPair(t).privateKey.toString("hex")},n.signPset=function(){var e=d(x.mark((function e(r){var n,i,s,o,a,u,c;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(n=t.Psbt.fromBase64(r),i=[],s=0;s<n.data.inputs.length;s++)(o=n.data.inputs[s]).witnessUtxo&&(a=this.scriptToAddressCache.get(o.witnessUtxo.script))&&(u=Buffer.from(a.signingPrivateKey,"hex"),c=t.ECPair.fromPrivateKey(u),i.push(n.signInputAsync(s,c)));return e.next=5,Promise.all(i);case 5:return e.abrupt("return",n.toBase64());case 6:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getAddresses=function(){return this.scriptToAddressCache.values().map((function(e){return e.address}))},n.generateSetOfAddresses=function(){var e=d(x.mark((function e(t,r){var n,i,s=this;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=function(){var e=d(x.mark((function e(t){return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s.getAddress(!1,t));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),i=Array.from({length:r},(function(e,r){return r+t})),e.abrupt("return",Promise.all(i.map(n)));case 3:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),n.addressToChangeAddressAsync=function(){var e=d(x.mark((function e(t){var r;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=G(t),e.abrupt("return",this.getAddress(!0,r));case 2:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.checkAddressesWithRestorer=function(){var e=d(x.mark((function e(t){var r;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.map((function(e){return e.address.confidentialAddress})),e.next=3,this.restorer.addressesHaveBeenUsed(r);case 3:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.restoreAddresses=function(){var e=d(x.mark((function e(){var t,n,i,s,o,a,u,c,p,f,d,h=this;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=20,n=0,i=0,s=[],o=function(e){return function(t,r){!0===t?(n=0,s.push(e[r])):n+=1}};case 5:if(!(n<t)){e.next=16;break}return e.next=8,this.generateSetOfAddresses(i,t-n);case 8:return a=e.sent,e.next=11,this.checkAddressesWithRestorer(a);case 11:e.sent.forEach(o(a)),i+=t,e.next=5;break;case 16:return u=s.map(G),this.index=u.length>0?Math.max.apply(Math,u)+1:r.INITIAL_INDEX,e.next=20,Promise.all(s.map((function(e){return h.addressToChangeAddressAsync(e)})));case 20:return c=e.sent,e.next=23,this.checkAddressesWithRestorer(c);case 23:return p=e.sent,f=c.filter((function(e,t){return p[t]})),d=f.map(G),this.changeIndex=d.length>0?Math.max.apply(Math,d)+1:r.INITIAL_INDEX,s.push.apply(s,f),e.abrupt("return",s);case 29:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.restore=function(){var e=d(x.mark((function e(){var t=this;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.restoreAddresses();case 2:return e.sent.forEach((function(e){return t.persistAddressToCache(e)})),e.abrupt("return",!0);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r}(H);X.INITIAL_BASE_PATH="m/84'/0'/0'",X.INITIAL_INDEX=0;var q=function(e){function r(r){var n,i;if((n=e.call(this,r)||this).isRestored=new Promise((function(){return!0})),r.type!==exports.IdentityType.PrivateKey)throw new Error("The identity arguments have not the PrivateKey type.");if(!("signingKeyWIF"in(i=r.value))||!("blindingKeyWIF"in i))throw new Error("The value of IdentityOpts is not valid for PrivateKey Identity.");n.signingKeyPair=n.decodeFromWif(r.value.signingKeyWIF),n.blindingKeyPair=n.decodeFromWif(r.value.blindingKeyWIF);var s=t.payments.p2wpkh({pubkey:n.signingKeyPair.publicKey,blindkey:n.blindingKeyPair.publicKey,network:n.network});return n.confidentialAddress=s.confidentialAddress,n.blindingPrivateKey=n.blindingKeyPair.privateKey.toString("hex"),n.scriptPubKey=s.output,n}h(r,e);var n=r.prototype;return n.blindPset=function(){var t=d(x.mark((function t(r,n,i,s){var o=this;return x.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e.prototype.blindPsetWithBlindKeysGetter.call(this,(function(e){return o.getBlindingKeyPair(e)}),r,n,i,s));case 1:case"end":return t.stop()}}),t,this)})));return function(e,r,n,i){return t.apply(this,arguments)}}(),n.getBlindingKeyPair=function(e){if(!e.equals(this.scriptPubKey))throw new Error(e+" is unknown by the PrivateKey Identity");return{publicKey:this.blindingKeyPair.publicKey,privateKey:this.blindingKeyPair.privateKey}},n.isAbleToSign=function(){return!0},n.decodeFromWif=function(e){return t.ECPair.fromWIF(e,this.network)},n.getAddress=function(){return{confidentialAddress:this.confidentialAddress,blindingPrivateKey:this.blindingPrivateKey}},n.getNextAddress=function(){return this.getAddress()},n.getNextChangeAddress=function(){return this.getAddress()},n.getBlindingPrivateKey=function(e){if(!Buffer.from(e,"hex").equals(this.scriptPubKey))throw new Error("The script is not PrivateKey.scriptPubKey.");return this.blindingPrivateKey},n.signPset=function(){var e=d(x.mark((function e(r){var n,i,s,o,a=this;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(n=t.Psbt.fromBase64(r),i=[],s=0;s<n.data.inputs.length;s++)(o=n.data.inputs[s]).witnessUtxo?o.witnessUtxo.script.equals(this.scriptPubKey)&&i.push(s):i.push(s);return e.next=5,Promise.all(i.map((function(e){return n.signInputAsync(e,a.signingKeyPair)})));case 5:return e.abrupt("return",n.toBase64());case 6:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getAddresses=function(){return[{confidentialAddress:this.confidentialAddress,blindingPrivateKey:this.blindingPrivateKey}]},r}(H);function z(e){var t=e.derivationPath.split("/");return parseInt(t[t.length-1])}var V=function(e){function r(t){var n;(n=e.call(this,t)||this).index=r.INITIAL_INDEX,n.changeIndex=r.INITIAL_INDEX,n.scriptToAddressCache=new O;var o,a=U(t.value.masterPublicKey);if(t.type!==exports.IdentityType.MasterPublicKey)throw new Error("The identity arguments have not the MasterPublicKey type.");if(!("masterPublicKey"in(o=t.value))||!("masterBlindingKey"in o))throw new Error("The value of IdentityOpts is not valid for MasterPublicKey Identity.");if(!C(a))throw new Error("Master public key is not valid");if(!F(t.value.masterBlindingKey))throw new Error("Master blinding key is not valid");return n.masterPublicKeyNode=i.fromBase58(a),n.masterBlindingKeyNode=s.fromMasterBlindingKey(t.value.masterBlindingKey),n.isRestored=new Promise((function(){return!0})),t.initializeFromRestorer&&(n.isRestored=n.restore().catch((function(e){throw new Error("Error during restoration step: "+e)}))),n}h(r,e);var n=r.prototype;return n.blindPset=function(){var t=d(x.mark((function t(r,n,i,s){var o=this;return x.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e.prototype.blindPsetWithBlindKeysGetter.call(this,(function(e){return o.getBlindingKeyPair(e)}),r,n,i,s));case 1:case"end":return t.stop()}}),t,this)})));return function(e,r,n,i){return t.apply(this,arguments)}}(),n.isAbleToSign=function(){return!1},n.derivePublicKeyWithIndex=function(e,t){return this.masterPublicKeyNode.derive(e?1:0).derive(t).publicKey},n.getBlindingKeyPair=function(e){var t=this.masterBlindingKeyNode.derive(e);return{publicKey:t.publicKey,privateKey:t.privateKey}},n.scriptFromPublicKey=function(e){return t.payments.p2wpkh({pubkey:e,network:this.network}).output},n.createConfidentialAddress=function(e,r){return t.payments.p2wpkh({pubkey:e,blindkey:r,network:this.network}).confidentialAddress},n.persistAddressToCache=function(e){var t=Buffer.from(e.publicKey,"hex"),r=this.scriptFromPublicKey(t);this.scriptToAddressCache.set(r,e)},n.getAddress=function(e,t){var r=this.derivePublicKeyWithIndex(e,t),n=this.scriptFromPublicKey(r),i=this.getBlindingKeyPair(n);return{address:{confidentialAddress:this.createConfidentialAddress(r,i.publicKey),blindingPrivateKey:i.privateKey.toString("hex")},derivationPath:(e?1:0)+"/"+t,publicKey:r.toString("hex")}},n.getNextAddress=function(){var e=this.getAddress(!1,this.index);return this.persistAddressToCache(e),this.index+=1,e.address},n.getNextChangeAddress=function(){var e=this.getAddress(!0,this.changeIndex);return this.persistAddressToCache(e),this.changeIndex+=1,e.address},n.getBlindingPrivateKey=function(e){var t=Buffer.from(e,"hex");return this.getBlindingKeyPair(t).privateKey.toString("hex")},n.signPset=function(e){throw new Error("MasterPublicKey is a watch only identity. Use Mnemonic to sign transactions")},n.getAddresses=function(){return this.scriptToAddressCache.values().map((function(e){return e.address}))},n.generateSetOfAddresses=function(){var e=d(x.mark((function e(t,r){var n,i,s=this;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=function(){var e=d(x.mark((function e(t){return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",s.getAddress(!1,t));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),i=Array.from({length:r},(function(e,r){return r+t})),e.abrupt("return",Promise.all(i.map(n)));case 3:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),n.addressToChangeAddressAsync=function(){var e=d(x.mark((function e(t){var r;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=z(t),e.abrupt("return",this.getAddress(!0,r));case 2:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.checkAddressesWithRestorer=function(){var e=d(x.mark((function e(t){var r;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.map((function(e){return e.address.confidentialAddress})),e.next=3,this.restorer.addressesHaveBeenUsed(r);case 3:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.restoreAddresses=function(){var e=d(x.mark((function e(){var t,n,i,s,o,a,u,c,p,f,d,h=this;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=20,n=0,i=0,s=[],o=function(e){return function(t,r){!0===t?(n=0,s.push(e[r])):n+=1}};case 5:if(!(n<t)){e.next=16;break}return e.next=8,this.generateSetOfAddresses(i,t-n);case 8:return a=e.sent,e.next=11,this.checkAddressesWithRestorer(a);case 11:e.sent.forEach(o(a)),i+=t,e.next=5;break;case 16:return u=s.map(z),this.index=u.length>0?Math.max.apply(Math,u)+1:r.INITIAL_INDEX,e.next=20,Promise.all(s.map((function(e){return h.addressToChangeAddressAsync(e)})));case 20:return c=e.sent,e.next=23,this.checkAddressesWithRestorer(c);case 23:return p=e.sent,f=c.filter((function(e,t){return p[t]})),d=f.map(z),this.changeIndex=d.length>0?Math.max.apply(Math,d)+1:r.INITIAL_INDEX,s.push.apply(s,f),e.abrupt("return",s);case 29:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),n.restore=function(){var e=d(x.mark((function e(){var t=this;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.restoreAddresses();case 2:return e.sent.forEach((function(e){return t.persistAddressToCache(e)})),e.abrupt("return",!0);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r}(H);V.INITIAL_INDEX=0;var Y=function(e,t){return e.value-t.value};function Z(e,t,r){for(var n,i=[],s=0,o=v(e=e.sort(r));!(n=o()).done;){var a=n.value;if(R(a)||(i.push(a),s+=a.value),s>=t)return{selected:i,changeAmount:s-t}}throw new Error("not enough utxos in wallet to found: "+t)}function $(e,t){return e.reduce((function(e,r){return(e[r[t]]=e[r[t]]||[]).push(r),e}),{})}function J(e){return"surjectionProof"in e&&"rangeProof"in e}function Q(){return(Q=d(x.mark((function e(t,r,n){return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ae([{confidentialAddress:t,blindingPrivateKey:r}],n);case 2:return e.abrupt("return",e.sent.reduce((function(e,t){var r=t.asset;return e[r]=e[r]||0,e[r]+=t.value,e}),{}));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ee(e,t){return te.apply(this,arguments)}function te(){return(te=d(x.mark((function e(t,n){return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.get(n+"/tx/"+t+"/hex");case 2:return e.abrupt("return",e.sent.data);case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function re(e,t){return ne.apply(this,arguments)}function ne(){return(ne=d(x.mark((function e(t,n){return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.get(n+"/address/"+t+"/utxo");case 2:return e.abrupt("return",e.sent.data);case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ie(){return(ie=d(x.mark((function e(t,r,n){var i,s,o;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=ce(t,r,n),s=[],e.next=4,i.next();case 4:o=e.sent;case 5:if(o.done){e.next=12;break}return s.push(o.value),e.next=9,i.next();case 9:o=e.sent,e.next=5;break;case 12:return e.abrupt("return",s);case 13:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function se(e,t){return oe.apply(this,arguments)}function oe(){return(oe=c(x.mark((function e(t,r){var n,i,s,o;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=0,i=x.mark((function e(){var t,i,s,a,u,c,f;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=(t=o.value).confidentialAddress,s=t.blindingPrivateKey,e.next=3,p(re(i,r));case 3:a=e.sent.map((function(e){return we(e,s,r)})),n+=a.length,u=v(a);case 7:if((c=u()).done){e.next=13;break}return f=c.value,e.next=11,f;case 11:e.next=7;break;case 13:case"end":return e.stop()}}),e)})),s=v(t);case 3:if((o=s()).done){e.next=7;break}return e.delegateYield(i(),"t0",5);case 5:e.next=3;break;case 7:return e.abrupt("return",n);case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ae(e,t){return ue.apply(this,arguments)}function ue(){return(ue=d(x.mark((function e(t,r){var n,i,s;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=se(t,r),i=[],e.next=4,n.next();case 4:s=e.sent;case 5:if(s.done){e.next=12;break}return i.push(s.value),e.next=9,n.next();case 9:s=e.sent,e.next=5;break;case 12:return e.abrupt("return",i);case 13:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ce(e,t,r){return pe.apply(this,arguments)}function pe(){return(pe=c(x.mark((function e(t,r,n){var i,s,o,a,u;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=v(t);case 1:if((s=i()).done){e.next=18;break}return o=fe(s.value,n),e.next=6,p(o.next());case 6:a=e.sent;case 7:if(a.done){e.next=16;break}return u=a.value,e.next=11,le(u,r);case 11:return e.next=13,p(o.next());case 13:a=e.sent,e.next=7;break;case 16:e.next=1;break;case 18:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function fe(e,t){return de.apply(this,arguments)}function de(){return(de=c(x.mark((function e(t,r){var n,i,s,o,a,u,c;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=void 0,i=[],s=0;case 3:return e.next=5,p(me(t,r,n));case 5:s+=(i=e.sent).length,o=i.map((function(e){return xe(e,r)})),a=v(o);case 9:if((u=a()).done){e.next=15;break}return c=u.value,e.next=13,c;case 13:e.next=9;break;case 15:if(i.length<25){e.next=3;break}case 16:return e.abrupt("return",s);case 17:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function he(e){return S(e)?{blindedAsset:e.asset,blindedValue:e.value,nonce:e.nonce,rangeProof:e.rangeProof,surjectionProof:e.surjectionProof,script:e.script.toString("hex")}:{asset:I(e.asset),value:T(e.value),script:e.script.toString("hex")}}function le(e,t){return ve.apply(this,arguments)}function ve(){return(ve=d(x.mark((function e(t,r){var n,i,s,o,a;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(n=[],i=function(e){var i=t.vin[e].prevout;J(i)&&n.push(function(){var n=d(x.mark((function n(){var s,o;return x.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:(s=r(i.script))&&(o=ye(i,s),t.vin[e].prevout=o);case 2:case"end":return n.stop()}}),n)})));return function(){return n.apply(this,arguments)}}()())},s=0;s<t.vin.length;s++)i(s);for(o=function(e){var i=t.vout[e];J(i)&&n.push(function(){var n=d(x.mark((function n(){var s,o;return x.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:(s=r(i.script))&&(o=ye(i,s),t.vout[e]=o);case 2:case"end":return n.stop()}}),n)})));return function(){return n.apply(this,arguments)}}()())},a=0;a<t.vout.length;a++)o(a);return e.next=7,Promise.all(n);case 7:return e.abrupt("return",t);case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ye(e,r){var n=Buffer.from(r,"hex"),i=t.confidential.unblindOutput(e.nonce,n,e.rangeProof,e.blindedValue,e.blindedAsset,Buffer.from(e.script,"hex"));return{asset:Buffer.from(i.asset.reverse()).toString("hex"),value:parseInt(i.value,10),script:e.script}}function xe(e,t){return ge.apply(this,arguments)}function ge(){return(ge=d(x.mark((function e(r,n){var i,s,o,a,u,c,p,f,d;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(i=[],s=[],o=v(r.vin);!(a=o()).done;)i.push((u=a.value).txid),s.push(u.vout);return e.next=5,Promise.all(i.map((function(e){return ee(e,n)})));case 5:return c=e.sent.map((function(e,r){return he(t.Transaction.fromHex(e).outs[s[r]])})),p=i.map((function(e,t){return{prevout:c[t],txid:e,vout:s[t]}})),e.next=10,ee(r.txid,n);case 10:return f=t.Transaction.fromHex(e.sent),d=f.outs.map(he),e.abrupt("return",{txid:r.txid,vin:p,vout:d,fee:r.fee,status:{confirmed:r.status.confirmed,blockHash:r.status.block_hash,blockHeight:r.status.block_height,blockTime:r.status.block_time}});case 15:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function me(e,t,r){return be.apply(this,arguments)}function be(){return(be=d(x.mark((function e(t,n,i){var s;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=n+"/address/"+t+"/txs/chain",i&&(s+="/"+i),e.next=4,r.get(s);case 4:return e.abrupt("return",e.sent.data);case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function we(e,t,r){return Pe.apply(this,arguments)}function Pe(){return(Pe=d(x.mark((function e(t,r,n){return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,ke(t,r,n);case 3:return e.abrupt("return",e.sent);case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",t);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})))).apply(this,arguments)}function ke(e,t,r){return Ae.apply(this,arguments)}function Ae(){return(Ae=d(x.mark((function e(r,n,i){var s,o;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ee(r.txid,i);case 2:return s=t.Transaction.fromHex(e.sent).outs[r.vout],o=t.confidential.unblindOutput(s.nonce,Buffer.from(n,"hex"),s.rangeProof,s.value,s.asset,s.script),e.abrupt("return",{txid:r.txid,vout:r.vout,asset:o.asset.reverse().toString("hex"),value:parseInt(o.value,10),prevout:s});case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Ke=function(){function e(e,t){this.network=t,this.cache=e}var r=e.prototype;return r.createTx=function(){return new t.Psbt({network:this.network}).toBase64()},r.buildTx=function(e,t,r,n,i,s){return m({psetBase64:e,recipients:t,coinSelector:r,changeAddressByAsset:n,addFee:i,satsPerByte:s,unspents:this.cache.getAll()})},e}();function Ie(){return(Ie=d(x.mark((function e(t,r,n){return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ae(t,r);case 2:return e.abrupt("return",Te(e.sent,n));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Te(e,t){return new Ke(new Ee(e),D(t))}var Ee=function(){function e(e){this.utxoMap=new Map,e&&this.push(e)}var t=e.prototype;return t.push=function(e){for(var t,r=v(e);!(t=r()).done;){var n=t.value;this.utxoMap.set(W(n),n)}},t.delete=function(e){return this.utxoMap.delete(e)},t.getAll=function(){return Array.from(this.utxoMap.values())},e}();Object.defineProperty(exports,"ECPair",{enumerable:!0,get:function(){return t.ECPair}}),Object.defineProperty(exports,"address",{enumerable:!0,get:function(){return t.address}}),Object.defineProperty(exports,"networks",{enumerable:!0,get:function(){return t.networks}}),Object.defineProperty(exports,"payments",{enumerable:!0,get:function(){return t.payments}}),exports.BufferMap=O,exports.EsploraIdentityRestorer=g,exports.MasterPublicKey=V,exports.Mnemonic=X,exports.PrivateKey=q,exports.UtxoCache=Ee,exports.Wallet=Ke,exports.addToTx=w,exports.buildTx=m,exports.createFeeOutput=b,exports.decodePset=P,exports.estimateTxSize=k,exports.fetchAndUnblindTxs=function(e,t,r){return ie.apply(this,arguments)},exports.fetchAndUnblindTxsGenerator=ce,exports.fetchAndUnblindUtxos=ae,exports.fetchAndUnblindUtxosGenerator=se,exports.fetchBalances=function(e,t,r){return Q.apply(this,arguments)},exports.fetchTxHex=ee,exports.fetchUtxos=re,exports.fromAssetHash=function(e){return Buffer.concat([Buffer.from("01","hex"),Buffer.from(e,"hex").reverse()])},exports.fromXpub=M,exports.getNetwork=D,exports.greedyCoinSelector=function(e){return void 0===e&&(e=Y),function(t,r,n){return function(e,t,r,n){for(var i={selectedUtxos:[],changeOutputs:[]},s=$(e=e.filter((function(e){return!R(e)})),"asset"),o=$(t,"asset"),a=0,u=Object.entries(o);a<u.length;a++){var c,p=u[a],f=p[0],d=p[1],h=s[f];if(!h)throw new Error("need unspents for the asset: "+f);var l=Z(h,d.reduce((function(e,t){return e+t.value}),0),n),v=l.changeAmount;if((c=i.selectedUtxos).push.apply(c,l.selected),v>0){var y=r(f);if(!y)throw new Error("need change address for asset: "+f);i.changeOutputs.push({asset:f,value:v,address:y})}}return i}(t,r,n,e)}},exports.isBlindedOutputInterface=J,exports.isBlindedUtxo=R,exports.isConfidentialOutput=S,exports.isValidAmount=function(e){return!(e<=0||!Number.isSafeInteger(e))},exports.isValidExtendedBlindKey=F,exports.isValidXpub=C,exports.psetToUnsignedHex=j,exports.psetToUnsignedTx=function(e){return t.Transaction.fromHex(j(e))},exports.toAssetHash=I,exports.toNumber=T,exports.toOutpoint=W,exports.toXpub=U,exports.tryToUnblindOutput=ye,exports.tryToUnblindUtxo=we,exports.unblindOutput=function(e,r){var n={asset:Buffer.alloc(0),value:0};if(!e.rangeProof)throw new Error("The output does not contain rangeProof.");var i=t.confidential.unblindOutput(e.nonce,r,e.rangeProof,e.value,e.asset,e.script);return n.asset=Buffer.concat([Buffer.alloc(1,10),i.asset]),n.value=parseInt(i.value,10),n},exports.unblindUtxo=ke,exports.walletFromAddresses=function(e,t,r){return Ie.apply(this,arguments)},exports.walletFromCoins=Te;
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("liquidjs-lib"),r=e(require("axios")),n=e(require("bs58check")),i=require("bip32"),o=require("slip77"),a=require("bip39");function s(e){this.wrapped=e}function u(e){var t,r;function n(t,r){try{var o=e[t](r),a=o.value,u=a instanceof s;Promise.resolve(u?a.wrapped:a).then((function(e){u?n("return"===t?"return":"next",e):i(o.done?"return":"normal",e)}),(function(e){n("throw",e)}))}catch(e){i("throw",e)}}function i(e,i){switch(e){case"return":t.resolve({value:i,done:!0});break;case"throw":t.reject(i);break;default:t.resolve({value:i,done:!1})}(t=t.next)?n(t.key,t.arg):r=null}this._invoke=function(e,i){return new Promise((function(o,a){var s={key:e,arg:i,resolve:o,reject:a,next:null};r?r=r.next=s:(t=r=s,n(e,i))}))},"function"!=typeof e.return&&(this.return=void 0)}function c(e){return function(){return new u(e.apply(this,arguments))}}function f(e){return new s(e)}function p(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function d(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){p(o,n,i,a,s,"next",e)}function s(e){p(o,n,i,a,s,"throw",e)}a(void 0)}))}}function h(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,(Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function v(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return l(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?l(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[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.")}return(r=e[Symbol.iterator]()).next.bind(r)}"function"==typeof Symbol&&Symbol.asyncIterator&&(u.prototype[Symbol.asyncIterator]=function(){return this}),u.prototype.next=function(e){return this._invoke("next",e)},u.prototype.throw=function(e){return this._invoke("throw",e)},u.prototype.return=function(e){return this._invoke("return",e)};var y,x=(function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var i=Object.create((t&&t.prototype instanceof p?t:p).prototype),o=new k(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return{value:void 0,done:!0}}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=m(a,r);if(s){if(s===f)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,o),i}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var f={};function p(){}function d(){}function h(){}var l={};l[i]=function(){return this};var v=Object.getPrototypeOf,y=v&&v(v(K([])));y&&y!==t&&r.call(y,i)&&(l=y);var x=h.prototype=p.prototype=Object.create(l);function g(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){var n;this._invoke=function(i,o){function a(){return new t((function(n,a){!function n(i,o,a,s){var u=c(e[i],e,o);if("throw"!==u.type){var f=u.arg,p=f.value;return p&&"object"==typeof p&&r.call(p,"__await")?t.resolve(p.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(p).then((function(e){f.value=e,a(f)}),(function(e){return n("throw",e,a,s)}))}s(u.arg)}(i,o,n,a)}))}return n=n?n.then(a,a):a()}}function m(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,m(e,t),"throw"===t.method))return f;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,f;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function w(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function P(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(w,this),this.reset(!0)}function K(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:A}}function A(){return{value:void 0,done:!0}}return d.prototype=x.constructor=h,h.constructor=d,d.displayName=s(h,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,s(e,a,"GeneratorFunction")),e.prototype=Object.create(x),e},e.awrap=function(e){return{__await:e}},g(b.prototype),b.prototype[o]=function(){return this},e.AsyncIterator=b,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new b(u(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(x),s(x,a,"Generator"),x[i]=function(){return this},x.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=K,k.prototype={constructor:k,reset:function(e){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),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){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"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,f):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),P(r),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;P(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:K(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}}(y={exports:{}}),y.exports),g=function e(t){var n=this;this.esploraEndpoint=e.DEFAULT_ESPLORA_ENDPOINT,this.addressesHaveBeenUsed=function(){var e=d(x.mark((function e(t){return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",r.all(t.map(n.addressHasBeenUsed)));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),this.addressHasBeenUsed=function(){var e=d(x.mark((function e(t){return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",r.get(n.esploraEndpoint+"/address/"+t+"/txs").then((function(e){return e.data.length>0}),(function(e){return!1})).catch((function(){return!1})));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),t&&(this.esploraEndpoint=t)};function b(e){var r=function(e){if(e.satsPerByte||(e.satsPerByte=.1),e.addFee||(e.addFee=!1),e.addFee&&e.satsPerByte<.1)throw new Error("satsPerByte minimum value is 0.1");if(0===e.recipients.length)throw new Error("need a least one recipient output to build the transaction");if(0===e.unspents.length)throw new Error("need at least one unspent to fund the transaction");return e}(e),n=r.changeAddressByAsset,i=r.coinSelector,o=r.psetBase64,a=r.recipients,s=r.unspents,u=r.addFee,c=r.satsPerByte,f=i(s,a,n),p=f.selectedUtxos,d=f.changeOutputs,h=p;if(!u)return w(o,h,a.concat(d));var l=P(o),y=l.data.inputs.length+h.length,x=l.data.outputs.length+a.length+d.length,g=t.address.getNetwork(a[0].address).assetHash,b=m(y,x,c,g),k=d.findIndex((function(e){return e.asset===g})),K=-1===k?0-b.value:d[k].value-b.value;if(K>0)return d[k].value=K,w(o,h,a.concat(d).concat(b));if(0===K)return w(o,h,a.concat(b));for(var A,I=[],E=v(s);!(A=E()).done;){var T=A.value;p.includes(T)||I.push(T)}var B=m(y+1,x+1,c,g),S=i(I,[B],n);return w(o,h.concat(S.selectedUtxos),a.concat(d).concat(S.changeOutputs).concat(B))}function m(e,t,r,n){var i=k(e,t);return{asset:n,value:Math.ceil(i*r),address:""}}function w(e,r,n){for(var i,o=P(e),a=Buffer.from("00","hex"),s=v(n);!(i=s()).done;){var u=i.value,c=u.asset,f=u.value,p=u.address,d=""===p?"":t.address.toOutputScript(p);o.addOutput({asset:c,value:f,script:d,nonce:a})}for(var h,l=v(r);!(h=l()).done;){var y=h.value;o.addInput({hash:y.txid,index:y.vout,witnessUtxo:y.prevout})}return o.toBase64()}function P(e){var r;try{r=t.Psbt.fromBase64(e)}catch(e){throw new Error("Invalid pset")}return r}function k(e,t){return(3*K(!1,e,t,!1)+K(!0,e,t,!0)+3)/4}function K(e,t,r,n){var i=function(e,t){var r=40*t;return e&&(r+=105*t),r}(e,t),o=function(e,t){var r=67*t;return e&&(r+=4273*t),r+43}(n,r);return 9+A(r)+A(t)+i+o}function A(e){return e<253?1:e<=65535?3:e<=4294967295?5:9}function I(e){return e.slice(1).reverse().toString("hex")}function E(e){return t.confidential.confidentialValueToSatoshi(e)}g.DEFAULT_ESPLORA_ENDPOINT="https://blockstream.info/liquid/api";var T=Buffer.from("0x00","hex");function B(e){return null!=e&&e.length>0}function S(e){var t=e.surjectionProof,r=e.nonce;return B(e.rangeProof)&&B(t)&&r!==T}var N,O=function(){function e(){this.map=new Map}var t=e.prototype;return t.bufferToStringPrimitive=function(e){return e.toString("hex").valueOf()},t.get=function(e){return this.map.get(this.bufferToStringPrimitive(e))},t.set=function(e,t){return this.map.set(this.bufferToStringPrimitive(e),t),this},t.values=function(){return Array.from(this.map.values())},e}(),L=new Map([["xpub","0488b21e"],["ypub","049d7cb2"],["Ypub","0295b43f"],["zpub","04b24746"],["Zpub","02aa7ed3"],["tpub","043587cf"],["upub","044a5262"],["Upub","024289ef"],["vpub","045f1cf6"],["Vpub","02575483"]]);function _(e,t){if(!L.has(t))return"Invalid target version";e=e.trim();try{var r=n.decode(e);return r=r.slice(4),r=Buffer.concat([Buffer.from(L.get(t),"hex"),r]),n.encode(r)}catch(e){throw new Error("Invalid extended public key! Please double check that you didn't accidentally paste extra data.")}}function M(e,t){return _(e,"regtest"===t?"vpub":"zpub")}function U(e){return _(e,"xpub")}function C(e,t){try{i.fromBase58(e,t)}catch(e){return!1}return!0}function F(e){try{o.fromMasterBlindingKey(e)}catch(e){return!1}return!0}function j(e){var r;try{r=t.Psbt.fromBase64(e)}catch(e){throw new Error("Invalid pset")}return r.data.globalMap.unsignedTx.toBuffer().toString("hex")}function W(e){return{txid:e.txid,vout:e.vout}}function D(e){return!e.asset||!e.value}function R(e){return e?t.networks[e]:t.networks.liquid}(N=exports.IdentityType||(exports.IdentityType={}))[N.PrivateKey=1]="PrivateKey",N[N.Mnemonic=2]="Mnemonic",N[N.MasterPublicKey=3]="MasterPublicKey",N[N.Inject=4]="Inject",N[N.Ledger=5]="Ledger",N[N.Trezor=6]="Trezor";var H=function(){function e(r){if(!r.chain||!t.networks.hasOwnProperty(r.chain))throw new Error("Network is missing or not valid");if(!r.type||!(r.type in exports.IdentityType))throw new Error("Type is missing or not valid");this.network=t.networks[r.chain],this.type=r.type,this.restorer=r.restorer?r.restorer:e.DEFAULT_RESTORER}return e.prototype.blindPsetWithBlindKeysGetter=function(){var e=d(x.mark((function e(r,n,i,o,a){var s,u,c,f,p,d,h,l,y,g,b,m,w,k,K,A;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s=new Map,u=new Map,c=P(n),f=t.Transaction.fromHex(j(n)),p=v(i);case 5:if((d=p()).done){e.next=16;break}if(h=d.value,!o||!o.has(h)){e.next=11;break}return l=Buffer.from(o.get(h),"hex"),u.set(h,l),e.abrupt("continue",14);case 11:y=r(f.outs[h].script).publicKey,u.set(h,y);case 14:e.next=5;break;case 16:g=0;case 17:if(!(g<c.data.inputs.length)){e.next=41;break}if(m=void 0,!(b=c.data.inputs[g]).witnessUtxo){e.next=24;break}if(S(b.witnessUtxo)){e.next=23;break}return e.abrupt("continue",38);case 23:m=b.witnessUtxo.script;case 24:if(!b.nonWitnessUtxo){e.next=30;break}if(w=f.ins[g].index,S(k=t.Transaction.fromBuffer(b.nonWitnessUtxo).outs[w])){e.next=29;break}return e.abrupt("continue",38);case 29:m=k.script;case 30:if(!a||!a.has(g)){e.next=34;break}return K=Buffer.from(a.get(g),"hex"),s.set(g,K),e.abrupt("continue",38);case 34:if(m){e.next=36;break}throw new Error("no witness script for input #"+g);case 36:A=r(m).privateKey,s.set(g,A);case 38:g++,e.next=17;break;case 41:return e.abrupt("return",c.blindOutputsByIndex(s,u).toBase64());case 42:case"end":return e.stop()}}),e)})));return function(t,r,n,i,o){return e.apply(this,arguments)}}(),e}();function G(e){var t=e.derivationPath.split("/");return parseInt(t[t.length-1])}H.DEFAULT_RESTORER=new g;var X=function(e){function r(n){var s;if((s=e.call(this,n)||this).baseDerivationPath=r.INITIAL_BASE_PATH,s.index=r.INITIAL_INDEX,s.changeIndex=r.INITIAL_INDEX,s.scriptToAddressCache=new O,n.type!==exports.IdentityType.Mnemonic)throw new Error("The identity arguments have not the Mnemonic type.");if(!("mnemonic"in n.value))throw new Error("The value of IdentityOpts is not valid for Mnemonic Identity.");if(a.setDefaultWordlist(n.value.language?n.value.language:"english"),!a.validateMnemonic(n.value.mnemonic))throw new Error("Mnemonic is not valid.");var u=a.mnemonicToSeedSync(n.value.mnemonic);s.masterPrivateKeyNode=i.fromSeed(u,s.network);var c=s.masterPrivateKeyNode.derivePath(s.baseDerivationPath),f=t.bip32.fromPublicKey(c.publicKey,c.chainCode,c.network).toBase58();return s.masterPublicKey=M(f,n.chain),s.masterBlindingKeyNode=o.fromSeed(u),s.masterBlindingKey=s.masterBlindingKeyNode.masterKey.toString("hex"),s.isRestored=new Promise((function(){return!0})),n.initializeFromRestorer&&(s.isRestored=s.restore().catch((function(e){throw new Error("Error during restoration step: "+e)}))),s}h(r,e);var n=r.prototype;return n.blindPset=function(){var t=d(x.mark((function t(r,n,i,o){var a=this;return x.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e.prototype.blindPsetWithBlindKeysGetter.call(this,(function(e){return a.getBlindingKeyPair(e)}),r,n,i,o));case 1:case"end":return t.stop()}}),t,this)})));return function(e,r,n,i){return t.apply(this,arguments)}}(),n.isAbleToSign=function(){return!0},n.getCurrentDerivationPath=function(e){return this.baseDerivationPath+"/"+(e?1:0)},n.deriveKeyWithIndex=function(e,r){var n=this.masterPrivateKeyNode.derivePath(this.getCurrentDerivationPath(e)).derive(r).toWIF(),i=t.ECPair.fromWIF(n,this.network);return{publicKey:i.publicKey,privateKey:i.privateKey}},n.getBlindingKeyPair=function(e){var t=this.masterBlindingKeyNode.derive(e);return{publicKey:t.publicKey,privateKey:t.privateKey}},n.scriptFromPublicKey=function(e){return t.payments.p2wpkh({pubkey:e,network:this.network}).output},n.createConfidentialAddress=function(e,r){return t.payments.p2wpkh({pubkey:e,blindkey:r,network:this.network}).confidentialAddress},n.persistAddressToCache=function(e){var r=Buffer.from(e.signingPrivateKey,"hex"),n=t.ECPair.fromPrivateKey(r,{network:this.network}).publicKey,i=this.scriptFromPublicKey(n);this.scriptToAddressCache.set(i,e)},n.getAddress=function(e,t){var r=this.deriveKeyWithIndex(e,t),n=this.scriptFromPublicKey(r.publicKey),i=this.getBlindingKeyPair(n);return{address:{confidentialAddress:this.createConfidentialAddress(r.publicKey,i.publicKey),blindingPrivateKey:i.privateKey.toString("hex")},derivationPath:this.baseDerivationPath+"/"+t,signingPrivateKey:r.privateKey.toString("hex")}},n.getNextAddress=function(){var e=this.getAddress(!1,this.index);return this.persistAddressToCache(e),this.index+=1,e.address},n.getNextChangeAddress=function(){var e=this.getAddress(!0,this.changeIndex);return this.persistAddressToCache(e),this.changeIndex+=1,e.address},n.getBlindingPrivateKey=function(e){var t=Buffer.from(e,"hex");return this.getBlindingKeyPair(t).privateKey.toString("hex")},n.signPset=function(){var e=d(x.mark((function e(r){var n,i,o,a,s,u,c;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(n=t.Psbt.fromBase64(r),i=[],o=0;o<n.data.inputs.length;o++)(a=n.data.inputs[o]).witnessUtxo&&(s=this.scriptToAddressCache.get(a.witnessUtxo.script))&&(u=Buffer.from(s.signingPrivateKey,"hex"),c=t.ECPair.fromPrivateKey(u),i.push(n.signInputAsync(o,c)));return e.next=5,Promise.all(i);case 5:return e.abrupt("return",n.toBase64());case 6:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getAddresses=function(){return this.scriptToAddressCache.values().map((function(e){return e.address}))},n.generateSetOfAddresses=function(){var e=d(x.mark((function e(t,r,n){var i,o,a=this;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=function(){var e=d(x.mark((function e(t){return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",a.getAddress(n,t));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),o=Array.from({length:r},(function(e,r){return r+t})),e.abrupt("return",Promise.all(o.map(i)));case 3:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),n.checkAddressesWithRestorer=function(){var e=d(x.mark((function e(t){var r;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.map((function(e){return e.address.confidentialAddress})),e.next=3,this.restorer.addressesHaveBeenUsed(r);case 3:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.restoreAddresses=function(){var e=d(x.mark((function e(){var t,n,i,o=this;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],n=x.mark((function e(n){var i,a,s,u,c,f,p;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=1===n,a=0,s=0,u=[],c=function(e){return function(t,r){a++,t&&(a=0,u.push(e[r]))}};case 5:if(!(a<20)){e.next=16;break}return e.next=8,o.generateSetOfAddresses(s,20-a,i);case 8:return f=e.sent,e.next=11,o.checkAddressesWithRestorer(f);case 11:e.sent.forEach(c(f)),s+=20,e.next=5;break;case 16:p=u.map(G),i?o.changeIndex=p.length>0?Math.max.apply(Math,p)+1:r.INITIAL_INDEX:o.index=p.length>0?Math.max.apply(Math,p)+1:r.INITIAL_INDEX,t=t.concat(u);case 19:case"end":return e.stop()}}),e)})),i=0;case 4:if(!(i<2)){e.next=9;break}return e.delegateYield(n(i),"t0",6);case 6:i++,e.next=4;break;case 9:return e.abrupt("return",t);case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),n.restore=function(){var e=d(x.mark((function e(){var t=this;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.restoreAddresses();case 2:return e.sent.forEach((function(e){return t.persistAddressToCache(e)})),e.abrupt("return",!0);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r}(H);X.INITIAL_BASE_PATH="m/84'/0'/0'",X.INITIAL_INDEX=0;var q=function(e){function r(r){var n,i;if((n=e.call(this,r)||this).isRestored=new Promise((function(){return!0})),r.type!==exports.IdentityType.PrivateKey)throw new Error("The identity arguments have not the PrivateKey type.");if(!("signingKeyWIF"in(i=r.value))||!("blindingKeyWIF"in i))throw new Error("The value of IdentityOpts is not valid for PrivateKey Identity.");n.signingKeyPair=n.decodeFromWif(r.value.signingKeyWIF),n.blindingKeyPair=n.decodeFromWif(r.value.blindingKeyWIF);var o=t.payments.p2wpkh({pubkey:n.signingKeyPair.publicKey,blindkey:n.blindingKeyPair.publicKey,network:n.network});return n.confidentialAddress=o.confidentialAddress,n.blindingPrivateKey=n.blindingKeyPair.privateKey.toString("hex"),n.scriptPubKey=o.output,n}h(r,e);var n=r.prototype;return n.blindPset=function(){var t=d(x.mark((function t(r,n,i,o){var a=this;return x.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e.prototype.blindPsetWithBlindKeysGetter.call(this,(function(e){return a.getBlindingKeyPair(e)}),r,n,i,o));case 1:case"end":return t.stop()}}),t,this)})));return function(e,r,n,i){return t.apply(this,arguments)}}(),n.getBlindingKeyPair=function(e){if(!e.equals(this.scriptPubKey))throw new Error(e+" is unknown by the PrivateKey Identity");return{publicKey:this.blindingKeyPair.publicKey,privateKey:this.blindingKeyPair.privateKey}},n.isAbleToSign=function(){return!0},n.decodeFromWif=function(e){return t.ECPair.fromWIF(e,this.network)},n.getAddress=function(){return{confidentialAddress:this.confidentialAddress,blindingPrivateKey:this.blindingPrivateKey}},n.getNextAddress=function(){return this.getAddress()},n.getNextChangeAddress=function(){return this.getAddress()},n.getBlindingPrivateKey=function(e){if(!Buffer.from(e,"hex").equals(this.scriptPubKey))throw new Error("The script is not PrivateKey.scriptPubKey.");return this.blindingPrivateKey},n.signPset=function(){var e=d(x.mark((function e(r){var n,i,o,a,s=this;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(n=t.Psbt.fromBase64(r),i=[],o=0;o<n.data.inputs.length;o++)(a=n.data.inputs[o]).witnessUtxo?a.witnessUtxo.script.equals(this.scriptPubKey)&&i.push(o):i.push(o);return e.next=5,Promise.all(i.map((function(e){return n.signInputAsync(e,s.signingKeyPair)})));case 5:return e.abrupt("return",n.toBase64());case 6:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.getAddresses=function(){return[{confidentialAddress:this.confidentialAddress,blindingPrivateKey:this.blindingPrivateKey}]},r}(H);function z(e){var t=e.derivationPath.split("/");return parseInt(t[t.length-1])}var V=function(e){function r(t){var n;(n=e.call(this,t)||this).index=r.INITIAL_INDEX,n.changeIndex=r.INITIAL_INDEX,n.scriptToAddressCache=new O;var a,s=U(t.value.masterPublicKey);if(t.type!==exports.IdentityType.MasterPublicKey)throw new Error("The identity arguments have not the MasterPublicKey type.");if(!("masterPublicKey"in(a=t.value))||!("masterBlindingKey"in a))throw new Error("The value of IdentityOpts is not valid for MasterPublicKey Identity.");if(!C(s))throw new Error("Master public key is not valid");if(!F(t.value.masterBlindingKey))throw new Error("Master blinding key is not valid");return n.masterPublicKeyNode=i.fromBase58(s),n.masterBlindingKeyNode=o.fromMasterBlindingKey(t.value.masterBlindingKey),n.isRestored=new Promise((function(){return!0})),t.initializeFromRestorer&&(n.isRestored=n.restore().catch((function(e){throw new Error("Error during restoration step: "+e)}))),n}h(r,e);var n=r.prototype;return n.blindPset=function(){var t=d(x.mark((function t(r,n,i,o){var a=this;return x.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e.prototype.blindPsetWithBlindKeysGetter.call(this,(function(e){return a.getBlindingKeyPair(e)}),r,n,i,o));case 1:case"end":return t.stop()}}),t,this)})));return function(e,r,n,i){return t.apply(this,arguments)}}(),n.isAbleToSign=function(){return!1},n.derivePublicKeyWithIndex=function(e,t){return this.masterPublicKeyNode.derive(e?1:0).derive(t).publicKey},n.getBlindingKeyPair=function(e){var t=this.masterBlindingKeyNode.derive(e);return{publicKey:t.publicKey,privateKey:t.privateKey}},n.scriptFromPublicKey=function(e){return t.payments.p2wpkh({pubkey:e,network:this.network}).output},n.createConfidentialAddress=function(e,r){return t.payments.p2wpkh({pubkey:e,blindkey:r,network:this.network}).confidentialAddress},n.persistAddressToCache=function(e){var t=Buffer.from(e.publicKey,"hex"),r=this.scriptFromPublicKey(t);this.scriptToAddressCache.set(r,e)},n.getAddress=function(e,t){var r=this.derivePublicKeyWithIndex(e,t),n=this.scriptFromPublicKey(r),i=this.getBlindingKeyPair(n);return{address:{confidentialAddress:this.createConfidentialAddress(r,i.publicKey),blindingPrivateKey:i.privateKey.toString("hex")},derivationPath:(e?1:0)+"/"+t,publicKey:r.toString("hex")}},n.getNextAddress=function(){var e=this.getAddress(!1,this.index);return this.persistAddressToCache(e),this.index+=1,e.address},n.getNextChangeAddress=function(){var e=this.getAddress(!0,this.changeIndex);return this.persistAddressToCache(e),this.changeIndex+=1,e.address},n.getBlindingPrivateKey=function(e){var t=Buffer.from(e,"hex");return this.getBlindingKeyPair(t).privateKey.toString("hex")},n.signPset=function(e){throw new Error("MasterPublicKey is a watch only identity. Use Mnemonic to sign transactions")},n.getAddresses=function(){return this.scriptToAddressCache.values().map((function(e){return e.address}))},n.generateSetOfAddresses=function(){var e=d(x.mark((function e(t,r,n){var i,o,a=this;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=function(){var e=d(x.mark((function e(t){return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",a.getAddress(n,t));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),o=Array.from({length:r},(function(e,r){return r+t})),e.abrupt("return",Promise.all(o.map(i)));case 3:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),n.checkAddressesWithRestorer=function(){var e=d(x.mark((function e(t){var r;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.map((function(e){return e.address.confidentialAddress})),e.next=3,this.restorer.addressesHaveBeenUsed(r);case 3:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),n.restoreAddresses=function(){var e=d(x.mark((function e(){var t,n,i,o=this;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],n=x.mark((function e(n){var i,a,s,u,c,f,p;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=1===n,a=0,s=0,u=[],c=function(e){return function(t,r){a++,t&&(a=0,u.push(e[r]))}};case 5:if(!(a<20)){e.next=16;break}return e.next=8,o.generateSetOfAddresses(s,20-a,i);case 8:return f=e.sent,e.next=11,o.checkAddressesWithRestorer(f);case 11:e.sent.forEach(c(f)),s+=20,e.next=5;break;case 16:p=u.map(z),i?o.changeIndex=p.length>0?Math.max.apply(Math,p)+1:r.INITIAL_INDEX:o.index=p.length>0?Math.max.apply(Math,p)+1:r.INITIAL_INDEX,t=t.concat(u);case 19:case"end":return e.stop()}}),e)})),i=0;case 4:if(!(i<2)){e.next=9;break}return e.delegateYield(n(i),"t0",6);case 6:i++,e.next=4;break;case 9:return e.abrupt("return",t);case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),n.restore=function(){var e=d(x.mark((function e(){var t=this;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.restoreAddresses();case 2:return e.sent.forEach((function(e){return t.persistAddressToCache(e)})),e.abrupt("return",!0);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r}(H);V.INITIAL_INDEX=0;var Y=function(e,t){return e.value-t.value};function Z(e,t,r){for(var n,i=[],o=0,a=v(e=e.sort(r));!(n=a()).done;){var s=n.value;if(D(s)||(i.push(s),o+=s.value),o>=t)return{selected:i,changeAmount:o-t}}throw new Error("not enough utxos in wallet to found: "+t)}function $(e,t){return e.reduce((function(e,r){return(e[r[t]]=e[r[t]]||[]).push(r),e}),{})}function J(e){return"surjectionProof"in e&&"rangeProof"in e}function Q(){return(Q=d(x.mark((function e(t,r,n){return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,se([{confidentialAddress:t,blindingPrivateKey:r}],n);case 2:return e.abrupt("return",e.sent.reduce((function(e,t){var r=t.asset;return e[r]=e[r]||0,e[r]+=t.value,e}),{}));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ee(e,t){return te.apply(this,arguments)}function te(){return(te=d(x.mark((function e(t,n){return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.get(n+"/tx/"+t+"/hex");case 2:return e.abrupt("return",e.sent.data);case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function re(e,t){return ne.apply(this,arguments)}function ne(){return(ne=d(x.mark((function e(t,n){return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.get(n+"/address/"+t+"/utxo");case 2:return e.abrupt("return",e.sent.data);case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ie(){return(ie=d(x.mark((function e(t,r,n){var i,o,a;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=ce(t,r,n),o=[],e.next=4,i.next();case 4:a=e.sent;case 5:if(a.done){e.next=12;break}return o.push(a.value),e.next=9,i.next();case 9:a=e.sent,e.next=5;break;case 12:return e.abrupt("return",o);case 13:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function oe(e,t){return ae.apply(this,arguments)}function ae(){return(ae=c(x.mark((function e(t,r){var n,i,o,a;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=0,i=x.mark((function e(){var t,i,o,s,u,c,p;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=(t=a.value).confidentialAddress,o=t.blindingPrivateKey,e.next=3,f(re(i,r));case 3:s=e.sent.map((function(e){return we(e,o,r)})),n+=s.length,u=v(s);case 7:if((c=u()).done){e.next=13;break}return p=c.value,e.next=11,p;case 11:e.next=7;break;case 13:case"end":return e.stop()}}),e)})),o=v(t);case 3:if((a=o()).done){e.next=7;break}return e.delegateYield(i(),"t0",5);case 5:e.next=3;break;case 7:return e.abrupt("return",n);case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function se(e,t){return ue.apply(this,arguments)}function ue(){return(ue=d(x.mark((function e(t,r){var n,i,o;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=oe(t,r),i=[],e.next=4,n.next();case 4:o=e.sent;case 5:if(o.done){e.next=12;break}return i.push(o.value),e.next=9,n.next();case 9:o=e.sent,e.next=5;break;case 12:return e.abrupt("return",i);case 13:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ce(e,t,r){return fe.apply(this,arguments)}function fe(){return(fe=c(x.mark((function e(t,r,n){var i,o,a,s,u;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=v(t);case 1:if((o=i()).done){e.next=18;break}return a=pe(o.value,n),e.next=6,f(a.next());case 6:s=e.sent;case 7:if(s.done){e.next=16;break}return u=s.value,e.next=11,le(u,r);case 11:return e.next=13,f(a.next());case 13:s=e.sent,e.next=7;break;case 16:e.next=1;break;case 18:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function pe(e,t){return de.apply(this,arguments)}function de(){return(de=c(x.mark((function e(t,r){var n,i,o,a,s,u,c;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=void 0,i=[],o=0;case 3:return e.next=5,f(be(t,r,n));case 5:o+=(i=e.sent).length,a=i.map((function(e){return xe(e,r)})),s=v(a);case 9:if((u=s()).done){e.next=15;break}return c=u.value,e.next=13,c;case 13:e.next=9;break;case 15:if(i.length<25){e.next=3;break}case 16:return e.abrupt("return",o);case 17:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function he(e){return S(e)?{blindedAsset:e.asset,blindedValue:e.value,nonce:e.nonce,rangeProof:e.rangeProof,surjectionProof:e.surjectionProof,script:e.script.toString("hex")}:{asset:I(e.asset),value:E(e.value),script:e.script.toString("hex")}}function le(e,t){return ve.apply(this,arguments)}function ve(){return(ve=d(x.mark((function e(t,r){var n,i,o,a,s;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(n=[],i=function(e){var i=t.vin[e].prevout;J(i)&&n.push(function(){var n=d(x.mark((function n(){var o,a;return x.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:(o=r(i.script))&&(a=ye(i,o),t.vin[e].prevout=a);case 2:case"end":return n.stop()}}),n)})));return function(){return n.apply(this,arguments)}}()())},o=0;o<t.vin.length;o++)i(o);for(a=function(e){var i=t.vout[e];J(i)&&n.push(function(){var n=d(x.mark((function n(){var o,a;return x.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:(o=r(i.script))&&(a=ye(i,o),t.vout[e]=a);case 2:case"end":return n.stop()}}),n)})));return function(){return n.apply(this,arguments)}}()())},s=0;s<t.vout.length;s++)a(s);return e.next=7,Promise.all(n);case 7:return e.abrupt("return",t);case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ye(e,r){var n=Buffer.from(r,"hex"),i=t.confidential.unblindOutput(e.nonce,n,e.rangeProof,e.blindedValue,e.blindedAsset,Buffer.from(e.script,"hex"));return{asset:Buffer.from(i.asset.reverse()).toString("hex"),value:parseInt(i.value,10),script:e.script}}function xe(e,t){return ge.apply(this,arguments)}function ge(){return(ge=d(x.mark((function e(r,n){var i,o,a,s,u,c,f,p,d;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(i=[],o=[],a=v(r.vin);!(s=a()).done;)i.push((u=s.value).txid),o.push(u.vout);return e.next=5,Promise.all(i.map((function(e){return ee(e,n)})));case 5:return c=e.sent.map((function(e,r){return he(t.Transaction.fromHex(e).outs[o[r]])})),f=i.map((function(e,t){return{prevout:c[t],txid:e,vout:o[t]}})),e.next=10,ee(r.txid,n);case 10:return p=t.Transaction.fromHex(e.sent),d=p.outs.map(he),e.abrupt("return",{txid:r.txid,vin:f,vout:d,fee:r.fee,status:{confirmed:r.status.confirmed,blockHash:r.status.block_hash,blockHeight:r.status.block_height,blockTime:r.status.block_time}});case 15:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function be(e,t,r){return me.apply(this,arguments)}function me(){return(me=d(x.mark((function e(t,n,i){var o;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=n+"/address/"+t+"/txs/chain",i&&(o+="/"+i),e.next=4,r.get(o);case 4:return e.abrupt("return",e.sent.data);case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function we(e,t,r){return Pe.apply(this,arguments)}function Pe(){return(Pe=d(x.mark((function e(t,r,n){return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,ke(t,r,n);case 3:return e.abrupt("return",e.sent);case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",t);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})))).apply(this,arguments)}function ke(e,t,r){return Ke.apply(this,arguments)}function Ke(){return(Ke=d(x.mark((function e(r,n,i){var o,a;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ee(r.txid,i);case 2:return o=t.Transaction.fromHex(e.sent).outs[r.vout],a=t.confidential.unblindOutput(o.nonce,Buffer.from(n,"hex"),o.rangeProof,o.value,o.asset,o.script),e.abrupt("return",{txid:r.txid,vout:r.vout,asset:a.asset.reverse().toString("hex"),value:parseInt(a.value,10),prevout:o});case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Ae=function(){function e(e,t){this.network=t,this.cache=e}var r=e.prototype;return r.createTx=function(){return new t.Psbt({network:this.network}).toBase64()},r.buildTx=function(e,t,r,n,i,o){return b({psetBase64:e,recipients:t,coinSelector:r,changeAddressByAsset:n,addFee:i,satsPerByte:o,unspents:this.cache.getAll()})},e}();function Ie(){return(Ie=d(x.mark((function e(t,r,n){return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,se(t,r);case 2:return e.abrupt("return",Ee(e.sent,n));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ee(e,t){return new Ae(new Te(e),R(t))}var Te=function(){function e(e){this.utxoMap=new Map,e&&this.push(e)}var t=e.prototype;return t.push=function(e){for(var t,r=v(e);!(t=r()).done;){var n=t.value;this.utxoMap.set(W(n),n)}},t.delete=function(e){return this.utxoMap.delete(e)},t.getAll=function(){return Array.from(this.utxoMap.values())},e}();Object.defineProperty(exports,"ECPair",{enumerable:!0,get:function(){return t.ECPair}}),Object.defineProperty(exports,"address",{enumerable:!0,get:function(){return t.address}}),Object.defineProperty(exports,"networks",{enumerable:!0,get:function(){return t.networks}}),Object.defineProperty(exports,"payments",{enumerable:!0,get:function(){return t.payments}}),exports.BufferMap=O,exports.EsploraIdentityRestorer=g,exports.MasterPublicKey=V,exports.Mnemonic=X,exports.PrivateKey=q,exports.UtxoCache=Te,exports.Wallet=Ae,exports.addToTx=w,exports.buildTx=b,exports.createFeeOutput=m,exports.decodePset=P,exports.estimateTxSize=k,exports.fetchAndUnblindTxs=function(e,t,r){return ie.apply(this,arguments)},exports.fetchAndUnblindTxsGenerator=ce,exports.fetchAndUnblindUtxos=se,exports.fetchAndUnblindUtxosGenerator=oe,exports.fetchBalances=function(e,t,r){return Q.apply(this,arguments)},exports.fetchTxHex=ee,exports.fetchUtxos=re,exports.fromAssetHash=function(e){return Buffer.concat([Buffer.from("01","hex"),Buffer.from(e,"hex").reverse()])},exports.fromXpub=M,exports.getNetwork=R,exports.greedyCoinSelector=function(e){return void 0===e&&(e=Y),function(t,r,n){return function(e,t,r,n){for(var i={selectedUtxos:[],changeOutputs:[]},o=$(e=e.filter((function(e){return!D(e)})),"asset"),a=$(t,"asset"),s=0,u=Object.entries(a);s<u.length;s++){var c,f=u[s],p=f[0],d=f[1],h=o[p];if(!h)throw new Error("need unspents for the asset: "+p);var l=Z(h,d.reduce((function(e,t){return e+t.value}),0),n),v=l.changeAmount;if((c=i.selectedUtxos).push.apply(c,l.selected),v>0){var y=r(p);if(!y)throw new Error("need change address for asset: "+p);i.changeOutputs.push({asset:p,value:v,address:y})}}return i}(t,r,n,e)}},exports.isBlindedOutputInterface=J,exports.isBlindedUtxo=D,exports.isConfidentialOutput=S,exports.isValidAmount=function(e){return!(e<=0||!Number.isSafeInteger(e))},exports.isValidExtendedBlindKey=F,exports.isValidXpub=C,exports.psetToUnsignedHex=j,exports.psetToUnsignedTx=function(e){return t.Transaction.fromHex(j(e))},exports.toAssetHash=I,exports.toNumber=E,exports.toOutpoint=W,exports.toXpub=U,exports.tryToUnblindOutput=ye,exports.tryToUnblindUtxo=we,exports.unblindOutput=function(e,r){var n={asset:Buffer.alloc(0),value:0};if(!e.rangeProof)throw new Error("The output does not contain rangeProof.");var i=t.confidential.unblindOutput(e.nonce,r,e.rangeProof,e.value,e.asset,e.script);return n.asset=Buffer.concat([Buffer.alloc(1,10),i.asset]),n.value=parseInt(i.value,10),n},exports.unblindUtxo=ke,exports.walletFromAddresses=function(e,t,r){return Ie.apply(this,arguments)},exports.walletFromCoins=Ee;
//# sourceMappingURL=ldk.cjs.production.min.js.map
{
"version": "0.1.6",
"version": "0.1.7",
"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