def get_collateral_tx_address_thread(self, ctrl: CtrlObject, bip44_wallet: Bip44Wallet): utxos = [] break_scanning = False txes_cnt = 0 msg = 'Scanning wallet transactions for 1000 Dash UTXOs.<br>' \ 'This may take a while (<a href="break">break</a>)....' ctrl.dlg_config_fun(dlg_title="Scanning wallet", show_progress_bar=False) ctrl.display_msg_fun(msg) def check_break_scanning(): nonlocal break_scanning if break_scanning: # stop the scanning process if the dialog finishes or the address/bip32path has been found raise BreakFetchTransactionsException() def fetch_txes_feeback(tx_cnt: int): nonlocal msg, txes_cnt txes_cnt += tx_cnt ctrl.display_msg_fun(msg + '<br><br>' + 'Number of transactions fetched so far: ' + str(txes_cnt)) def on_msg_link_activated(link: str): nonlocal break_scanning if link == 'break': break_scanning = True lbl = ctrl.get_msg_label_control() if lbl: def set(): lbl.setOpenExternalLinks(False) lbl.setTextInteractionFlags(lbl.textInteractionFlags() & ~Qt.TextSelectableByMouse) lbl.linkActivated.connect(on_msg_link_activated) lbl.repaint() WndUtils.call_in_main_thread(set) try: bip44_wallet.on_fetch_account_txs_feedback = fetch_txes_feeback bip44_wallet.fetch_all_accounts_txs(check_break_scanning) for utxo in bip44_wallet.list_utxos_for_account( account_id=None, filter_by_satoshis=1e11): utxos.append(utxo) except BreakFetchTransactionsException: return None return utxos
def load_mn_addresses_in_bip44_wallet(self, bip44_wallet: Bip44Wallet): addr_ids = [] for mni in self.mn_items: if mni.masternode.collateral_address: a = bip44_wallet.get_address_item(mni.masternode.collateral_address, True) address_loc = Bip44AddressType(tree_id=None) address_loc.copy_from(a) if not address_loc.bip32_path: address_loc.bip32_path = mni.masternode.collateral_bip32_path a.bip32_path = mni.masternode.collateral_bip32_path mni.address = address_loc if mni.masternode.collateral_address not in addr_ids: addr_ids.append(mni.address.id) if addr_ids: bip44_wallet.subscribe_addresses_for_chbalance(addr_ids, True)
def on_btnLocateCollateral_clicked(self, checked): break_scanning = False if not self.main_dlg.connect_hardware_wallet(): return def do_break_scanning(): nonlocal break_scanning break_scanning = True return False def check_break_scanning(): nonlocal break_scanning return break_scanning def apply_utxo(utxo): self.masternode.collateralAddress = utxo.address self.edtCollateralAddress.setText(utxo.address) self.masternode.collateralBip32Path = utxo.bip32_path self.edtCollateralPath.setText(utxo.bip32_path) self.masternode.collateralTx = utxo.txid self.edtCollateralTxHash.setText(utxo.txid) self.masternode.collateralTxIndex = str(utxo.output_index) self.edtCollateralTxIndex.setText(str(utxo.output_index)) self.update_ui_controls_state() self.set_modified() bip44_wallet = Bip44Wallet(self.app_config.hw_coin_name, self.main_dlg.hw_session, self.app_config.db_intf, self.crownd_intf, self.app_config.crown_network) utxos = WndUtils.run_thread_dialog( self.get_collateral_tx_address_thread, (bip44_wallet, check_break_scanning, self.edtCollateralAddress.text()), True, force_close_dlg_callback=do_break_scanning) if utxos: if len(utxos) == 1 and \ (not self.masternode.collateralAddress or (utxos[0].address_obj and self.masternode.collateralAddress == utxos[0].address_obj.address)) \ and (not self.masternode.collateralTx or utxos[0].txid == self.masternode.collateralTx): apply_utxo(utxos[0]) return dlg = ListCollateralTxsDlg(self, self.masternode, self.app_config, False, utxos) if dlg.exec_(): utxo = dlg.get_selected_utxo() if utxo: apply_utxo(utxo) else: if utxos is not None: WndUtils.warnMsg('Couldn\'t find any 10000 Crown UTXO in your wallet.')
def __init__(self, main_dlg, config: AppConfig, dashd_intf: DashdInterface, masternode: MasternodeConfig, on_proregtx_success_callback: Callable): QDialog.__init__(self, main_dlg) ui_reg_masternode_dlg.Ui_RegMasternodeDlg.__init__(self) WndUtils.__init__(self, main_dlg.config) self.main_dlg = main_dlg self.masternode = masternode self.app_config = config self.dashd_intf = dashd_intf self.on_proregtx_success_callback = on_proregtx_success_callback self.style = '<style>.info{color:darkblue} .warning{color:red} .error{background-color:red;color:white}</style>' self.operator_reward_saved = None self.owner_pkey_old: str = self.masternode.dmn_owner_pubkey_hash self.owner_pkey_generated: str = None self.operator_pkey_generated: str = None self.voting_pkey_generated: str = None self.current_step = STEP_MN_DATA self.step_stack: List[int] = [] self.proregtx_prepare_thread_ref = None self.deterministic_mns_spork_active = False self.dmn_collateral_tx: str = None self.dmn_collateral_tx_index: int = None self.dmn_collateral_tx_address: str = None self.dmn_collateral_tx_address_path: str = None self.dmn_ip: str = None self.dmn_tcp_port: int = None self.dmn_owner_payout_addr: str = None self.dmn_operator_reward: int = 0 self.dmn_owner_privkey: str = None self.dmn_owner_address: str = None self.dmn_operator_privkey: str = None self.dmn_operator_pubkey: str = None self.dmn_voting_privkey: str = None self.dmn_voting_address: str = None self.dmn_reg_tx_hash: str = None self.manual_signed_message: bool = False self.last_manual_prepare_string: str = None self.wait_for_confirmation_timer_id = None self.show_field_hinds = True self.summary_info = [] if self.masternode: self.dmn_collateral_tx_address_path = self.masternode.collateralBip32Path self.bip44_wallet = Bip44Wallet(self.app_config.hw_coin_name, self.main_dlg.hw_session, self.app_config.db_intf, self.dashd_intf, self.app_config.dash_network) self.finishing = False self.setupUi()
def on_btnLocateCollateral_clicked(self, checked): if not self.main_dlg.connect_hardware_wallet(): return def apply_utxo(utxo): self.masternode.collateralAddress = utxo.address self.edtCollateralAddress.setText(utxo.address) self.masternode.collateralBip32Path = utxo.bip32_path self.edtCollateralPath.setText(utxo.bip32_path) self.masternode.collateralTx = utxo.txid self.edtCollateralTxHash.setText(utxo.txid) self.masternode.collateralTxIndex = str(utxo.output_index) self.edtCollateralTxIndex.setText(str(utxo.output_index)) self.update_ui() self.set_modified() bip44_wallet = Bip44Wallet(self.app_config.hw_coin_name, self.main_dlg.hw_session, self.app_config.db_intf, self.dashd_intf, self.app_config.dash_network) utxos = WndUtils.run_thread_dialog( self.get_collateral_tx_address_thread, (bip44_wallet, ), True) if utxos: if len( utxos ) == 1 and not self.masternode.collateralAddress and not self.masternode.collateralTx: used = False for mn in self.app_config.masternodes: if utxos[0].address == mn.collateralAddress or mn.collateralTx + '-' + str(mn.collateralTxIndex) == \ utxos[0].txid + '-' + str(utxos[0].output_index): used = True break if not used: apply_utxo(utxos[0]) return dlg = ListCollateralTxsDlg(self, self.masternode, self.app_config, False, utxos) if dlg.exec_(): utxo = dlg.get_selected_utxo() if utxo: apply_utxo(utxo) else: if utxos is not None: WndUtils.warnMsg( 'Couldn\'t find any 1000 Dash UTXO in your wallet.')
def __init__(self, parent, masternode_list: List[MasternodeConfig], bip44_wallet: Bip44Wallet): ExtSortFilterTableModel.__init__( self, parent, [TableModelColumn('description', 'Description', True, 100)], False, False) self.mn_items: List[MnAddressItem] = [] for mn in masternode_list: mni = MnAddressItem() mni.masternode = mn if mni.masternode.collateralAddress: a = bip44_wallet.get_address_item( mni.masternode.collateralAddress, True) address_loc = Bip44AddressType(tree_id=None) address_loc.copy_from(a) if not address_loc.bip32_path: address_loc.bip32_path = mni.masternode.collateralBip32Path mni.address = address_loc self.mn_items.append(mni)