コード例 #1
0
ファイル: mainWindow.py プロジェクト: lubinalubina/PIVX-SPMT
    def updateHWstatus(self, ctrl):
        if self.hwdevice is not None:
            if hasattr(self.hwdevice, 'dongle'):
                self.hwdevice.dongle.close()

        self.hwdevice = HWdevice()

        statusCode, statusMess = self.hwdevice.getStatus()
        printDbg("mess: %s" % statusMess)
        if statusCode != 2:
            # If is not connected try again
            try:
                if hasattr(self.hwdevice, 'dongle'):
                    self.hwdevice.dongle.close()
                self.hwdevice = HWdevice()
                self.hwdevice.initDevice()
                statusCode, statusMess = self.hwdevice.getStatus()

            except Exception as e:
                err_msg = "error in checkHw"
                printException(getCallerName(), getFunctionName(), err_msg,
                               e.args)

        self.hwStatus = statusCode
        self.hwStatusMess = statusMess
コード例 #2
0
    def load_utxos_thread(self, ctrl):
        self.apiConnected = False
        try:
            if not self.caller.rpcConnected:
                self.rewards = []
                printDbg('PIVX daemon not connected')

            else:
                try:
                    if self.apiClient.getStatus() != 200:
                        return
                    self.apiConnected = True
                    self.blockCount = self.caller.rpcClient.getBlockCount()
                    self.rewards = self.apiClient.getAddressUtxos(
                        self.curr_addr)['unspent_outputs']
                    for utxo in self.rewards:
                        self.rawtransactions[utxo[
                            'tx_hash']] = self.caller.rpcClient.getRawTransaction(
                                utxo['tx_hash'])

                except Exception as e:
                    self.errorMsg = 'Error occurred while calling getaddressutxos method: ' + str(
                        e)
                    printDbg(self.errorMsg)

        except Exception as e:
            print(e)
            pass
コード例 #3
0
ファイル: database.py プロジェクト: icambacoin/PIVX-SPMT
    def addMasternode(self, mn, old_mn=None):
        add_defaultKeys_to_dict(mn, DEFAULT_MN_CONF)

        if not old_mn is None:
            printDbg("DB: Editing masternode %s" % old_mn)
            try:
                cursor = self.getCursor()

                cursor.execute(
                    "UPDATE MASTERNODES "
                    "SET name = ?, ip = ?, port = ?, mnPrivKey = ?, hwAcc = ?, isTestnet = ?, isHardware = ?,"
                    "    address = ?, spath = ?, pubkey = ?, txid = ?, txidn = ?"
                    "WHERE name = ?",
                    (mn['name'], mn['ip'], mn['port'], mn['mnPrivKey'],
                     mn['hwAcc'], mn['isTestnet'],
                     1 if mn['isHardware'] else 0,
                     mn['collateral'].get('address'),
                     mn['collateral'].get('spath'),
                     mn['collateral'].get('pubKey'),
                     mn['collateral'].get('txid'),
                     mn['collateral'].get('txidn'), old_mn['name']))

            except Exception as e:
                err_msg = 'error writing masternode to DB'
                printException(getCallerName(), getFunctionName(), err_msg,
                               e.args)
            finally:
                self.releaseCursor()

        else:
            # Add new record to the table
            self.addNewMasternode(mn)
コード例 #4
0
ファイル: hwdevice.py プロジェクト: damon000/SPMT
    def scanForBip32(self, account, address, starting_spath=0, spath_count=10, isTestnet=False):
        found = False
        spath = -1
        
        printOK("Scanning for Bip32 path of address: %s" % address)
        for i in range(starting_spath, starting_spath+spath_count):
            curr_path = MPATH + "%d'/0/%d" % (account, i)
            printDbg("checking path... %s" % curr_path)
            self.lock.acquire()
            try:
                if not isTestnet:
                    curr_addr = self.chip.getWalletPublicKey(curr_path).get('address')[12:-2]
                else:
                    pubkey = compress_public_key(self.chip.getWalletPublicKey(curr_path).get('publicKey')).hex()          
                    curr_addr = pubkey_to_address(pubkey, isTestnet)     

                             
                if curr_addr == address:
                    found = True
                    spath = i
                    break
                
                sleep(0.01)
            
            except Exception as e:
                err_msg = 'error in scanForBip32'
                printException(getCallerName(), getFunctionName(), err_msg, e.args)
                
            finally:
                self.lock.release()
                
        return (found, spath)
コード例 #5
0
ファイル: tabRewards.py プロジェクト: tgroh007/PET4L
 def FinishSend(self, serialized_tx, amount_to_send):
     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."
                 self.caller.myPopUp2(QMessageBox.Warning, 'transaction Warning', mess)
             
             else:
                 message = 'Broadcast signed transaction?<br><br>Destination address:<br><b>%s</b><br><br>' % (self.dest_addr)
                 message += 'Amount to send: <b>%s PIV</b><br>' % amount_to_send
                 message += 'Fee: <b>%s PIV</b><br>Size: <b>%d bytes</b>' % (str(round(self.currFee / 1e8, 8) ), len(tx_hex)/2)
                 reply = self.caller.myPopUp(QMessageBox.Information, 'Send transaction', message)
                 if reply == QMessageBox.Yes:                   
                     txid = self.caller.rpcClient.sendRawTransaction(tx_hex)
                     mess = QMessageBox(QMessageBox.Information, 'transaction Sent', 'transaction Sent')
                     mess.setDetailedText(txid)
                     mess.exec_()
                     
                 else:
                     self.caller.myPopUp2(QMessageBox.Information, 'transaction NOT Sent', "transaction NOT sent")
                     
                 self.onCancel()
                     
         except Exception as e:
             err_msg = "Exception in sendRewards"
             printException(getCallerName(), getFunctionName(), err_msg, e.args)
コード例 #6
0
ファイル: dlg_sweepAll.py プロジェクト: damon000/SPMT
    def onButtonSend(self):
        try:
            self.dest_addr = self.ui.edt_destination.text().strip()
            if self.useSwiftX():
                self.currFee = 0.01 * 1e8
            else:
                self.currFee = self.ui.feeLine.value() * 1e8
             
             # Check RPC & dongle  
            if not self.main_tab.caller.rpcConnected or self.main_tab.caller.hwStatus != 2:
                self.main_tab.caller.myPopUp2(QMessageBox.Critical, 'SPMT - hw/rpc device check', "Connect to RPC server and HW device first")
                return None
            
            # Check destination Address      
            if not checkPivxAddr(self.dest_addr):
                self.main_tab.caller.myPopUp2(QMessageBox.Critical, 'SPMT - PIVX address check', "The destination address is missing, or invalid.")
                return None

            # LET'S GO
            if len(self.rawtransactions) > 0:
                printDbg("Preparing transaction. Please wait...")
                self.ui.loadingLine.show()
                self.ui.loadingLinePercent.show()
                QApplication.processEvents()
                
                # save last destination address and swiftxCheck to cache
                self.main_tab.caller.parent.cache["lastAddress"] = self.dest_addr
                self.main_tab.caller.parent.cache["useSwiftX"] = self.useSwiftX()
                writeToFile(self.main_tab.caller.parent.cache, cache_File)
                    
                # re-connect signals
                try:
                    self.main_tab.caller.hwdevice.sigTxdone.disconnect()
                except:
                    pass
                try:
                    self.main_tab.caller.hwdevice.sigTxabort.disconnect()
                except:
                    pass
                try:
                    self.main_tab.caller.hwdevice.tx_progress.disconnect()
                except:
                    pass
                self.main_tab.caller.hwdevice.sigTxdone.connect(self.FinishSend)
                self.main_tab.caller.hwdevice.sigTxabort.connect(self.AbortSend)
                self.main_tab.caller.hwdevice.tx_progress.connect(self.updateProgressPercent)
    
                self.txFinished = False
                self.main_tab.caller.hwdevice.prepare_transfer_tx_bulk(self.main_tab.caller, self.rewards, self.dest_addr, self.currFee, self.rawtransactions, self.useSwiftX())
            else:
                self.main_tab.caller.myPopUp2(QMessageBox.Information, 'Transaction NOT sent', "No UTXO to send") 
                
        except DisconnectedException as e:
            self.main_tab.caller.hwStatus = 0
            self.main_tab.caller.updateHWleds()
            self.onButtonCancel()
                
        except Exception as e:
            err_msg = "Exception in onButtonSend"
            printException(getCallerName(), getFunctionName(), err_msg, e.args)
コード例 #7
0
ファイル: rpcClient.py プロジェクト: chilly2k/PIVX-SPMT
    def decodemasternodebroadcast(self, work):
        printDbg("RPC: Decoding masternode broadcast...")
        res = ""
        with self.lock:
            res = self.conn.decodemasternodebroadcast(work.strip())

        return res
コード例 #8
0
ファイル: rpcClient.py プロジェクト: chilly2k/PIVX-SPMT
    def getMasternodes(self):
        printDbg("RPC: Getting masternode list...")
        mnList = {}
        score = []
        masternodes = []
        with self.lock:
            masternodes = self.conn.listmasternodes()

        for mn in masternodes:
            if mn.get('status') == 'ENABLED':
                # compute masternode score
                if mn.get('lastpaid') == 0:
                    mn['score'] = mn.get('activetime')
                else:
                    lastpaid_ago = now() - mn.get('lastpaid')
                    mn['score'] = min(lastpaid_ago, mn.get('activetime'))

            else:
                mn['score'] = 0

            score.append(mn)

        # sort masternodes by decreasing score
        score.sort(key=lambda x: x['score'], reverse=True)

        # save masternode position in the payment queue
        for mn in masternodes:
            mn['queue_pos'] = score.index(mn)

        mnList['masternodes'] = masternodes

        return mnList
コード例 #9
0
ファイル: rpcClient.py プロジェクト: chilly2k/PIVX-SPMT
    def relaymasternodebroadcast(self, work):
        printDbg("RPC: Relaying masternode broadcast...")
        res = ""
        with self.lock:
            res = self.conn.relaymasternodebroadcast(work.strip())

        return res
コード例 #10
0
ファイル: tabMain.py プロジェクト: icambacoin/PIVX-SPMT
 def displayMNlistUpdated(self):
     for masternode in self.caller.masternode_list:
         printDbg(
             "Checking %s (%s)..." %
             (masternode['name'], masternode['collateral'].get('txid')))
         self.displayMNStatus(masternode)
         time.sleep(0.1)
コード例 #11
0
ファイル: trezorClient.py プロジェクト: icambacoin/PIVX-SPMT
 def initDevice(self):
     printDbg("Initializing Trezor")
     with self.lock:
         self.status = 0
         devices = enumerate_devices()
         if not len(devices):
             # No device connected
             return
         # Use the first device for now
         d = devices[0]
         ui = TrezorUi()
         try:
             self.client = TrezorClient(d, ui)
         except IOError:
             raise Exception("TREZOR device is currently in use")
         printOK("Trezor HW device connected [v. %s.%s.%s]" %
                 (self.client.features.major_version,
                  self.client.features.minor_version,
                  self.client.features.patch_version))
         self.status = 1
         model = self.client.features.model or "1"
         if not self.checkModel(model):
             self.status = 3
             self.messages[
                 3] = "Wrong device model (%s) detected.\nLooking for model %s." % (
                     HW_devices[self.model][0], model)
             return
         required_version = MINIMUM_FIRMWARE_VERSION[model]
         printDbg("Current version is %s (minimum required: %s)" %
                  (str(self.client.version), str(required_version)))
         # Check device is unlocked
         bip32_path = parse_path(MPATH + "%d'/0/%d" % (0, 0))
         _ = btc.get_address(self.client, 'PIVX', bip32_path, False)
         self.status = 2
コード例 #12
0
ファイル: database.py プロジェクト: dennismann/PET4L
    def initTables(self):
        printDbg("DB: Initializing tables...")
        try:
            cursor = self.conn.cursor()

            # Tables for RPC Servers
            cursor.execute("CREATE TABLE IF NOT EXISTS PUBLIC_RPC_SERVERS("
                           " id INTEGER PRIMARY KEY, protocol TEXT, host TEXT,"
                           " user TEXT, pass TEXT)")

            cursor.execute("CREATE TABLE IF NOT EXISTS CUSTOM_RPC_SERVERS("
                           " id INTEGER PRIMARY KEY, protocol TEXT, host TEXT,"
                           " user TEXT, pass TEXT)")

            self.initTable_RPC(cursor)

            # Tables for Utxos
            cursor.execute(
                "CREATE TABLE IF NOT EXISTS UTXOS("
                " tx_hash TEXT, tx_ouput_n INTEGER, satoshis INTEGER, confirmations INTEGER,"
                " script TEXT, raw_tx TEXT, receiver TEXT, staker TEXT, coinstake BOOLEAN,"
                " PRIMARY KEY (tx_hash, tx_ouput_n))")

            printDbg("DB: Tables initialized")

        except Exception as e:
            err_msg = 'error initializing tables'
            printException(getCallerName(), getFunctionName(), err_msg, e.args)
コード例 #13
0
ファイル: tabMain.py プロジェクト: curiumofficial/PIVX-SPMT
    def onStartMN(self, data=None):
        # Check RPC & dongle
        if not self.caller.rpcConnected or self.caller.hwStatus != 2:
            self.caller.myPopUp2(QMessageBox.Critical,
                                 '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 = self.caller.myPopUp(
                            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'])
                            # 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)
コード例 #14
0
    def onStartAllMN(self):
        printOK("Start-All pressed")
        # Check RPC & dongle
        if not self.caller.rpcConnected:
            self.caller.myPopUp2(QMessageBox.Critical,
                                 'QMT - hw/rpc device check',
                                 "Connect to RPC server and HW device first")
            printDbg("Hardware device or RPC server not connected")
            return None
        try:
            reply = self.caller.myPopUp(
                QMessageBox.Question, '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'])
                    # 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)
コード例 #15
0
    def onButtonSave(self, main_dlg):
        main_dlg.rpc_ip = ip_address(self.edt_rpcIp.text().strip()).compressed
        main_dlg.rpc_port = int(self.edt_rpcPort.value())
        main_dlg.rpc_user = self.edt_rpcUser.text()
        main_dlg.rpc_password = self.edt_rpcPassword.text()
        conf = {}
        conf["rpc_ip"] = main_dlg.rpc_ip
        conf["rpc_port"] = main_dlg.rpc_port
        conf["rpc_user"] = main_dlg.rpc_user
        conf["rpc_password"] = main_dlg.rpc_password

        urlstring = "http://%s:%s@%s:%d" % (conf["rpc_user"],
                                            conf["rpc_password"],
                                            conf["rpc_ip"], conf["rpc_port"])

        if checkRPCstring(urlstring,
                          action_msg="Restoring previous configuration"):
            # Update datafile
            writeToFile(conf, rpc_File)
            # Update current RPC Server
            main_dlg.main_wnd.mainWindow.rpcClient = None
            main_dlg.main_wnd.mainWindow.rpcConnected = False
            printDbg("Trying to connect to RPC server [%s]:%s" %
                     (conf["rpc_ip"], str(conf["rpc_port"])))
            self.runInThread = ThreadFuns.runInThread(
                main_dlg.main_wnd.mainWindow.updateRPCstatus, (),
                main_dlg.main_wnd.mainWindow.updateRPCled)
        else:
            printDbg("Restored RPC credentials. ")

        main_dlg.close()
コード例 #16
0
    def append_inputs_to_TX(self, utxo, bip32_path):
        self.amount += int(utxo['value'])
        raw_tx = bytearray.fromhex(utxo['raw_tx'])
        
        # parse the raw transaction, so that we can extract the UTXO locking script we refer to
        prev_transaction = bitcoinTransaction(raw_tx)

        utxo_tx_index = utxo['tx_ouput_n']
        if utxo_tx_index < 0 or utxo_tx_index > len(prev_transaction.outputs):
            raise Exception('Incorrect value of outputIndex for UTXO %s-%d' % 
                            (utxo['raw_tx'], utxo['tx_ouput_n']))
        
        trusted_input = self.chip.getTrustedInput(prev_transaction, utxo_tx_index)
        self.trusted_inputs.append(trusted_input)
        
        # Hash check
        curr_pubkey = compress_public_key(self.chip.getWalletPublicKey(bip32_path)['publicKey'])
        pubkey_hash = bin_hash160(curr_pubkey)
        pubkey_hash_from_script = extract_pkh_from_locking_script(prev_transaction.outputs[utxo_tx_index].script)
        if pubkey_hash != pubkey_hash_from_script:
            text = "Error: The hashes for the public key for the BIP32 path, and the UTXO locking script do not match."
            text += "Your signed transaction will not be validated by the network.\n"
            text += "pubkey_hash: %s\n" % pubkey_hash.hex()
            text += "pubkey_hash_from_script: %s\n" % pubkey_hash_from_script.hex()
            printDbg(text)

        self.arg_inputs.append({
            'locking_script': prev_transaction.outputs[utxo['tx_ouput_n']].script,
            'pubkey': curr_pubkey,
            'bip32_path': bip32_path,
            'outputIndex': utxo['tx_ouput_n'],
            'txid': utxo['tx_hash']
        })
コード例 #17
0
ファイル: tabMNConf.py プロジェクト: lemonclik/PIVX-SPMT
    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)
コード例 #18
0
    def load_utxos_thread(self, ctrl):
        self.apiConnected = False
        try:
            if not self.rpcClient.getStatus():
                printDbg('PIVX daemon not connected')
            else:
                try:
                    if self.apiClient.getStatus() != 200:
                        return
                    self.apiConnected = True
                    self.blockCount = self.rpcClient.getBlockCount()
                    utxos = self.apiClient.getAddressUtxos(
                        self.pivx_addr)['unspent_outputs']
                    printDbg("loading utxos\nblockCount=%s\n%s" %
                             (str(self.blockCount), str(self.utxos)))
                    self.utxos = [
                        utxo for utxo in utxos
                        if round(int(utxo.get('value', 0)) /
                                 1e8, 8) == 10000.00000000
                    ]

                except Exception as e:
                    self.errorMsg = 'Error occurred while calling getaddressutxos method: ' + str(
                        e)
                    print(self.errorMsg)

        except Exception as e:
            print(e)
            pass
コード例 #19
0
ファイル: mainWindow.py プロジェクト: jakop345/QMT
    def updateHWstatus(self, ctrl):
        if self.hwdevice is not None:
            if hasattr(self.hwdevice, 'dongle'):
                self.hwdevice.dongle.close()

        self.hwdevice = HWdevice()

        statusCode, statusMess = self.hwdevice.getStatus()
        printDbg("mess: %s" % statusMess)
        if statusCode != 2:
            # If is not connected try again
            try:
                if hasattr(self.hwdevice, 'dongle'):
                    self.hwdevice.dongle.close()
                self.hwdevice = HWdevice()
                self.hwdevice.initDevice()
                statusCode, statusMess = self.hwdevice.getStatus()

            except Exception as e:
                err_msg = "error in checkHw"
                printException(getCallerName(), getFunctionName(), err_msg, e.args)

        self.hwStatus = statusCode
        self.hwStatusMess = statusMess

        # if all is good connect the signals
        if statusCode == 2:
            self.hwdevice.sigTxdone.connect(self.t_rewards.FinishSend)
            self.hwdevice.sigTxabort.connect(self.t_rewards.onCancel)
            self.hwdevice.tx_progress.connect(self.t_rewards.updateProgressPercent)
コード例 #20
0
    def getStatus(self):
        status = False
        statusMess = "Unable to connect to a PIVX RPC server.\n"
        statusMess += "Either the local PIVX wallet is not open, or the remote RPC server is not responding."
        n = 0
        try:
            self.lock.acquire()
            n = self.conn.getblockcount()
            if n > 0:
                status = True
                statusMess = "Connected to PIVX RPC client"

        except Exception as e:
            # If loading block index set lastBlock=1
            if str(e.args[0]) == "Loading block index..." or str(
                    e.args[0]) == "Verifying blocks...":
                printDbg(str(e.args[0]))
                statusMess = "PIVX wallet is connected but still synchronizing / verifying blocks"
                n = 1
            elif str(e.args[0]) != "Request-sent" and str(
                    e.args[0]) != "10061":
                err_msg = "Error while contacting RPC server"
                printException(getCallerName(), getFunctionName(), err_msg,
                               e.args)

        finally:
            self.lock.release()

        return status, statusMess, n
コード例 #21
0
    def onButtonSave(self, main_dlg):
        try:
            main_dlg.rpc_ip = ip_address(
                self.edt_rpcIp.text().strip()).compressed
            main_dlg.rpc_port = int(self.edt_rpcPort.value())
            main_dlg.rpc_user = self.edt_rpcUser.text()
            main_dlg.rpc_password = self.edt_rpcPassword.text()
            conf = {}
            conf["rpc_ip"] = main_dlg.rpc_ip
            conf["rpc_port"] = main_dlg.rpc_port
            conf["rpc_user"] = main_dlg.rpc_user
            conf["rpc_password"] = main_dlg.rpc_password

            # Update File
            writeRPCfile(conf)

            # Update current RPC Server
            main_dlg.main_wnd.mainWindow.rpcClient = None
            main_dlg.main_wnd.mainWindow.rpcConnected = False
            printDbg("Trying to connect to RPC server [%s]:%s" %
                     (conf["rpc_ip"], str(conf["rpc_port"])))
            self.runInThread = ThreadFuns.runInThread(
                main_dlg.main_wnd.mainWindow.updateRPCstatus, (),
                main_dlg.main_wnd.mainWindow.updateRPCled)
            main_dlg.close()

        except Exception as e:
            print(e)
コード例 #22
0
ファイル: rpcClient.py プロジェクト: chilly2k/PIVX-SPMT
    def verifyMessage(self, pivxaddress, signature, message):
        printDbg("RPC: Verifying message...")
        res = False
        with self.lock:
            res = self.conn.verifymessage(pivxaddress, signature, message)

        return res
コード例 #23
0
    def initTables(self):
        printDbg("DB: Initializing tables...")
        try:
            cursor = self.conn.cursor()

            # Tables for RPC Servers
            cursor.execute("CREATE TABLE IF NOT EXISTS PUBLIC_RPC_SERVERS("
                           " id INTEGER PRIMARY KEY, protocol TEXT, host TEXT,"
                           " user TEXT, pass TEXT)")

            cursor.execute("CREATE TABLE IF NOT EXISTS CUSTOM_RPC_SERVERS("
                           " id INTEGER PRIMARY KEY, protocol TEXT, host TEXT,"
                           " user TEXT, pass TEXT)")

            self.initTable_RPC(cursor)

            # Tables for Masternodes
            cursor.execute(
                "CREATE TABLE IF NOT EXISTS MASTERNODES("
                " name TEXT PRIMARY KEY, ip TEXT, port INTEGER, mnPrivKey TEXT,"
                " hwAcc INTEGER, isTestnet INTEGER, isHardware INTEGER,"
                " address TEXT, spath INTEGER, pubkey TEXT, txid TEXT, txidn INTEGER)"
            )

            # Tables for Rewards
            cursor.execute(
                "CREATE TABLE IF NOT EXISTS REWARDS("
                " tx_hash TEXT, tx_ouput_n INTEGER,"
                " satoshis INTEGER, confirmations INTEGER, script TEXT, mn_name TEXT, coinstake BOOLEAN,"
                " staker TEXT,"
                " PRIMARY KEY (tx_hash, tx_ouput_n))")

            cursor.execute(
                "CREATE TABLE IF NOT EXISTS RAWTXES("
                " tx_hash TEXT PRIMARY KEY,  rawtx TEXT, lastfetch INTEGER)")

            # Tables for Governance Objects
            cursor.execute(
                "CREATE TABLE IF NOT EXISTS PROPOSALS("
                " name TEXT, url TEXT, hash TEXT PRIMARY KEY, feeHash TEXT,"
                " blockStart INTEGER, blockEnd INTEGER, totalPayCount INTEGER,"
                " remainingPayCount INTEGER, paymentAddress TEXT,"
                " yeas INTEGER, nays INTEGER, abstains INTEGER, "
                " totalPayment REAL, monthlyPayment REAL)")

            #cursor.execute("CREATE TABLE IF NOT EXISTS PROJECTED_PROPOSALS("
            #               " name TEXT, hash TEXT PRIMARY KEY, "
            #               " allotted REAL, votes INTEGER, totaAllotted REAL)")

            cursor.execute(
                "CREATE TABLE IF NOT EXISTS MY_VOTES("
                " mn_name TEXT, p_hash, vote INTEGER, timeslip INTEGER, "
                " PRIMARY KEY (mn_name, p_hash))")

            printDbg("DB: Tables initialized")

        except Exception as e:
            err_msg = 'error initializing tables'
            printException(getCallerName(), getFunctionName(), err_msg, e.args)
コード例 #24
0
ファイル: hwdevice.py プロジェクト: damon000/SPMT
 def __init__(self, *args, **kwargs):
     QObject.__init__(self, *args, **kwargs)
     # Device Lock for threads
     self.lock = threading.Lock()
     printDbg("Creating HW device class")
     self.initDevice()
     # Connect signal
     self.sig_progress.connect(self.updateSigProgress)
コード例 #25
0
ファイル: database.py プロジェクト: icambacoin/PIVX-SPMT
 def __init__(self, app):
     printDbg("DB: Initializing...")
     self.app = app
     self.file_name = database_File
     self.lock = threading.Lock()
     self.isOpen = False
     self.conn = None
     printDbg("DB: Initialized")
コード例 #26
0
ファイル: spmtApp.py プロジェクト: amadeobrands/PIVX-SPMT
 def onEditRPCServer(self):
     # Create Dialog
     try:
         ui = ConfigureRPCserver_dlg(self)
         if ui.exec():
             printDbg("Configuring RPC Server...")
     except Exception as e:
         print(e)
コード例 #27
0
 def __init__(self, *args, **kwargs):
     QObject.__init__(self, *args, **kwargs)
     # Device Lock for threads
     self.lock = threading.RLock()
     self.status = 0
     self.dongle = None
     printDbg("Creating HW device class")
     # Connect signal
     self.sig_progress.connect(self.updateSigProgress)
コード例 #28
0
ファイル: rpcClient.py プロジェクト: chilly2k/PIVX-SPMT
    def sendRawTransaction(self, tx_hex):
        dbg_mess = "RPC: Sending raw transaction"
        dbg_mess += "..."
        printDbg(dbg_mess)
        tx_id = None
        with self.lock:
            tx_id = self.conn.sendrawtransaction(tx_hex, True)

        return tx_id
コード例 #29
0
ファイル: tabMain.py プロジェクト: mygirl8893/PIVX-SPMT
 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)
コード例 #30
0
ファイル: tabMNConf.py プロジェクト: lemonclik/PIVX-SPMT
 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)