Ejemplo n.º 1
0
bool Currency::getTransactionFee(const Transaction& tx, uint64_t& fee, uint32_t height) const {
  uint64_t amount_in = 0;
  uint64_t amount_out = 0;

  //if (tx.inputs.size() == 0)// || tx.outputs.size() == 0) //0 outputs needed in TestGenerator::constructBlock
  //	  return false;
  
  for (const auto& in : tx.inputs) {
    amount_in += getTransactionInputAmount(in, height);
  }

  for (const auto& o : tx.outputs) {
    amount_out += o.amount;
  }

  if (amount_out > amount_in){
	if (tx.inputs.size() > 0 && tx.outputs.size() > 0 && amount_out > amount_in + parameters::MINIMUM_FEE) //interest shows up in the output of the W/D transactions and W/Ds always have min fee
	  fee = parameters::MINIMUM_FEE;
	else
	  return false;
  } else
	fee = amount_in - amount_out;

  return true;
}
Ejemplo n.º 2
0
uint64_t Currency::getTransactionAllInputsAmount(const Transaction& tx, uint32_t height) const {
  uint64_t amount = 0;
  for (const auto& in : tx.inputs) {
    amount += getTransactionInputAmount(in, height);
  }
  return amount;
}
uint64_t TransactionPrefixImpl::getInputTotalAmount() const {
    return std::accumulate(m_txPrefix.inputs.begin(), m_txPrefix.inputs.end(), 0ULL, [](uint64_t val, const TransactionInput& in) {
        return val + getTransactionInputAmount(in);
    });
}