diff options
| author | Adam Soltys <[email protected]> | 2021-04-27 15:18:41 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2021-04-27 15:18:41 -0700 |
| commit | 0351d70dd561ddf3bad4d716b4b01f77d3ac4a5e (patch) | |
| tree | aba5d6c8a753a5b60673560d549abc884f81d29b | |
| parent | 33aea5d408afdda7b63957adc5f3439fb542e5f6 (diff) | |
| download | coinos-server-0351d70dd561ddf3bad4d716b4b01f77d3ac4a5e.tar.gz coinos-server-0351d70dd561ddf3bad4d716b4b01f77d3ac4a5e.zip | |
catch exceptions
| -rw-r--r-- | routes/liquid/receive.js | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/routes/liquid/receive.js b/routes/liquid/receive.js index 7955de80..3ce6ca9a 100644 --- a/routes/liquid/receive.js +++ b/routes/liquid/receive.js @@ -5,10 +5,10 @@ const { Op } = require("sequelize"); const { fromBase58 } = require("bip32"); const bitcoin = require("bitcoinjs-lib"); const elements = require("elementsjs-lib"); -const liquid = require("liquidjs-lib"); +const { networks } = require("liquidjs-lib"); const network = - liquid.networks[ + networks[ config.liquid.network === "mainnet" ? "liquid" : config.liquid.network ]; @@ -68,9 +68,16 @@ zmqRawTx.subscribe("rawtx"); zmqRawTx.on("message", async (topic, message, sequence) => { const hex = message.toString("hex"); - const unblinded = await lq.unblindRawTransaction(hex); - const tx = await lq.decodeRawTransaction(unblinded.hex); - const blinded = await lq.decodeRawTransaction(hex); + + let unblinded, tx, blinded; + try { + unblinded = await lq.unblindRawTransaction(hex); + tx = await lq.decodeRawTransaction(unblinded.hex); + blinded = await lq.decodeRawTransaction(hex); + } catch (e) { + return console.log(e); + } + if (payments.includes(blinded.txid)) return; Promise.all( @@ -186,8 +193,15 @@ zmqRawBlock.on("message", async (topic, message, sequence) => { }); const block = elements.Block.fromHex(message.toString("hex"), true); - const hash = await lq.getBlockHash(block.height); - const json = await lq.getBlock(hash, 2); + + let hash, json; + + try { + hash = await lq.getBlockHash(block.height); + json = await lq.getBlock(hash, 2); + } catch (e) { + return console.log(e); + } json.tx.map(async tx => { if (issuances[tx.txid]) { |
