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

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

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
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    233x
    3x

    3x
    2x

    2x
    2x

    1x

    1x

     const { Tx } = require('leap-core');
    const checkSpendCond = require('../../tx/applyTx/checkSpendCond.js');

    module.exports = async (bridgeState, rawTx) => {
      const tx = Tx.fromRaw(rawTx);

      let logOuts;
      try {
        logOuts = await checkSpendCond(bridgeState.currentState, tx, bridgeState);
      } catch (err) {
        return {
          error: err.message ? err.message : JSON.stringify(err),
          logs: bridgeState.logsCache[tx.hash()],
          outputs: err.logOuts,
        };
      }

      return {
        outputs: logOuts,
        logs: bridgeState.logsCache[tx.hash()],
      };
    };