fee calculation.
This commit is contained in:
parent
af4e9921b9
commit
399052d95a
@ -875,16 +875,15 @@ MTX.prototype.selectCoins = function selectCoins(coins, options) {
|
|||||||
size = tx.maxSize(options.m, options.n);
|
size = tx.maxSize(options.m, options.n);
|
||||||
|
|
||||||
if (options.free) {
|
if (options.free) {
|
||||||
if (newkb == null && tx.isFree(null, size)) {
|
if (tx.isFree(null, size)) {
|
||||||
fee = new bn(0);
|
fee = new bn(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
options.free = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.accurate) {
|
if (options.accurate) {
|
||||||
newkb = size / 1024;
|
fee = tx.getMinFee(size);
|
||||||
fee = new bn(newkb * minFee | 0);
|
|
||||||
totalkb = newkb;
|
|
||||||
} else {
|
} else {
|
||||||
newkb = Math.ceil(size / 1024) - totalkb;
|
newkb = Math.ceil(size / 1024) - totalkb;
|
||||||
fee.iaddn(newkb * minFee);
|
fee.iaddn(newkb * minFee);
|
||||||
|
|||||||
@ -1066,6 +1066,20 @@ TX.prototype.getMinFee = function getMinFee(size) {
|
|||||||
return fee;
|
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) {
|
TX.prototype.getConfirmations = function getConfirmations(height) {
|
||||||
if (height == null)
|
if (height == null)
|
||||||
height = network.height;
|
height = network.height;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user