def FinishSend(self, serialized_tx, amount_to_send): self.AbortSend() if not self.txFinished: try: self.txFinished = True tx_hex = serialized_tx.hex() printDbg("Raw signed transaction: " + tx_hex) printDbg("Amount to send :" + amount_to_send) if len(tx_hex) > 90000: mess = "Transaction's length exceeds 90000 bytes. Select less UTXOs and try again." myPopUp_sb(self.main_tab.caller, "crit", 'transaction Warning', mess) else: decodedTx = None try: decodedTx = ParseTx(tx_hex, self.main_tab.caller.isTestnetRPC) destination = decodedTx.get("vout")[0].get("scriptPubKey").get("addresses")[0] amount = decodedTx.get("vout")[0].get("value") message = '<p>Broadcast signed transaction?</p><p>Destination address:<br><b>%s</b></p>' % destination message += '<p>Amount: <b>%s</b> PIV<br>' % str(round(amount / 1e8, 8)) message += 'Fees: <b>%s</b> PIV <br>Size: <b>%d</b> Bytes</p>' % (str(round(self.currFee / 1e8, 8) ), len(tx_hex)/2) except Exception as e: printException(getCallerName(), getFunctionName(), "decoding exception", str(e)) message = '<p>Unable to decode TX- Broadcast anyway?</p>' mess1 = QMessageBox(QMessageBox.Information, 'Send transaction', message) if decodedTx is not None: mess1.setDetailedText(json.dumps(decodedTx, indent=4, sort_keys=False)) mess1.setStandardButtons(QMessageBox.Yes | QMessageBox.No) reply = mess1.exec_() if reply == QMessageBox.Yes: txid = self.main_tab.caller.rpcClient.sendRawTransaction(tx_hex, self.useSwiftX()) if txid is None: raise Exception("Unable to send TX - connection to RPC server lost.") mess2_text = "<p>Transaction successfully sent.</p>" mess2 = QMessageBox(QMessageBox.Information, 'transaction Sent', mess2_text) mess2.setDetailedText(txid) mess2.exec_() # remove spent rewards (All of them except for collaterals) self.removeSpentRewards() # reload utxos self.main_tab.caller.t_rewards.display_mn_utxos() self.main_tab.caller.t_rewards.onCancel() else: myPopUp_sb(self.main_tab.caller, "warn", 'Transaction NOT sent', "Transaction NOT sent") except Exception as e: err_msg = "Exception in FinishSend" printException(getCallerName(), getFunctionName(), err_msg, e) finally: self.close()
def load_prev_txes(self, rewardsArray): curr_utxo_checked = 0 txes = {} num_of_txes = sum([len(mnode['utxos']) for mnode in rewardsArray]) for mn in rewardsArray: for utxo in mn['utxos']: prev_hash = bytes.fromhex(utxo["txid"]) if prev_hash not in txes: raw_tx = TxCache(self.main_wnd)[utxo['txid']] json_tx = ParseTx(raw_tx) txes[prev_hash] = self.json_to_tx(json_tx) # completion percent emitted curr_utxo_checked += 1 completion = int(95 * curr_utxo_checked / num_of_txes) self.tx_progress.emit(completion) self.tx_progress.emit(100) return txes