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.0 to 0.1.1

1

dist/index.d.ts

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

export { networks, address } from 'liquidjs-lib';
export * from './identity';

@@ -2,0 +3,0 @@ export * from './identities/mnemonic';

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=e(require("axios")),r=require("liquidjs-lib"),n=require("bip39"),i=require("slip77"),s=require("bip32"),o=e(require("bs58check"));function a(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 u(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var s=e.apply(t,r);function o(e){a(s,n,i,o,u,"next",e)}function u(e){a(s,n,i,o,u,"throw",e)}o(void 0)}))}}function c(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var d,f,p=(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=w(o,r);if(a){if(a===d)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===d)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 d={};function f(){}function p(){}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 g=h.prototype=f.prototype=Object.create(l);function m(e){["next","throw","return"].forEach((function(t){a(e,t,(function(e){return this._invoke(t,e)}))}))}function x(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 d=u.arg,f=d.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){d.value=e,o(d)}),(function(e){return n("throw",e,o,a)}))}a(u.arg)}(i,s,n,o)}))}return n=n?n.then(o,o):o()}}function w(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,w(e,t),"throw"===t.method))return d;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,d;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,d):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}function b(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(b,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 p.prototype=g.constructor=h,h.constructor=p,p.displayName=a(h,o,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"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(g),e},e.awrap=function(e){return{__await:e}},m(x.prototype),x.prototype[s]=function(){return this},e.AsyncIterator=x,e.async=function(t,r,n,i,s){void 0===s&&(s=Promise);var o=new x(u(t,r,n,i),s);return e.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},m(g),a(g,o,"Generator"),g[i]=function(){return this},g.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,d):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),d},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),d}},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),d}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}}(f={exports:{}}),f.exports),h=function e(r){var n=this;this.esploraEndpoint=e.DEFAULT_ESPLORA_ENDPOINT,this.addressesHaveBeenUsed=function(){var e=u(p.mark((function e(r){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t.all(r.map(n.addressHasBeenUsed)));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),this.addressHasBeenUsed=function(){var e=u(p.mark((function e(r){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t.get(n.esploraEndpoint+"/address/"+r+"/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)}}(),r&&(this.esploraEndpoint=r)};h.DEFAULT_ESPLORA_ENDPOINT="https://blockstream.info/liquid/api",(d=exports.IdentityType||(exports.IdentityType={}))[d.PrivateKey=1]="PrivateKey",d[d.Mnemonic=2]="Mnemonic",d[d.MasterPublicKey=3]="MasterPublicKey",d[d.Inject=4]="Inject",d[d.Ledger=5]="Ledger",d[d.Trezor=6]="Trezor";var l=function e(t){if(!t.chain||!r.networks.hasOwnProperty(t.chain))throw new Error("Network is missing or not valid");if(!t.type||!(t.type in exports.IdentityType))throw new Error("Type is missing or not valid");this.network=r.networks[t.chain],this.type=t.type,this.restorer=t.restorer?t.restorer:e.DEFAULT_RESTORER};function v(e){return e.slice(1).reverse().toString("hex")}function y(e){return r.confidential.confidentialValueToSatoshi(e)}function g(e,t){var n={asset:Buffer.alloc(0),value:0};if(!e.rangeProof)throw new Error("The output does not contain rangeProof.");var i=r.confidential.unblindOutput(e.nonce,t,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}l.DEFAULT_RESTORER=new h;var m=Buffer.from("0x00","hex");function x(e){return null!=e&&e.length>0}function w(e){return x(e.rangeProof)&&x(e.surjectionProof)&&e.nonce!==m}var b=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}(),P=new Map([["xpub","0488b21e"],["ypub","049d7cb2"],["Ypub","0295b43f"],["zpub","04b24746"],["Zpub","02aa7ed3"],["tpub","043587cf"],["upub","044a5262"],["Upub","024289ef"],["vpub","045f1cf6"],["Vpub","02575483"]]);function K(e,t){if(!P.has(t))return"Invalid target version";e=e.trim();try{var r=o.decode(e);return r=r.slice(4),r=Buffer.concat([Buffer.from(P.get(t),"hex"),r]),o.encode(r)}catch(e){throw new Error("Invalid extended public key! Please double check that you didn't accidentally paste extra data.")}}function A(e,t){return K(e,"regtest"===t?"vpub":"zpub")}function k(e){return K(e,"xpub")}function I(e,t){try{s.fromBase58(e,t)}catch(e){return!1}return!0}function T(e){try{i.fromMasterBlindingKey(e)}catch(e){return!1}return!0}function E(e){var t=e.derivationPath.split("/");return parseInt(t[t.length-1])}var B=function(e){function t(o){var a;if((a=e.call(this,o)||this).baseDerivationPath=t.INITIAL_BASE_PATH,a.index=t.INITIAL_INDEX,a.changeIndex=t.INITIAL_INDEX,a.scriptToAddressCache=new b,o.type!==exports.IdentityType.Mnemonic)throw new Error("The identity arguments have not the Mnemonic type.");if(!("mnemonic"in o.value))throw new Error("The value of IdentityOpts is not valid for Mnemonic Identity.");if(n.setDefaultWordlist(o.value.language?o.value.language:"english"),!n.validateMnemonic(o.value.mnemonic))throw new Error("Mnemonic is not valid.");var u=n.mnemonicToSeedSync(o.value.mnemonic);a.masterPrivateKeyNode=s.fromSeed(u,a.network);var c=a.masterPrivateKeyNode.derivePath(a.baseDerivationPath),d=r.bip32.fromPublicKey(c.publicKey,c.chainCode,c.network).toBase58();return a.masterPublicKey=A(d,o.chain),a.masterBlindingKeyNode=i.fromSeed(u),a.masterBlindingKey=a.masterBlindingKeyNode.masterKey.toString("hex"),a.isRestored=new Promise((function(){return!0})),o.initializeFromRestorer&&(a.isRestored=a.restore().catch((function(e){throw new Error("Error during restoration step: "+e)}))),a}c(t,e);var o=t.prototype;return o.isAbleToSign=function(){return!0},o.getCurrentDerivationPath=function(e){return this.baseDerivationPath+"/"+(e?1:0)},o.deriveKeyWithIndex=function(e,t){var n=this.masterPrivateKeyNode.derivePath(this.getCurrentDerivationPath(e)).derive(t).toWIF(),i=r.ECPair.fromWIF(n,this.network);return{publicKey:i.publicKey,privateKey:i.privateKey}},o.getBlindingKeyPair=function(e){var t=this.masterBlindingKeyNode.derive(e);return{publicKey:t.publicKey,privateKey:t.privateKey}},o.scriptFromPublicKey=function(e){return r.payments.p2wpkh({pubkey:e,network:this.network}).output},o.createConfidentialAddress=function(e,t){return r.payments.p2wpkh({pubkey:e,blindkey:t,network:this.network}).confidentialAddress},o.persistAddressToCache=function(e){var t=Buffer.from(e.signingPrivateKey,"hex"),n=r.ECPair.fromPrivateKey(t,{network:this.network}).publicKey,i=this.scriptFromPublicKey(n);this.scriptToAddressCache.set(i,e)},o.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")}},o.getNextAddress=function(){var e=this.getAddress(!1,this.index);return this.persistAddressToCache(e),this.index+=1,e.address},o.getNextChangeAddress=function(){var e=this.getAddress(!0,this.changeIndex);return this.persistAddressToCache(e),this.changeIndex+=1,e.address},o.getBlindingPrivateKey=function(e){var t=Buffer.from(e,"hex");return this.getBlindingKeyPair(t).privateKey.toString("hex")},o.signPset=function(){var e=u(p.mark((function e(t){var n,i,s,o,a,u,c;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(n=r.Psbt.fromBase64(t),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=r.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)}}(),o.getAddresses=function(){return this.scriptToAddressCache.values().map((function(e){return e.address}))},o.generateSetOfAddresses=function(){var e=u(p.mark((function e(t,r){var n,i,s=this;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=function(){var e=u(p.mark((function e(t){return p.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)}}(),o.addressToChangeAddressAsync=function(){var e=u(p.mark((function e(t){var r;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=E(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)}}(),o.checkAddressesWithRestorer=function(){var e=u(p.mark((function e(t){var r;return p.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)}}(),o.restoreAddresses=function(){var e=u(p.mark((function e(){var r,n,i,s,o,a,u,c,d,f,h,l=this;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=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<r)){e.next=16;break}return e.next=8,this.generateSetOfAddresses(i,r-n);case 8:return a=e.sent,e.next=11,this.checkAddressesWithRestorer(a);case 11:e.sent.forEach(o(a)),i+=r,e.next=5;break;case 16:return u=s.map(E),this.index=u.length>0?Math.max.apply(Math,u)+1:t.INITIAL_INDEX,e.next=20,Promise.all(s.map((function(e){return l.addressToChangeAddressAsync(e)})));case 20:return c=e.sent,e.next=23,this.checkAddressesWithRestorer(c);case 23:return d=e.sent,f=c.filter((function(e,t){return d[t]})),h=f.map(E),this.changeIndex=h.length>0?Math.max.apply(Math,h)+1:t.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)}}(),o.restore=function(){var e=u(p.mark((function e(){var t=this;return p.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)}}(),t}(l);B.INITIAL_BASE_PATH="m/84'/0'/0'",B.INITIAL_INDEX=0;var S=function(e){function t(t){var n,i;if((n=e.call(this,t)||this).isRestored=new Promise((function(){return!0})),t.type!==exports.IdentityType.PrivateKey)throw new Error("The identity arguments have not the PrivateKey type.");if(!("signingKeyWIF"in(i=t.value))||!("blindingKeyWIF"in i))throw new Error("The value of IdentityOpts is not valid for PrivateKey Identity.");n.signingKeyPair=n.decodeFromWif(t.value.signingKeyWIF),n.blindingKeyPair=n.decodeFromWif(t.value.blindingKeyWIF);var s=r.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}c(t,e);var n=t.prototype;return n.isAbleToSign=function(){return!0},n.decodeFromWif=function(e){return r.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=u(p.mark((function e(t){var n,i,s,o,a=this;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(n=r.Psbt.fromBase64(t),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}]},t}(l);function N(e){var t=e.derivationPath.split("/");return parseInt(t[t.length-1])}var O=function(e){function t(r){var n;(n=e.call(this,r)||this).index=t.INITIAL_INDEX,n.changeIndex=t.INITIAL_INDEX,n.scriptToAddressCache=new b;var o,a=k(r.value.masterPublicKey);if(r.type!==exports.IdentityType.MasterPublicKey)throw new Error("The identity arguments have not the MasterPublicKey type.");if(!("masterPublicKey"in(o=r.value))||!("masterBlindingKey"in o))throw new Error("The value of IdentityOpts is not valid for MasterPublicKey Identity.");if(!I(a))throw new Error("Master public key is not valid");if(!T(r.value.masterBlindingKey))throw new Error("Master blinding key is not valid");return n.masterPublicKeyNode=s.fromBase58(a),n.masterBlindingKeyNode=i.fromMasterBlindingKey(r.value.masterBlindingKey),n.isRestored=new Promise((function(){return!0})),r.initializeFromRestorer&&(n.isRestored=n.restore().catch((function(e){throw new Error("Error during restoration step: "+e)}))),n}c(t,e);var n=t.prototype;return 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 r.payments.p2wpkh({pubkey:e,network:this.network}).output},n.createConfidentialAddress=function(e,t){return r.payments.p2wpkh({pubkey:e,blindkey:t,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=u(p.mark((function e(t,r){var n,i,s=this;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=function(){var e=u(p.mark((function e(t){return p.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=u(p.mark((function e(t){var r;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=N(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=u(p.mark((function e(t){var r;return p.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=u(p.mark((function e(){var r,n,i,s,o,a,u,c,d,f,h,l=this;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=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<r)){e.next=16;break}return e.next=8,this.generateSetOfAddresses(i,r-n);case 8:return a=e.sent,e.next=11,this.checkAddressesWithRestorer(a);case 11:e.sent.forEach(o(a)),i+=r,e.next=5;break;case 16:return u=s.map(N),this.index=u.length>0?Math.max.apply(Math,u)+1:t.INITIAL_INDEX,e.next=20,Promise.all(s.map((function(e){return l.addressToChangeAddressAsync(e)})));case 20:return c=e.sent,e.next=23,this.checkAddressesWithRestorer(c);case 23:return d=e.sent,f=c.filter((function(e,t){return d[t]})),h=f.map(N),this.changeIndex=h.length>0?Math.max.apply(Math,h)+1:t.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=u(p.mark((function e(){var t=this;return p.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)}}(),t}(l);O.INITIAL_INDEX=0;var L=function(){function e(e){var t=this,n=e.addresses,i=e.network;this.addresses=[],this.blindingPrivateKeyByScript={},this.network=i,this.addresses=n,n.forEach((function(e){var n=r.address.toOutputScript(e.confidentialAddress,i).toString("hex");t.blindingPrivateKeyByScript[n]=Buffer.from(e.blindingPrivateKey,"hex")}))}var t=e.prototype;return t.createTx=function(){return new r.Psbt({network:this.network}).toBase64()},t.buildTx=function(e,t,n,i,s,o){var a=this,u=C(e),c=[],d=[],f=2e3;if(s===this.network.assetHash){f+=i;var p=r.address.toOutputScript(n,this.network).toString("hex");u.addOutput({script:p,value:r.confidential.satoshiToConfidentialValue(i),asset:this.network.assetHash,nonce:Buffer.from("00","hex")}),d.push(r.address.fromConfidential(n).blindingKey)}else{var h=$(t,i,s,this.blindingPrivateKeyByScript),l=h.change;h.selectedUnspents.forEach((function(e){u.addInput({hash:e.txid,index:e.vout,witnessUtxo:e.prevout});var t=e.prevout.script.toString("hex");c.push(a.blindingPrivateKeyByScript[t])}));var v=r.address.toOutputScript(n,this.network).toString("hex");if(u.addOutput({script:v,value:r.confidential.satoshiToConfidentialValue(i),asset:s,nonce:Buffer.from("00","hex")}),d.push(r.address.fromConfidential(n).blindingKey),l>0){var y=r.address.toOutputScript(o,this.network).toString("hex");u.addOutput({script:y,value:r.confidential.satoshiToConfidentialValue(l),asset:s,nonce:Buffer.from("00","hex")}),d.push(r.address.fromConfidential(o).blindingKey)}}var g=$(t,f,this.network.assetHash,this.blindingPrivateKeyByScript),m=g.change;if(g.selectedUnspents.forEach((function(e){u.addInput({hash:e.txid,index:e.vout,witnessUtxo:e.prevout});var t=e.prevout.script.toString("hex");c.push(a.blindingPrivateKeyByScript[t])})),m>0){var x=r.address.toOutputScript(o,this.network).toString("hex");u.addOutput({script:x,value:r.confidential.satoshiToConfidentialValue(m),asset:this.network.assetHash,nonce:Buffer.from("00","hex")}),d.push(r.address.fromConfidential(o).blindingKey)}return u.addOutput({script:Buffer.alloc(0),value:r.confidential.satoshiToConfidentialValue(2e3),asset:this.network.assetHash,nonce:Buffer.from("00","hex")}),u.blindOutputs(c,d),u.toBase64()},t.updateTx=function(e,t,n,i,s,o,a,u){var c=this,d=C(e),f=$(t,n,s,this.blindingPrivateKeyByScript),p=f.change,h={},l={};f.selectedUnspents.forEach((function(e){d.addInput({hash:e.txid,index:e.vout,witnessUtxo:e.prevout});var t=e.prevout.script.toString("hex");h[t]=c.blindingPrivateKeyByScript[t]}));var v=r.address.toOutputScript(a.confidentialAddress,this.network).toString("hex");if(d.addOutput({script:v,value:r.confidential.satoshiToConfidentialValue(i),asset:o,nonce:Buffer.from("00","hex")}),l[v]=Buffer.from(a.blindingPrivateKey,"hex"),p>0){var y=r.address.toOutputScript(u.confidentialAddress,this.network).toString("hex");d.addOutput({script:y,value:r.confidential.satoshiToConfidentialValue(p),asset:s,nonce:Buffer.from("00","hex")}),l[y]=Buffer.from(u.blindingPrivateKey,"hex")}return{psetBase64:d.toBase64(),inputBlindingKeys:h,outputBlindingKeys:l}},e.toHex=function(e){var t;try{t=r.Psbt.fromBase64(e)}catch(e){throw new Error("Invalid pset")}return t.validateSignaturesOfAllInputs(),t.finalizeAllInputs(),t.extractTransaction().toHex()},e}();function C(e){var t;try{t=r.Psbt.fromBase64(e)}catch(e){throw new Error("Invalid pset")}return t}function _(e,t){return M.apply(this,arguments)}function M(){return(M=u(p.mark((function e(r,n){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.get(n+"/tx/"+r+"/hex");case 2:return e.abrupt("return",e.sent.data);case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function F(e,t){return U.apply(this,arguments)}function U(){return(U=u(p.mark((function e(r,n){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.get(n+"/address/"+r+"/utxo");case 2:return e.abrupt("return",e.sent.data);case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function R(e,t,r){return D.apply(this,arguments)}function D(){return(D=u(p.mark((function e(t,n,i){var s,o,a;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,F(t,i);case 2:return s=e.sent,e.next=5,Promise.all(s.map((function(e){return _(e.txid,i)})));case 5:return o=e.sent,a=s.map((function(e,t){var i=r.Transaction.fromHex(String(o[t])).outs[e.vout],s=r.confidential.unblindOutput(i.nonce,Buffer.from(n,"hex"),i.rangeProof,i.value,i.asset,i.script);return{txid:e.txid,vout:e.vout,asset:s.asset.reverse().toString("hex"),value:parseInt(s.value,10),prevout:i}})),e.abrupt("return",a);case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function H(){return(H=u(p.mark((function e(t,r,n){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,R(t,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 W(e){return"surjectionProof"in e&&"rangeProof"in e}function j(){return(j=u(p.mark((function e(t,r,n){var i;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,V(t,n);case 2:return i=e.sent.map((function(e){return Y(e,r)})),e.abrupt("return",i);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function V(e,t){return X.apply(this,arguments)}function X(){return(X=u(p.mark((function e(t,r){var n,i,s;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=[],i=void 0;case 2:return e.next=4,J(t,r,i);case 4:n.push.apply(n,s=e.sent),25===s.length&&(i=s[24].txid);case 7:if(null!=i){e.next=2;break}case 8:return e.abrupt("return",Promise.all(n.map((function(e){return q(e,r)}))));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function q(e,t){return G.apply(this,arguments)}function G(){return(G=u(p.mark((function e(t,n){var i,s,o,a,u,c,d;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=t.vin.map((function(e){return e.txid})),s=t.vin.map((function(e){return e.vout})),e.next=4,Promise.all(i.map((function(e){return _(e,n)})));case 4:return o=e.sent.map((function(e,t){return r.Transaction.fromHex(e).outs[s[t]]})),a=o.map(z),u=i.map((function(e,t){return{prevout:a[t],txid:e,vout:s[t]}})),e.next=10,_(t.txid,n);case 10:return c=r.Transaction.fromHex(e.sent),d=c.outs.map(z),e.abrupt("return",{txid:t.txid,vin:u,vout:d,fee:t.fee,status:{confirmed:t.status.confirmed,blockHash:t.status.block_hash,blockHeight:t.status.block_height,blockTime:t.status.block_time}});case 15:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function z(e){return w(e)?{blindedAsset:e.asset,blindedValue:e.value,nonce:e.nonce,rangeProof:e.rangeProof,surjectionProof:e.surjectionProof,script:e.script.toString("hex")}:{asset:v(e.asset),value:y(e.value),script:e.script.toString("hex")}}function Y(e,t){for(var r=0;r<e.vin.length;r++){var n=e.vin[r].prevout;if(W(n))for(var i=0;i<t.length;i++)try{var s=Z(n,t[i]);e.vin[r].prevout=s;break}catch(e){continue}}for(var o=0;o<e.vout.length;o++){var a=e.vout[o];if(W(a))for(var u=0;u<t.length;u++)try{var c=Z(a,t[u]);e.vout[o]=c;break}catch(e){continue}}return e}function Z(e,t){var n=Buffer.from(t,"hex"),i=r.confidential.unblindOutput(e.nonce,n,e.rangeProof,e.blindedValue,e.blindedAsset,Buffer.from(e.script,"hex"));return{asset:i.asset.reverse().toString("hex"),value:parseInt(i.value,10),script:e.script}}function J(e,t,r){return Q.apply(this,arguments)}function Q(){return(Q=u(p.mark((function e(r,n,i){var s;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=n+"/address/"+r+"/txs/chain",i&&(s+="/"+i),e.next=4,t.get(s);case 4:return e.abrupt("return",e.sent.data);case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function $(e,t,n,i){for(var s=[],o=0,a=0;a<e.length;a++){var u=e[a];try{if(w(u.prevout)){var c=g(u.prevout,i[u.prevout.script.toString("hex")]),d=c.value;if(v(c.asset)!==n)continue;if(s.push(u),(o+=d)>=t)break;continue}}catch(e){continue}if(v(u.prevout.asset)===n&&(s.push(u),(o+=r.confidential.confidentialValueToSatoshi(u.prevout.value))>=t))break}if(o<t)throw new Error("You do not have enough in your wallet");return{selectedUnspents:s,change:o-t}}exports.BufferMap=b,exports.EsploraIdentityRestorer=h,exports.MasterPublicKey=O,exports.Mnemonic=B,exports.PrivateKey=S,exports.Wallet=L,exports.coinselect=$,exports.fetchAndUnblindTxs=function(e,t,r){return j.apply(this,arguments)},exports.fetchAndUnblindUtxos=R,exports.fetchBalances=function(e,t,r){return H.apply(this,arguments)},exports.fetchTxHex=_,exports.fetchUtxos=F,exports.fromAssetHash=function(e){return Buffer.concat([Buffer.from("01","hex"),Buffer.from(e,"hex").reverse()])},exports.fromXpub=A,exports.isBlindedOutputInterface=W,exports.isConfidentialOutput=w,exports.isValidAmount=function(e){return!(e<=0||!Number.isSafeInteger(e))},exports.isValidExtendedBlindKey=T,exports.isValidXpub=I,exports.toAssetHash=v,exports.toNumber=y,exports.toXpub=k,exports.unblindOutput=g,exports.walletFromAddresses=function(e,t){var n=t?r.networks[t]:r.networks.liquid;try{return new L({addresses:e,network:n})}catch(e){throw new Error("fromAddress: Invalid addresses list or network")}};
"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=require("bip39"),i=require("slip77"),s=require("bip32"),o=e(require("bs58check"));function a(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 u(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var s=e.apply(t,r);function o(e){a(s,n,i,o,u,"next",e)}function u(e){a(s,n,i,o,u,"throw",e)}o(void 0)}))}}function c(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var d,f,p=(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===d)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===d)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 d={};function f(){}function p(){}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 g=h.prototype=f.prototype=Object.create(l);function m(e){["next","throw","return"].forEach((function(t){a(e,t,(function(e){return this._invoke(t,e)}))}))}function x(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 d=u.arg,f=d.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){d.value=e,o(d)}),(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 d;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,d;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,d):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}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 p.prototype=g.constructor=h,h.constructor=p,p.displayName=a(h,o,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"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(g),e},e.awrap=function(e){return{__await:e}},m(x.prototype),x.prototype[s]=function(){return this},e.AsyncIterator=x,e.async=function(t,r,n,i,s){void 0===s&&(s=Promise);var o=new x(u(t,r,n,i),s);return e.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},m(g),a(g,o,"Generator"),g[i]=function(){return this},g.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,d):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),d},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),d}},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),d}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}}(f={exports:{}}),f.exports),h=function e(t){var n=this;this.esploraEndpoint=e.DEFAULT_ESPLORA_ENDPOINT,this.addressesHaveBeenUsed=function(){var e=u(p.mark((function e(t){return p.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=u(p.mark((function e(t){return p.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)};h.DEFAULT_ESPLORA_ENDPOINT="https://blockstream.info/liquid/api",(d=exports.IdentityType||(exports.IdentityType={}))[d.PrivateKey=1]="PrivateKey",d[d.Mnemonic=2]="Mnemonic",d[d.MasterPublicKey=3]="MasterPublicKey",d[d.Inject=4]="Inject",d[d.Ledger=5]="Ledger",d[d.Trezor=6]="Trezor";var l=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};function v(e){return e.slice(1).reverse().toString("hex")}function y(e){return t.confidential.confidentialValueToSatoshi(e)}function g(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}l.DEFAULT_RESTORER=new h;var m=Buffer.from("0x00","hex");function x(e){return null!=e&&e.length>0}function b(e){return x(e.rangeProof)&&x(e.surjectionProof)&&e.nonce!==m}var w=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}(),P=new Map([["xpub","0488b21e"],["ypub","049d7cb2"],["Ypub","0295b43f"],["zpub","04b24746"],["Zpub","02aa7ed3"],["tpub","043587cf"],["upub","044a5262"],["Upub","024289ef"],["vpub","045f1cf6"],["Vpub","02575483"]]);function K(e,t){if(!P.has(t))return"Invalid target version";e=e.trim();try{var r=o.decode(e);return r=r.slice(4),r=Buffer.concat([Buffer.from(P.get(t),"hex"),r]),o.encode(r)}catch(e){throw new Error("Invalid extended public key! Please double check that you didn't accidentally paste extra data.")}}function A(e,t){return K(e,"regtest"===t?"vpub":"zpub")}function k(e){return K(e,"xpub")}function I(e,t){try{s.fromBase58(e,t)}catch(e){return!1}return!0}function T(e){try{i.fromMasterBlindingKey(e)}catch(e){return!1}return!0}function E(e){var t=e.derivationPath.split("/");return parseInt(t[t.length-1])}var B=function(e){function r(o){var a;if((a=e.call(this,o)||this).baseDerivationPath=r.INITIAL_BASE_PATH,a.index=r.INITIAL_INDEX,a.changeIndex=r.INITIAL_INDEX,a.scriptToAddressCache=new w,o.type!==exports.IdentityType.Mnemonic)throw new Error("The identity arguments have not the Mnemonic type.");if(!("mnemonic"in o.value))throw new Error("The value of IdentityOpts is not valid for Mnemonic Identity.");if(n.setDefaultWordlist(o.value.language?o.value.language:"english"),!n.validateMnemonic(o.value.mnemonic))throw new Error("Mnemonic is not valid.");var u=n.mnemonicToSeedSync(o.value.mnemonic);a.masterPrivateKeyNode=s.fromSeed(u,a.network);var c=a.masterPrivateKeyNode.derivePath(a.baseDerivationPath),d=t.bip32.fromPublicKey(c.publicKey,c.chainCode,c.network).toBase58();return a.masterPublicKey=A(d,o.chain),a.masterBlindingKeyNode=i.fromSeed(u),a.masterBlindingKey=a.masterBlindingKeyNode.masterKey.toString("hex"),a.isRestored=new Promise((function(){return!0})),o.initializeFromRestorer&&(a.isRestored=a.restore().catch((function(e){throw new Error("Error during restoration step: "+e)}))),a}c(r,e);var o=r.prototype;return o.isAbleToSign=function(){return!0},o.getCurrentDerivationPath=function(e){return this.baseDerivationPath+"/"+(e?1:0)},o.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}},o.getBlindingKeyPair=function(e){var t=this.masterBlindingKeyNode.derive(e);return{publicKey:t.publicKey,privateKey:t.privateKey}},o.scriptFromPublicKey=function(e){return t.payments.p2wpkh({pubkey:e,network:this.network}).output},o.createConfidentialAddress=function(e,r){return t.payments.p2wpkh({pubkey:e,blindkey:r,network:this.network}).confidentialAddress},o.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)},o.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")}},o.getNextAddress=function(){var e=this.getAddress(!1,this.index);return this.persistAddressToCache(e),this.index+=1,e.address},o.getNextChangeAddress=function(){var e=this.getAddress(!0,this.changeIndex);return this.persistAddressToCache(e),this.changeIndex+=1,e.address},o.getBlindingPrivateKey=function(e){var t=Buffer.from(e,"hex");return this.getBlindingKeyPair(t).privateKey.toString("hex")},o.signPset=function(){var e=u(p.mark((function e(r){var n,i,s,o,a,u,c;return p.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)}}(),o.getAddresses=function(){return this.scriptToAddressCache.values().map((function(e){return e.address}))},o.generateSetOfAddresses=function(){var e=u(p.mark((function e(t,r){var n,i,s=this;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=function(){var e=u(p.mark((function e(t){return p.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)}}(),o.addressToChangeAddressAsync=function(){var e=u(p.mark((function e(t){var r;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=E(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)}}(),o.checkAddressesWithRestorer=function(){var e=u(p.mark((function e(t){var r;return p.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)}}(),o.restoreAddresses=function(){var e=u(p.mark((function e(){var t,n,i,s,o,a,u,c,d,f,h,l=this;return p.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(E),this.index=u.length>0?Math.max.apply(Math,u)+1:r.INITIAL_INDEX,e.next=20,Promise.all(s.map((function(e){return l.addressToChangeAddressAsync(e)})));case 20:return c=e.sent,e.next=23,this.checkAddressesWithRestorer(c);case 23:return d=e.sent,f=c.filter((function(e,t){return d[t]})),h=f.map(E),this.changeIndex=h.length>0?Math.max.apply(Math,h)+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)}}(),o.restore=function(){var e=u(p.mark((function e(){var t=this;return p.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}(l);B.INITIAL_BASE_PATH="m/84'/0'/0'",B.INITIAL_INDEX=0;var S=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}c(r,e);var n=r.prototype;return 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=u(p.mark((function e(r){var n,i,s,o,a=this;return p.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}(l);function N(e){var t=e.derivationPath.split("/");return parseInt(t[t.length-1])}var O=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 w;var o,a=k(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(!I(a))throw new Error("Master public key is not valid");if(!T(t.value.masterBlindingKey))throw new Error("Master blinding key is not valid");return n.masterPublicKeyNode=s.fromBase58(a),n.masterBlindingKeyNode=i.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}c(r,e);var n=r.prototype;return 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=u(p.mark((function e(t,r){var n,i,s=this;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=function(){var e=u(p.mark((function e(t){return p.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=u(p.mark((function e(t){var r;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=N(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=u(p.mark((function e(t){var r;return p.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=u(p.mark((function e(){var t,n,i,s,o,a,u,c,d,f,h,l=this;return p.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(N),this.index=u.length>0?Math.max.apply(Math,u)+1:r.INITIAL_INDEX,e.next=20,Promise.all(s.map((function(e){return l.addressToChangeAddressAsync(e)})));case 20:return c=e.sent,e.next=23,this.checkAddressesWithRestorer(c);case 23:return d=e.sent,f=c.filter((function(e,t){return d[t]})),h=f.map(N),this.changeIndex=h.length>0?Math.max.apply(Math,h)+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=u(p.mark((function e(){var t=this;return p.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}(l);O.INITIAL_INDEX=0;var L=function(){function e(e){var r=this,n=e.addresses,i=e.network;this.addresses=[],this.blindingPrivateKeyByScript={},this.network=i,this.addresses=n,n.forEach((function(e){var n=t.address.toOutputScript(e.confidentialAddress,i).toString("hex");r.blindingPrivateKeyByScript[n]=Buffer.from(e.blindingPrivateKey,"hex")}))}var r=e.prototype;return r.createTx=function(){return new t.Psbt({network:this.network}).toBase64()},r.buildTx=function(e,r,n,i,s,o){var a=this,u=C(e),c=[],d=[],f=2e3;if(s===this.network.assetHash){f+=i;var p=t.address.toOutputScript(n,this.network).toString("hex");u.addOutput({script:p,value:t.confidential.satoshiToConfidentialValue(i),asset:this.network.assetHash,nonce:Buffer.from("00","hex")}),d.push(t.address.fromConfidential(n).blindingKey)}else{var h=$(r,i,s,this.blindingPrivateKeyByScript),l=h.change;h.selectedUnspents.forEach((function(e){u.addInput({hash:e.txid,index:e.vout,witnessUtxo:e.prevout});var t=e.prevout.script.toString("hex");c.push(a.blindingPrivateKeyByScript[t])}));var v=t.address.toOutputScript(n,this.network).toString("hex");if(u.addOutput({script:v,value:t.confidential.satoshiToConfidentialValue(i),asset:s,nonce:Buffer.from("00","hex")}),d.push(t.address.fromConfidential(n).blindingKey),l>0){var y=t.address.toOutputScript(o,this.network).toString("hex");u.addOutput({script:y,value:t.confidential.satoshiToConfidentialValue(l),asset:s,nonce:Buffer.from("00","hex")}),d.push(t.address.fromConfidential(o).blindingKey)}}var g=$(r,f,this.network.assetHash,this.blindingPrivateKeyByScript),m=g.change;if(g.selectedUnspents.forEach((function(e){u.addInput({hash:e.txid,index:e.vout,witnessUtxo:e.prevout});var t=e.prevout.script.toString("hex");c.push(a.blindingPrivateKeyByScript[t])})),m>0){var x=t.address.toOutputScript(o,this.network).toString("hex");u.addOutput({script:x,value:t.confidential.satoshiToConfidentialValue(m),asset:this.network.assetHash,nonce:Buffer.from("00","hex")}),d.push(t.address.fromConfidential(o).blindingKey)}return u.addOutput({script:Buffer.alloc(0),value:t.confidential.satoshiToConfidentialValue(2e3),asset:this.network.assetHash,nonce:Buffer.from("00","hex")}),u.blindOutputs(c,d),u.toBase64()},r.updateTx=function(e,r,n,i,s,o,a,u){var c=this,d=C(e),f=$(r,n,s,this.blindingPrivateKeyByScript),p=f.change,h={},l={};f.selectedUnspents.forEach((function(e){d.addInput({hash:e.txid,index:e.vout,witnessUtxo:e.prevout});var t=e.prevout.script.toString("hex");h[t]=c.blindingPrivateKeyByScript[t]}));var v=t.address.toOutputScript(a.confidentialAddress,this.network).toString("hex");if(d.addOutput({script:v,value:t.confidential.satoshiToConfidentialValue(i),asset:o,nonce:Buffer.from("00","hex")}),l[v]=Buffer.from(a.blindingPrivateKey,"hex"),p>0){var y=t.address.toOutputScript(u.confidentialAddress,this.network).toString("hex");d.addOutput({script:y,value:t.confidential.satoshiToConfidentialValue(p),asset:s,nonce:Buffer.from("00","hex")}),l[y]=Buffer.from(u.blindingPrivateKey,"hex")}return{psetBase64:d.toBase64(),inputBlindingKeys:h,outputBlindingKeys:l}},e.toHex=function(e){var r;try{r=t.Psbt.fromBase64(e)}catch(e){throw new Error("Invalid pset")}return r.validateSignaturesOfAllInputs(),r.finalizeAllInputs(),r.extractTransaction().toHex()},e}();function C(e){var r;try{r=t.Psbt.fromBase64(e)}catch(e){throw new Error("Invalid pset")}return r}function _(e,t){return M.apply(this,arguments)}function M(){return(M=u(p.mark((function e(t,n){return p.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 F(e,t){return U.apply(this,arguments)}function U(){return(U=u(p.mark((function e(t,n){return p.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 R(e,t,r){return j.apply(this,arguments)}function j(){return(j=u(p.mark((function e(r,n,i){var s,o,a;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,F(r,i);case 2:return s=e.sent,e.next=5,Promise.all(s.map((function(e){return _(e.txid,i)})));case 5:return o=e.sent,a=s.map((function(e,r){var i=t.Transaction.fromHex(String(o[r])).outs[e.vout],s=t.confidential.unblindOutput(i.nonce,Buffer.from(n,"hex"),i.rangeProof,i.value,i.asset,i.script);return{txid:e.txid,vout:e.vout,asset:s.asset.reverse().toString("hex"),value:parseInt(s.value,10),prevout:i}})),e.abrupt("return",a);case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function D(){return(D=u(p.mark((function e(t,r,n){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,R(t,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 H(e){return"surjectionProof"in e&&"rangeProof"in e}function W(){return(W=u(p.mark((function e(t,r,n){var i;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,V(t,n);case 2:return i=e.sent.map((function(e){return Y(e,r)})),e.abrupt("return",i);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function V(e,t){return X.apply(this,arguments)}function X(){return(X=u(p.mark((function e(t,r){var n,i,s;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=[],i=void 0;case 2:return e.next=4,J(t,r,i);case 4:n.push.apply(n,s=e.sent),25===s.length&&(i=s[24].txid);case 7:if(null!=i){e.next=2;break}case 8:return e.abrupt("return",Promise.all(n.map((function(e){return q(e,r)}))));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function q(e,t){return G.apply(this,arguments)}function G(){return(G=u(p.mark((function e(r,n){var i,s,o,a,u,c,d;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=r.vin.map((function(e){return e.txid})),s=r.vin.map((function(e){return e.vout})),e.next=4,Promise.all(i.map((function(e){return _(e,n)})));case 4:return o=e.sent.map((function(e,r){return t.Transaction.fromHex(e).outs[s[r]]})),a=o.map(z),u=i.map((function(e,t){return{prevout:a[t],txid:e,vout:s[t]}})),e.next=10,_(r.txid,n);case 10:return c=t.Transaction.fromHex(e.sent),d=c.outs.map(z),e.abrupt("return",{txid:r.txid,vin:u,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 z(e){return b(e)?{blindedAsset:e.asset,blindedValue:e.value,nonce:e.nonce,rangeProof:e.rangeProof,surjectionProof:e.surjectionProof,script:e.script.toString("hex")}:{asset:v(e.asset),value:y(e.value),script:e.script.toString("hex")}}function Y(e,t){for(var r=0;r<e.vin.length;r++){var n=e.vin[r].prevout;if(H(n))for(var i=0;i<t.length;i++)try{var s=Z(n,t[i]);e.vin[r].prevout=s;break}catch(e){continue}}for(var o=0;o<e.vout.length;o++){var a=e.vout[o];if(H(a))for(var u=0;u<t.length;u++)try{var c=Z(a,t[u]);e.vout[o]=c;break}catch(e){continue}}return e}function Z(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:i.asset.reverse().toString("hex"),value:parseInt(i.value,10),script:e.script}}function J(e,t,r){return Q.apply(this,arguments)}function Q(){return(Q=u(p.mark((function e(t,n,i){var s;return p.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 $(e,r,n,i){for(var s=[],o=0,a=0;a<e.length;a++){var u=e[a];try{if(b(u.prevout)){var c=g(u.prevout,i[u.prevout.script.toString("hex")]),d=c.value;if(v(c.asset)!==n)continue;if(s.push(u),(o+=d)>=r)break;continue}}catch(e){continue}if(v(u.prevout.asset)===n&&(s.push(u),(o+=t.confidential.confidentialValueToSatoshi(u.prevout.value))>=r))break}if(o<r)throw new Error("You do not have enough in your wallet");return{selectedUnspents:s,change:o-r}}Object.defineProperty(exports,"address",{enumerable:!0,get:function(){return t.address}}),Object.defineProperty(exports,"networks",{enumerable:!0,get:function(){return t.networks}}),exports.BufferMap=w,exports.EsploraIdentityRestorer=h,exports.MasterPublicKey=O,exports.Mnemonic=B,exports.PrivateKey=S,exports.Wallet=L,exports.coinselect=$,exports.fetchAndUnblindTxs=function(e,t,r){return W.apply(this,arguments)},exports.fetchAndUnblindUtxos=R,exports.fetchBalances=function(e,t,r){return D.apply(this,arguments)},exports.fetchTxHex=_,exports.fetchUtxos=F,exports.fromAssetHash=function(e){return Buffer.concat([Buffer.from("01","hex"),Buffer.from(e,"hex").reverse()])},exports.fromXpub=A,exports.isBlindedOutputInterface=H,exports.isConfidentialOutput=b,exports.isValidAmount=function(e){return!(e<=0||!Number.isSafeInteger(e))},exports.isValidExtendedBlindKey=T,exports.isValidXpub=I,exports.toAssetHash=v,exports.toNumber=y,exports.toXpub=k,exports.unblindOutput=g,exports.walletFromAddresses=function(e,r){var n=r?t.networks[r]:t.networks.liquid;try{return new L({addresses:e,network:n})}catch(e){throw new Error("fromAddress: Invalid addresses list or network")}};
//# sourceMappingURL=ldk.cjs.production.min.js.map
{
"version": "0.1.0",
"version": "0.1.1",
"license": "MIT",

@@ -7,4 +7,3 @@ "main": "dist/index.js",

"files": [
"dist",
"src"
"dist"
],

@@ -39,3 +38,19 @@ "engines": {

"name": "ldk",
"author": "Marco Argentieri",
"contributors": [
{
"name": "Marco Argentieri",
"email": "marco@vulpem.com",
"url": "https://vulpem.com"
},
{
"name": "Pietralberto Mazza",
"email": "pietro@vulpem.com",
"url": "https://vulpem.com"
},
{
"name": "Louis Singer",
"email": "louis@vulpem.com",
"url": "https://vulpem.com"
}
],
"module": "dist/ldk.esm.js",

@@ -42,0 +57,0 @@ "size-limit": [

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