diff --git a/README.md b/README.md
index b6c40e4..9bd4954 100644
--- a/README.md
+++ b/README.md
@@ -131,7 +131,7 @@ Click on `Hide Collateral` to hide it again.
Select those UTXOs you wish to spend.
-The suggested fee is automatically adjusted based on the TX size and the average fee of the last 10 blocks.
+The suggested fee is automatically adjusted based on the TX size and the average fee of the last 200 blocks.
Adjust it as preferred.
Then insert the PIVX `Destination Address` and click on `Send`
diff --git a/src/qt/dlg_sweepAll.py b/src/qt/dlg_sweepAll.py
index 6db8b34..95cab9b 100644
--- a/src/qt/dlg_sweepAll.py
+++ b/src/qt/dlg_sweepAll.py
@@ -72,8 +72,7 @@ def item(value):
# update fee
estimatedTxSize = (44+numOfInputs*148)*1.0 / 1000 # kB
- feePerKb = self.main_tab.caller.rpcClient.getFeePerKb()
- suggestedFee = round(feePerKb * estimatedTxSize, 8)
+ suggestedFee = round(self.feePerKb * estimatedTxSize, 8)
self.ui.feeLine.setValue(suggestedFee)
# load last used destination from cache
@@ -109,7 +108,8 @@ def load_utxos_thread(self, ctrl):
print("Unable to get raw TX from RPC server\n")
self.rewards = []
return
-
+ # update fee
+ self.feePerKb = self.main_tab.caller.rpcClient.getFeePerKb()
diff --git a/src/rpcClient.py b/src/rpcClient.py
index 54ce28b..f39daee 100644
--- a/src/rpcClient.py
+++ b/src/rpcClient.py
@@ -91,8 +91,8 @@ def getBlockHash(self, blockNum):
def getFeePerKb(self):
try:
self.lock.acquire()
- # get transaction data from last 10 blocks
- feePerKb = float(self.conn.getfeeinfo(10)['feeperkb'])
+ # get transaction data from last 120 blocks
+ feePerKb = float(self.conn.getfeeinfo(200)['feeperkb'])
res = (feePerKb if feePerKb > MINIMUM_FEE else MINIMUM_FEE)
except Exception as e:
err_msg = 'error in getFeePerKb'
diff --git a/src/tabRewards.py b/src/tabRewards.py
index a01c1e1..0aeaeca 100644
--- a/src/tabRewards.py
+++ b/src/tabRewards.py
@@ -26,6 +26,7 @@ def __init__(self, caller):
self.rewards = None
self.selectedRewards = None
self.rawtransactions = {}
+ self.feePerKb = MINIMUM_FEE
##--- Initialize GUI
self.ui = TabRewards_gui()
self.caller.tabRewards = self.ui
@@ -85,6 +86,8 @@ def item(value):
self.ui.rewardsList.statusLabel.setText('Unable to connect to API provider')
self.ui.rewardsList.statusLabel.setVisible(True)
+
+
@@ -136,15 +139,19 @@ def load_utxos_thread(self, ctrl):
try:
if self.caller.apiClient.getStatus() != 200:
return
+
self.apiConnected = True
self.blockCount = self.caller.rpcClient.getBlockCount()
self.rewards = self.caller.apiClient.getAddressUtxos(self.curr_addr)['unspent_outputs']
+
for utxo in self.rewards:
rawtx = self.caller.rpcClient.getRawTransaction(utxo['tx_hash'])
self.rawtransactions[utxo['tx_hash']] = rawtx
if rawtx is None:
print("Unable to get raw TX from RPC server\n")
+ self.feePerKb = self.caller.rpcClient.getFeePerKb()
+
except Exception as e:
self.errorMsg = 'Error occurred while calling getaddressutxos method: ' + str(e)
printDbg(self.errorMsg)
@@ -379,13 +386,12 @@ def updateSelection(self, clicked_item=None):
for i in range(0, numOfInputs):
total += int(self.selectedRewards[i].get('value'))
-
+
# update suggested fee and selected rewards
estimatedTxSize = (44+numOfInputs*148)*1.0 / 1000 # kB
- feePerKb = self.caller.rpcClient.getFeePerKb()
- suggestedFee = round(feePerKb * estimatedTxSize, 8)
+ suggestedFee = round(self.feePerKb * estimatedTxSize, 8)
printDbg("estimatedTxSize is %s kB" % str(estimatedTxSize))
- printDbg("suggested fee is %s PIV (%s PIV/kB)" % (str(suggestedFee), str(feePerKb)))
+ printDbg("suggested fee is %s PIV (%s PIV/kB)" % (str(suggestedFee), str(self.feePerKb)))
self.ui.selectedRewardsLine.setText(str(round(total/1e8, 8)))
self.ui.feeLine.setValue(suggestedFee)