calculateFeeEC8 function

BigInt calculateFeeEC8({
  1. required RawTransaction tx,
})

Implementation

BigInt calculateFeeEC8({
  required RawTransaction tx,
}) {
  var fee = 1000.toBI; // Base fee

  final outputLength = tx.outputs.length;

  if (outputLength > 2) {
    fee += 1000.toBI * (outputLength - 2).toBI;
  }

  if (tx.weight > max_cheap_tx_weight.toBI) {
    fee += 1000.toBI * ((tx.weight + 999.toBI) / 1000.toBI).toBI;
  }

  assert(fee % 1000.toBI == 0.toBI);

  return fee;
}