File tree 3 files changed +40
-2
lines changed
3 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -612,7 +612,7 @@ Transaction.prototype.lastLedger = function(sequence) {
612
612
613
613
/**
614
614
* Set max fee. Submission will abort if this is exceeded. Specified fee must
615
- * be >= 0
615
+ * be >= 0.
616
616
*
617
617
* @param {Number } fee The proposed fee
618
618
*/
@@ -625,6 +625,23 @@ Transaction.prototype.maxFee = function(fee) {
625
625
return this ;
626
626
} ;
627
627
628
+ /*
629
+ * Set the fee user will pay to the network for submitting this transaction.
630
+ * Specified fee must be >= 0.
631
+ *
632
+ * @param {Number } fee The proposed fee
633
+ *
634
+ * @returns {Transaction } calling instance for chaining
635
+ */
636
+ Transaction . prototype . setFixedFee = function ( fee ) {
637
+ if ( typeof fee === 'number' && fee >= 0 ) {
638
+ this . _setFixedFee = true ;
639
+ this . tx_json . Fee = String ( fee ) ;
640
+ }
641
+
642
+ return this ;
643
+ } ;
644
+
628
645
/**
629
646
* Filter invalid properties from path objects in a path array
630
647
*
Original file line number Diff line number Diff line change @@ -200,6 +200,10 @@ TransactionManager.prototype._adjustFees = function() {
200
200
} ;
201
201
202
202
this . _pending . forEach ( function ( transaction ) {
203
+ if ( transaction . _setFixedFee === true ) {
204
+ return ;
205
+ }
206
+
203
207
var oldFee = transaction . tx_json . Fee ;
204
208
var newFee = transaction . _computeFee ( ) ;
205
209
@@ -239,7 +243,7 @@ TransactionManager.prototype._updatePendingStatus = function(ledger) {
239
243
assert . strictEqual ( typeof ledger , 'object' ) ;
240
244
assert . strictEqual ( typeof ledger . ledger_index , 'number' ) ;
241
245
242
- this . _pending . forEach ( function ( transaction ) {
246
+ this . _pending . forEach ( function ( transaction ) {
243
247
switch ( ledger . ledger_index - transaction . submitIndex ) {
244
248
case 4 :
245
249
transaction . emit ( 'missing' , ledger ) ;
Original file line number Diff line number Diff line change @@ -828,6 +828,23 @@ describe('Transaction', function() {
828
828
assert . strictEqual ( transaction . _setMaxFee , true ) ;
829
829
} ) ;
830
830
831
+ it ( 'Set Fixed Fee' , function ( ) {
832
+ var transaction = new Transaction ( ) ;
833
+
834
+ transaction . setFixedFee ( 'a' ) ;
835
+ assert ( ! transaction . _setFixedFee ) ;
836
+
837
+ transaction . setFixedFee ( - 1000 ) ;
838
+ assert ( ! transaction . _setFixedFee ) ;
839
+
840
+ transaction . setFixedFee ( NaN ) ;
841
+ assert ( ! transaction . _setFixedFee ) ;
842
+
843
+ transaction . setFixedFee ( 1000 ) ;
844
+ assert . strictEqual ( transaction . _setFixedFee , true ) ;
845
+ assert . strictEqual ( transaction . tx_json . Fee , '1000' ) ;
846
+ } ) ;
847
+
831
848
it ( 'Rewrite transaction path' , function ( ) {
832
849
var transaction = new Transaction ( ) ;
833
850
You can’t perform that action at this time.
0 commit comments