def generate_priv_key(self, pk_type:str, edit_control: QLineEdit, compressed: bool): if edit_control.text(): if WndUtils.queryDlg( f'This will overwrite the current {pk_type} private key value. Do you really want to proceed?', buttons=QMessageBox.Yes | QMessageBox.Cancel, default_button=QMessageBox.Yes, icon=QMessageBox.Warning) != QMessageBox.Yes: return None if pk_type == 'operator': pk = dash_utils.generate_bls_privkey() else: pk = dash_utils.generate_wif_privkey(self.app_config.dash_network, compressed=compressed) edit_control.setText(pk) return pk
def generate_keys(self): """ Generate new operator and voting keys if were not provided before.""" gen_owner = False gen_operator = False gen_voting = False if self.masternode.dmn_owner_private_key or self.masternode.dmn_operator_private_key \ or self.masternode.dmn_voting_private_key: # if any of the owner/operator/voting key used in the configuration is the same as the corresponding # key shown in the blockchain, replace that key by a new one found_protx = False protx_state = {} try: for protx in self.dashd_intf.protx('list', 'registered', True): protx_state = protx.get('state') if (protx_state and protx_state.get('addr') == self.masternode.ip + ':' + self.masternode.port) or \ (protx.get('collateralHash') == self.masternode.collateralTx and str(protx.get('collateralIndex')) == str(self.masternode.collateralTxIndex)): found_protx = True break except Exception as e: pass if found_protx: if self.masternode.dmn_owner_private_key and \ self.masternode.dmn_owner_pubkey_hash == protx_state.get('keyIDOwner'): gen_owner = True if self.masternode.dmn_operator_private_key and \ self.masternode.dmn_operator_pubkey == protx_state.get('pubKeyOperator'): gen_operator = True if self.masternode.dmn_voting_private_key and \ self.masternode.dmn_voting_pubkey_hash == protx_state.get('keyIDVoting'): gen_voting = True if not self.masternode.dmn_owner_private_key: gen_owner = True if not self.masternode.dmn_operator_private_key: gen_operator = True if not self.masternode.dmn_voting_private_key: gen_voting = True if gen_owner: log.debug('Generation owner key') self.owner_pkey_generated = generate_wif_privkey( self.app_config.dash_network, compressed=True) self.edtOwnerKey.setText(self.owner_pkey_generated) else: self.edtOwnerKey.setText(self.masternode.dmn_owner_private_key) if gen_operator: log.debug('Generation bls key') self.operator_pkey_generated = generate_bls_privkey() self.edtOperatorKey.setText(self.operator_pkey_generated) else: self.edtOperatorKey.setText( self.masternode.dmn_operator_private_key) if self.deterministic_mns_spork_active: if gen_voting: log.debug('Generation voting key') self.voting_pkey_generated = generate_wif_privkey( self.app_config.dash_network, compressed=True) else: self.edtVotingKey.setText( self.masternode.dmn_voting_private_key) else: self.voting_pkey_generated = self.edtOwnerKey.text().strip() if self.voting_pkey_generated: self.edtVotingKey.setText(self.voting_pkey_generated)
def on_btnGenerateOperatorKey_clicked(self, active): self.edtOperatorKey.setText(generate_bls_privkey()) self.edtOperatorKey.repaint( ) # qt 5.11.3 has issue with automatic repainting after setText on mac
def on_btnGenerateOperatorKey_clicked(self, active): self.edtOperatorKey.setText(generate_bls_privkey())