How to use the bitgo.bitcoin.networks function in bitgo

To help you get started, we’ve selected a few bitgo 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 BitGo / bitgo-cli / src / recovery.js View on Github external
CrossChainRecoveryTool.prototype._setCoinInstances = function _setCoinInstances(source, recovery) {
  /* eslint-disable no-unused-vars */
  const [sourceCoin, sourceModifier] = source.split('-');
  const [recoveryCoin, recoveryModifier] = recovery.split('-');
  /* eslint-enable no-unused-vars */

  // Leaving modifiers alone for now. In the future we can use this to do SegWit recoveries

  let network;

  if (this.test) {
    this.sourceCoin = this.bitgo.coin('t' + sourceCoin);
    this.recoveryCoin = this.bitgo.coin('t' + recoveryCoin);

    network = bitcoin.networks.testnet;
  } else {
    this.sourceCoin = this.bitgo.coin(sourceCoin);
    this.recoveryCoin = this.bitgo.coin(recoveryCoin);

    network = bitcoin.networks.bitcoin;
  }

  this.recoveryTx = new bitcoin.TransactionBuilder(network);

  if (sourceCoin === 'bch') {
    this.recoveryTx.enableBitcoinCash(true);
    this.recoveryTx.setVersion(2);
  }
};