Comparing version 0.2.2 to 0.2.3
@@ -5,10 +5,13 @@ import { AddressInterface, BlindedOutputInterface, BlindingKeyGetter, TxInterface, UnblindedOutputInterface, UtxoInterface } from '../types'; | ||
export declare function fetchUtxos(address: string, url: string): Promise<any[]>; | ||
export declare function fetchAndUnblindTxs(addresses: string[], blindingKeyGetter: BlindingKeyGetter, explorerUrl: string): Promise<TxInterface[]>; | ||
export declare function fetchAndUnblindTxs(addresses: string[], blindingKeyGetter: BlindingKeyGetter, explorerUrl: string, skip?: (tx: TxInterface) => boolean): Promise<TxInterface[]>; | ||
export declare function fetchAndUnblindUtxosGenerator(addressesAndBlindingKeys: Array<AddressInterface>, url: string, skip?: (utxo: UtxoInterface) => boolean): AsyncGenerator<UtxoInterface, number, undefined>; | ||
export declare function fetchAndUnblindUtxos(addressesAndBlindingKeys: Array<AddressInterface>, url: string, skip?: (utxo: UtxoInterface) => boolean): Promise<UtxoInterface[]>; | ||
/** | ||
* fetch all tx associated to an address and unblind the tx's outputs and prevouts. | ||
* @param explorerUrl the esplora endpoint | ||
* Return an async generator fetching and unblinding addresses' transactions | ||
* @param addresses | ||
* @param blindingKeyGetter | ||
* @param explorerUrl | ||
* @param skip optional, can be used to skip certain transaction | ||
*/ | ||
export declare function fetchAndUnblindTxsGenerator(addresses: string[], blindingKeyGetter: BlindingKeyGetter, explorerUrl: string): AsyncGenerator<TxInterface, void, undefined>; | ||
export declare function fetchAndUnblindTxsGenerator(addresses: string[], blindingKeyGetter: BlindingKeyGetter, explorerUrl: string, skip?: (tx: TxInterface) => boolean): AsyncGenerator<TxInterface, void, undefined>; | ||
export declare function unblindOutput(output: BlindedOutputInterface, BlindingPrivateKey: string): Promise<UnblindedOutputInterface>; | ||
@@ -15,0 +18,0 @@ /** |
@@ -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"),o=require("slip77"),s=require("bip39");function a(e){this.wrapped=e}function u(e){var t,r;function n(t,r){try{var o=e[t](r),s=o.value,u=s instanceof a;Promise.resolve(u?s.wrapped:s).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,s){var a={key:e,arg:i,resolve:o,reject:s,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,o,s){try{var a=e[o](s),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 o=e.apply(t,r);function s(e){f(o,n,i,s,a,"next",e)}function a(e){f(o,n,i,s,a,"throw",e)}s(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",s=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),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 s=r.delegate;if(s){var a=m(s,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,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 p={};function f(){}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=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 b(e,t){var n;this._invoke=function(i,o){function s(){return new t((function(n,s){!function n(i,o,s,a){var u=c(e[i],e,o);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,s,a)}),(function(e){n("throw",e,s,a)})):t.resolve(f).then((function(e){p.value=e,s(p)}),(function(e){return n("throw",e,s,a)}))}a(u.arg)}(i,o,n,s)}))}return n=n?n.then(s,s):s()}}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 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 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=a(h,s,"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,s,"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 s=new b(u(t,r,n,i),o);return e.isGeneratorFunction(r)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},g(x),a(x,s,"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 s.type="throw",s.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],s=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var a=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(a&&u){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(a){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 s=o?o.completion:{};return s.type=e,s.arg=t,o?(this.method="next",this.next=o.finallyLoc,p):this.complete(s)},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:K(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 b(e){return e.slice(1).reverse().toString("hex")}function m(e){return t.confidential.confidentialValueToSatoshi(e)}g.DEFAULT_ESPLORA_ENDPOINT="https://blockstream.info/liquid/api";var w=Buffer.from("0x00","hex");function P(e){return null!=e&&e.length>0}function k(e){var t=e.surjectionProof,r=e.nonce;return P(e.rangeProof)&&P(t)&&r!==w}var K,A=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}(),I=new Map([["xpub","0488b21e"],["ypub","049d7cb2"],["Ypub","0295b43f"],["zpub","04b24746"],["Zpub","02aa7ed3"],["tpub","043587cf"],["upub","044a5262"],["Upub","024289ef"],["vpub","045f1cf6"],["Vpub","02575483"]]);function E(e,t){if(!I.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(I.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 T(e,t){return E(e,"regtest"===t?"vpub":"zpub")}function B(e){return E(e,"xpub")}function S(e,t){try{i.fromBase58(e,t)}catch(e){return!1}return!0}function N(e){try{o.fromMasterBlindingKey(e)}catch(e){return!1}return!0}function O(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 L(e){return{txid:e.txid,vout:e.vout}}function _(e){return!e.asset||!e.value}function M(e){return e?t.networks[e]:t.networks.liquid}function U(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,s=r.recipients,a=r.unspents,u=r.addFee,c=r.satsPerByte,p=i(a,s,n),f=p.selectedUtxos,d=p.changeOutputs,h=f;if(!u)return F(o,h,s.concat(d));var l=j(o),y=l.data.inputs.length+h.length,x=l.data.outputs.length+s.length+d.length,g=t.address.getNetwork(s[0].address).assetHash,b=C(y,x,c,g),m=d.findIndex((function(e){return e.asset===g})),w=-1===m?0-b.value:d[m].value-b.value;if(w>0)return d[m].value=w,F(o,h,s.concat(d).concat(b));if(0===w)return F(o,h,s.concat(b));for(var P,k=[],K=v(a);!(P=K()).done;){var A=P.value;f.includes(A)||k.push(A)}var I=C(y+1,x+1,c,g),E=i(k,[I],n);return F(o,h.concat(E.selectedUtxos),s.concat(d).concat(E.changeOutputs).concat(I))}function C(e,t,r,n){var i=W(e,t);return{asset:n,value:Math.ceil(i*r),address:""}}function F(e,r,n){for(var i,o=j(e),s=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);o.addOutput({asset:c,value:p,script:d,nonce:s})}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 j(e){var r;try{r=t.Psbt.fromBase64(e)}catch(e){throw new Error("Invalid pset")}return r}function W(e,t){return(3*D(!1,e,t,!1)+D(!0,e,t,!0)+3)/4}function D(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+R(r)+R(t)+i+o}function R(e){return e<253?1:e<=65535?3:e<=4294967295?5:9}(K=exports.IdentityType||(exports.IdentityType={}))[K.PrivateKey=1]="PrivateKey",K[K.Mnemonic=2]="Mnemonic",K[K.MasterPublicKey=3]="MasterPublicKey",K[K.Inject=4]="Inject",K[K.Ledger=5]="Ledger",K[K.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,s){var a,u,c,p,f,d,h,l,y,g,b,m,w,P,K;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=new Map,u=new Map,c=j(n),p=t.Transaction.fromHex(O(n)),f=v(i);case 5:if((d=f()).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(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=43;break}if(m=void 0,!(b=c.data.inputs[g]).witnessUtxo){e.next=24;break}if(k(b.witnessUtxo)){e.next=23;break}return e.abrupt("continue",40);case 23:m=b.witnessUtxo.script;case 24:if(!b.nonWitnessUtxo){e.next=30;break}if(w=p.ins[g].index,k(P=t.Transaction.fromBuffer(b.nonWitnessUtxo).outs[w])){e.next=29;break}return e.abrupt("continue",40);case 29:m=P.script;case 30:if(!s||!s.has(g)){e.next=33;break}return a.set(g,s.get(g)),e.abrupt("continue",40);case 33:if(m){e.next=35;break}throw new Error("no witness script for input #"+g);case 35:return K=r(m).privateKey,e.next=38,t.confidential.unblindOutputWithKey(b.witnessUtxo,K);case 38:a.set(g,e.sent);case 40:g++,e.next=17;break;case 43:return e.next=45,c.blindOutputsByIndex(a,u);case 45:return e.abrupt("return",e.sent.toBase64());case 47: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 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 A,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(s.setDefaultWordlist(n.value.language?n.value.language:"english"),!s.validateMnemonic(n.value.mnemonic))throw new Error("Mnemonic is not valid.");var u=s.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=T(p,n.chain),a.masterBlindingKeyNode=o.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,o){var s=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 s.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,s,a,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++)(s=n.data.inputs[o]).witnessUtxo&&(a=this.scriptToAddressCache.get(s.witnessUtxo.script))&&(u=Buffer.from(a.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,s=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",s.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,s,a,u,c,p,f;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=1===n,s=0,a=0,u=[],c=function(e){return function(t,r){s++,t&&(s=0,u.push(e[r]))}};case 5:if(!(s<20)){e.next=16;break}return e.next=8,o.generateSetOfAddresses(a,20-s,i);case 8:return p=e.sent,e.next=11,o.checkAddressesWithRestorer(p);case 11:e.sent.forEach(c(p)),a+=20,e.next=5;break;case 16:f=u.map(G),i?o.changeIndex=f.length>0?Math.max.apply(Math,f)+1:r.INITIAL_INDEX:o.index=f.length>0?Math.max.apply(Math,f)+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 s=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 s.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,s,a=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++)(s=n.data.inputs[o]).witnessUtxo?s.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,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 A;var s,a=B(t.value.masterPublicKey);if(t.type!==exports.IdentityType.MasterPublicKey)throw new Error("The identity arguments have not the MasterPublicKey type.");if(!("masterPublicKey"in(s=t.value))||!("masterBlindingKey"in s))throw new Error("The value of IdentityOpts is not valid for MasterPublicKey Identity.");if(!S(a))throw new Error("Master public key is not valid");if(!N(t.value.masterBlindingKey))throw new Error("Master blinding key is not valid");return n.masterPublicKeyNode=i.fromBase58(a),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 s=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 s.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,s=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",s.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,s,a,u,c,p,f;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=1===n,s=0,a=0,u=[],c=function(e){return function(t,r){s++,t&&(s=0,u.push(e[r]))}};case 5:if(!(s<20)){e.next=16;break}return e.next=8,o.generateSetOfAddresses(a,20-s,i);case 8:return p=e.sent,e.next=11,o.checkAddressesWithRestorer(p);case 11:e.sent.forEach(c(p)),a+=20,e.next=5;break;case 16:f=u.map(z),i?o.changeIndex=f.length>0?Math.max.apply(Math,f)+1:r.INITIAL_INDEX:o.index=f.length>0?Math.max.apply(Math,f)+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,s=v(e=e.sort(r));!(n=s()).done;){var a=n.value;if(_(a)||(i.push(a),o+=a.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,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,o,s;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:s=e.sent;case 5:if(s.done){e.next=12;break}return o.push(s.value),e.next=9,i.next();case 9:s=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,r){return se.apply(this,arguments)}function se(){return(se=c(x.mark((function e(t,r,n){var i,o,s,a;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=0,o=x.mark((function e(){var t,o,s,u,c,f,d,h;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=(t=a.value).confidentialAddress,s=t.blindingPrivateKey,e.next=3,p(re(o,r));case 3:u=e.sent.map((function(e){return n&&n(e)?e:Pe(e,s,r)})),i+=u.length,c=v(u);case 7:if((f=c()).done){e.next=16;break}return d=f.value,e.next=11,p(d);case 11:return h=e.sent,e.next=14,h;case 14:e.next=7;break;case 16:case"end":return e.stop()}}),e)})),s=v(t);case 3:if((a=s()).done){e.next=7;break}return e.delegateYield(o(),"t0",5);case 5:e.next=3;break;case 7:return e.abrupt("return",i);case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ae(e,t,r){return ue.apply(this,arguments)}function ue(){return(ue=d(x.mark((function e(t,r,n){var i,o,s;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=oe(t,r,n),o=[],e.next=4,i.next();case 4:s=e.sent;case 5:if(s.done){e.next=12;break}return o.push(s.value),e.next=9,i.next();case 9:s=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 ce(e,t,r){return pe.apply(this,arguments)}function pe(){return(pe=c(x.mark((function e(t,r,n){var i,o,s,a,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 s=fe(o.value,n),e.next=6,p(s.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(s.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,o,s,a,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,p(me(t,r,n));case 5:o+=(i=e.sent).length,s=i.map((function(e){return ge(e,r)})),a=v(s);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",o);case 17:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function he(e){return k(e)?{blindedAsset:e.asset,blindedValue:e.value,nonce:e.nonce,rangeProof:e.rangeProof,surjectionProof:e.surjectionProof,script:e.script.toString("hex")}:{asset:b(e.asset),value:m(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,s,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 o;return x.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(o=r(i.script))){n.next=6;break}return n.next=4,ye(i,o);case 4:t.vin[e].prevout=n.sent;case 6:case"end":return n.stop()}}),n)})));return function(){return n.apply(this,arguments)}}()())},o=0;o<t.vin.length;o++)i(o);for(s=function(e){var i=t.vout[e];J(i)&&n.push(function(){var n=d(x.mark((function n(){var o;return x.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(o=r(i.script))){n.next=6;break}return n.next=4,ye(i,o);case 4:t.vout[e]=n.sent;case 6:case"end":return n.stop()}}),n)})));return function(){return n.apply(this,arguments)}}()())},a=0;a<t.vout.length;a++)s(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,t){return xe.apply(this,arguments)}function xe(){return(xe=d(x.mark((function e(r,n){var i,o,s,a;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i={asset:r.blindedAsset,value:r.blindedValue,rangeProof:r.rangeProof,surjectionProof:r.surjectionProof,nonce:r.nonce,script:Buffer.from(r.script,"hex")},o=Buffer.from(n,"hex"),e.next=4,t.confidential.unblindOutputWithKey(i,o);case 4:return s=e.sent,a={asset:Buffer.from(s.asset.reverse()).toString("hex"),value:parseInt(s.value,10),script:r.script},e.abrupt("return",a);case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ge(e,t){return be.apply(this,arguments)}function be(){return(be=d(x.mark((function e(r,n){var i,o,s,a,u,c,p,f,d;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(i=[],o=[],s=v(r.vin);!(a=s()).done;)i.push((u=a.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]])})),p=i.map((function(e,t){return{prevout:c[t],txid:e,vout:o[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 we.apply(this,arguments)}function we(){return(we=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 Pe(e,t,r){return ke.apply(this,arguments)}function ke(){return(ke=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 o,s,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],e.next=6,t.confidential.unblindOutputWithKey(o,Buffer.from(n,"hex"));case 6:return s=e.sent,a=Buffer.alloc(32),s.asset.copy(a),e.abrupt("return",{txid:r.txid,vout:r.vout,asset:a.reverse().toString("hex"),value:parseInt(s.value,10),prevout:o,unblindData:s});case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Ie=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 U({psetBase64:e,recipients:t,coinSelector:r,changeAddressByAsset:n,addFee:i,satsPerByte:o,unspents:this.cache.getAll()})},e}();function Ee(){return(Ee=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 Ie(new Be(e),M(t))}var Be=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(L(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=A,exports.EsploraIdentityRestorer=g,exports.MasterPublicKey=V,exports.Mnemonic=X,exports.PrivateKey=q,exports.UtxoCache=Be,exports.Wallet=Ie,exports.addToTx=F,exports.buildTx=U,exports.createFeeOutput=C,exports.decodePset=j,exports.estimateTxSize=W,exports.fetchAndUnblindTxs=function(e,t,r){return ie.apply(this,arguments)},exports.fetchAndUnblindTxsGenerator=ce,exports.fetchAndUnblindUtxos=ae,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=T,exports.getNetwork=M,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!_(e)})),"asset"),s=$(t,"asset"),a=0,u=Object.entries(s);a<u.length;a++){var c,p=u[a],f=p[0],d=p[1],h=o[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=_,exports.isConfidentialOutput=k,exports.isValidAmount=function(e){return!(e<=0||!Number.isSafeInteger(e))},exports.isValidExtendedBlindKey=N,exports.isValidXpub=S,exports.psetToUnsignedHex=O,exports.psetToUnsignedTx=function(e){return t.Transaction.fromHex(O(e))},exports.toAssetHash=b,exports.toNumber=m,exports.toOutpoint=L,exports.toXpub=B,exports.tryToUnblindUtxo=Pe,exports.unblindOutput=ye,exports.unblindUtxo=Ke,exports.walletFromAddresses=function(e,t,r){return Ee.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"),a=require("slip77"),o=require("bip39");function s(e){this.wrapped=e}function u(e){var t,r;function n(t,r){try{var a=e[t](r),o=a.value,u=o instanceof s;Promise.resolve(u?o.wrapped:o).then((function(e){u?n("return"===t?"return":"next",e):i(a.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(a,o){var s={key:e,arg:i,resolve:a,reject:o,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 p(e){return new s(e)}function f(e,t,r,n,i,a,o){try{var s=e[a](o),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 a=e.apply(t,r);function o(e){f(a,n,i,o,s,"next",e)}function s(e){f(a,n,i,o,s,"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",a=n.asyncIterator||"@@asyncIterator",o=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 f?t:f).prototype),a=new k(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(i,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw a;return{value:void 0,done:!0}}for(r.method=i,r.arg=a;;){var o=r.delegate;if(o){var s=m(o,r);if(s){if(s===p)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(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,a),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(K([])));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){s(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){var n;this._invoke=function(i,a){function o(){return new t((function(n,o){!function n(i,a,o,s){var u=c(e[i],e,a);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,s)}),(function(e){n("throw",e,o,s)})):t.resolve(f).then((function(e){p.value=e,o(p)}),(function(e){return n("throw",e,o,s)}))}s(u.arg)}(i,a,n,o)}))}return n=n?n.then(o,o):o()}}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 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 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,a=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 a.next=a}}return{next:A}}function A(){return{value:void 0,done:!0}}return d.prototype=x.constructor=h,h.constructor=d,d.displayName=s(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,s(e,o,"GeneratorFunction")),e.prototype=Object.create(x),e},e.awrap=function(e){return{__await:e}},g(b.prototype),b.prototype[a]=function(){return this},e.AsyncIterator=b,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var o=new b(u(t,r,n,i),a);return e.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},g(x),s(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=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 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 a=this.tryEntries[i],o=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.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 a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.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:K(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 b(e){return e.slice(1).reverse().toString("hex")}function m(e){return t.confidential.confidentialValueToSatoshi(e)}g.DEFAULT_ESPLORA_ENDPOINT="https://blockstream.info/liquid/api";var w=Buffer.from("0x00","hex");function P(e){return null!=e&&e.length>0}function k(e){var t=e.surjectionProof,r=e.nonce;return P(e.rangeProof)&&P(t)&&r!==w}var K,A=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}(),I=new Map([["xpub","0488b21e"],["ypub","049d7cb2"],["Ypub","0295b43f"],["zpub","04b24746"],["Zpub","02aa7ed3"],["tpub","043587cf"],["upub","044a5262"],["Upub","024289ef"],["vpub","045f1cf6"],["Vpub","02575483"]]);function E(e,t){if(!I.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(I.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 T(e,t){return E(e,"regtest"===t?"vpub":"zpub")}function B(e){return E(e,"xpub")}function S(e,t){try{i.fromBase58(e,t)}catch(e){return!1}return!0}function N(e){try{a.fromMasterBlindingKey(e)}catch(e){return!1}return!0}function O(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 L(e){return{txid:e.txid,vout:e.vout}}function _(e){return!e.asset||!e.value}function M(e){return e?t.networks[e]:t.networks.liquid}function U(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,a=r.psetBase64,o=r.recipients,s=r.unspents,u=r.addFee,c=r.satsPerByte,p=i(s,o,n),f=p.selectedUtxos,d=p.changeOutputs,h=f;if(!u)return F(a,h,o.concat(d));var l=j(a),y=l.data.inputs.length+h.length,x=l.data.outputs.length+o.length+d.length,g=t.address.getNetwork(o[0].address).assetHash,b=C(y,x,c,g),m=d.findIndex((function(e){return e.asset===g})),w=-1===m?0-b.value:d[m].value-b.value;if(w>0)return d[m].value=w,F(a,h,o.concat(d).concat(b));if(0===w)return F(a,h,o.concat(b));for(var P,k=[],K=v(s);!(P=K()).done;){var A=P.value;f.includes(A)||k.push(A)}var I=C(y+1,x+1,c,g),E=i(k,[I],n);return F(a,h.concat(E.selectedUtxos),o.concat(d).concat(E.changeOutputs).concat(I))}function C(e,t,r,n){var i=W(e,t);return{asset:n,value:Math.ceil(i*r),address:""}}function F(e,r,n){for(var i,a=j(e),o=Buffer.from("00","hex"),s=v(n);!(i=s()).done;){var u=i.value,c=u.asset,p=u.value,f=u.address,d=""===f?"":t.address.toOutputScript(f);a.addOutput({asset:c,value:p,script:d,nonce:o})}for(var h,l=v(r);!(h=l()).done;){var y=h.value;a.addInput({hash:y.txid,index:y.vout,witnessUtxo:y.prevout})}return a.toBase64()}function j(e){var r;try{r=t.Psbt.fromBase64(e)}catch(e){throw new Error("Invalid pset")}return r}function W(e,t){return(3*D(!1,e,t,!1)+D(!0,e,t,!0)+3)/4}function D(e,t,r,n){var i=function(e,t){var r=40*t;return e&&(r+=105*t),r}(e,t),a=function(e,t){var r=67*t;return e&&(r+=4273*t),r+43}(n,r);return 9+R(r)+R(t)+i+a}function R(e){return e<253?1:e<=65535?3:e<=4294967295?5:9}(K=exports.IdentityType||(exports.IdentityType={}))[K.PrivateKey=1]="PrivateKey",K[K.Mnemonic=2]="Mnemonic",K[K.MasterPublicKey=3]="MasterPublicKey",K[K.Inject=4]="Inject",K[K.Ledger=5]="Ledger",K[K.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,a,o){var s,u,c,p,f,d,h,l,y,g,b,m,w,P,K;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s=new Map,u=new Map,c=j(n),p=t.Transaction.fromHex(O(n)),f=v(i);case 5:if((d=f()).done){e.next=16;break}if(h=d.value,!a||!a.has(h)){e.next=11;break}return l=Buffer.from(a.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=43;break}if(m=void 0,!(b=c.data.inputs[g]).witnessUtxo){e.next=24;break}if(k(b.witnessUtxo)){e.next=23;break}return e.abrupt("continue",40);case 23:m=b.witnessUtxo.script;case 24:if(!b.nonWitnessUtxo){e.next=30;break}if(w=p.ins[g].index,k(P=t.Transaction.fromBuffer(b.nonWitnessUtxo).outs[w])){e.next=29;break}return e.abrupt("continue",40);case 29:m=P.script;case 30:if(!o||!o.has(g)){e.next=33;break}return s.set(g,o.get(g)),e.abrupt("continue",40);case 33:if(m){e.next=35;break}throw new Error("no witness script for input #"+g);case 35:return K=r(m).privateKey,e.next=38,t.confidential.unblindOutputWithKey(b.witnessUtxo,K);case 38:s.set(g,e.sent);case 40:g++,e.next=17;break;case 43:return e.next=45,c.blindOutputsByIndex(s,u);case 45:return e.abrupt("return",e.sent.toBase64());case 47:case"end":return e.stop()}}),e)})));return function(t,r,n,i,a){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 A,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);s.masterPrivateKeyNode=i.fromSeed(u,s.network);var c=s.masterPrivateKeyNode.derivePath(s.baseDerivationPath),p=t.bip32.fromPublicKey(c.publicKey,c.chainCode,c.network).toBase58();return s.masterPublicKey=T(p,n.chain),s.masterBlindingKeyNode=a.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,a){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,a));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,a,o,s,u,c;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(n=t.Psbt.fromBase64(r),i=[],a=0;a<n.data.inputs.length;a++)(o=n.data.inputs[a]).witnessUtxo&&(s=this.scriptToAddressCache.get(o.witnessUtxo.script))&&(u=Buffer.from(s.signingPrivateKey,"hex"),c=t.ECPair.fromPrivateKey(u),i.push(n.signInputAsync(a,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,a,o=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",o.getAddress(n,t));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),a=Array.from({length:r},(function(e,r){return r+t})),e.abrupt("return",Promise.all(a.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,a=this;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],n=x.mark((function e(n){var i,o,s,u,c,p,f;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=1===n,o=0,s=0,u=[],c=function(e){return function(t,r){o++,t&&(o=0,u.push(e[r]))}};case 5:if(!(o<20)){e.next=16;break}return e.next=8,a.generateSetOfAddresses(s,20-o,i);case 8:return p=e.sent,e.next=11,a.checkAddressesWithRestorer(p);case 11:e.sent.forEach(c(p)),s+=20,e.next=5;break;case 16:f=u.map(G),i?a.changeIndex=f.length>0?Math.max.apply(Math,f)+1:r.INITIAL_INDEX:a.index=f.length>0?Math.max.apply(Math,f)+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 a=t.payments.p2wpkh({pubkey:n.signingKeyPair.publicKey,blindkey:n.blindingKeyPair.publicKey,network:n.network});return n.confidentialAddress=a.confidentialAddress,n.blindingPrivateKey=n.blindingKeyPair.privateKey.toString("hex"),n.scriptPubKey=a.output,n}h(r,e);var n=r.prototype;return n.blindPset=function(){var t=d(x.mark((function t(r,n,i,a){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,a));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,a,o,s=this;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(n=t.Psbt.fromBase64(r),i=[],a=0;a<n.data.inputs.length;a++)(o=n.data.inputs[a]).witnessUtxo?o.witnessUtxo.script.equals(this.scriptPubKey)&&i.push(a):i.push(a);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 A;var o,s=B(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(!S(s))throw new Error("Master public key is not valid");if(!N(t.value.masterBlindingKey))throw new Error("Master blinding key is not valid");return n.masterPublicKeyNode=i.fromBase58(s),n.masterBlindingKeyNode=a.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,a){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,a));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,a,o=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",o.getAddress(n,t));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),a=Array.from({length:r},(function(e,r){return r+t})),e.abrupt("return",Promise.all(a.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,a=this;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],n=x.mark((function e(n){var i,o,s,u,c,p,f;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=1===n,o=0,s=0,u=[],c=function(e){return function(t,r){o++,t&&(o=0,u.push(e[r]))}};case 5:if(!(o<20)){e.next=16;break}return e.next=8,a.generateSetOfAddresses(s,20-o,i);case 8:return p=e.sent,e.next=11,a.checkAddressesWithRestorer(p);case 11:e.sent.forEach(c(p)),s+=20,e.next=5;break;case 16:f=u.map(z),i?a.changeIndex=f.length>0?Math.max.apply(Math,f)+1:r.INITIAL_INDEX:a.index=f.length>0?Math.max.apply(Math,f)+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=[],a=0,o=v(e=e.sort(r));!(n=o()).done;){var s=n.value;if(_(s)||(i.push(s),a+=s.value),a>=t)return{selected:i,changeAmount:a-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,i){var a,o,s;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=ce(t,r,n,i),o=[],e.next=4,a.next();case 4:s=e.sent;case 5:if(s.done){e.next=12;break}return o.push(s.value),e.next=9,a.next();case 9:s=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 ae(e,t,r){return oe.apply(this,arguments)}function oe(){return(oe=c(x.mark((function e(t,r,n){var i,a,o,s;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=0,a=x.mark((function e(){var t,a,o,u,c,f,d,h;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=(t=s.value).confidentialAddress,o=t.blindingPrivateKey,e.next=3,p(re(a,r));case 3:u=e.sent.map((function(e){return n&&n(e)?e:Pe(e,o,r)})),i+=u.length,c=v(u);case 7:if((f=c()).done){e.next=16;break}return d=f.value,e.next=11,p(d);case 11:return h=e.sent,e.next=14,h;case 14:e.next=7;break;case 16:case"end":return e.stop()}}),e)})),o=v(t);case 3:if((s=o()).done){e.next=7;break}return e.delegateYield(a(),"t0",5);case 5:e.next=3;break;case 7:return e.abrupt("return",i);case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function se(e,t,r){return ue.apply(this,arguments)}function ue(){return(ue=d(x.mark((function e(t,r,n){var i,a,o;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=ae(t,r,n),a=[],e.next=4,i.next();case 4:o=e.sent;case 5:if(o.done){e.next=12;break}return a.push(o.value),e.next=9,i.next();case 9:o=e.sent,e.next=5;break;case 12:return e.abrupt("return",a);case 13:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ce(e,t,r,n){return pe.apply(this,arguments)}function pe(){return(pe=c(x.mark((function e(t,r,n,i){var a,o,s,u,c,f;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a=[],o=v(t);case 2:if((s=o()).done){e.next=22;break}return u=fe(s.value,n,i),e.next=7,p(u.next());case 7:c=e.sent;case 8:if(c.done){e.next=20;break}if(!a.includes((f=c.value).txid)){e.next=12;break}return e.abrupt("continue",8);case 12:return a.push(f.txid),e.next=15,le(f,r);case 15:return e.next=17,p(u.next());case 17:c=e.sent,e.next=8;break;case 20:e.next=2;break;case 22:return e.abrupt("return");case 23:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function fe(e,t,r){return de.apply(this,arguments)}function de(){return(de=c(x.mark((function e(t,r,n){var i,a,o,s,u,c,f,d;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i=void 0,a=[],o=0;case 3:return e.next=5,p(me(t,r,i));case 5:if(0!==(a=e.sent).length){e.next=8;break}return e.abrupt("break",24);case 8:i=a[a.length-1].txid,o+=a.length,s=a.map((function(e){return ge(e,r)})),u=v(s);case 12:if((c=u()).done){e.next=23;break}return f=c.value,e.next=16,p(f);case 16:if(d=e.sent,!n||!n(d)){e.next=19;break}return e.abrupt("continue",21);case 19:return e.next=21,d;case 21:e.next=12;break;case 23:if(i){e.next=3;break}case 24:return e.abrupt("return",o);case 25:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function he(e){return k(e)?{blindedAsset:e.asset,blindedValue:e.value,nonce:e.nonce,rangeProof:e.rangeProof,surjectionProof:e.surjectionProof,script:e.script.toString("hex")}:{asset:b(e.asset),value:m(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,a,o,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 a;return x.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(a=r(i.script))){n.next=6;break}return n.next=4,ye(i,a);case 4:t.vin[e].prevout=n.sent;case 6:case"end":return n.stop()}}),n)})));return function(){return n.apply(this,arguments)}}()())},a=0;a<t.vin.length;a++)i(a);for(o=function(e){var i=t.vout[e];J(i)&&n.push(function(){var n=d(x.mark((function n(){var a;return x.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!(a=r(i.script))){n.next=6;break}return n.next=4,ye(i,a);case 4:t.vout[e]=n.sent;case 6:case"end":return n.stop()}}),n)})));return function(){return n.apply(this,arguments)}}()())},s=0;s<t.vout.length;s++)o(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,t){return xe.apply(this,arguments)}function xe(){return(xe=d(x.mark((function e(r,n){var i,a,o,s;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i={asset:r.blindedAsset,value:r.blindedValue,rangeProof:r.rangeProof,surjectionProof:r.surjectionProof,nonce:r.nonce,script:Buffer.from(r.script,"hex")},a=Buffer.from(n,"hex"),e.next=4,t.confidential.unblindOutputWithKey(i,a);case 4:return o=e.sent,s={asset:Buffer.from(o.asset.reverse()).toString("hex"),value:parseInt(o.value,10),script:r.script},e.abrupt("return",s);case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ge(e,t){return be.apply(this,arguments)}function be(){return(be=d(x.mark((function e(r,n){var i,a,o,s,u,c,p,f,d;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(i=[],a=[],o=v(r.vin);!(s=o()).done;)i.push((u=s.value).txid),a.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[a[r]])})),p=i.map((function(e,t){return{prevout:c[t],txid:e,vout:a[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 we.apply(this,arguments)}function we(){return(we=d(x.mark((function e(t,n,i){var a;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=n+"/address/"+t+"/txs/chain",i&&(a+="/"+i),e.next=4,r.get(a);case 4:return e.abrupt("return",e.sent.data);case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Pe(e,t,r){return ke.apply(this,arguments)}function ke(){return(ke=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 a,o,s;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ee(r.txid,i);case 2:return a=t.Transaction.fromHex(e.sent).outs[r.vout],e.next=6,t.confidential.unblindOutputWithKey(a,Buffer.from(n,"hex"));case 6:return o=e.sent,s=Buffer.alloc(32),o.asset.copy(s),e.abrupt("return",{txid:r.txid,vout:r.vout,asset:s.reverse().toString("hex"),value:parseInt(o.value,10),prevout:a,unblindData:o});case 10:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Ie=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,a){return U({psetBase64:e,recipients:t,coinSelector:r,changeAddressByAsset:n,addFee:i,satsPerByte:a,unspents:this.cache.getAll()})},e}();function Ee(){return(Ee=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",Te(e.sent,n));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Te(e,t){return new Ie(new Be(e),M(t))}var Be=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(L(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=A,exports.EsploraIdentityRestorer=g,exports.MasterPublicKey=V,exports.Mnemonic=X,exports.PrivateKey=q,exports.UtxoCache=Be,exports.Wallet=Ie,exports.addToTx=F,exports.buildTx=U,exports.createFeeOutput=C,exports.decodePset=j,exports.estimateTxSize=W,exports.fetchAndUnblindTxs=function(e,t,r,n){return ie.apply(this,arguments)},exports.fetchAndUnblindTxsGenerator=ce,exports.fetchAndUnblindUtxos=se,exports.fetchAndUnblindUtxosGenerator=ae,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=T,exports.getNetwork=M,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:[]},a=$(e=e.filter((function(e){return!_(e)})),"asset"),o=$(t,"asset"),s=0,u=Object.entries(o);s<u.length;s++){var c,p=u[s],f=p[0],d=p[1],h=a[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=_,exports.isConfidentialOutput=k,exports.isValidAmount=function(e){return!(e<=0||!Number.isSafeInteger(e))},exports.isValidExtendedBlindKey=N,exports.isValidXpub=S,exports.psetToUnsignedHex=O,exports.psetToUnsignedTx=function(e){return t.Transaction.fromHex(O(e))},exports.toAssetHash=b,exports.toNumber=m,exports.toOutpoint=L,exports.toXpub=B,exports.tryToUnblindUtxo=Pe,exports.unblindOutput=ye,exports.unblindUtxo=Ke,exports.walletFromAddresses=function(e,t,r){return Ee.apply(this,arguments)},exports.walletFromCoins=Te; | ||
//# sourceMappingURL=ldk.cjs.production.min.js.map |
{ | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"license": "MIT", | ||
@@ -4,0 +4,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
776078
6943