mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 04:05:52 +00:00
Fix fractional transaction fee
This commit is contained in:
@@ -286,7 +286,7 @@ Transaction.prototype._computeFee = function() {
|
|||||||
var midInd = Math.floor(fees.length / 2);
|
var midInd = Math.floor(fees.length / 2);
|
||||||
|
|
||||||
var median = fees.length % 2 === 0
|
var median = fees.length % 2 === 0
|
||||||
? (fees[midInd] + fees[midInd - 1]) / 2
|
? Math.floor(0.5 + (fees[midInd] + fees[midInd - 1]) / 2)
|
||||||
: fees[midInd];
|
: fees[midInd];
|
||||||
|
|
||||||
return String(median);
|
return String(median);
|
||||||
|
|||||||
@@ -318,7 +318,7 @@ describe('Transaction', function() {
|
|||||||
|
|
||||||
assert(transaction.complete());
|
assert(transaction.complete());
|
||||||
var json = transaction.serialize().to_json();
|
var json = transaction.serialize().to_json();
|
||||||
assert(json.Fee != '66500000', 'Fee == 66500000, i.e. 66.5 XRP!');
|
assert.notStrictEqual(json.Fee, '66500000', 'Fee == 66500000, i.e. 66.5 XRP!');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user