bitpay / bitcore-lib

A pure and powerful JavaScript Bitcoin library
https://bitcore.io/
Other
611 stars 1.03k forks source link

Question about feePerKb #185

Open khrisanfov opened 6 years ago

khrisanfov commented 6 years ago

I see that if transaction size is smaller than 1 kb then total fee is equal to feePerKb value.

Transaction._estimateFee = function(size, amountAvailable, feePerKb) {         
  var fee = Math.ceil(size / 1000) * (feePerKb || Transaction.FEE_PER_KB);     
  if (amountAvailable > fee) {                                                 
    size += Transaction.CHANGE_OUTPUT_MAX_SIZE;                                
  }                                                                            
  return Math.ceil(size / 1000) * (feePerKb || Transaction.FEE_PER_KB);        
}; 

Is this a bug or a feature?

I am expecting it to work like this:

Math.ceil(size / 1000 * (feePerKb || Transaction.FEE_PER_KB)); instead of Math.ceil(size / 1000) * (feePerKb || Transaction.FEE_PER_KB);

jguthrie7 commented 6 years ago

I was about to make an issue about the same thing

skaplan commented 5 years ago

+1