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);
|
||||
|
||||
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);
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user