Exemple #1
0
    def update(self):
        format_amount = self.app.format_amount_and_units
        tx_details = self.wallet.get_tx_info(self.tx)
        tx_mined_status = tx_details.tx_mined_status
        exp_n = tx_details.mempool_depth_bytes
        amount, fee = tx_details.amount, tx_details.fee
        self.status_str = tx_details.status
        self.description = tx_details.label
        self.can_broadcast = tx_details.can_broadcast
        self.tx_hash = tx_details.txid or ''
        if tx_mined_status.timestamp:
            self.date_label = _('Date')
            self.date_str = datetime.fromtimestamp(
                tx_mined_status.timestamp).isoformat(' ')[:-3]
        elif exp_n:
            self.date_label = _('Mempool depth')
            self.date_str = _('{} from tip').format('%.2f MB' %
                                                    (exp_n / 1000000))
        else:
            self.date_label = ''
            self.date_str = ''

        if amount is None:
            self.amount_str = _("Transaction unrelated to your wallet")
        elif amount > 0:
            self.is_mine = False
            self.amount_str = format_amount(amount)
        else:
            self.is_mine = True
            self.amount_str = format_amount(-amount)
        self.fee_str = format_amount(fee) if fee is not None else _('unknown')
        self.can_sign = self.wallet.can_sign(self.tx)
        self.ids.output_list.update(self.tx.get_outputs_for_UI())
        self.is_local_tx = tx_mined_status.height == TX_HEIGHT_LOCAL
        self.update_action_button()
Exemple #2
0
 def update(self):
     self.menu_actions = [(_('Use'), self.do_use), (_('Details'), self.do_view)]
     wallet = self.app.wallet
     if self.show_change == 0:
         _list = wallet.get_receiving_addresses()
     elif self.show_change == 1:
         _list = wallet.get_change_addresses()
     else:
         _list = wallet.get_addresses()
     search = self.message
     container = self.ids.search_container
     n = 0
     cards = []
     for address in _list:
         label = wallet.labels.get(address, '')
         balance = sum(wallet.get_addr_balance(address))
         is_used_and_empty = wallet.is_used(address) and balance == 0
         if self.show_used == 1 and (balance or is_used_and_empty):
             continue
         if self.show_used == 2 and balance == 0:
             continue
         if self.show_used == 3 and not is_used_and_empty:
             continue
         card = self.get_card(address, balance, is_used_and_empty, label)
         if search and not self.ext_search(card, search):
             continue
         cards.append(card)
         n += 1
     container.data = cards
     if not n:
         self.app.show_error('No address matching your search')
Exemple #3
0
class PasswordDialog(AbstractPasswordDialog):
    enter_pw_message = _('Enter your password')
    enter_new_pw_message = _('Enter new password')
    confirm_new_pw_message = _('Confirm new password')
    wrong_password_message = _('Wrong password')
    allow_disable = False

    def __init__(self, app, **kwargs):
        AbstractPasswordDialog.__init__(self, app, **kwargs)

    def clear_password(self):
        self.ids.textinput_generic_password.text = ''

    def on_password(self, pw: str):
        #
        if not self.require_password:
            self.success = True
            self.message = _('Please wait...')
            self.dismiss()
            return
        # if setting new generic password, enforce min length
        if self.level > 0:
            if len(pw) < 6:
                self.app.show_error(
                    _('Password is too short (min {} characters)').format(6))
                return
        # don't enforce minimum length on existing
        self.do_check(pw)
Exemple #4
0
 def read_invoice(self):
     address = str(self.address)
     if not address:
         self.app.show_error(
             _('Recipient not specified.') + ' ' +
             _('Please scan a Dash address or a payment request'))
         return
     if not self.amount:
         self.app.show_error(_('Please enter an amount'))
         return
     if self.is_max:
         amount = '!'
     else:
         try:
             amount = self.app.get_amount(self.amount)
         except:
             self.app.show_error(_('Invalid amount') + ':\n' + self.amount)
             return
     message = self.message
     if self.payment_request:
         outputs = self.payment_request.get_outputs()
     else:
         if not bitcoin.is_address(address):
             self.app.show_error(
                 _('Invalid Dash Address') + ':\n' + address)
             return
         outputs = [PartialTxOutput.from_address_and_value(address, amount)]
     return self.app.wallet.create_invoice(outputs=outputs,
                                           message=message,
                                           pr=self.payment_request,
                                           URI=self.parsed_URI)
Exemple #5
0
 def privatesend_txt(self, is_ps=None):
     if is_ps is None:
         is_ps = self.is_ps
     if is_ps:
         return _('PrivateSend')
     else:
         return _('Regular Transaction')
Exemple #6
0
    def update(self):
        format_amount = self.app.format_amount_and_units
        tx_hash, self.status_str, self.description, self.can_broadcast, amount, fee, height, conf, timestamp, exp_n = self.wallet.get_tx_info(
            self.tx)
        self.tx_hash = tx_hash or ''
        if timestamp:
            self.date_label = _('Date')
            self.date_str = datetime.fromtimestamp(timestamp).isoformat(
                ' ')[:-3]
        elif exp_n:
            self.date_label = _('Mempool depth')
            self.date_str = _('{} from tip').format('%.2f MB' %
                                                    (exp_n / 1000000))
        else:
            self.date_label = ''
            self.date_str = ''

        if amount is None:
            self.amount_str = _("Transaction unrelated to your wallet")
        elif amount > 0:
            self.is_mine = False
            self.amount_str = format_amount(amount)
        else:
            self.is_mine = True
            self.amount_str = format_amount(-amount)
        self.fee_str = format_amount(fee) if fee is not None else _('unknown')
        self.can_sign = self.wallet.can_sign(self.tx)
        self.ids.output_list.update(self.tx.get_outputs_for_UI())
Exemple #7
0
 def new_request(self):
     amount = self.amount
     amount = self.app.get_amount(amount) if amount else 0
     message = self.message
     try:
         addr = self.address or self.app.wallet.get_unused_address()
         if not addr:
             if not self.app.wallet.is_deterministic():
                 addr = self.app.wallet.get_receiving_address()
             else:
                 self.app.show_info(
                     _('No address available. Please remove some of your pending requests.'
                       ))
                 return
         self.address = addr
         req = self.app.wallet.make_payment_request(addr, amount, message,
                                                    self.expiry())
         self.app.wallet.add_payment_request(req)
         key = addr
     except InvoiceError as e:
         self.app.show_error(
             _('Error creating payment request') + ':\n' + str(e))
         return
     self.clear()
     self.update()
     self.app.show_request(key)
Exemple #8
0
    def update(self):
        format_amount = self.app.format_amount_and_units
        tx_hash, self.status_str, self.description, self.can_broadcast, amount, fee, height, conf, timestamp, exp_n = self.wallet.get_tx_info(self.tx)
        self.tx_hash = tx_hash or ''
        if timestamp:
            self.date_label = _('Date')
            self.date_str = datetime.fromtimestamp(timestamp).isoformat(' ')[:-3]
        elif exp_n:
            self.date_label = _('Mempool depth')
            self.date_str = _('{} from tip').format('%.2f MB'%(exp_n/1000000))
        else:
            self.date_label = ''
            self.date_str = ''

        if amount is None:
            self.amount_str = _("Transaction unrelated to your wallet")
        elif amount > 0:
            self.is_mine = False
            self.amount_str = format_amount(amount)
        else:
            self.is_mine = True
            self.amount_str = format_amount(-amount)
        self.fee_str = format_amount(fee) if fee is not None else _('unknown')
        self.can_sign = self.wallet.can_sign(self.tx)
        self.ids.output_list.update(self.tx.outputs())
Exemple #9
0
    def selection_changed(self, nodes):
        w = self.app.wallet
        psman = w.psman
        self.hide_menu()
        self.coins_selected = [self.utxos[i] for i in nodes]
        if not self.coins_selected:
            self.selected_str = ''
            self.ids.clear_btn.disabled = True
            return
        else:
            self.selected_str = f' ({len(self.coins_selected)})'
            self.ids.clear_btn.disabled = False

        coins = self.coins_selected
        if len(coins) != 1:
            return
        r = coins[0].ps_rounds
        if r is None:
            return
        if r in [PSCoinRounds.OTHER, PSCoinRounds.MIX_ORIGIN] or r >= 0:
            coin_value = coins[0].value_sats()
            if coin_value >= psman.min_new_denoms_from_coins_val:
                cmenu = [(_('Create New Denoms'), self.create_new_denoms)]
            elif coin_value >= psman.min_new_collateral_from_coins_val:
                cmenu = [(_('Create New Collateral'),
                          self.create_new_collateral)]
            self.context_menu = ContextMenu(None, cmenu)
            self.cmbox.add_widget(self.context_menu)
Exemple #10
0
    def update_abs_cnt(self):
        psman = self.psman
        method = psman.calc_denoms_method
        show_abs = (method == psman.CalcDenomsMethod.ABS)
        self.clear_widgets()
        self.cols = 2
        self.add_widget(Factory.Label(size_hint_y=None, height='48dp'))
        self.add_widget(Factory.Label(text=_('Existing count:'),
                                      size_hint_y=None, height='48dp'))
        if show_abs:
            self.cols = 3
            self.add_widget(Factory.Label(text=_('Absolute count:'),
                                          size_hint_y=None, height='48dp'))

        denoms = psman.calc_denoms_by_values()
        abs_cnt = psman.abs_denoms_cnt
        for i, d in enumerate(PS_DENOMS_VALS[::-1]):
            dv_lb = Factory.Label(text=self.format_amount(d),
                                  size_hint_y=None, height='48dp')
            self.add_widget(dv_lb)

            d_le = Factory.Label(text=str(denoms[d]) if denoms else '0',
                                 size_hint_y=None, height='48dp')
            self.denoms_le[d] = d_le
            self.add_widget(d_le)
            if show_abs:
                abs_sb = Factory.DenomCount()
                abs_sb.disabled = psman.state in psman.mixing_running_states
                abs_sb.val = abs_cnt[d]
                abs_sb.bind(val=partial(self.on_abs_sb_changed, d))
                self.abs_sb[d] = abs_sb
                self.add_widget(abs_sb)
Exemple #11
0
 def init_storage_from_path(self, path):
     self.storage = WalletStorage(path)
     self.basename = self.storage.basename()
     if not self.storage.file_exists():
         self.require_password = False
         self.message = _('Press Next to create')
     elif self.storage.is_encrypted():
         if not self.storage.is_encrypted_with_user_pw():
             raise Exception(
                 "Kivy GUI does not support this type of encrypted wallet files."
             )
         self.require_password = True
         self.pw_check = self.storage.check_password
         self.message = self.enter_pw_message
     else:
         # it is a bit wasteful load the wallet here and load it again in main_window,
         # but that is fine, because we are progressively enforcing storage encryption.
         db = WalletDB(self.storage.read(), manual_upgrades=False)
         if db.upgrade_done:
             self.storage.backup_old_version()
             self.app.show_backup_msg()
         if db.check_unfinished_multisig():
             self.require_password = False
         else:
             wallet = Wallet(db,
                             self.storage,
                             config=self.app.electrum_config)
             self.require_password = wallet.has_password()
             self.pw_check = wallet.check_password
         self.message = (self.enter_pw_message if self.require_password else
                         _('Wallet not encrypted'))
Exemple #12
0
 def update(self, *args, **kwargs):
     self.vbox.clear_widgets()
     self.vbox.add_widget(DashPeerCard(_('Peer'),
                                       _('User Agent'),
                                       is_title=True))
     for peer, ua in self.dn_dlg.peers:
         self.vbox.add_widget(DashPeerCard(peer, ua))
Exemple #13
0
    def update_action_button(self):
        action_button = self.ids.action_button
        options = (
            ActionButtonOption(text=_('Sign'), func=lambda btn: self.do_sign(), enabled=self.can_sign),
            ActionButtonOption(text=_('Broadcast'), func=lambda btn: self.do_broadcast(), enabled=self.can_broadcast),
            ActionButtonOption(text=_('Remove'), func=lambda btn: self.remove_local_tx(), enabled=self.is_local_tx),
        )
        num_options = sum(map(lambda o: bool(o.enabled), options))
        # if no options available, hide button
        if num_options == 0:
            action_button.disabled = True
            action_button.opacity = 0
            return
        action_button.disabled = False
        action_button.opacity = 1

        if num_options == 1:
            # only one option, button will correspond to that
            for option in options:
                if option.enabled:
                    action_button.text = option.text
                    self._action_button_fn = option.func
        else:
            # multiple options. button opens dropdown which has one sub-button for each
            dropdown = DropDown()
            action_button.text = _('Options')
            self._action_button_fn = dropdown.open
            for option in options:
                if option.enabled:
                    btn = Button(text=option.text, size_hint_y=None, height='48dp')
                    btn.bind(on_release=option.func)
                    dropdown.add_widget(btn)
Exemple #14
0
 def update(self):
     self.menu_actions = [(_('Use'), self.do_use),
                          (_('Details'), self.do_view)]
     wallet = self.app.wallet
     if self.show_change == 0:
         _list = wallet.get_receiving_addresses()
     elif self.show_change == 1:
         _list = wallet.get_change_addresses()
     else:
         _list = wallet.get_addresses()
     search = self.message
     container = self.ids.search_container
     n = 0
     cards = []
     for address in _list:
         label = wallet.labels.get(address, '')
         balance = sum(wallet.get_addr_balance(address))
         is_used_and_empty = wallet.is_used(address) and balance == 0
         if self.show_used == 1 and (balance or is_used_and_empty):
             continue
         if self.show_used == 2 and balance == 0:
             continue
         if self.show_used == 3 and not is_used_and_empty:
             continue
         card = self.get_card(address, balance, is_used_and_empty, label)
         if search and not self.ext_search(card, search):
             continue
         cards.append(card)
         n += 1
     container.data = cards
     if not n:
         self.app.show_error('No address matching your search')
 def do_send(self):
     if self.screen.is_pr:
         if self.payment_request.has_expired():
             self.app.show_error(_('Payment request has expired'))
             return
         outputs = self.payment_request.get_outputs()
     else:
         address = str(self.screen.address)
         if not address:
             self.app.show_error(
                 _('Recipient not specified.') + ' ' +
                 _('Please scan a PACGlobal address or a payment request'))
             return
         if not bitcoin.is_address(address):
             self.app.show_error(
                 _('Invalid PACGlobal Address') + ':\n' + address)
             return
         try:
             amount = self.app.get_amount(self.screen.amount)
         except:
             self.app.show_error(
                 _('Invalid amount') + ':\n' + self.screen.amount)
             return
         outputs = [TxOutput(bitcoin.TYPE_ADDRESS, address, amount)]
     message = self.screen.message
     amount = sum(map(lambda x: x[2], outputs))
     self._do_send(amount, message, outputs)
Exemple #16
0
 def update(self):
     self.menu_actions = [(_('Show'), self.do_show), (_('Delete'), self.do_delete)]
     requests_list = self.ids.requests_container
     requests_list.clear_widgets()
     _list = self.app.wallet.get_sorted_requests(self.app.electrum_config)
     for pr in _list:
         ci = self.get_card(pr)
         requests_list.add_widget(ci)
Exemple #17
0
 def get_card(self, addr, balance, is_used, label):
     ci = {}
     ci['screen'] = self
     ci['address'] = addr
     ci['memo'] = label
     ci['amount'] = self.app.format_amount_and_units(balance)
     ci['status'] = _('Used') if is_used else _('Funded') if balance > 0 else _('Unused')
     return ci
Exemple #18
0
 def get_card(self, addr, balance, is_used, label):
     ci = {}
     ci['screen'] = self
     ci['address'] = addr
     ci['memo'] = label
     ci['amount'] = self.app.format_amount_and_units(balance)
     ci['status'] = _('Used') if is_used else _(
         'Funded') if balance > 0 else _('Unused')
     return ci
Exemple #19
0
 def show_keep_amount_popup(self, *args):
     psman = self.psman
     if psman.calc_denoms_method == psman.CalcDenomsMethod.ABS:
         self.app.show_info(_('Value is calculated from denoms count'))
         return
     if psman.state in psman.mixing_running_states:
         self.app.show_info(_('To change value stop mixing process'))
         return
     KeepAmountPopup(self).open()
Exemple #20
0
 def update_action_dropdown(self):
     action_dropdown = self.ids.action_dropdown  # type: ActionDropdown
     # note: button texts need to be short; there is only horizontal space for ~13 chars
     options = (
         ActionButtonOption(text=_('Sign'), func=lambda btn: self.do_sign(), enabled=self.can_sign),
         ActionButtonOption(text=_('Broadcast'), func=lambda btn: self.do_broadcast(), enabled=self.can_broadcast),
         ActionButtonOption(text=_('Remove'), func=lambda btn: self.remove_local_tx(), enabled=self.can_remove_tx),
     )
     action_dropdown.update(options=options)
Exemple #21
0
 def update_status(self):
     req = self.app.wallet.get_request(self.key)
     self.status = self.app.wallet.get_request_status(self.key)
     self.status_str = req.get_status_str(self.status)
     self.status_color = pr_color[self.status]
     if self.status == PR_UNPAID:
         address = req.get_address()
         if self.app.wallet.is_used(address):
             self.warning = _('Warning') + ': ' + _('This address is being reused')
Exemple #22
0
 def __init__(self, msg, callback, *,
              yes_str: str = None, no_str: str = None,
              title: str = None):
     Factory.Popup.__init__(self)
     self.yes_str = yes_str or _('Yes')
     self.no_str = no_str or _('No')
     self.title = title or _('Question')
     self.message = msg
     self.callback = callback
Exemple #23
0
 def update(self):
     self.menu_actions = [(_('Show'), self.do_show),
                          (_('Delete'), self.do_delete)]
     requests_list = self.ids.requests_container
     requests_list.clear_widgets()
     _list = self.app.wallet.get_sorted_requests(self.app.electrum_config)
     for pr in _list:
         ci = self.get_card(pr)
         requests_list.add_widget(ci)
 def send_report(self):
     try:
         response = BaseCrashReporter.send_report(self, "/crash.json").json()
     except requests.exceptions.RequestException:
         self.show_popup(_('Unable to send report'), _("Please check your network connection."))
     else:
         self.show_popup(_('Report sent'), response["text"])
         if response["location"]:
             self.open_url(response["location"])
     self.dismiss()
Exemple #25
0
 def send_report(self):
     try:
         response = BaseCrashReporter.send_report(self,
                                                  "/crash.json").json()
     except requests.exceptions.RequestException:
         self.show_popup(_('Unable to send report'),
                         _("Please check your network connection."))
     else:
         self.show_popup(_('Report sent'), response["text"])
         if response["location"]:
             self.open_url(response["location"])
     self.dismiss()
 def on_password(self, pw: str):
     #
     if not self.require_password:
         self.success = True
         self.message = _('Please wait...')
         self.dismiss()
         return
     # if setting new generic password, enforce min length
     if self.level > 0:
         if len(pw) < 6:
             self.app.show_error(_('Password is too short (min {} characters)').format(6))
             return
     # don't enforce minimum length on existing
     self.do_check(pw)
Exemple #27
0
 def on_text(self, new_val):
     if not new_val:
         self.err.text = _('Missing value')
         self.err.subs_val = self.min_val
         return
     new_val = int(new_val)
     if new_val < self.min_val:
         self.err.text = _('Value too small')
         self.err.subs_val = self.min_val
     elif new_val > self.max_val:
         self.err.text = _('Value too large')
         self.err.subs_val = self.max_val
     else:
         self.err.text = ''
         self.value = new_val
Exemple #28
0
 def send_report(self):
     try:
         loop = self.main_window.network.asyncio_loop
         proxy = self.main_window.network.proxy
         response = json.loads(
             BaseCrashReporter.send_report(self, loop, proxy,
                                           "/crash.json"))
     except (ValueError, ClientError):
         self.show_popup(_('Unable to send report'),
                         _("Please check your network connection."))
     else:
         self.show_popup(_('Report sent'), response["text"])
         if response["location"]:
             self.open_url(response["location"])
     self.dismiss()
Exemple #29
0
 def update_tx(self):
     try:
         # make unsigned transaction
         tx = self.make_tx()
     except NotEnoughFunds:
         self.warning = _("Not enough funds")
         self.ids.ok_button.disabled = True
         return
     except Exception as e:
         self.ids.ok_button.disabled = True
         self.app.logger.exception('')
         self.app.show_error(repr(e))
         return
     self.ids.ok_button.disabled = False
     amount = self.amount if self.amount != '!' else tx.output_value()
     tx_size = tx.estimated_size()
     fee = tx.get_fee()
     self.ids.fee_label.text = self.app.format_amount_and_units(fee)
     feerate = Decimal(fee) / Decimal(tx_size / 1000)  # duffs/kB
     self.ids.feerate_label.text = f'{feerate:.1f} duffs/kB'
     self.ids.amount_label.text = self.app.format_amount_and_units(amount)
     x_fee = run_hook('get_tx_extra_fee', self.app.wallet, tx)
     if x_fee:
         x_fee_address, x_fee_amount = x_fee
         self.extra_fee = self.app.format_amount_and_units(x_fee_amount)
     else:
         self.extra_fee = ''
     fee_warning_tuple = self.app.wallet.get_tx_fee_warning(
         invoice_amt=amount, tx_size=tx_size, fee=fee)
     if fee_warning_tuple:
         allow_send, long_warning, short_warning = fee_warning_tuple
         self.warning = long_warning
     else:
         self.warning = ''
     self.tx = tx
 def update(self):
     if not self.screen.address:
         self.get_new_address()
     else:
         status = self.app.wallet.get_request_status(self.screen.address)
         self.screen.status = _(
             'Payment received') if status == PR_PAID else ''
Exemple #31
0
    def __init__(self, app):
        super(PluginsDialog, self).__init__()
        self.app = app
        self.config = app.electrum_config
        self.network = app.network
        plugins = app.plugins
        grid = self.ids.grid
        for i, plugin_dict in enumerate(plugins.descriptions.values()):
            if plugin_dict.get('registers_keystore'):
                continue
            try:
                module_name = plugin_dict['__name__']
                prefix, _separator, name = module_name.rpartition('.')
                settings_box = SettingsBox()
                plugin_widget = PluginWidget(app=app, name=name,
                                             fullname=plugin_dict['fullname'],
                                             settings_box=settings_box)
                grid.add_widget(plugin_widget)
                grid.add_widget(settings_box)

                help_text = plugin_dict['description']
                requires = plugin_dict.get('requires')
                if requires:
                    help_text += '\n\n' + _('Requires') + ':\n'
                    help_text += '\n'.join(map(lambda x: x[1], requires))
                plugin_help = PluginHelp(app=app, help_text=help_text)
                grid.add_widget(plugin_help)
            except Exception as e:
                self.logger.exception(f'cannot display plugin {name}')
Exemple #32
0
    def remove_local_tx(self):
        txid = self.tx.txid()
        num_child_txs = len(self.wallet.get_depending_transactions(txid))
        question = _("Are you sure you want to remove this transaction?")
        if num_child_txs > 0:
            question = (_("Are you sure you want to remove this transaction and {} child transactions?")
                        .format(num_child_txs))

        def on_prompt(b):
            if b:
                self.wallet.remove_transaction(txid)
                self.wallet.save_db()
                self.app._trigger_update_wallet()  # FIXME private...
                self.dismiss()
        d = Question(question, on_prompt)
        d.open()
 def get_card(self, tx_hash, tx_type, tx_mined_status, value, balance,
              islock):
     status, status_str = self.app.wallet.get_tx_status(
         tx_hash, tx_mined_status, islock)
     icon = "atlas://electrum_dash/gui/kivy/theming/light/" + TX_ICONS[
         status]
     label = self.app.wallet.get_label(tx_hash) if tx_hash else _(
         'Pruned transaction outputs')
     ri = {}
     ri['screen'] = self
     ri['tx_hash'] = tx_hash
     ri['icon'] = icon
     ri['date'] = status_str
     ri['message'] = label
     ri['confirmations'] = tx_mined_status.conf
     if value is not None:
         ri['is_mine'] = value < 0
         if value < 0: value = -value
         ri['amount'] = self.app.format_amount_and_units(value)
         if self.app.fiat_unit:
             fx = self.app.fx
             fiat_value = value / Decimal(
                 bitcoin.COIN) * self.app.wallet.price_at_timestamp(
                     tx_hash, fx.timestamp_rate)
             fiat_value = Fiat(fiat_value, fx.ccy)
             ri['quote_text'] = fiat_value.to_ui_string()
     return ri
Exemple #34
0
 def show_qr(self):
     from electrum_dash.bitcoin import base_encode, bfh
     raw_tx = str(self.tx)
     text = bfh(raw_tx)
     text = base_encode(text, base=43)
     self.app.qr_dialog(_("Raw Transaction"),
                        text,
                        text_for_clipboard=raw_tx)
Exemple #35
0
 def fx_status(self):
     fx = self.app.fx
     if fx.is_enabled():
         source = fx.exchange.name()
         ccy = fx.get_currency()
         return '%s [%s]' %(ccy, source)
     else:
         return _('None')
Exemple #36
0
 def show_log(self):
     if self.log:
         log_str = _('Payment log:') + '\n\n'
         for payment_attempt_log in self.log:
             route_str, chan_str, message = payment_attempt_log.formatted_tuple(
             )
             log_str += chan_str + '  ---  ' + message + '\n'
         self.app.show_info(log_str)
Exemple #37
0
 def unit_dialog(self, item, dt):
     if self._unit_dialog is None:
         def cb(text):
             self.app._set_bu(text)
             item.bu = self.app.base_unit
         self._unit_dialog = ChoiceDialog(_('Denomination'), base_units_list,
                                          self.app.base_unit, cb, keep_choice_order=True)
     self._unit_dialog.open()
Exemple #38
0
    def _do_send(self, amount, message, outputs):
        # make unsigned transaction
        config = self.app.electrum_config
        coins = self.app.wallet.get_spendable_coins(None, config)
        try:
            tx = self.app.wallet.make_unsigned_transaction(coins, outputs, config, None)
        except NotEnoughFunds:
            self.app.show_error(_("Not enough funds"))
            return
        except Exception as e:
            traceback.print_exc(file=sys.stdout)
            self.app.show_error(str(e))
            return
        fee = tx.get_fee()
        msg = [
            _("Amount to be sent") + ": " + self.app.format_amount_and_units(amount),
            _("Mining fee") + ": " + self.app.format_amount_and_units(fee),
        ]
        x_fee = run_hook('get_tx_extra_fee', self.app.wallet, tx)
        if x_fee:
            x_fee_address, x_fee_amount = x_fee
            msg.append(_("Additional fees") + ": " + self.app.format_amount_and_units(x_fee_amount))

        if fee >= config.get('confirm_fee', 10000):
            msg.append(_('Warning')+ ': ' + _("The fee for this transaction seems unusually high."))
        msg.append(_("Enter your PIN code to proceed"))
        self.app.protected('\n'.join(msg), self.send_tx, (tx, message))
Exemple #39
0
 def do_delete(self, req):
     from .question import Question
     def cb(result):
         if result:
             self.app.wallet.remove_payment_request(req.address, self.app.electrum_config)
             self.hide_menu()
             self.update()
     d = Question(_('Delete request'), cb)
     d.open()
Exemple #40
0
 def label_dialog(self, obj):
     from .dialogs.label_dialog import LabelDialog
     key = obj.tx_hash
     text = self.app.wallet.get_label(key)
     def callback(text):
         self.app.wallet.set_label(key, text)
         self.update()
     d = LabelDialog(_('Enter Transaction Label'), text, callback)
     d.open()
Exemple #41
0
 def language_dialog(self, item, dt):
     if self._language_dialog is None:
         l = self.config.get('language', 'en_UK')
         def cb(key):
             self.config.set_key("language", key, True)
             item.lang = self.get_language_name()
             self.app.language = key
         self._language_dialog = ChoiceDialog(_('Language'), languages, l, cb)
     self._language_dialog.open()
Exemple #42
0
 def coinselect_dialog(self, item, dt):
     if self._coinselect_dialog is None:
         choosers = sorted(coinchooser.COIN_CHOOSERS.keys())
         chooser_name = coinchooser.get_name(self.config)
         def cb(text):
             self.config.set_key('coin_chooser', text)
             item.status = text
         self._coinselect_dialog = ChoiceDialog(_('Coin selection'), choosers, chooser_name, cb)
     self._coinselect_dialog.open()
Exemple #43
0
 def on_currency(self, ccy):
     b = (ccy != _('None'))
     self.fx.set_enabled(b)
     if b:
         if ccy != self.fx.get_currency():
             self.fx.set_currency(ccy)
         self.app.fiat_unit = ccy
     else:
         self.app.is_fiat = False
     Clock.schedule_once(lambda dt: self.add_exchanges())
Exemple #44
0
 def on_address(self, addr):
     req = self.app.wallet.get_payment_request(addr, self.app.electrum_config)
     self.screen.status = ''
     if req:
         self.screen.message = req.get('memo', '')
         amount = req.get('amount')
         self.screen.amount = self.app.format_amount_and_units(amount) if amount else ''
         status = req.get('status', PR_UNKNOWN)
         self.screen.status = _('Payment received') if status == PR_PAID else ''
     Clock.schedule_once(lambda dt: self.update_qr())
Exemple #45
0
 def do_send(self):
     if self.screen.is_pr:
         if self.payment_request.has_expired():
             self.app.show_error(_('Payment request has expired'))
             return
         outputs = self.payment_request.get_outputs()
     else:
         address = str(self.screen.address)
         if not address:
             self.app.show_error(_('Recipient not specified.') + ' ' + _('Please scan a Dash address or a payment request'))
             return
         if not bitcoin.is_address(address):
             self.app.show_error(_('Invalid Dash Address') + ':\n' + address)
             return
         try:
             amount = self.app.get_amount(self.screen.amount)
         except:
             self.app.show_error(_('Invalid amount') + ':\n' + self.screen.amount)
             return
         outputs = [TxOutput(bitcoin.TYPE_ADDRESS, address, amount)]
     message = self.screen.message
     amount = sum(map(lambda x:x[2], outputs))
     self._do_send(amount, message, outputs)
 def on_password(self, pw):
     if len(pw) == 6:
         if self.check_password(pw):
             if self.is_change == 0:
                 self.success = True
                 self.pw = pw
                 self.message = _('Please wait...')
                 self.dismiss()
             elif self.is_change == 1:
                 self.pw = pw
                 self.message = _('Enter new PIN')
                 self.ids.kb.password = ''
                 self.is_change = 2
             elif self.is_change == 2:
                 self.new_password = pw
                 self.message = _('Confirm new PIN')
                 self.ids.kb.password = ''
                 self.is_change = 3
             elif self.is_change == 3:
                 self.success = pw == self.new_password
                 self.dismiss()
         else:
             self.app.show_error(_('Wrong PIN'))
             self.ids.kb.password = ''
Exemple #47
0
 def set_URI(self, text):
     if not self.app.wallet:
         self.payment_request_queued = text
         return
     import electrum_dash
     try:
         uri = electrum_dash.util.parse_URI(text, self.app.on_pr)
     except:
         self.app.show_info(_("Not a Dash URI"))
         return
     amount = uri.get('amount')
     self.screen.address = uri.get('address', '')
     self.screen.message = uri.get('message', '')
     self.screen.amount = self.app.format_amount_and_units(amount) if amount else ''
     self.payment_request = None
     self.screen.is_pr = False
Exemple #48
0
 def save_request(self):
     addr = self.screen.address
     if not addr:
         return False
     amount = self.screen.amount
     message = self.screen.message
     amount = self.app.get_amount(amount) if amount else 0
     req = self.app.wallet.make_payment_request(addr, amount, message, None)
     try:
         self.app.wallet.add_payment_request(req, self.app.electrum_config)
         added_request = True
     except Exception as e:
         self.app.show_error(_('Error adding payment request') + ':\n' + str(e))
         added_request = False
     finally:
         self.app.update_tab('requests')
     return added_request
Exemple #49
0
 def get_card(self, tx_hash, tx_mined_status, value, balance):
     status, status_str = self.app.wallet.get_tx_status(tx_hash, tx_mined_status)
     icon = "atlas://electrum_dash/gui/kivy/theming/light/" + TX_ICONS[status]
     label = self.app.wallet.get_label(tx_hash) if tx_hash else _('Pruned transaction outputs')
     ri = {}
     ri['screen'] = self
     ri['tx_hash'] = tx_hash
     ri['icon'] = icon
     ri['date'] = status_str
     ri['message'] = label
     ri['confirmations'] = tx_mined_status.conf
     if value is not None:
         ri['is_mine'] = value < 0
         if value < 0: value = - value
         ri['amount'] = self.app.format_amount_and_units(value)
         if self.app.fiat_unit:
             fx = self.app.fx
             fiat_value = value / Decimal(bitcoin.COIN) * self.app.wallet.price_at_timestamp(tx_hash, fx.timestamp_rate)
             fiat_value = Fiat(fiat_value, fx.ccy)
             ri['quote_text'] = str(fiat_value)
     return ri
Exemple #50
0
 def do_save(self):
     if not self.screen.address:
         return
     if self.screen.is_pr:
         # it should be already saved
         return
     # save address as invoice
     from electrum_dash.paymentrequest import make_unsigned_request, PaymentRequest
     req = {'address':self.screen.address, 'memo':self.screen.message}
     amount = self.app.get_amount(self.screen.amount) if self.screen.amount else 0
     req['amount'] = amount
     pr = make_unsigned_request(req).SerializeToString()
     pr = PaymentRequest(pr)
     self.app.wallet.invoices.add(pr)
     self.app.show_info(_("Invoice saved"))
     if pr.is_pr():
         self.screen.is_pr = True
         self.payment_request = pr
     else:
         self.screen.is_pr = False
         self.payment_request = None
Exemple #51
0
 def __do_sign(self, password):
     try:
         self.app.wallet.sign_transaction(self.tx, password)
     except InvalidPassword:
         self.app.show_error(_("Invalid PIN"))
     self.update()
Exemple #52
0
 def do_paste(self):
     contents = self.app._clipboard.paste()
     if not contents:
         self.app.show_info(_("Clipboard is empty"))
         return
     self.set_URI(contents)
Exemple #53
0
''')

from kivy.properties import BooleanProperty
from electrum_dash.gui.kivy.i18n import _
from electrum_dash.util import format_time
from electrum_dash.paymentrequest import PR_UNPAID, PR_PAID, PR_UNKNOWN, PR_EXPIRED
from electrum_dash.gui.kivy.uix.context_menu import ContextMenu

pr_icon = {
    PR_UNPAID: 'atlas://electrum_dash/gui/kivy/theming/light/important',
    PR_UNKNOWN: 'atlas://electrum_dash/gui/kivy/theming/light/important',
    PR_PAID: 'atlas://electrum_dash/gui/kivy/theming/light/confirmed',
    PR_EXPIRED: 'atlas://electrum_dash/gui/kivy/theming/light/close'
}
request_text = {
    PR_UNPAID: _('Pending'),
    PR_UNKNOWN: _('Unknown'),
    PR_PAID: _('Received'),
    PR_EXPIRED: _('Expired')
}


class RequestsDialog(Factory.Popup):

    def __init__(self, app, screen, callback):
        Factory.Popup.__init__(self)
        self.app = app
        self.screen = screen
        self.callback = callback
        self.cards = {}
        self.context_menu = None
Exemple #54
0
 def do_save(self):
     if self.save_request():
         self.app.show_info(_('Request was saved.'))
Exemple #55
0
 def do_new(self):
     addr = self.get_new_address()
     if not addr:
         self.app.show_info(_('Please use the existing requests first.'))
Exemple #56
0
 def do_copy(self):
     uri = self.get_URI()
     self.app._clipboard.copy(uri)
     self.app.show_info(_('Request copied to clipboard'))
Exemple #57
0
 def do_share(self):
     uri = self.get_URI()
     self.app.do_share(uri, _("Share Dash Request"))
Exemple #58
0
 def show_qr(self):
     from electrum_dash.bitcoin import base_encode, bfh
     raw_tx = str(self.tx)
     text = bfh(raw_tx)
     text = base_encode(text, base=43)
     self.app.qr_dialog(_("Raw Transaction"), text, text_for_clipboard=raw_tx)
Exemple #59
0
 def add_currencies(self):
     currencies = [_('None')] + self.fx.get_currencies(True)
     my_ccy = self.fx.get_currency() if self.fx.is_enabled() else _('None')
     self.ids.ccy.values = currencies
     self.ids.ccy.text = my_ccy
Exemple #60
0
 def update(self):
     if not self.screen.address:
         self.get_new_address()
     else:
         status = self.app.wallet.get_request_status(self.screen.address)
         self.screen.status = _('Payment received') if status == PR_PAID else ''