diff --git a/routes/shepherd/electrum/network.js b/routes/shepherd/electrum/network.js index 6bf4db0..aace093 100644 --- a/routes/shepherd/electrum/network.js +++ b/routes/shepherd/electrum/network.js @@ -58,9 +58,14 @@ module.exports = (shepherd) => { }; shepherd.getNetworkData = (network) => { - const coin = shepherd.findNetworkObj(network) || shepherd.findNetworkObj(network.toUpperCase()) || shepherd.findNetworkObj(network.toLowerCase()); + let coin = shepherd.findNetworkObj(network) || shepherd.findNetworkObj(network.toUpperCase()) || shepherd.findNetworkObj(network.toLowerCase()); const coinUC = coin ? coin.toUpperCase() : null; + if (!coin && + !coinUC) { + coin = network.toUpperCase(); + } + if (coin === 'SUPERNET' || coin === 'REVS' || coin === 'SUPERNET' || @@ -72,7 +77,7 @@ module.exports = (shepherd) => { coin === 'COQUI' || coin === 'OOT' || coin === 'HODL' || - coin === 'EQL' || + coin === 'EQL' || coin === 'SHARK' || coin === 'MSHARK' || coin === 'BOTS' || @@ -101,7 +106,7 @@ module.exports = (shepherd) => { coinUC === 'CRYPTO' || coinUC === 'COQUI' || coinUC === 'OOT' || - coinUC === 'EQL' || + coinUC === 'EQL' || coinUC === 'HODL' || coinUC === 'SHARK' || coinUC === 'MSHARK' || diff --git a/routes/shepherd/electrum/transactions.js b/routes/shepherd/electrum/transactions.js index 45bdb07..bff9d71 100644 --- a/routes/shepherd/electrum/transactions.js +++ b/routes/shepherd/electrum/transactions.js @@ -131,6 +131,8 @@ module.exports = (shepherd) => { const decodedTx = shepherd.electrumJSTxDecoder(_rawtxJSON, network, _network); let txInputs = []; + let opreturn = false; + shepherd.log(`decodedtx network ${network}`, true); shepherd.log('decodedtx =>', true); @@ -138,6 +140,16 @@ module.exports = (shepherd) => { let index2 = 0; + if (decodedTx && + decodedTx.outputs && + decodedTx.outputs.length) { + for (let i = 0; i < decodedTx.outputs.length; i++) { + if (decodedTx.outputs[i].scriptPubKey.type === 'nulldata') { + opreturn = shepherd.hex2str(decodedTx.outputs[i].scriptPubKey.hex); + } + } + } + if (decodedTx && decodedTx.inputs && decodedTx.inputs.length) { @@ -170,6 +182,7 @@ module.exports = (shepherd) => { formattedTx.locktime = decodedTx.format.locktime; formattedTx.vinLen = decodedTx.inputs.length; formattedTx.vinMaxLen = MAX_VIN_LENGTH; + formattedTx.opreturn = opreturn; _rawtx.push(formattedTx); } else { formattedTx[0].height = transaction.height; @@ -181,6 +194,7 @@ module.exports = (shepherd) => { formattedTx[0].locktime = decodedTx.format.locktime; formattedTx[0].vinLen = decodedTx.inputs.length; formattedTx[0].vinMaxLen = MAX_VIN_LENGTH; + formattedTx[0].opreturn = opreturn[0]; formattedTx[1].height = transaction.height; formattedTx[1].blocktime = blockInfo.timestamp; formattedTx[1].timereceived = blockInfo.timereceived; @@ -190,6 +204,7 @@ module.exports = (shepherd) => { formattedTx[1].locktime = decodedTx.format.locktime; formattedTx[1].vinLen = decodedTx.inputs.length; formattedTx[1].vinMaxLen = MAX_VIN_LENGTH; + formattedTx[1].opreturn = opreturn[1]; _rawtx.push(formattedTx[0]); _rawtx.push(formattedTx[1]); } @@ -237,6 +252,7 @@ module.exports = (shepherd) => { height: transaction.height, timestamp: Number(transaction.height) === 0 ? Math.floor(Date.now() / 1000) : blockInfo.timestamp, confirmations: Number(transaction.height) === 0 ? 0 : currentHeight - transaction.height, + opreturn, }; const formattedTx = shepherd.parseTransactionAddresses(_parsedTx, _address, network);