/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/react-native-electrum@1.0.0-5/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
import nodejs from"nodejs-mobile-react-native";this.getAddressBalance={},this.getMempool={},this.listUnspentAddress={},this.getFeeEstimate={},this.getAddressHistory={},this.getTransactionHex={},this.getDonationAddress={},this.disconnectFromPeer={},this.getAvailablePeers={},this.getPeers={},this.getNewBlockHeightSubscribe={},this.getTransactionMerkle={},this.getAddressUtxo={},this.broadcastTransaction={},this.getBlockChunk={},this.getBlockHeader={},this.getAddressProof={};export default class ElectrumUtils{constructor(){nodejs.start("main.js")}addElectrumListener=()=>{try{this.listenerRef=e=>{try{(e=JSON.parse(e)).method}catch(e){JSON.stringify(e)}},nodejs.channel.addListener("message",this.listenerRef,this)}catch(e){console.log(e)}};removeElectrumListener=()=>{try{this.listenerRef&&nodejs.channel.removeListener("message",this.listenerRef)}catch(e){console.log(e)}};getAddressBalance=({address:e="",id:s=Math.random()})=>new Promise((async t=>{try{this.getAddressBalance[s]=e=>{"getAddressBalance"===(e=JSON.parse(e)).method&&e.id===s&&(nodejs.channel.removeListener("message",this.getAddressBalance[s]),t(e))},await nodejs.channel.addListener("message",this.getAddressBalance[s],this),nodejs.channel.send(JSON.stringify({method:"getAddressBalance",address:e,id:s}))}catch(e){t({error:!0,errorTitle:"",errorMsg:"",data:e})}}));getMempool=({address:e="",id:s=Math.random()})=>new Promise((async t=>{try{this.getMempool=e=>{"getMempool"===(e=JSON.parse(e)).method&&e.id===s&&(nodejs.channel.removeListener("message",this.getMempool),t(e))},await nodejs.channel.addListener("message",this.getMempool,this),nodejs.channel.send(JSON.stringify({method:"getMempool",address:e,id:s}))}catch(e){t({error:!0,errorTitle:"",errorMsg:"",data:e})}}));listUnspentAddress=({address:e="",id:s=Math.random()})=>new Promise((async t=>{try{this.listUnspentAddress[s]=e=>{"listUnspentAddress"===(e=JSON.parse(e)).method&&e.id===s&&(nodejs.channel.removeListener("message",this.listUnspentAddress[s]),t(e))},await nodejs.channel.addListener("message",this.listUnspentAddress[s],this),nodejs.channel.send(JSON.stringify({method:"listUnspentAddress",address:e,id:s}))}catch(e){t({error:!0,errorTitle:"",errorMsg:"",data:e})}}));getFeeEstimate=({blocksWillingToWait:e=8,id:s=Math.random()})=>new Promise((async t=>{try{this.getFeeEstimate=e=>{"getFeeEstimate"===(e=JSON.parse(e)).method&&(nodejs.channel.removeListener("message",this.getFeeEstimate),t(e))},await nodejs.channel.addListener("message",this.getFeeEstimate,this),nodejs.channel.send(JSON.stringify({id:s,method:"getFeeEstimate",blocksWillingToWait:e}))}catch(e){t({id:s,error:!0,errorTitle:"",errorMsg:"",data:e})}}));getAddressHistory=({address:e="",id:s=Math.random()})=>new Promise((async t=>{try{this.getAddressHistory[s]=e=>{"getAddressHistory"===(e=JSON.parse(e)).method&&e.id===s&&(nodejs.channel.removeListener("message",this.getAddressHistory[s]),t(e))},await nodejs.channel.addListener("message",this.getAddressHistory[s],this),nodejs.channel.send(JSON.stringify({method:"getAddressHistory",address:e,id:s}))}catch(e){t({id:s,error:!0,errorTitle:"",errorMsg:"",data:e})}}));getTransactionHex=({txId:e="",id:s=Math.random()})=>new Promise((async t=>{try{this.getTransactionHex[s]=e=>{"getTransactionHex"===(e=JSON.parse(e)).method&&e.id===s&&(nodejs.channel.removeListener("message",this.getTransactionHex[s]),t(e))},await nodejs.channel.addListener("message",this.getTransactionHex[s],this),nodejs.channel.send(JSON.stringify({method:"getTransactionHex",txId:e,id:s}))}catch(e){t({id:s,error:!0,errorTitle:"",errorMsg:"",data:e})}}));getDonationAddress=({id:e=Math.random()})=>new Promise((async s=>{try{this.getDonationAddress[e]=t=>{"getDonationAddress"===(t=JSON.parse(t)).method&&t.id===e&&(nodejs.channel.removeListener("message",this.getDonationAddress[e]),s(t))},await nodejs.channel.addListener("message",this.getDonationAddress[e],this),nodejs.channel.send(JSON.stringify({method:"getDonationAddress",id:e}))}catch(t){s({id:e,error:!0,errorTitle:"",errorMsg:"",data:t})}}));disconnectFromPeer=({id:e=Math.random()})=>new Promise((async s=>{try{this.disconnectFromPeer[e]=t=>{"disconnectFromPeer"===(t=JSON.parse(t)).method&&t.id===e&&(nodejs.channel.removeListener("message",this.disconnectFromPeer[e]),s(t))},await nodejs.channel.addListener("message",this.disconnectFromPeer[e],this),nodejs.channel.send(JSON.stringify({method:"disconnectFromPeer",id:e}))}catch(t){s({id:e,error:!0,errorTitle:"",errorMsg:"",data:t})}}));getPeers=({id:e=Math.random()})=>new Promise((async s=>{try{this.getPeers[e]=t=>{"getPeers"===(t=JSON.parse(t)).method&&t.id===e&&(nodejs.channel.removeListener("message",this.getPeers[e]),s(t))},await nodejs.channel.addListener("message",this.getPeers[e],this),nodejs.channel.send(JSON.stringify({method:"getPeers",id:e}))}catch(t){s({id:e,error:!0,errorTitle:"",errorMsg:"",data:t})}}));getAvailablePeers=({id:e=Math.random()})=>new Promise((async s=>{try{this.getAvailablePeers[e]=t=>{"getAvailablePeers"===(t=JSON.parse(t)).method&&t.id===e&&(nodejs.channel.removeListener("message",this.getAvailablePeers[e]),s(t))},await nodejs.channel.addListener("message",this.getAvailablePeers[e],this),nodejs.channel.send(JSON.stringify({method:"getAvailablePeers",id:e}))}catch(t){s({id:e,error:!0,errorTitle:"",errorMsg:"",data:t})}}));getNewBlockHeightSubscribe=()=>new Promise((async e=>{try{this.getNewBlockHeightSubscribe=s=>{"getNewBlockHeightSubscribe"===(s=JSON.parse(s)).method&&(alert(JSON.stringify(s)),e({...s,message:"Successfully subscribed to receive new block heights."}))},await nodejs.channel.addListener("message",this.getNewBlockHeightSubscribe,this),nodejs.channel.send(JSON.stringify({method:"getNewBlockHeightSubscribe"}))}catch(s){e({error:!0,errorTitle:"",errorMsg:"",data:s})}}));getTransactionMerkle=({id:e=Math.random(),txHash:s="",height:t=""})=>new Promise((async r=>{try{this.getTransactionMerkle[e]=s=>{"getTransactionMerkle"===(s=JSON.parse(s)).method&&s.id===e&&(nodejs.channel.removeListener("message",this.getTransactionMerkle[e]),r(s))},await nodejs.channel.addListener("message",this.getTransactionMerkle[e],this),nodejs.channel.send(JSON.stringify({method:"getTransactionMerkle",id:e,txHash:s,height:t}))}catch(s){r({id:e,error:!0,errorTitle:"",errorMsg:"",data:s})}}));getAddressUtxo=({id:e=Math.random(),txHash:s="",index:t=""})=>new Promise((async r=>{try{this.getAddressUtxo[e]=s=>{"getAddressUtxo"===(s=JSON.parse(s)).method&&s.id===e&&(nodejs.channel.removeListener("message",this.getAddressUtxo[e]),r(s))},await nodejs.channel.addListener("message",this.getAddressUtxo[e],this),nodejs.channel.send(JSON.stringify({method:"getAddressUtxo",id:e,txHash:s,index:t}))}catch(s){r({id:e,error:!0,errorTitle:"",errorMsg:"",data:s})}}));broadcastTransaction=({id:e=Math.random(),rawTx:s=""})=>new Promise((async t=>{try{this.broadcastTransaction[e]=s=>{"broadcastTransaction"===(s=JSON.parse(s)).method&&s.id===e&&(nodejs.channel.removeListener("message",this.broadcastTransaction[e]),t(s))},await nodejs.channel.addListener("message",this.broadcastTransaction[e],this),nodejs.channel.send(JSON.stringify({method:"broadcastTransaction",id:e,rawTx:s}))}catch(s){t({id:e,error:!0,errorTitle:"",errorMsg:"",data:s})}}));getBlockChunk=({id:e=Math.random(),index:s=""})=>new Promise((async t=>{try{this.getBlockChunk[e]=s=>{"getBlockChunk"===(s=JSON.parse(s)).method&&s.id===e&&(nodejs.channel.removeListener("message",this.getBlockChunk[e]),t(s))},await nodejs.channel.addListener("message",this.getBlockChunk[e],this),nodejs.channel.send(JSON.stringify({method:"getBlockChunk",id:e,index:s}))}catch(s){t({id:e,error:!0,errorTitle:"",errorMsg:"",data:s})}}));getBlockHeader=({id:e=Math.random(),height:s=""})=>new Promise((async t=>{try{this.getBlockHeader[e]=s=>{"getBlockHeader"===(s=JSON.parse(s)).method&&s.id===e&&(nodejs.channel.removeListener("message",this.getBlockHeader[e]),t(s))},await nodejs.channel.addListener("message",this.getBlockHeader[e],this),nodejs.channel.send(JSON.stringify({method:"getBlockHeader",id:e,height:s}))}catch(s){t({id:e,error:!0,errorTitle:"",errorMsg:"",data:s})}}));getBanner=({id:e=Math.random()})=>new Promise((async s=>{try{this.getBanner[e]=t=>{"getBanner"===(t=JSON.parse(t)).method&&t.id===e&&(nodejs.channel.removeListener("message",this.getBanner[e]),s(t))},await nodejs.channel.addListener("message",this.getBanner[e],this),nodejs.channel.send(JSON.stringify({method:"getBanner",id:e}))}catch(t){s({id:e,error:!0,errorTitle:"",errorMsg:"",data:t})}}));getAddressProof=({address:e="",id:s=Math.random()})=>new Promise((async t=>{try{this.getAddressProof[s]=e=>{"getAddressProof"===(e=JSON.parse(e)).method&&e.id===s&&(nodejs.channel.removeListener("message",this.getAddressProof[s]),t(e))},await nodejs.channel.addListener("message",this.getAddressProof[s],this),nodejs.channel.send(JSON.stringify({method:"getAddressProof",address:e,id:s}))}catch(e){t({id:s,error:!0,errorTitle:"",errorMsg:"",data:e})}}))}
//# sourceMappingURL=/sm/2b9cbf7a7ee20c37ba0b1d18b2efb60ca7ed2f08537553c113aeb08477e4b364.map