api/transactions.js
function(transaction, _callback) {
      try {
        transaction.secret(secret);
      } catch (exception) {
        return _callback(exception);
      }

      transaction.once('error', _callback);

      transaction.once('submitted', function(message) {
        if (message.result.slice(0, 3) === 'tec'
            && options.validated !== true) {
          return formatTransactionResponseWrapper(transaction, message,
            _callback);
        }

        // Handle erred transactions that should not make it into ledger (all
        // errors that aren't tec-class). This function is called before the
        // transaction `error` listener.
        switch (message.engine_result) {
          case 'terNO_ACCOUNT':
          case 'terNO_AUTH':
          case 'terNO_LINE':
          case 'terINSUF_FEE_B':
            // The transaction needs to be aborted. Preserve the original ter-
            // class error for presentation to the client
            transaction.removeListener('error', _callback);
            transaction.once('error', function() {
              _callback(message);
            });
            transaction.abort();
            break;
        }
      });

      transaction.once('proposed', function(message) {
        if (options.validated !== true) {
          formatTransactionResponseWrapper(transaction, message, _callback);
        }
      });

      transaction.once('success', function(message) {
        if (options.validated === true) {
          formatTransactionResponseWrapper(transaction, message, _callback);
        }
      });

      if (options.saveTransaction === true) {
        transaction.on('state', function() {
          var transactionSummary = transaction.summary();
          if (transactionSummary.submitIndex !== undefined) {
            api.db.saveTransaction(transactionSummary);
          }
        });

        transaction.on('postsubmit', function() {
          api.db.saveTransaction(transaction.summary());
        });
      }

      transaction.submit();
    }
function(transaction, _callback) {
      try {
        transaction.secret(secret);
      } catch (exception) {
        return _callback(exception);
      }

      transaction.once('error', _callback);

      transaction.once('submitted', function(message) {
        if (message.result.slice(0, 3) === 'tec'
            && options.validated !== true) {
          return formatTransactionResponseWrapper(transaction, message,
            _callback);
        }

        // Handle erred transactions that should not make it into ledger (all
        // errors that aren't tec-class). This function is called before the
        // transaction `error` listener.
        switch (message.engine_result) {
          case 'terNO_ACCOUNT':
          case 'terNO_AUTH':
          case 'terNO_LINE':
          case 'terINSUF_FEE_B':
            // The transaction needs to be aborted. Preserve the original ter-
            // class error for presentation to the client
            transaction.removeListener('error', _callback);
            transaction.once('error', function() {
              _callback(message);
            });
            transaction.abort();
            break;
        }
      });

      transaction.once('proposed', function(message) {
        if (options.validated !== true) {
          formatTransactionResponseWrapper(transaction, message, _callback);
        }
      });

      transaction.once('success', function(message) {
        if (options.validated === true) {
          formatTransactionResponseWrapper(transaction, message, _callback);
        }
      });

      if (options.saveTransaction === true) {
        transaction.on('state', function() {
          var transactionSummary = transaction.summary();
          if (transactionSummary.submitIndex !== undefined) {
            api.db.saveTransaction(transactionSummary);
          }
        });

        transaction.on('postsubmit', function() {
          api.db.saveTransaction(transaction.summary());
        });
      }

      transaction.submit();
    }
function ( transaction , _callback ) { try { transaction . secret ( secret ) ; } catch ( exception ) { return _callback ( exception ) ; } transaction . once ( 'error' , _callback ) ; transaction . once ( 'submitted' , function ( message ) { if ( message . result . slice ( 0 , 3 ) === 'tec' && options . validated !== true ) { return formatTransactionResponseWrapper ( transaction , message , _callback ) ; } // Handle erred transactions that should not make it into ledger (all // errors that aren't tec-class). This function is called before the // transaction `error` listener. switch ( message . engine_result ) { case 'terNO_ACCOUNT' : case 'terNO_AUTH' : case 'terNO_LINE' : case 'terINSUF_FEE_B' : // The transaction needs to be aborted. Preserve the original ter- // class error for presentation to the client transaction . removeListener ( 'error' , _callback ) ; transaction . once ( 'error' , function ( ) { _callback ( message ) ; } ) ; transaction . abort ( ) ; break ; } } ) ; transaction . once ( 'proposed' , function ( message ) { if ( options . validated !== true ) { formatTransactionResponseWrapper ( transaction , message , _callback ) ; } } ) ; transaction . once ( 'success' , function ( message ) { if ( options . validated === true ) { formatTransactionResponseWrapper ( transaction , message , _callback ) ; } } ) ; if ( options . saveTransaction === true ) { transaction . on ( 'state' , function ( ) { var transactionSummary = transaction . summary ( ) ; if ( transactionSummary . submitIndex !== undefined ) { api . db . saveTransaction ( transactionSummary ) ; } } ) ; transaction . on ( 'postsubmit' , function ( ) { api . db . saveTransaction ( transaction . summary ( ) ) ; } ) ; } transaction . submit ( ) ; }
Transaction parameters are set, listeners are registered, and is submitted here
Transaction parameters are set listeners are registered and is submitted here