Exemple #1
0
    def onStartAllMN(self):
        printOK("Start-All pressed")
        # Check RPC & HW device
        if not self.caller.rpcConnected or self.caller.hwStatus != 2:
            myPopUp_sb(self.caller, "crit", 'SPMT - hw/rpc device check',
                       "Connect to RPC server and HW device first")
            printDbg("Hardware device or RPC server not connected")
            return None

        try:
            reply = myPopUp(self.caller, "quest", 'Confirm START',
                            "Are you sure you want to start ALL masternodes?",
                            QMessageBox.Yes)
            if reply == QMessageBox.Yes:
                mnList = [
                    x for x in self.caller.masternode_list if x['isHardware']
                ]
                for mn_conf in mnList:
                    self.masternodeToStart = Masternode(
                        self, mn_conf['name'], mn_conf['ip'], mn_conf['port'],
                        mn_conf['mnPrivKey'], mn_conf['hwAcc'],
                        mn_conf['collateral'], mn_conf['isTestnet'])
                    # connect signal
                    self.masternodeToStart.sigdone.connect(self.sendBroadcast)
                    self.mnToStartList.append(self.masternodeToStart)

                self.startMN()

        except Exception as e:
            err_msg = "error before starting node"
            printException(getCallerName(), getFunctionName(), err_msg, e)
Exemple #2
0
    def onVerify(self):
        # check fields
        addy = self.ui.addressLineEdit.text().strip()
        if len(addy) == 0:
            mess = "No address inserted"
            myPopUp_sb(self.main_wnd, QMessageBox.Warning, 'SPMT - no address', mess)
            return
        if not checkPivxAddr(addy, True) and not checkPivxAddr(addy, False):
            mess = "PIVX address not valid. Insert valid PIVX address"
            myPopUp_sb(self.main_wnd, QMessageBox.Warning, 'SPMT - invalid address', mess)
            return
        if self.ui.messageTextEdt.document().isEmpty():
            mess = "No message inserted"
            myPopUp_sb(self.main_wnd, QMessageBox.Warning, 'SPMT - no message', mess)
            return
        if self.ui.signatureTextEdt.document().isEmpty():
            mess = "No signature inserted"
            myPopUp_sb(self.main_wnd, QMessageBox.Warning, 'SPMT - no signature', mess)
            return

        try:
            ok = ecdsa_verify_addr(self.ui.messageTextEdt.toPlainText(),
                                   self.ui.signatureTextEdt.toPlainText(),
                                   self.ui.addressLineEdit.text().strip())
        except Exception as e:
            mess = "Error decoding signature:\n" + str(e)
            myPopUp_sb(self.main_wnd, QMessageBox.Warning, 'SPMT - invalid signature', mess)
            ok = False
        if ok:
            mess = "<span style='color: green'>Signature OK"
        else:
            mess = "<span style='color: red'>Signature doesn't verify"
        mess = "<b>" + mess + "</span></b>"
        self.ui.resultLabel.setText(mess)
        self.ui.resultLabel.setVisible(True)
Exemple #3
0
    def onStartMN(self, data=None):
        # Check RPC & HW device
        if not self.caller.rpcConnected or self.caller.hwStatus != 2:
            myPopUp_sb(self.caller, "crit", 'SPMT - hw/rpc device check',
                       "Connect to RPC server and HW device first")
            printDbg("Hardware device or RPC server not connected")
            return None
        try:
            if not data:
                target = self.ui.sender()
                masternode_alias = target.alias
                printOK("Start-masternode %s pressed" % masternode_alias)
                for mn_conf in self.caller.masternode_list:
                    if mn_conf['name'] == masternode_alias:
                        reply = myPopUp(
                            self.caller, QMessageBox.Question, 'Confirm START',
                            "Are you sure you want to start masternoode:\n'%s'?"
                            % mn_conf['name'], QMessageBox.Yes)
                        if reply == QMessageBox.Yes:
                            self.masternodeToStart = Masternode(
                                self, mn_conf['name'], mn_conf['ip'],
                                mn_conf['port'], mn_conf['mnPrivKey'],
                                mn_conf['hwAcc'], mn_conf['collateral'],
                                mn_conf['isTestnet'])
                            # connect signal
                            self.masternodeToStart.sigdone.connect(
                                self.sendBroadcast)
                            self.mnToStartList.append(self.masternodeToStart)
                            self.startMN()
                        break

        except Exception as e:
            err_msg = "error before starting node"
            printException(getCallerName(), getFunctionName(), err_msg, e)
Exemple #4
0
    def onSearchPK(self):
        fromAddress = self.ui.fromAddressRadioBtn.isChecked()
        self.hwAcc = self.ui.hwAccountSpingBox.value()
        self.currIsTestnet = self.ui.testnetCheckBox.isChecked()
        if fromAddress:
            addy = self.ui.addressLineEdit.text().strip()
            if len(addy) == 0:
                mess = "No address. Insert PIVX address first."
                myPopUp_sb(self.main_wnd, QMessageBox.Warning, 'SPMT - no address', mess)
                return

            if not checkPivxAddr(addy, self.currIsTestnet):
                net = "testnet" if self.currIsTestnet else "mainnet"
                mess = "PIVX address not valid. Insert valid PIVX %s address" % net
                myPopUp_sb(self.main_wnd, QMessageBox.Warning, 'SPMT - invalid address', mess)
                return

        # check hw connection
        while self.main_wnd.hwStatus != 2:
            mess = "HW device not connected. Try to connect?"
            ans = myPopUp(self.main_wnd, QMessageBox.Question, 'SPMT - hw check', mess)
            if ans == QMessageBox.No:
                return
            # re connect
            self.main_wnd.onCheckHw()

        # Go!
        if fromAddress:
            self.spath_found = False
            ThreadFuns.runInThread(self.findSpath, (0, 10), self.findSpath_done)
        else:
            self.spath_found = True
            self.spath = self.ui.spathSpinBox.value()
            self.findPubKey()
Exemple #5
0
    def findPubKey(self):
        printDbg("Computing public key...")
        currSpath = self.ui.edt_spath.value()
        currHwAcc = self.ui.edt_hwAccount.value()
        # Check HW device
        if self.caller.hwStatus != 2:
            myPopUp_sb(self.caller, "crit", 'SPMT - hw device check', "Connect to HW device first")
            printDbg("Unable to connect to hardware device. The device status is: %d" % self.caller.hwStatus)
            return None

        result = self.caller.hwdevice.scanForPubKey(currHwAcc, currSpath, self.isTestnet())

        # Connection pop-up
        warningText = "Unable to find public key. The action was refused on the device or another application "
        warningText += "might have taken over the USB communication with the device.<br><br>"
        warningText += "To continue click the <b>Retry</b> button.\nTo cancel, click the <b>Abort</b> button."
        mBox = QMessageBox(QMessageBox.Critical, "WARNING", warningText, QMessageBox.Retry)
        mBox.setStandardButtons(QMessageBox.Retry | QMessageBox.Abort);

        while result is None:
            ans = mBox.exec_()
            if ans == QMessageBox.Abort:
                return
            # we need to reconnect the device
            self.caller.hwdevice.clearDevice()
            self.caller.hwdevice.initDevice(self.caller.header.hwDevices.currentIndex())

            result = self.caller.hwdevice.scanForPubKey(currHwAcc, currSpath, self.isTestnet())

        mess = "Found public key:\n%s" % result
        myPopUp_sb(self.caller, "info", "SPMT - findPubKey", mess)
        printOK("Public Key: %s" % result)
        self.ui.edt_pubKey.setText(result)
Exemple #6
0
 def clearHWstatus(self, message=''):
     self.hwStatus = 0
     self.hwStatusMess = "Not Connected"
     self.header.hwLed.setPixmap(self.ledGrayH_icon)
     if message != '':
         self.hwStatus = 1
         myPopUp_sb(self, "crit", "hw device Disconnected", message)
Exemple #7
0
 def sendBroadcast(self, text):
     if text == "None":
         self.sendBroadcastCheck()
         return
     
     printOK("Start Message: %s" % text)
     ret = self.caller.rpcClient.decodemasternodebroadcast(text)
     if ret is None:
         myPopUp_sb(self.caller, "crit", 'message decoding failed', 'message decoding failed')
         self.sendBroadcastCheck()
         return
     
     msg = "Broadcast START message?\n" + json.dumps(ret, indent=4, sort_keys=True)  
     reply = myPopUp(self.caller, "quest", 'message decoded', msg, QMessageBox.Yes)
     if reply == QMessageBox.No:
         self.sendBroadcastCheck()
         return
     
     ret2 = self.caller.rpcClient.relaymasternodebroadcast(text)
     
     if json.dumps(ret2)[1:26] == "Masternode broadcast sent":
         message = "Start-message was successfully sent to the network.<br>"
         message += "If your remote server is correctly configured and connected to the network, "
         message += "the output of the <b>./pivx-cli masternode status</b> command on the VPS should show:<br>"
         message += "<br><em>\"message\": \"Masternode successfully started\"</em>"
         myPopUp_sb(self.caller, "info", 'message relayed', message)
     else:
         print(json.dumps(ret2)[1:26])
         print("\n")
     self.sendBroadcastCheck()
Exemple #8
0
 def showRPCstatus(self, server_index, fDebug):
     # Update displayed status only if selected server is not changed
     if server_index == self.header.rpcClientsBox.currentIndex():
         self.updateRPCled(fDebug)
         if fDebug:
             myPopUp_sb(self, "info", 'PET4L - rpc check',
                        "%s" % self.rpcStatusMess)
    def onToggleCollateral(self):
        if self.ui.rewardsList.box.collateralRow is not None:
            if not self.ui.collateralHidden:
                try:
                    # If collateral row was selected, deselect it before hiding
                    if self.ui.rewardsList.box.item(self.ui.rewardsList.box.collateralRow, 0).isSelected():
                        self.ui.rewardsList.box.selectRow(self.ui.rewardsList.box.collateralRow)
                except Exception as e:
                    err_msg = "Error toggling collateral"
                    printException(getCallerName(), getFunctionName(), err_msg, e.args)

                self.ui.rewardsList.box.hideRow(self.ui.rewardsList.box.collateralRow)
                self.ui.btn_toggleCollateral.setText("Show Collateral")
                self.ui.collateralHidden = True
                self.updateSelection()
            else:
                self.ui.rewardsList.box.showRow(self.ui.rewardsList.box.collateralRow)
                self.ui.btn_toggleCollateral.setText("Hide Collateral")
                self.ui.collateralHidden = False
                self.updateSelection()
                self.ui.rewardsList.box.resizeColumnsToContents()
                self.ui.rewardsList.box.horizontalHeader().setSectionResizeMode(2, QHeaderView.Stretch)

        else:
            myPopUp_sb(self.caller, "warn", 'No Collateral', "No collateral selected")
Exemple #10
0
 def onSign(self):
     # check message
     if self.ui.messageTextEdt.document().isEmpty():
         mess = "Nothing to sign. Insert message."
         myPopUp_sb(self.main_wnd, QMessageBox.Warning,
                    'PET4L - no message', mess)
         return
     # check hw connection
     while self.main_wnd.hwStatus != 2:
         mess = "HW device not connected. Try to connect?"
         ans = myPopUp(self.main_wnd, QMessageBox.Question,
                       'PET4L - hw check', mess)
         if ans == QMessageBox.No:
             return
         # re connect
         self.main_wnd.onCheckHw()
     # sign message on HW device
     serializedData = str(self.ui.messageTextEdt.toPlainText())
     device = self.main_wnd.hwdevice
     try:
         device.sig1done.disconnect()
     except:
         pass
     device.sig1done.connect(self.displaySignature)
     try:
         device.signMess(self.main_wnd, self.currHwPath, serializedData,
                         self.currIsTestnet)
         # wait for signal when device.sig1 is ready then --> displaySignature
     except Exception as e:
         err_msg = "error during signature"
         printException(getCallerName(), getFunctionName(), err_msg, e.args)
     except KeyboardInterrupt:
         err_msg = "Keyboard Interrupt"
         printException(getCallerName(), getFunctionName(), err_msg, '')
Exemple #11
0
    def findSpath_done(self):
        currAddr = self.ui.edt_address.text().strip()
        currHwAcc = self.ui.edt_hwAccount.value()
        spath = self.spath
        starting_spath = self.curr_starting_spath
        spath_count = self.curr_spath_count

        if self.spath_found:
            printOK("spath is %d" % spath)
            mess = "Found address %s in HW account %s with spath_id %s" % (
                currAddr, currHwAcc, spath)
            myPopUp_sb(self.caller, "info", 'SPMT - spath search', mess)
            self.ui.edt_spath.setValue(spath)
            self.findPubKey()

        else:
            mess = "Scanned addresses <b>%d</b> to <b>%d</b> of HW account <b>%d</b>.<br>" % (
                starting_spath, starting_spath + spath_count - 1, currHwAcc)
            mess += "Unable to find the address <i>%s</i>.<br>Maybe it's on a different account.<br><br>" % currAddr
            mess += "Do you want to scan %d more addresses of account n.<b>%d</b> ?" % (
                spath_count, currHwAcc)
            ans = myPopUp(self.caller, "crit", 'SPMT - spath search', mess)
            if ans == QMessageBox.Yes:
                starting_spath += spath_count
                self.runInThread(self.findSpath, (starting_spath, spath_count),
                                 self.findSpath_done)
Exemple #12
0
 def addressToSpath(self):
     printOK("addressToSpath pressed")
     self.spath_found = False
     # Check HW device
     if self.caller.hwStatus != 2:
         myPopUp_sb(self.caller, "crit", 'SPMT - hw device check', "Connect to HW device first")
         printDbg("Unable to connect to hardware device. The device status is: %d" % self.caller.hwStatus)
         return None
     self.runInThread(self.findSpath, (0, 10), self.findSpath_done)
Exemple #13
0
 def onCopy(self):
     if self.ui.signatureTextEdt.document().isEmpty():
         mess = "Nothing to copy. Sign message first."
         myPopUp_sb(self.main_wnd, QMessageBox.Warning, 'SPMT - no signature', mess)
         return
     cb = QApplication.clipboard()
     cb.clear(mode=cb.Clipboard)
     cb.setText(self.ui.signatureTextEdt.toPlainText(), mode=cb.Clipboard)
     myPopUp_sb(self.main_wnd, QMessageBox.Information, 'SPMT - copied', "Signature copied to the clipboard")
Exemple #14
0
 def startMN(self):       
     if self.caller.hwStatus != 2:
         myPopUp_sb(self.caller, "warn", 'SPMT - hw device check', self.caller.hwStatusMess)
     elif not self.caller.rpcConnected:
         myPopUp_sb(self.caller, "warn", 'SPMT - rpc device check', self.caller.rpcStatusMess)
     else:           
         self.masternodeToStart = self.mnToStartList.pop()
         printDbg("Starting...%s" % self.masternodeToStart.name)
         self.masternodeToStart.startMessage(self.caller.hwdevice, self.caller.rpcClient)
 def vote_thread_end(self):
     message = '<p>Votes sent</p>'
     if self.successVotes > 0:
         message += '<p>Successful Votes: <b>%d</b></p>' % self.successVotes
     if self.failedVotes > 0:
         message += '<p>Failed Votes: <b>%d</b>' % self.failedVotes
     myPopUp_sb(self.caller, "info", 'Vote Finished', message)
     # refresh my votes on proposals
     self.ui.selectedPropLabel.setText("<em><b>0</b> proposals selected")
     self.ui.resetStatusLabel()
Exemple #16
0
 def onSweepAllRewards(self):
     if not self.caller.rpcConnected or self.caller.hwStatus != 2:
         myPopUp_sb(self.caller, "crit", 'SPMT - hw/rpc device check', "Connect to RPC server and HW device first")
         return None
     try:
         self.sweepAllDlg.showDialog()
                   
     except Exception as e:
         err_msg = "exception in SweepAll_dlg"
         printException(getCallerName(), getFunctionName(), err_msg, e)
Exemple #17
0
    def loadSelection(self):
        # Check dongle
        printDbg("Checking HW device")
        if self.caller.hwStatus != 2:
            myPopUp_sb(self.caller, "crit", 'PET4L - hw device check', "Connect to HW device first")
            printDbg("Unable to connect - hw status: %d" % self.caller.hwStatus)
            return None

        self.ui.addySelect.clear()
        ThreadFuns.runInThread(self.loadSelection_thread, ())
Exemple #18
0
 def onOK(self):
     if self.pin:
         if len(self.pin) > 9:
             text = "The PIN entered exceeds the 9-character limit."
             myPopUp_sb(self, "warn", 'Wrong PIN!', text)
         else:
             self.accept()
     else:
         text = "No PIN entered"
         myPopUp_sb(self, "warn", 'Wrong PIN!', text)
Exemple #19
0
    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()
Exemple #20
0
    def findPubKey(self):
        device = self.main_wnd.hwdevice

        pk = device.scanForPubKey(self.hwAcc, self.spath, self.currIsTestnet)
        if pk is None:
            mess = "Unable to find public key. The action was refused on the device or another application "
            mess += "might have taken over the USB communication with the device.<br><br>"
            mess += "The operation was canceled."
            myPopUp_sb(self.main_wnd, QMessageBox.Critical, 'SPMT - PK not found', mess)
            return
        self.updateGenericAddress(pk)
Exemple #21
0
    def onSweepAllRewards(self):
        if not self.caller.rpcConnected:
            myPopUp_sb(self.caller, "crit", 'SPMT - rpc check',
                       "Connect to wallet / RPC server first")
            return None
        try:
            self.sweepAllDlg.showDialog()

        except Exception as e:
            err_msg = "exception in SweepAll_dlg"
            printException(getCallerName(), getFunctionName(), err_msg, e)
Exemple #22
0
 def onCopy(self):
     if self.ui.addySelect.count() == 0:
         mess = "Nothing to copy. Load/Refresh addresses first."
         myPopUp_sb(self.caller, QMessageBox.Warning, 'PET4L - no address', mess)
         return
     cb = QApplication.clipboard()
     cb.clear(mode=cb.Clipboard)
     ct = self.ui.addySelect.currentText()
     addy = ct.split("  --  ")[1].split("   ")[0].strip()
     cb.setText(addy, mode=cb.Clipboard)
     myPopUp_sb(self.caller, QMessageBox.Information, 'PET4L - copied', "address copied to the clipboard")
Exemple #23
0
 def displaySignature(self, sig):
     if sig == "None":
         self.ui.signatureTextEdt.setText("Signature refused by the user")
         return
     from utils import b64encode
     self.ui.signatureTextEdt.setText(b64encode(sig))
     self.ui.copyBtn.setVisible(True)
     self.ui.saveBtn.setVisible(True)
     # verify sig
     ok = ecdsa_verify_addr(self.ui.messageTextEdt.toPlainText(), b64encode(sig), self.currAddress)
     if not ok:
         mess = "Signature doesn't verify."
         myPopUp_sb(self.main_wnd, QMessageBox.Warning, 'SPMT - no signature', mess)
Exemple #24
0
 def spathToAddress(self):
     printOK("spathToAddress pressed")
     currHwAcc = self.ui.edt_hwAccount.value()
     currSpath = self.ui.edt_spath.value()
     # Check HW device
     if self.caller.hwStatus != 2:
         myPopUp_sb(self.caller, "crit", 'SPMT - hw device check', "Connect to HW device first")
         printDbg("Unable to connect to hardware device. The device status is: %d" % self.caller.hwStatus)
         return None
     addr = self.caller.hwdevice.scanForAddress(currHwAcc, currSpath, self.isTestnet())
     if addr:
         self.ui.edt_address.setText(addr)
         self.findPubKey()
Exemple #25
0
    def onVote(self, vote_code):
        if len(self.selectedProposals) == 0:
            message = "NO PROPOSAL SELECTED. Select proposals from the list."
            myPopUp_sb(self.caller, "crit", 'Vote on proposals', message)
            return
        if len(self.votingMasternodes) == 0:
            message = "NO MASTERNODE SELECTED FOR VOTING. Click on 'Select Masternodes...'"
            myPopUp_sb(self.caller, "crit", 'Vote on proposals', message)
            return

        reply = self.summaryDlg(vote_code)

        if reply == 1:
            ThreadFuns.runInThread(self.vote_thread, ([vote_code]), self.vote_thread_end)
Exemple #26
0
 def onCheckAllMN(self):
     if not self.caller.rpcConnected:
         myPopUp_sb(self.caller, "crit", 'SPMT - hw device check', "RPC server must be connected to perform this action.")
         printDbg("Unable to connect: %s" % self.caller.rpcStatusMess)
         return
     if self.caller.masternode_list is None or self.caller.masternode_list == []:
         myPopUp_sb(self.caller, "crit", 'SPMT - Check-All masternodes', "No masternode in list. Add masternodes first.")
         return
     try:
         printDbg("Check-All pressed")
         ThreadFuns.runInThread(self.updateAllMasternodes_thread, (), self.displayMNlistUpdated)
                
     except Exception as e:
         err_msg = "error in checkAllMN"
         printException(getCallerName(), getFunctionName(), err_msg, e)        
Exemple #27
0
 def updateGenericAddress(self, pk):
     genericAddy = pubkey_to_address(pk, self.currIsTestnet)
     if self.ui.fromAddressRadioBtn.isChecked():
         # double check address
         addy = self.ui.addressLineEdit.text().strip()
         if addy != genericAddy:
             mess = "Error! retrieved address (%s) different from input (%s)" % (genericAddy, addy)
             myPopUp_sb(self.main_wnd, QMessageBox.Critical, 'SPMT - address mismatch', mess)
             self.ui.addressLabel.setText("")
             return
     # update generic address
     self.setSignEnabled(True)
     self.currAddress = genericAddy
     self.currHwPath = "%d'/0/%d" % (self.hwAcc, self.spath)
     self.ui.addressLabel.setText(self.currAddress)
     self.ui.editBtn.setVisible(True)
Exemple #28
0
    def onSendRewards(self):
        self.dest_addr = self.ui.destinationLine.text().strip()
        self.currFee = self.ui.feeLine.value() * 1e8

        # Check HW device
        while self.caller.hwStatus != 2:
            mess = "HW device not connected. Try to connect?"
            ans = myPopUp(self.caller, QMessageBox.Question, 'PET4L - hw check', mess)
            if ans == QMessageBox.No:
                return
            # re connect
            self.caller.onCheckHw()
        if self.caller.hwStatus != 2:
            myPopUp_sb(self.caller, "crit", 'PET4L - hw device check', "Connect to HW device first")
            printDbg("Unable to connect to hardware device. The device status is: %d" % self.caller.hwStatus)
            return None

        # SEND
        self.SendRewards()
Exemple #29
0
    def onLookupTx(self):
        # address check
        currAddr = self.ui.edt_address.text().strip()
        # Check rpc connection
        printDbg("Checking RPC connection")
        if not self.caller.rpcConnected:
            myPopUp_sb(self.caller, "crit", 'SPMT - hw device check', "Connect to RPC server first")
            printDbg("Unable to connect: %s" % self.caller.rpcStatusMess)
            return None
        try:
            # Update Lookup dialog
            self.dlg.load_data(currAddr)
            if self.dlg.exec_():
                txid, txidn = self.dlg.getSelection()
                self.ui.edt_txid.setText(txid)
                self.ui.edt_txidn.setValue(txidn)

        except Exception as e:
            printDbg(e)
Exemple #30
0
 def onSave(self):
     if self.ui.signatureTextEdt.document().isEmpty():
         mess = "Nothing to save. Sign message first."
         myPopUp_sb(self.main_wnd, QMessageBox.Warning,
                    'PET4L - no signature', mess)
         return
     options = QFileDialog.Options()
     options |= QFileDialog.DontUseNativeDialog
     fileName, _ = QFileDialog.getSaveFileName(
         self.main_wnd,
         "Save signature to file",
         "sig.txt",
         "All Files (*);; Text Files (*.txt)",
         options=options)
     try:
         if fileName:
             save_file = open(fileName, 'w')
             save_file.write(self.ui.signatureTextEdt.toPlainText())
             save_file.close()
             myPopUp_sb(self.main_wnd, QMessageBox.Information,
                        'PET4L - saved', "Signature saved to file")
             return
     except Exception as e:
         err_msg = "error writing signature to file"
         printException(getCallerName(), getFunctionName(), err_msg, e.args)
     myPopUp_sb(self.main_wnd, QMessageBox.Warning, 'PET4L - NOT saved',
                "Signature NOT saved to file")