api/transaction/settings.js
function setTransactionFields(transaction, input, fieldSchema) {
  for (var fieldName in fieldSchema) {
    var field = fieldSchema[fieldName];
    var value = input[field.name];

    if (typeof value === 'undefined') {
      continue;
    }

    // The value required to clear an account root field varies
    if (value === CLEAR_SETTING && field.hasOwnProperty('defaults')) {
      value = field.defaults;
    }

    if (field.encoding === 'hex') {
      // If the field is supposed to be hex, why don't we do a
      //  toString('hex') on it?
      if (field.length) {
        // Field is fixed length, why are we checking here though?
        // We could move this to validateInputs
        if (value.length > field.length) {
          throw new InvalidRequestError(
            'Parameter length exceeded: ' + fieldName);
        } else if (value.length < field.length) {
          value = padValue(value, field.length);
        }
      } else {
        // Field is variable length. Expecting an ascii string as input.
        // This is currently only used for Domain field
        value = new Buffer(value, 'ascii').toString('hex');
      }

      value = value.toUpperCase();
    }

    transaction.tx_json[fieldName] = value;
  }
}
function setTransactionFields(transaction, input, fieldSchema) {
  for (var fieldName in fieldSchema) {
    var field = fieldSchema[fieldName];
    var value = input[field.name];

    if (typeof value === 'undefined') {
      continue;
    }

    // The value required to clear an account root field varies
    if (value === CLEAR_SETTING && field.hasOwnProperty('defaults')) {
      value = field.defaults;
    }

    if (field.encoding === 'hex') {
      // If the field is supposed to be hex, why don't we do a
      //  toString('hex') on it?
      if (field.length) {
        // Field is fixed length, why are we checking here though?
        // We could move this to validateInputs
        if (value.length > field.length) {
          throw new InvalidRequestError(
            'Parameter length exceeded: ' + fieldName);
        } else if (value.length < field.length) {
          value = padValue(value, field.length);
        }
      } else {
        // Field is variable length. Expecting an ascii string as input.
        // This is currently only used for Domain field
        value = new Buffer(value, 'ascii').toString('hex');
      }

      value = value.toUpperCase();
    }

    transaction.tx_json[fieldName] = value;
  }
}
function setTransactionFields ( transaction , input , fieldSchema ) { for ( var fieldName in fieldSchema ) { var field = fieldSchema [ fieldName ] ; var value = input [ field . name ] ; if ( typeof value === 'undefined' ) { continue ; } // The value required to clear an account root field varies if ( value === CLEAR_SETTING && field . hasOwnProperty ( 'defaults' ) ) { value = field . defaults ; } if ( field . encoding === 'hex' ) { // If the field is supposed to be hex, why don't we do a //  toString('hex') on it? if ( field . length ) { // Field is fixed length, why are we checking here though? // We could move this to validateInputs if ( value . length > field . length ) { throw new InvalidRequestError ( 'Parameter length exceeded: ' + fieldName ) ; } else if ( value . length < field . length ) { value = padValue ( value , field . length ) ; } } else { // Field is variable length. Expecting an ascii string as input. // This is currently only used for Domain field value = new Buffer ( value , 'ascii' ) . toString ( 'hex' ) ; } value = value . toUpperCase ( ) ; } transaction . tx_json [ fieldName ] = value ; } }
Set fields on a transaction based on input and fields schema object

@param {Transaction} transaction
@param {Object} input - Object whose properties are used to set fields on
the transaction
@param {Object} fieldSchema - Object that holds the schema of each field

@returns undefined
Set fields on a transaction based on input and fields schema object