File tree 2 files changed +35
-0
lines changed
2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -491,6 +491,24 @@ Transaction.prototype.lastLedger = function(sequence) {
491
491
return this ;
492
492
} ;
493
493
494
+ /*
495
+ * Set the transaction's proposed fee. No op when fee parameter
496
+ * is not 0 or a positive number
497
+ *
498
+ * @param {Number } fee The proposed fee
499
+ *
500
+ * @returns {Transaction } calling instance for chaining
501
+ */
502
+ Transaction . prototype . maxFee = function ( fee ) {
503
+ if ( typeof fee === 'number' && fee >= 0 ) {
504
+ this . _setMaxFee = true ;
505
+ this . tx_json . Fee = String ( fee ) ;
506
+ this . _maxFee = fee ;
507
+ }
508
+
509
+ return this ;
510
+ } ;
511
+
494
512
Transaction . _pathRewrite = function ( path ) {
495
513
if ( ! Array . isArray ( path ) ) {
496
514
return ;
Original file line number Diff line number Diff line change @@ -835,6 +835,23 @@ describe('Transaction', function() {
835
835
assert ( transaction . _setLastLedger ) ;
836
836
} ) ;
837
837
838
+ it ( 'Set Max Fee' , function ( ) {
839
+ var transaction = new Transaction ( ) ;
840
+
841
+ transaction . maxFee ( 'a' ) ;
842
+ assert . strictEqual ( transaction . tx_json . Fee , void ( 0 ) ) ;
843
+ assert ( ! transaction . _setLastLedger ) ;
844
+
845
+ transaction . maxFee ( NaN ) ;
846
+ assert . strictEqual ( transaction . tx_json . Fee , void ( 0 ) ) ;
847
+ assert ( ! transaction . _setLastLedger ) ;
848
+
849
+ transaction . maxFee ( 1000 ) ;
850
+ assert . strictEqual ( transaction . tx_json . Fee , '1000' ) ;
851
+ assert . strictEqual ( transaction . _maxFee , 1000 ) ;
852
+ assert . strictEqual ( transaction . _setMaxFee , true ) ;
853
+ } ) ;
854
+
838
855
it ( 'Rewrite transaction path' , function ( ) {
839
856
var transaction = new Transaction ( ) ;
840
857
You can’t perform that action at this time.
0 commit comments