From 37f87e47937f81fd962de43256fd17838206b20c Mon Sep 17 00:00:00 2001
From: Ivan Socolsky <jungans@gmail.com>
Date: Fri, 4 Mar 2016 10:25:12 -0300
Subject: [PATCH] accept feeLevel on createTx

---
 lib/model/txproposal.js    | 2 ++
 lib/server.js              | 2 ++
 test/integration/server.js | 2 ++
 3 files changed, 6 insertions(+)

diff --git a/lib/model/txproposal.js b/lib/model/txproposal.js
index af4f764..a286927 100644
--- a/lib/model/txproposal.js
+++ b/lib/model/txproposal.js
@@ -46,6 +46,7 @@ TxProposal.create = function(opts) {
   x.actions = [];
   x.fee = opts.fee;
   x.feePerKb = opts.feePerKb;
+  x.feeLevel = opts.feeLevel;
   x.excludeUnconfirmedUtxos = opts.excludeUnconfirmedUtxos;
 
   x.addressType = opts.addressType || (x.walletN > 1 ? Constants.SCRIPT_TYPES.P2SH : Constants.SCRIPT_TYPES.P2PKH);
@@ -95,6 +96,7 @@ TxProposal.fromObj = function(obj) {
   x.outputOrder = obj.outputOrder;
   x.fee = obj.fee;
   x.feePerKb = obj.feePerKb;
+  x.feeLevel = obj.feeLevel;
   x.excludeUnconfirmedUtxos = obj.excludeUnconfirmedUtxos;
   x.addressType = obj.addressType;
   x.customData = obj.customData;
diff --git a/lib/server.js b/lib/server.js
index c7c70a4..f651bba 100644
--- a/lib/server.js
+++ b/lib/server.js
@@ -1546,6 +1546,7 @@ WalletService.prototype.createTxLegacy = function(opts, cb) {
  * @param {Array} opts.inputs - Optional. Inputs for this TX
  * @param {string} opts.fee - Optional. Use an alternative fee for this TX (mutually exclusive with feePerKb)
  * @param {string} opts.feePerKb - Optional. Use an alternative fee per KB for this TX (mutually exclusive with fee)
+ * @param {string} opts.feeLevel - Optional. Specify the fee level used to compute feePerKb for this txp.
  * @param {string} opts.payProUrl - Optional. Paypro URL for peers to verify TX
  * @param {string} opts.excludeUnconfirmedUtxos[=false] - Optional. Do not use UTXOs of unconfirmed transactions as inputs
  * @param {string} opts.validateOutputs[=true] - Optional. Perform validation on outputs.
@@ -1595,6 +1596,7 @@ WalletService.prototype.createTx = function(opts, cb) {
           changeAddress: wallet.createAddress(true),
           fee: opts.fee,
           feePerKb: opts.feePerKb,
+          feeLevel: opts.feeLevel,
           payProUrl: opts.payProUrl,
           walletM: wallet.m,
           walletN: wallet.n,
diff --git a/test/integration/server.js b/test/integration/server.js
index 7aa5166..58cd249 100644
--- a/test/integration/server.js
+++ b/test/integration/server.js
@@ -2718,6 +2718,7 @@ describe('Wallet service', function() {
             }],
             message: 'some message',
             customData: 'some custom data',
+            feeLevel: 'priority',
           };
           server.createTx(txOpts, function(err, tx) {
             should.not.exist(err);
@@ -2731,6 +2732,7 @@ describe('Wallet service', function() {
             tx.isPending().should.equal.true;
             tx.isTemporary().should.equal.true;
             tx.amount.should.equal(helpers.toSatoshi(0.8));
+            tx.feeLevel.should.equal('priority');
             server.getPendingTxs({}, function(err, txs) {
               should.not.exist(err);
               txs.should.be.empty;