# All files / src/api/methods getTransactionByHash.js

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

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    111x
    1x

    1x
    2x
    2x

    1x
    1x

     const { Tx } = require('leap-core');
    const txResponse = require('./txResponse');

    module.exports = async (db, hash) => {
      const txDoc = await db.getTransaction(hash);
      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
    };