All files / src/api/methods getTransactionByPrevOut.js

100% Statements 8/8
100% Branches 2/2
100% Functions 1/1
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 113x 3x   3x 2x 2x   1x 1x    
const { Tx } = require('leap-core');
const txResponse = require('./txResponse');
 
module.exports = async (db, utxoId) => {
  const txDoc = await db.getTransactionByPrevOut(utxoId);
  if (!txDoc) return null; // return null as Infura does
 
  const { txData, blockHash, height, txPos } = txDoc;
  return await txResponse(db, Tx.fromJSON(txData), blockHash, height, txPos); // eslint-disable-line no-return-await
};