How to use the bitcore-lib-cash.Unit function in bitcore-lib-cash

To help you get started, we’ve selected a few bitcore-lib-cash examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ninjadotorg / handshake-app / src / services / Wallets / BitcoinCash.js View on Github external
async getFee(blocks = NB_BLOCKS, toBTC) {
    const url = `${this.network}/utils/estimatefee?nbBlocks=${blocks}`;
    const response = await axios.get(url);

    if (response.status === 200) {
      let txFee = '';
      if (toBTC) {
        txFee = bitcore.Unit.fromBTC(response.data[blocks]).toBTC();
      } else {
        txFee = bitcore.Unit.fromBTC(response.data[blocks]).toSatoshis();
      }
      return txFee;
    }
    return false;
  }