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

0% Statements 0/9
0% Branches 0/4
0% Functions 0/3
0% Lines 0/8

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26

     const path = require('path');
    const fs = require('fs');
    const { promisify } = require('util');

    const readFile = promisify(fs.readFile);

    module.exports = async (bridgeState, app) => {
      const validatorKeyPath = path.join(
        app.lotionPath(),
        'config',
        'priv_validator.json'
      );
      const validatorKey = JSON.parse(await readFile(validatorKeyPath, 'utf-8'));
      const validatorID = Buffer.from(
        validatorKey.pub_key.value,
        'base64'
      ).toString('hex');

      const data = {
        ethAddress: bridgeState.account.address,
        tendermintAddress: validatorID,
      };

      return data;
    };