Skip to content
This repository was archived by the owner on Apr 3, 2019. It is now read-only.

Commit c1091ab

Browse files
committed
improve Transaction._estimateFeePerKb() precision
Use the binary interpretation of kilobyte (1024 bytes) and return the correct amount of satoshis.
1 parent 46c6501 commit c1091ab

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/transaction/transaction.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -985,11 +985,11 @@ Transaction.prototype._clearSignatures = function() {
985985
};
986986

987987
Transaction._estimateFee = function(size, amountAvailable, feePerKb) {
988-
var fee = Math.ceil(size / 1000) * (feePerKb || Transaction.FEE_PER_KB);
988+
var fee = Math.ceil((size / 1024) * (feePerKb || Transaction.FEE_PER_KB));
989989
if (amountAvailable > fee) {
990990
size += Transaction.CHANGE_OUTPUT_MAX_SIZE;
991991
}
992-
return Math.ceil(size / 1000) * (feePerKb || Transaction.FEE_PER_KB);
992+
return Math.ceil((size / 1024) * (feePerKb || Transaction.FEE_PER_KB));
993993
};
994994

995995
Transaction.prototype._estimateSize = function() {

0 commit comments

Comments
 (0)