From fbb59614ede47fe993322c5261c6d60842ee2f71 Mon Sep 17 00:00:00 2001 From: Yoshi Date: Sat, 6 Jul 2019 23:04:47 +0200 Subject: [PATCH] Try-Catch block to catch scripts that contain no addresses, such as op_returns --- lib/TransactionDb.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/TransactionDb.js b/lib/TransactionDb.js index 80b771414..29970aff0 100644 --- a/lib/TransactionDb.js +++ b/lib/TransactionDb.js @@ -523,12 +523,16 @@ TransactionDb.prototype.getStandardizedTx = function(tx, time, isCoinBase) { var val; if (txout.s) { var s = new Script(txout.s); - var addrs = new Address.fromScriptPubKey(s, config.network); - // support only for p2pubkey p2pubkeyhash and p2sh - if (addrs && addrs.length === 1) { - val = { - addresses: [addrs[0].toString()] - }; + try { + var addrs = new Address.fromScriptPubKey(s, config.network); + // support only for p2pubkey p2pubkeyhash and p2sh + if (addrs && addrs.length === 1) { + val = { + addresses: [addrs[0].toString()] + }; + } + } catch(e) { + val = { addresses: [] } } } return {