src/index.js
function getAddress(addressInput) {
  var address = addressInput; // eslint-disable-line
  var result = null; // eslint-disable-line

  if (typeof(address) !== 'string') { throw new Error(`[ethjs-account] invalid address value ${JSON.stringify(address)} not a valid hex string`); }

  // Missing the 0x prefix
  if (address.substring(0, 2) !== '0x' &&
      address.substring(0, 2) !== 'XE') { address = `0x${address}`; }

  if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) {
    result = getChecksumAddress(address);

    // It is a checksummed address with a bad checksum
    if (address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && result !== address) {
      throw new Error('[ethjs-account] invalid address checksum');
    }

  // Maybe ICAP? (we only support direct mode)
  } else if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {
    throw new Error('[ethjs-account] ICAP and IBAN addresses, not supported yet..');

    /*
    // It is an ICAP address with a bad checksum
    if (address.substring(2, 4) !== ibanChecksum(address)) {
      throw new Error('invalid address icap checksum');
    }

    result = (new BN(address.substring(4), 36)).toString(16);
    while (result.length < 40) { result = '0' + result; }
    result = getChecksumAddress('0x' + result);
    */
  } else {
    throw new Error(`[ethjs-account] invalid address value ${JSON.stringify(address)} not a valid hex string`);
  }

  return result;
}
function getAddress(addressInput) {
  var address = addressInput; // eslint-disable-line
  var result = null; // eslint-disable-line

  if (typeof(address) !== 'string') { throw new Error(`[ethjs-account] invalid address value ${JSON.stringify(address)} not a valid hex string`); }

  // Missing the 0x prefix
  if (address.substring(0, 2) !== '0x' &&
      address.substring(0, 2) !== 'XE') { address = `0x${address}`; }

  if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) {
    result = getChecksumAddress(address);

    // It is a checksummed address with a bad checksum
    if (address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && result !== address) {
      throw new Error('[ethjs-account] invalid address checksum');
    }

  // Maybe ICAP? (we only support direct mode)
  } else if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {
    throw new Error('[ethjs-account] ICAP and IBAN addresses, not supported yet..');

    /*
    // It is an ICAP address with a bad checksum
    if (address.substring(2, 4) !== ibanChecksum(address)) {
      throw new Error('invalid address icap checksum');
    }

    result = (new BN(address.substring(4), 36)).toString(16);
    while (result.length < 40) { result = '0' + result; }
    result = getChecksumAddress('0x' + result);
    */
  } else {
    throw new Error(`[ethjs-account] invalid address value ${JSON.stringify(address)} not a valid hex string`);
  }

  return result;
}
function getAddress ( addressInput ) { var address = addressInput ; // eslint-disable-line var result = null ; // eslint-disable-line if ( typeof ( address ) !== 'string' ) { throw new Error ( ` ${ JSON . stringify ( address ) } ` ) ; } // Missing the 0x prefix if ( address . substring ( 0 , 2 ) !== '0x' && address . substring ( 0 , 2 ) !== 'XE' ) { address = ` ${ address } ` ; } if ( address . match ( / ^(0x)?[0-9a-fA-F]{40}$ / ) ) { result = getChecksumAddress ( address ) ; // It is a checksummed address with a bad checksum if ( address . match ( / ([A-F].*[a-f])|([a-f].*[A-F]) / ) && result !== address ) { throw new Error ( '[ethjs-account] invalid address checksum' ) ; } // Maybe ICAP? (we only support direct mode) } else if ( address . match ( / ^XE[0-9]{2}[0-9A-Za-z]{30,31}$ / ) ) { throw new Error ( '[ethjs-account] ICAP and IBAN addresses, not supported yet..' ) ; /*
    // It is an ICAP address with a bad checksum
    if (address.substring(2, 4) !== ibanChecksum(address)) {
      throw new Error('invalid address icap checksum');
    }

    result = (new BN(address.substring(4), 36)).toString(16);
    while (result.length < 40) { result = '0' + result; }
    result = getChecksumAddress('0x' + result);
    */ } else { throw new Error ( ` ${ JSON . stringify ( address ) } ` ) ; } return result ; }
Get the address from a public key

@method getAddress
@param {String} addressInput
@returns {String} output the string is a hex string
Get the address from a public key