All files / src/utils dposUtils.ts

100% Statements 8/8
100% Branches 0/0
100% Functions 1/1
100% Lines 8/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 181x 1x               1x 101x 101x 101x 808x   101x    
import {bigNumberFromBuffer} from './bignumber';
import {toSha256} from './sha256';
 
/**
 * Derive an address from the public key
 * @param {string} publicKey publicKey to derive address from
 * @param {string} suffix a suffix character
 * @returns {string} the calculated address
 */
export const deriveDPOSAddress = (publicKey: string, suffix: string): string => {
  const hash = toSha256(new Buffer(publicKey, 'hex'));
  const temp = new Buffer(8);
  for (let i = 0; i < 8; i++) {
    temp[i] = hash[7 - i];
  }
  return `${bigNumberFromBuffer(temp).toString()}${suffix}`;
};