fee calculation.

This commit is contained in:
Christopher Jeffrey 2016-03-31 04:47:41 -07:00
parent af4e9921b9
commit 399052d95a
2 changed files with 17 additions and 4 deletions

View File

@ -875,16 +875,15 @@ MTX.prototype.selectCoins = function selectCoins(coins, options) {
size = tx.maxSize(options.m, options.n);
if (options.free) {
if (newkb == null && tx.isFree(null, size)) {
if (tx.isFree(null, size)) {
fee = new bn(0);
break;
}
options.free = false;
}
if (options.accurate) {
newkb = size / 1024;
fee = new bn(newkb * minFee | 0);
totalkb = newkb;
fee = tx.getMinFee(size);
} else {
newkb = Math.ceil(size / 1024) - totalkb;
fee.iaddn(newkb * minFee);

View File

@ -1066,6 +1066,20 @@ TX.prototype.getMinFee = function getMinFee(size) {
return fee;
};
TX.prototype.getMaxFee = function getMaxFee(size) {
var fee;
if (size == null)
size = this.maxSize();
fee = new bn(constants.tx.minFee).muln(Math.ceil(size / 1000));
if (fee.cmpn(0) === 0 && constants.tx.minFee > 0)
fee = new bn(constants.tx.minFee);
return fee;
};
TX.prototype.getConfirmations = function getConfirmations(height) {
if (height == null)
height = network.height;