1111from apiClient import ApiClient
1212from constants import MPATH , MINIMUM_FEE
1313from hwdevice import DisconnectedException
14- from misc import printDbg , printException , getCallerName , getFunctionName , persistCacheSetting , myPopUp , myPopUp_sb
14+ from misc import printDbg , printError , printException , getCallerName , getFunctionName , persistCacheSetting , myPopUp , myPopUp_sb
1515from qt .gui_tabRewards import TabRewards_gui
1616from threads import ThreadFuns
1717from utils import checkPivxAddr
@@ -74,6 +74,10 @@ def display_mn_utxos(self):
7474 # update fee
7575 if self .caller .rpcConnected :
7676 self .feePerKb = self .caller .rpcClient .getFeePerKb ()
77+ if self .feePerKb is None :
78+ self .feePerKb = MINIMUM_FEE
79+ else :
80+ self .feePerKb = MINIMUM_FEE
7781
7882 rewards = self .caller .parent .db .getRewardsList (self .curr_name )
7983 self .updateTotalBalance (rewards )
@@ -188,24 +192,23 @@ def load_utxos_thread(self, ctrl):
188192
189193 # If rpc is not connected warn and return.
190194 if not self .caller .rpcConnected :
191- printDbg ('PIVX daemon not connected - Unable to update UTXO list' )
195+ printError ('PIVX daemon not connected - Unable to update UTXO list' )
192196 return
193197
194198 api_status = self .caller .apiClient .getStatus ()
195199 if api_status != 200 :
196- printDbg ("Wrong response from API client. Status: %s" % api_status )
200+ printError ("Wrong response from API client. Status: %s" % api_status )
197201 return
198202
199203 self .apiConnected = True
200- self .blockCount = self .caller .rpcClient .getBlockCount ()
201204
202205 for mn in self .caller .masternode_list :
203206 # Load UTXOs from API client
204207 rewards = self .caller .apiClient .getAddressUtxos (
205208 mn ['collateral' ].get ('address' ))['unspent_outputs' ]
206209
207210 if rewards is None :
208- printDbg ( 'Error occurred while calling getaddressutxos method .' )
211+ printError ( 'API client not responding .' )
209212 return
210213
211214 # for each UTXO
@@ -215,7 +218,7 @@ def load_utxos_thread(self, ctrl):
215218
216219 # Don't save UTXO if raw TX is unavailable
217220 if rawtx is None :
218- printDbg ("Unable to get raw TX with hash=%s from RPC server" % utxo ['tx_hash' ])
221+ printError ("Unable to get raw TX with hash=%s from RPC server" % utxo ['tx_hash' ])
219222 continue
220223
221224 # Add mn_name and raw_tx to UTXO and save it to DB
@@ -412,6 +415,8 @@ def FinishSend(self, serialized_tx, amount_to_send):
412415
413416 else :
414417 decodedTx = self .caller .rpcClient .decodeRawTransaction (tx_hex )
418+ if decodedTx is None :
419+ raise Exception ("Unable to decode TX - connection to RPC server lost." )
415420 destination = decodedTx .get ("vout" )[0 ].get ("scriptPubKey" ).get ("addresses" )[0 ]
416421 amount = decodedTx .get ("vout" )[0 ].get ("value" )
417422 message = '<p>Broadcast signed transaction?</p><p>Destination address:<br><b>%s</b></p>' % destination
@@ -424,6 +429,9 @@ def FinishSend(self, serialized_tx, amount_to_send):
424429 reply = mess1 .exec_ ()
425430 if reply == QMessageBox .Yes :
426431 txid = self .caller .rpcClient .sendRawTransaction (tx_hex , self .useSwiftX ())
432+ if txid is None :
433+ raise Exception ("Unable to send TX - connection to RPC server lost." )
434+
427435 mess2_text = "<p>Transaction successfully sent.</p>"
428436 mess2 = QMessageBox (QMessageBox .Information , 'transaction Sent' , mess2_text )
429437 mess2 .setDetailedText (txid )
0 commit comments