setBaseFee method

FeeBumpTransactionBuilder setBaseFee(
  1. int baseFee
)

Implementation

FeeBumpTransactionBuilder setBaseFee(int baseFee) {
  if (_mBaseFee != null) {
    throw Exception("base fee has been already set.");
  }
  if (baseFee < AbstractTransaction.MIN_BASE_FEE) {
    throw new Exception("baseFee cannot be smaller than the BASE_FEE (" +
        AbstractTransaction.MIN_BASE_FEE.toString() +
        "): " +
        baseFee.toString());
  }

  int innerBaseFee = _mInner.fee;
  int numOperations = _mInner.operations.length;
  if (numOperations > 0) {
    innerBaseFee = (innerBaseFee / numOperations).round();
  }

  if (baseFee < innerBaseFee) {
    throw new Exception(
        "base fee cannot be lower than provided inner transaction base fee");
  }

  int maxFee = baseFee * (numOperations + 1);
  if (maxFee < 0) {
    throw new Exception("fee overflows 64 bit int");
  }

  _mBaseFee = maxFee;
  return this;
}