Ejemplo n.º 1
0
 def __init__(self, main_dlg, app_config: AppConfig,
              crownd_intf: CrowndInterface, masternode: MasternodeConfig,
              on_upd_success_callback: Callable, show_upd_payout: bool,
              show_upd_operator: bool, show_upd_voting: bool):
     QDialog.__init__(self, main_dlg)
     ui_upd_mn_registrar_dlg.Ui_UpdMnRegistrarDlg.__init__(self)
     WndUtils.__init__(self, main_dlg.app_config)
     self.main_dlg = main_dlg
     self.masternode = masternode
     self.app_config = app_config
     self.crownd_intf = crownd_intf
     self.on_upd_success_callback = on_upd_success_callback
     self.dmn_operator_key_type = InputKeyType.PRIVATE
     self.dmn_voting_key_type = InputKeyType.PRIVATE
     self.dmn_protx_hash = self.masternode.dmn_tx_hash
     self.dmn_owner_address = ""
     self.dmn_prev_operator_pubkey = ""
     self.dmn_prev_voting_address = ""
     self.dmn_prev_payout_address = ""
     self.dmn_new_operator_pubkey = ""
     self.dmn_new_operator_privkey = ""
     self.dmn_new_voting_address = ""
     self.dmn_new_voting_privkey = ""
     self.dmn_new_payout_address = ""
     self.show_upd_payout = show_upd_payout
     self.show_upd_operator = show_upd_operator
     self.show_upd_voting = show_upd_voting
     self.show_manual_commands = False
     self.setupUi()
Ejemplo n.º 2
0
 def __init__(self, message):
     QDialog.__init__(self)
     ui_hw_pin_dlg.Ui_HardwareWalletPinDlg.__init__(self)
     WndUtils.__init__(self, app_config=None)
     self.pin = ''
     self.message = message
     self.setupUi()
Ejemplo n.º 3
0
 def __init__(self, parent, app_path, app_version_str):
     QDialog.__init__(self, parent)
     ui_about_dlg.Ui_AboutDlg.__init__(self)
     WndUtils.__init__(self, app_path)
     self.app_path = app_path
     self.app_version_str = app_version_str
     self.setupUi()
Ejemplo n.º 4
0
    def __init__(self, window,
                 on_connection_initiated_callback=None,
                 on_connection_failed_callback=None,
                 on_connection_successful_callback=None,
                 on_connection_disconnected_callback=None):
        WndUtils.__init__(self, app_config=None)

        self.config = None
        self.db_intf = None
        self.connections = []
        self.cur_conn_index = 0
        self.cur_conn_def = None

        # below is the connection with which particular RPC call has started; if connection is switched because of
        # problems with some nodes, switching stops if we close round and return to the starting connection
        self.starting_conn = None

        self.masternodes = []  # cached list of all masternodes (Masternode object)
        self.masternodes_by_ident = {}
        self.payment_queue = []

        self.ssh = None
        self.window = window
        self.active = False
        self.rpc_url = None
        self.proxy = None
        self.http_conn = None  # HTTPConnection object passed to the AuthServiceProxy (for convinient connection reset)
        self.on_connection_initiated_callback = on_connection_initiated_callback
        self.on_connection_failed_callback = on_connection_failed_callback
        self.on_connection_successful_callback = on_connection_successful_callback
        self.on_connection_disconnected_callback = on_connection_disconnected_callback
        self.last_error_message = None
        self.http_lock = threading.Lock()
Ejemplo n.º 5
0
 def __init__(self, parent, columns):
     QDialog.__init__(self, parent)
     ui_columns_cfg_dlg.Ui_ColumnsConfigDlg.__init__(self)
     WndUtils.__init__(self, None)
     self.columns = columns
     self.initialized = False
     self.setupUi()
Ejemplo n.º 6
0
 def __init__(self,
              parent: QDialog,
              app_config: AppConfig,
              dashd_intf: DashdInterface,
              raw_transaction: str,
              tx_inputs: List[UtxoType],
              tx_outputs: List[TxOutputType],
              cur_hd_tree_id: int,
              hw_session: HwSessionInfo,
              after_send_tx_callback: Callable[[dict], None],
              decoded_transaction: Optional[dict] = None,
              dependent_transactions: Optional[dict] = None,
              fn_show_address_on_hw: Callable[[Bip44AddressType],
                                              None] = None):
     QDialog.__init__(self, parent=parent)
     QDetectThemeChange.__init__(self)
     Ui_TransactionDlg.__init__(self)
     WndUtils.__init__(self, app_config)
     self.app_config = app_config
     self.parent = parent
     self.dashd_intf = dashd_intf
     self.transaction_sent = False
     self.raw_transaction = raw_transaction
     self.tx_inputs = tx_inputs
     self.tx_outputs = tx_outputs
     self.tx_id = None  # will be decoded from rawtransaction
     self.tx_size = None  # as above
     self.cur_hd_tree_id = cur_hd_tree_id
     self.hw_session = hw_session
     self.decoded_transaction: Optional[dict] = decoded_transaction
     self.dependent_transactions = dependent_transactions  # key: txid, value: transaction dict
     self.after_send_tx_callback: Callable[[Dict],
                                           None] = after_send_tx_callback
     self.fn_show_address_on_hw = fn_show_address_on_hw
     self.setupUi(self)
Ejemplo n.º 7
0
 def __init__(
     self,
     parent: QDialog,
     config: AppConfig,
     dashd_intf: DashdInterface,
     raw_transaction: str,
     use_instant_send: bool,
     tx_inputs: List[UtxoType],
     tx_outputs: List[TxOutputType],
     after_send_tx_callback: Callable[[dict], None],
     decoded_transaction: Optional[dict] = None,
     dependent_transactions: Optional[dict] = None,
 ):
     QDialog.__init__(self, parent=parent)
     Ui_TransactionDlg.__init__(self)
     WndUtils.__init__(self, config)
     self.config = config
     self.parent = parent
     self.dashd_intf = dashd_intf
     self.transaction_sent = False
     self.raw_transaction = raw_transaction
     self.use_instant_send = use_instant_send
     self.tx_inputs = tx_inputs
     self.tx_outputs = tx_outputs
     self.tx_id = None  # will be decoded from rawtransaction
     self.tx_size = None  # as above
     self.decoded_transaction: Optional[dict] = decoded_transaction
     self.dependent_transactions = dependent_transactions  # key: txid, value: transaction dict
     self.after_send_tx_callback: Callable[[Dict],
                                           None] = after_send_tx_callback
     self.setupUi()
Ejemplo n.º 8
0
 def __init__(self, parent, doc_text, style_sheet, window_title=None):
     QDialog.__init__(self, parent)
     ui_doc_dlg.Ui_DocDlg.__init__(self)
     WndUtils.__init__(self)
     self.doc_text = doc_text
     self.style_sheet = style_sheet
     self.window_title = window_title
     self.setupUi(self)
Ejemplo n.º 9
0
 def __init__(self, message, wordlist):
     QDialog.__init__(self)
     WndUtils.__init__(self, app_config=None)
     ui_hw_word_dlg.Ui_HardwareWalletWordDlg.__init__(self)
     self.wordlist = wordlist
     self.message = message
     self.word = ''
     self.setupUi()
Ejemplo n.º 10
0
 def __init__(self, pass_available_on_device: bool):
     QDialog.__init__(self)
     WndUtils.__init__(self, app_config=None)
     ui_hw_pass_dlg.Ui_HardwareWalletPassDlg.__init__(self)
     self.passphrase = ''
     self.enter_on_device = False
     self.pass_available_on_device = pass_available_on_device
     self.setupUi(self)
Ejemplo n.º 11
0
 def __init__(self,
              message,
              wordlist,
              parent_window: Optional[QWidget] = None):
     QDialog.__init__(self, parent=parent_window)
     WndUtils.__init__(self, app_config=None)
     ui_hw_word_dlg.Ui_HardwareWalletWordDlg.__init__(self)
     self.wordlist = wordlist
     self.message = message
     self.word = ''
     self.setupUi(self)
Ejemplo n.º 12
0
    def __init__(self, parent, config):
        QDialog.__init__(self, parent=parent)
        Ui_ConfigDlg.__init__(self)
        WndUtils.__init__(self, config.app_path)
        self.config = config
        self.main_window = parent
        self.local_config = copy.deepcopy(config)

        # block ui controls -> cur config data copying while setting ui controls initial values
        self.disable_cfg_update = False
        self.is_modified = False
        self.setupUi()
    def __init__(self, main_ui, initial_mn_sel: int):
        """
        :param initial_mn_sel:
          if the value is from 0 to len(masternodes), show utxos for the masternode
            having the 'initial_mn' index in self.config.mastrnodes
          if the value is -1, show utxo for all masternodes
          if the value is None, show the default utxo source type
        """
        QDialog.__init__(self, parent=main_ui)
        WndUtils.__init__(self, main_ui.config)
        self.rawtransactions = {}
        self.masternodes = main_ui.config.masternodes
        self.masternode_addresses: List[Tuple[str, str]] = []  #  Tuple: address, bip32 path
        for idx, mn in enumerate(self.masternodes):
            self.masternode_addresses.append((mn.collateralAddress.strip(), mn.collateralBip32Path.strip()))
            logging.debug(f'WalletDlg initial_mn_sel({idx}) addr - path: {mn.collateralAddress}-{mn.collateralBip32Path}')

        self.gobyted_intf: GobytedInterface = main_ui.gobyted_intf
        self.db_intf: DBCache = main_ui.config.db_intf
        self.table_model = None
        self.finishing = False  # true if closing window
        self.load_utxos_thread_ref: Optional[WorkerThread] = None
        self.last_utxos_source_hash = ''
        self.initial_mn_sel = initial_mn_sel
        self.utxos = []
        self.utxos_dict = {}  # key: txid + outputIndex, value: utxo dict

        # 1: masternode collateral address
        # 2: wallet account (the account number and base bip32 path are selected from the GUI by a user)
        # 3: bip32 path entered by a user from GUI, converted to address
        self.utxo_src_mode: Optional[int] = None

        # for self.utxo_src_mode == 1
        self.mn_src_index = None

        # for self.utxo_src_mode == 2
        self.hw_account_numbers = [x for x in range(5)]
        self.hw_account_base_bip32_path = ''
        self.hw_account_number = None

        # for self.utxo_src_mode == 3
        self.hw_src_bip32_path = None
        self.hw_src_address = None

        self.sel_addresses_balance = 0.0
        self.sel_addresses_received = 0.0

        self.org_message = ''
        self.main_ui = main_ui
        self.grid_column_widths = []
        self.recipient_list_from_cache = []
        self.setupUi()
 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()
Ejemplo n.º 15
0
 def __init__(self, main_dlg, app_config: AppConfig,
              polisd_intf: PolisdInterface, masternode: MasternodeConfig):
     QDialog.__init__(self, main_dlg)
     ui_revoke_mn_dlg.Ui_RevokeMnDlg.__init__(self)
     WndUtils.__init__(self, main_dlg.app_config)
     self.main_dlg = main_dlg
     self.masternode = masternode
     self.app_config = app_config
     self.polisd_intf = polisd_intf
     self.dmn_protx_hash = self.masternode.dmn_tx_hash
     self.dmn_actual_operator_pubkey = ""
     self.revocation_reason = 0
     self.show_manual_commands = False
     self.setupUi()
 def __init__(self, utxos_source, main_ui):
     """
     Constructor
     :param utxos_source: list of tuples (dash address, bip32 path) - from which
         we'll list all unspent outputs
     :param masternodes: list of masternodes in configuration; used for checking if txid/index 
         is assigned to mn's collateral 
     """
     QDialog.__init__(self)
     WndUtils.__init__(self, main_ui.app_path)
     assert isinstance(utxos_source, list)
     assert isinstance(main_ui.dashd_intf, DashdInterface)
     self.utxos_source = utxos_source
     self.dashd_intf = main_ui.dashd_intf
     self.table_model = None
     self.utxos = []
     self.masternodes = main_ui.config.masternodes
     self.main_ui = main_ui
     self.setupUi()
Ejemplo n.º 17
0
    def __init__(self, parent, app_config: AppConfig):
        QDialog.__init__(self, parent=parent)
        Ui_ConfigDlg.__init__(self)
        WndUtils.__init__(self, app_config)
        self.app_config = app_config
        self.main_window = parent
        self.local_config = AppConfig()
        self.local_config.copy_from(app_config)

        # list of connections from self.local_config.dash_net_configs split on separate lists for mainnet and testnet
        self.connections_mainnet = []
        self.connections_testnet = []
        self.connections_current = None
        self.current_network_cfg: Optional[DashNetworkConnectionCfg] = None

        # block ui controls -> cur config data copying while setting ui controls initial values
        self.disable_cfg_update = False
        self.is_modified = False
        self.setupUi()
 def __init__(self, parent: QDialog,
              config: AppConfig,
              dashd_intf: DashdInterface,
              raw_transaction: str,
              decoded_transaction: Optional[dict] = None,
              dependent_transactions: Optional[dict] = None
              ):
     QDialog.__init__(self, parent=parent)
     Ui_TransactionDlg.__init__(self)
     WndUtils.__init__(self, config)
     self.config = config
     self.parent = parent
     self.dashd_intf = dashd_intf
     self.transaction_sent = False
     self.raw_transaction = raw_transaction
     self.tx_id = None  # will be decoded from rawtransaction
     self.tx_size = None  # as above
     self.decoded_transaction: Optional[dict] = decoded_transaction
     self.dependent_transactions = dependent_transactions  # key: txid, value: transaction dict
     self.setupUi()
 def __init__(self, parent) -> None:
     QDialog.__init__(self, parent)
     ui_wallet_tools_dlg.Ui_WalletToolsDlg.__init__(self)
     WndUtils.__init__(self, parent.app_config)
     self.finishing = False
     self.main_ui = parent
     self.app_config: AppConfig = parent.app_config
     self.current_action = ACTION_NONE
     self.action_widget: Optional[ActionPageBase] = None
     self.action_layout: Optional[QtWidgets.QVBoxLayout] = None
     self.hw_devices = HWDevices.get_instance()
     if not self.hw_devices:
         raise InternalError('HWDevices not initialized')
     self.hw_devices.save_state(
     )  # save the hw device currently connected in the main window
     self.hw_devices.set_allow_bootloader_mode(True)
     self.wdg_select_hw_device = CurrentHwDeviceWdg(self, self.hw_devices,
                                                    True)
     self.hw_devices.sig_connected_hw_device_changed.connect(
         self.on_connected_hw_device_changed)
     self.setupUi(self)
Ejemplo n.º 20
0
 def __init__(self, main_dlg, config: AppConfig, fixd_intf: FixdInterface,
              masternode: MasternodeConfig,
              on_mn_config_updated_callback: Callable):
     QDialog.__init__(self, main_dlg)
     ui_upd_mn_service_dlg.Ui_UpdMnServiceDlg.__init__(self)
     WndUtils.__init__(self, main_dlg.config)
     self.main_dlg = main_dlg
     self.masternode = masternode
     self.app_config = config
     self.fixd_intf = fixd_intf
     self.on_mn_config_updated_callback = on_mn_config_updated_callback
     self.dmn_protx_hash = self.masternode.dmn_tx_hash
     self.dmn_actual_operator_pubkey = ""
     self.dmn_actual_operator_reward = 0
     self.dmn_new_operator_payout_address = ''
     self.dmn_prev_ip_port = self.masternode.ip + ':' + str(
         self.masternode.port)
     self.dmn_new_ip = ''
     self.dmn_new_port = ''
     self.upd_payout_active = False
     self.show_manual_commands = False
     self.setupUi()
Ejemplo n.º 21
0
 def __init__(self,
              message,
              hide_numbers=True,
              window_title: str = None,
              max_length=12,
              button_heights: Optional[int] = None,
              parent_window: Optional[QWidget] = None,
              columns: int = 3):
     QDialog.__init__(self)
     QDetectThemeChange.__init__(self)
     ui_hw_pin_dlg.Ui_HardwareWalletPinDlg.__init__(self)
     WndUtils.__init__(self, app_config=None)
     self.pin = ''
     self.message = message
     self.hide_numbers = hide_numbers
     self.window_title = window_title if window_title else 'Hardware wallet PIN'
     self.max_length = max_length
     self.button_heights = button_heights
     self.columns = columns
     if columns not in (2, 3):
         raise Exception('Invalid number of matrix columns')
     self.setupUi(self)
Ejemplo n.º 22
0
    def __init__(self,
                 config,
                 window,
                 connection=None,
                 on_connection_begin_callback=None,
                 on_connection_try_fail_callback=None,
                 on_connection_finished_callback=None):
        WndUtils.__init__(self, app_path=config.app_path)
        assert isinstance(config, AppConfig)

        self.config = config
        # conn configurations are used from the first item in the list; if one fails, then next is taken
        if connection:
            # this parameter is used for testing specific connection
            self.connections = [connection]
        else:
            # get connection list orderd by priority of use
            self.connections = self.config.get_ordered_conn_list()
        self.cur_conn_index = 0
        if self.connections:
            self.cur_conn_def = self.connections[self.cur_conn_index]
        else:
            self.cur_conn_def = None

        # below is the connection with which particular RPC call has started; if connection is switched because of
        # problems with some nodes, switching stops if we close round and return to the starting connection
        self.starting_conn = None

        self.ssh = None
        self.window = window
        self.active = False
        self.rpc_url = None
        self.proxy = None
        self.http_conn = None  # HTTPConnection object passed to the AuthServiceProxy (for convinient connection reset)
        self.on_connection_begin_callback = on_connection_begin_callback
        self.on_connection_try_fail_callback = on_connection_try_fail_callback
        self.on_connection_finished_callback = on_connection_finished_callback
        self.last_error_message = None
Ejemplo n.º 23
0
 def __init__(self):
     QDialog.__init__(self)
     WndUtils.__init__(self, app_config=None)
     ui_hw_pass_dlg.Ui_HardwareWalletPassDlg.__init__(self)
     self.passphrase = ''
     self.setupUi()
Ejemplo n.º 24
0
 def __init__(self, parent):
     QWidget.__init__(self, parent=parent)
     Ui_RpcConnection.__init__(self)
     WndUtils.__init__(self, app_path='')
     self.setupUi()
Ejemplo n.º 25
0
    def __init__(self,
                 config,
                 window,
                 connection=None,
                 on_connection_begin_callback=None,
                 on_connection_try_fail_callback=None,
                 on_connection_finished_callback=None):
        WndUtils.__init__(self, app_config=config)
        assert isinstance(config, AppConfig)

        self.config = config
        self.db_intf = self.config.db_intf

        # conn configurations are used from the first item in the list; if one fails, then next is taken
        if connection:
            # this parameter is used for testing specific connection
            self.connections = [connection]
        else:
            # get connection list orderd by priority of use
            self.connections = self.config.get_ordered_conn_list()
        self.cur_conn_index = 0
        if self.connections:
            self.cur_conn_def = self.connections[self.cur_conn_index]
        else:
            self.cur_conn_def = None

        # below is the connection with which particular RPC call has started; if connection is switched because of
        # problems with some nodes, switching stops if we close round and return to the starting connection
        self.starting_conn = None

        self.masternodes = [
        ]  # cached list of all masternodes (Masternode object)
        self.masternodes_by_ident = {}
        self.payment_queue = []

        self.ssh = None
        self.window = window
        self.active = False
        self.rpc_url = None
        self.proxy = None
        self.http_conn = None  # HTTPConnection object passed to the AuthServiceProxy (for convinient connection reset)
        self.on_connection_begin_callback = on_connection_begin_callback
        self.on_connection_try_fail_callback = on_connection_try_fail_callback
        self.on_connection_finished_callback = on_connection_finished_callback
        self.last_error_message = None
        self.governanceinfo = None  # cached result of getgovernanceinfo query
        self.http_lock = threading.Lock()

        cur = self.db_intf.get_cursor()
        cur2 = self.db_intf.get_cursor()
        db_modified = False
        try:
            tm_start = time.time()
            db_correction_duration = 0.0
            logging.debug("Reading masternodes' data from DB")
            cur.execute(
                "SELECT id, ident, status, protocol, payee, last_seen, active_seconds,"
                " last_paid_time, last_paid_block, IP from MASTERNODES where dmt_active=1"
            )
            for row in cur.fetchall():
                db_id = row[0]
                ident = row[1]

                # correct duplicated masternodes issue
                mn_first = self.masternodes_by_ident.get(ident)
                if mn_first is not None:
                    continue

                # delete duplicated (caused by breaking the app while loading)
                tm_start_1 = time.time()
                cur2.execute('DELETE from MASTERNODES where ident=? and id<>?',
                             (ident, db_id))
                if cur2.rowcount > 0:
                    db_modified = True
                db_correction_duration += (time.time() - tm_start_1)

                mn = Masternode()
                mn.db_id = db_id
                mn.ident = ident
                mn.status = row[2]
                mn.protocol = row[3]
                mn.payee = row[4]
                mn.lastseen = row[5]
                mn.activeseconds = row[6]
                mn.lastpaidtime = row[7]
                mn.lastpaidblock = row[8]
                mn.ip = row[9]
                self.masternodes.append(mn)
                self.masternodes_by_ident[mn.ident] = mn

            tm_diff = time.time() - tm_start
            logging.info(
                'DB read time of %d MASTERNODES: %s s, db fix time: %s' %
                (len(self.masternodes), str(tm_diff),
                 str(db_correction_duration)))
            self.update_mn_queue_values()
        except Exception as e:
            logging.exception('SQLite initialization error')
        finally:
            if db_modified:
                self.db_intf.commit()
            self.db_intf.release_cursor()
            self.db_intf.release_cursor()