Ejemplo n.º 1
0
    def update(self):
        self.menu_actions = [('Pay', self.do_pay), ('Details', self.do_view), ('Delete', self.do_delete)]
        invoices_list = self.screen.ids.invoices_container
        invoices_list.clear_widgets()

        _list = self.app.invoices.sorted_list()
        for pr in _list:
            ci = Factory.InvoiceItem()
            ci.key = pr.get_id()
            ci.requestor = pr.get_requestor()
            ci.memo = pr.get_memo()
            amount = pr.get_amount()
            if amount:
                ci.amount = self.app.format_amount_and_units(amount)
                status = self.app.invoices.get_status(ci.key)
                ci.status = invoice_text[status]
                ci.icon = pr_icon[status]
            else:
                ci.amount = _('No Amount')
                ci.status = ''
            exp = pr.get_expiration_date()
            ci.date = format_time(exp) if exp else _('Never')
            ci.screen = self
            invoices_list.add_widget(ci)

        if not _list:
            msg = _('This screen shows the list of payment requests that have been sent to you. You may also use it to store contact addresses.')
            invoices_list.add_widget(EmptyLabel(text=msg))
Ejemplo n.º 2
0
    def update(self):
        self.menu_actions = [('Show', self.do_show), ('Details', self.do_view), ('Delete', self.do_delete)]
        requests_list = self.screen.ids.requests_container
        requests_list.clear_widgets()
        _list = self.app.wallet.get_sorted_requests(self.app.electrum_config) if self.app.wallet else []
        for req in _list:
            address = req['address']
            timestamp = req.get('time', 0)
            amount = req.get('amount')
            expiration = req.get('exp', None)
            status = req.get('status')
            signature = req.get('sig')

            ci = Factory.RequestItem()
            ci.address = address
            ci.memo = self.app.wallet.get_label(address)
            if amount:
                status = req.get('status')
                ci.status = request_text[status]
            else:
                received = self.app.wallet.get_addr_received(address)
                ci.status = self.app.format_amount_and_units(amount)

            ci.icon = pr_icon[status]
            ci.amount = self.app.format_amount_and_units(amount) if amount else _('No Amount')
            ci.date = format_time(timestamp)
            ci.screen = self
            requests_list.add_widget(ci)

        if not _list:
            msg = _('This screen shows the list of payment requests you made.')
            requests_list.add_widget(EmptyLabel(text=msg))
Ejemplo n.º 3
0
    def notify_transactions(self, *dt):
        if not self.network or not self.network.is_connected():
            return
        # temporarily disabled for merge
        return
        iface = self.network
        ptfn = iface.pending_transactions_for_notifications
        if len(ptfn) > 0:
            # Combine the transactions if there are more then three
            tx_amount = len(ptfn)
            if(tx_amount >= 3):
                total_amount = 0
                for tx in ptfn:
                    is_relevant, is_mine, v, fee = self.wallet.get_tx_value(tx)
                    if(v > 0):
                        total_amount += v
                self.notify(_("{txs}s new transactions received. Total amount"
                              "received in the new transactions {amount}s"
                              "{unit}s").format(txs=tx_amount,
                                    amount=self.format_amount(total_amount),
                                    unit=self.base_unit()))

                iface.pending_transactions_for_notifications = []
            else:
              for tx in iface.pending_transactions_for_notifications:
                  if tx:
                      iface.pending_transactions_for_notifications.remove(tx)
                      is_relevant, is_mine, v, fee = self.wallet.get_tx_value(tx)
                      if(v > 0):
                          self.notify(
                              _("{txs} new transaction received. {amount} {unit}").
                              format(txs=tx_amount, amount=self.format_amount(v),
                                     unit=self.base_unit))
Ejemplo n.º 4
0
    def parse_history(self, items):
        for item in items:
            tx_hash, conf, value, timestamp, balance = item
            time_str = _("unknown")
            if conf > 0:
                try:
                    time_str = datetime.datetime.fromtimestamp(timestamp).isoformat(' ')[:-3]
                except Exception:
                    time_str = _("error")
            if conf == -1:
                time_str = _('Not Verified')
                icon = "atlas://gui/kivy/theming/light/close"
            elif conf == 0:
                time_str = _('Unconfirmed')
                icon = "atlas://gui/kivy/theming/light/unconfirmed"
            elif conf < 6:
                conf = max(1, conf)
                icon = "atlas://gui/kivy/theming/light/clock{}".format(conf)
            else:
                icon = "atlas://gui/kivy/theming/light/confirmed"

            label = self.app.wallet.get_label(tx_hash) if tx_hash else _('Pruned transaction outputs')
            date = timestamp_to_datetime(timestamp)
            quote_text = ''
            if self.app.fiat_unit and date:
                rate = run_hook('history_rate', date)
                if rate:
                    s = run_hook('value_str', value, rate)
                    quote_text = '' if s is None else s + ' ' + self.app.fiat_unit
            yield (conf, icon, time_str, label, value, tx_hash, quote_text)
Ejemplo n.º 5
0
 def do_new(self):
     addr = self.get_new_address()
     if not addr:
         self.app.show_info(_('Please use the existing requests first.'))
     else:
         self.save_request()
         self.app.show_info(_('New request added to your list.'))
Ejemplo n.º 6
0
 def choose_seed(self):
     msg = ' '.join([
         _("Do you want to create a new seed, or to restore a wallet using an existing seed?")
     ])
     choices = [
         (_('Create a new seed'), 'create_seed'),
         (_('I already have a seed'), 'restore_seed'),
         (_('Watching-only wallet'), 'restore_xpub')
     ]
     self.choice_dialog(msg=msg, choices=choices, run_prev=self.new, run_next=self.run)
Ejemplo n.º 7
0
 def __init__(self, wizard, **kwargs):
     super(RestoreSeedDialog, self).__init__(wizard, **kwargs)
     self._test = kwargs['test']
     from electrum_ltc.mnemonic import Mnemonic
     from electrum_ltc.old_mnemonic import words as old_wordlist
     self.words = set(Mnemonic('en').wordlist).union(set(old_wordlist))
     self.ids.text_input_seed.text = test_seed if is_test else ''
     self.message = _('Please type your seed phrase using the virtual keyboard.')
     self.title = _('Enter Seed')
     self.ext = False
Ejemplo n.º 8
0
 def new(self):
     name = os.path.basename(self.storage.path)
     msg = "\n".join([
         _("Welcome to the Electrum installation wizard."),
         _("The wallet '%s' does not exist.") % name,
         _("What kind of wallet do you want to create?")
     ])
     choices = [
         (_('Standard wallet'), 'create_standard'),
         (_('Multi-signature wallet'), 'create_multisig'),
     ]
     self.choice_dialog(msg=msg, choices=choices, run_prev=self.cancel, run_next=self.run)
Ejemplo n.º 9
0
 def rbf_dialog(self, label, dt):
     if self._rbf_dialog is None:
         from checkbox_dialog import CheckBoxDialog
         def cb(x):
             self.config.set_key('use_rbf', x, True)
             label.status = self.rbf_status()
         msg = [_('If you check this box, your transactions will be marked as non-final,'),
                _('and you will have the possiblity, while they are unconfirmed, to replace them with transactions that pays higher fees.'),
                _('Note that some merchants do not accept non-final transactions until they are confirmed.')]
         fullname = _('Replace by fee')
         self._rbf_dialog = CheckBoxDialog(fullname, ' '.join(msg), self.config.get('use_rbf', False), cb)
     self._rbf_dialog.open()
Ejemplo n.º 10
0
 def _show_seed(self, label, password):
     if self.wallet.has_password() and password is None:
         return
     keystore = self.wallet.keystore
     try:
         seed = keystore.get_seed(password)
         passphrase = keystore.get_passphrase(password)
     except:
         self.show_error("Invalid PIN")
         return
     label.text = _('Seed') + ':\n' + seed
     if passphrase:
         label.text += '\n\n' + _('Passphrase') + ': ' + passphrase
Ejemplo n.º 11
0
    def broadcast(self, tx, pr=None):
        def on_complete(ok, txid):
            self.show_info(txid)
            if ok and pr:
                pr.set_paid(tx.hash())
                self.invoices.save()
                self.update_tab('invoices')

        if self.network and self.network.is_connected():
            self.show_info(_('Sending'))
            threading.Thread(target=self._broadcast_thread, args=(tx, on_complete)).start()
        else:
            self.show_info(_('Cannot broadcast transaction') + ':\n' + _('Not connected'))
Ejemplo n.º 12
0
 def description_dialog(self, screen):
     from uix.dialogs.label_dialog import LabelDialog
     text = screen.message
     def callback(text):
         screen.message = text
     d = LabelDialog(_('Enter description'), text, callback)
     d.open()
Ejemplo n.º 13
0
 def do_delete(self, obj):
     from dialogs.question import Question
     def cb():
         self.app.invoices.remove(obj.key)
         self.app.update_tab('invoices')
     d = Question(_('Delete invoice?'), cb)
     d.open()
Ejemplo n.º 14
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.keys(), self.app.base_unit, cb)
     self._unit_dialog.open()
Ejemplo n.º 15
0
    def __init__(self, **kwargs):
        # initialize variables
        self._clipboard = Clipboard
        self.info_bubble = None
        self.qrscanner = None
        self.nfcscanner = None
        self.tabs = None
        self.is_exit = False

        super(ElectrumWindow, self).__init__(**kwargs)

        title = _('Electrum-LTC App')
        self.electrum_config = config = kwargs.get('config', None)
        self.language = config.get('language', 'en')
        self.network = network = kwargs.get('network', None)
        self.plugins = kwargs.get('plugins', [])

        self.gui_object = kwargs.get('gui_object', None)

        #self.config = self.gui_object.config
        self.contacts = Contacts(self.electrum_config)
        self.invoices = InvoiceStore(self.electrum_config)

        # create triggers so as to minimize updation a max of 2 times a sec
        self._trigger_update_wallet =\
            Clock.create_trigger(self.update_wallet, .5)
        self._trigger_update_status =\
            Clock.create_trigger(self.update_status, .5)
        self._trigger_notify_transactions = \
            Clock.create_trigger(self.notify_transactions, 5)
        # cached dialogs
        self._settings_dialog = None
        self._password_dialog = None
Ejemplo n.º 16
0
 def _sign_tx(self, tx, password, on_success, on_failure):
     try:
         self.wallet.sign_transaction(tx, password)
     except InvalidPassword:
         Clock.schedule_once(lambda dt: on_failure(_("Invalid PIN")))
         return
     Clock.schedule_once(lambda dt: on_success(tx))
Ejemplo n.º 17
0
    def get_card(self, req):
        address = req['address']
        timestamp = req.get('time', 0)
        amount = req.get('amount')
        expiration = req.get('exp', None)
        status = req.get('status')
        signature = req.get('sig')

        ci = self.cards.get(address)
        if ci is None:
            ci = Factory.RequestItem()
            ci.screen = self
            ci.address = address
            self.cards[address] = ci

        ci.memo = self.app.wallet.get_label(address)
        if amount:
            status = req.get('status')
            ci.status = request_text[status]
        else:
            received = self.app.wallet.get_addr_received(address)
            ci.status = self.app.format_amount_and_units(amount)
        ci.icon = pr_icon[status]
        ci.amount = self.app.format_amount_and_units(amount) if amount else _('No Amount')
        ci.date = format_time(timestamp)
        return ci
Ejemplo n.º 18
0
 def do_delete(self, obj):
     from dialogs.question import Question
     def cb():
         self.app.wallet.remove_payment_request(obj.address, self.app.electrum_config)
         self.update()
     d = Question(_('Delete request?'), cb)
     d.open()
Ejemplo n.º 19
0
    def update(self, see_all=False):
        if self.app.wallet is None:
            return

        history = self.parse_history(reversed(
            self.app.wallet.get_history(self.app.current_account)))
        # repopulate History Card
        history_card = self.screen.ids.history_container
        history_card.clear_widgets()
        count = 0
        for item in history:
            count += 1
            conf, icon, date_time, message, value, tx, quote_text = item
            ri = Factory.HistoryItem()
            ri.icon = icon
            ri.date = date_time
            ri.message = message
            ri.value = value
            ri.quote_text = quote_text
            ri.confirmations = conf
            ri.tx_hash = tx
            ri.screen = self
            history_card.add_widget(ri)
            if count == 8 and not see_all:
                break

        if count == 0:
            msg = _('This screen shows your list of transactions. It is currently empty.')
            history_card.add_widget(EmptyLabel(text=msg))
Ejemplo n.º 20
0
 def on_ref_label(self, label, touch):
     if label.touched:
         label.touched = False
         self.qr_dialog(label.name, label.data, True)
     else:
         label.touched = True
         self._clipboard.copy(label.data)
         Clock.schedule_once(lambda dt: self.show_info(_('Text copied to clipboard.\nTap again to display it as QR code.')))
Ejemplo n.º 21
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()
Ejemplo n.º 22
0
 def new_wallet(self, app, dirname):
     def cb(text):
         if text:
             app.load_wallet_by_name(os.path.join(dirname, text))
     if self.ids.wallet_selector.selection:
         app.load_wallet_by_name(self.ids.wallet_selector.selection[0])
     else:
         d = LabelDialog(_('Enter wallet name'), '', cb)
         d.open()
Ejemplo n.º 23
0
 def _show_seed(self, label, password):
     if self.wallet.use_encryption and password is None:
         return
     try:
         seed = self.wallet.get_seed(password)
     except:
         self.show_error("Invalid PIN")
         return
     label.text = _('Seed') + ':\n' + seed
Ejemplo n.º 24
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()
Ejemplo n.º 25
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()
Ejemplo n.º 26
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()
Ejemplo n.º 27
0
 def on_keyboard(self, instance, key, keycode, codepoint, modifiers):
     if key == 27 and self.is_exit is False:
         self.is_exit = True
         self.show_info(_('Press again to exit'))
         return True
     # override settings button
     if key in (319, 282): #f1/settings button on android
         #self.gui.main_gui.toggle_settings(self)
         return True
Ejemplo n.º 28
0
 def add_cosigner(self):
     def on_xpub(xpub):
         self.wallet.add_cosigner(xpub)
         i = self.wallet.get_missing_cosigner()
         action = 'add_cosigner' if i else 'create_main_account'
         self.run(action)
     title = "ADD COSIGNER"
     message = _('Please paste your cosigners master public key, or scan it using the camera button.')
     self.add_xpub_dialog(run_prev=self.add_cosigners, run_next=on_xpub, title=title, message=message, test=Wallet.is_xpub)
Ejemplo n.º 29
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()
Ejemplo n.º 30
0
    def load_wallet_by_name(self, path, ask_if_wizard=False):
        if not path:
            return
        if self.wallet and self.wallet.storage.path == path:
            return
        wallet = self.daemon.load_wallet(path, None)
        if wallet:
            if wallet.has_password():
                self.password_dialog(wallet, _('Enter PIN code'),
                                     lambda x: self.load_wallet(wallet),
                                     self.stop)
            else:
                self.load_wallet(wallet)
        else:
            Logger.debug(
                'Electrum: Wallet not found or action needed. Launching install wizard'
            )

            def launch_wizard():
                storage = WalletStorage(path, manual_upgrades=True)
                wizard = Factory.InstallWizard(self.electrum_config,
                                               self.plugins, storage)
                wizard.bind(on_wizard_complete=self.on_wizard_complete)
                action = wizard.storage.get_action()
                wizard.run(action)

            if not ask_if_wizard:
                launch_wizard()
            else:
                from .uix.dialogs.question import Question

                def handle_answer(b: bool):
                    if b:
                        launch_wizard()
                    else:
                        try:
                            os.unlink(path)
                        except FileNotFoundError:
                            pass
                        self.stop()

                d = Question(_('Do you want to launch the wizard again?'),
                             handle_answer)
                d.open()
Ejemplo n.º 31
0
 def on_keyboard(self, instance, key, keycode, codepoint, modifiers):
     if key == 27 and self.is_exit is False:
         self.is_exit = True
         self.show_info(_('Press again to exit'))
         return True
     self.is_exit = False
     # override settings button
     if key in (319, 282):  #f1/settings button on android
         #self.gui.main_gui.toggle_settings(self)
         return True
Ejemplo n.º 32
0
 def update_status(self, *dt):
     if not self.wallet:
         self.status = _("No Wallet")
         return
     if self.network is None or not self.network.is_running():
         self.status = _("Offline")
     elif self.network.is_connected():
         server_height = self.network.get_server_height()
         server_lag = self.network.get_local_height() - server_height
         if not self.wallet.up_to_date or server_height == 0:
             self.status = _("Synchronizing...")
         elif server_lag > 1:
             self.status = _("Server lagging (%d blocks)" % server_lag)
         else:
             c, u, x = self.wallet.get_account_balance(self.current_account)
             text = self.format_amount(c + x + u)
             self.status = str(text.strip() + ' ' + self.base_unit)
     else:
         self.status = _("Not connected")
Ejemplo n.º 33
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 = unicode(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())
Ejemplo n.º 34
0
 def update_status(self, *dt):
     if not self.wallet:
         self.status = _("No Wallet")
         return
     if self.network is None or not self.network.is_running():
         self.status = _("Offline")
     elif self.network.is_connected():
         server_height = self.network.get_server_height()
         server_lag = self.network.get_local_height() - server_height
         if not self.wallet.up_to_date or server_height == 0:
             self.status = _("Synchronizing...")
         elif server_lag > 1:
             self.status = _("Server lagging (%d blocks)"%server_lag)
         else:
             c, u, x = self.wallet.get_account_balance(self.current_account)
             text = self.format_amount(c+x+u)
             self.status = str(text.strip() + ' ' + self.base_unit)
     else:
         self.status = _("Not connected")
Ejemplo n.º 35
0
 def do_rbf(self):
     from .bump_fee_dialog import BumpFeeDialog
     is_relevant, is_mine, v, fee = self.wallet.get_wallet_delta(self.tx)
     if fee is None:
         self.app.show_error(
             _("Can't bump fee: unknown fee for original transaction."))
         return
     size = self.tx.estimated_size()
     d = BumpFeeDialog(self.app, fee, size, self._do_rbf)
     d.open()
Ejemplo n.º 36
0
    def do_delete(self, obj):
        from dialogs.question import Question

        def cb():
            self.app.wallet.remove_payment_request(obj.address,
                                                   self.app.electrum_config)
            self.update()

        d = Question(_('Delete request?'), cb)
        d.open()
Ejemplo n.º 37
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())
Ejemplo n.º 38
0
 def on_ref_label(self, label, touch):
     if label.touched:
         label.touched = False
         self.qr_dialog(label.name, label.data, True)
     else:
         label.touched = True
         self._clipboard.copy(label.data)
         Clock.schedule_once(lambda dt: self.show_info(
             _('Text copied to clipboard.\nTap again to display it as QR code.'
               )))
Ejemplo n.º 39
0
 def _change_password(self, cb, old_password):
     if self.wallet.has_password():
         if old_password is None:
             return
         try:
             self.wallet.check_password(old_password)
         except InvalidPassword:
             self.show_error("Invalid PIN")
             return
     self.password_dialog(_('Enter new PIN'), self._change_password2, (cb, old_password,))
Ejemplo n.º 40
0
    def export_private_keys(self, pk_label, addr):
        def show_private_key(addr, pk_label, password):
            if self.wallet.has_password() and password is None:
                return
            key = str(self.wallet.export_private_key(addr, password)[0])
            pk_label.data = key

        self.protected(
            _("Enter your PIN code in order to decrypt your private key"),
            show_private_key, (addr, pk_label))
Ejemplo n.º 41
0
    def new_wallet(self, app, dirname):
        def cb(text):
            if text:
                app.load_wallet_by_name(os.path.join(dirname, text))

        if self.ids.wallet_selector.selection:
            app.load_wallet_by_name(self.ids.wallet_selector.selection[0])
        else:
            d = LabelDialog(_('Enter wallet name'), '', cb)
            d.open()
Ejemplo n.º 42
0
    def do_delete(self, obj):
        from .dialogs.question import Question

        def cb(result):
            if result:
                self.app.wallet.invoices.remove(obj.key)
                self.app.update_tab('invoices')

        d = Question(_('Delete invoice?'), cb)
        d.open()
Ejemplo n.º 43
0
 def _change_password(self, cb, old_password):
     if self.wallet.use_encryption:
         if old_password is None:
             return
         try:
             self.wallet.check_password(old_password)
         except InvalidPassword:
             self.show_error("Invalid PIN")
             return
     self.password_dialog(_('Enter new PIN'), self._change_password2, (cb, old_password,))
Ejemplo n.º 44
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())
Ejemplo n.º 45
0
    def show_info_bubble(self,
                         text=_('Hello World'),
                         pos=None,
                         duration=0,
                         arrow_pos='bottom_mid',
                         width=None,
                         icon='',
                         modal=False,
                         exit=False):
        '''Method to show an Information Bubble

        .. parameters::
            text: Message to be displayed
            pos: position for the bubble
            duration: duration the bubble remains on screen. 0 = click to hide
            width: width of the Bubble
            arrow_pos: arrow position for the bubble
        '''
        info_bubble = self.info_bubble
        if not info_bubble:
            info_bubble = self.info_bubble = Factory.InfoBubble()

        win = Window
        if info_bubble.parent:
            win.remove_widget(info_bubble if not info_bubble.modal else
                              info_bubble._modal_view)

        if not arrow_pos:
            info_bubble.show_arrow = False
        else:
            info_bubble.show_arrow = True
            info_bubble.arrow_pos = arrow_pos
        img = info_bubble.ids.img
        if text == 'texture':
            # icon holds a texture not a source image
            # display the texture in full screen
            text = ''
            img.texture = icon
            info_bubble.fs = True
            info_bubble.show_arrow = False
            img.allow_stretch = True
            info_bubble.dim_background = True
            info_bubble.background_image = 'atlas://gui/kivy/theming/light/card'
        else:
            info_bubble.fs = False
            info_bubble.icon = icon
            #if img.texture and img._coreimage:
            #    img.reload()
            img.allow_stretch = False
            info_bubble.dim_background = False
            info_bubble.background_image = 'atlas://data/images/defaulttheme/bubble'
        info_bubble.message = text
        if not pos:
            pos = (win.center[0], win.center[1] - (info_bubble.height / 2))
        info_bubble.show(pos, duration, width, modal=modal, exit=exit)
Ejemplo n.º 46
0
 def choose_server_dialog(self, popup):
     from uix.dialogs.choice_dialog import ChoiceDialog
     protocol = 's'
     def cb2(host):
         from electrum_ltc.network import DEFAULT_PORTS
         pp = servers.get(host, DEFAULT_PORTS)
         port = pp.get(protocol, '')
         popup.ids.host.text = host
         popup.ids.port.text = port
     servers = self.network.get_servers()
     ChoiceDialog(_('Choose a server'), sorted(servers), popup.ids.host.text, cb2).open()
Ejemplo n.º 47
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.keys(),
                                             self.app.base_unit, cb)
        self._unit_dialog.open()
Ejemplo n.º 48
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()
Ejemplo n.º 49
0
    def rbf_dialog(self, label, dt):
        if self._rbf_dialog is None:
            from checkbox_dialog import CheckBoxDialog

            def cb(x):
                self.config.set_key('use_rbf', x, True)
                label.status = self.rbf_status()

            msg = [
                _('If you check this box, your transactions will be marked as non-final,'
                  ),
                _('and you will have the possiblity, while they are unconfirmed, to replace them with transactions that pays higher fees.'
                  ),
                _('Note that some merchants do not accept non-final transactions until they are confirmed.'
                  )
            ]
            fullname = _('Replace by fee')
            self._rbf_dialog = CheckBoxDialog(
                fullname, ' '.join(msg), self.config.get('use_rbf', False), cb)
        self._rbf_dialog.open()
Ejemplo n.º 50
0
 def update(self):
     self.menu_actions = [('Pay', self.do_pay), ('Details', self.do_view), ('Delete', self.do_delete)]
     invoices_list = self.screen.ids.invoices_container
     invoices_list.clear_widgets()
     _list = self.app.wallet.invoices.sorted_list()
     for pr in _list:
         ci = self.get_card(pr)
         invoices_list.add_widget(ci)
     if not _list:
         msg = _('This screen shows the list of payment requests that have been sent to you. You may also use it to store contact addresses.')
         invoices_list.add_widget(EmptyLabel(text=msg))
Ejemplo n.º 51
0
    def do_delete(self, obj):
        from .question import Question

        def cb(result):
            if result:
                self.app.wallet.invoices.remove(obj.key)
            self.hide_menu()
            self.update()

        d = Question(_('Delete invoice?'), cb)
        d.open()
Ejemplo n.º 52
0
 def update(self):
     self.menu_actions = [('Show', self.do_show), ('Details', self.do_view), ('Delete', self.do_delete)]
     requests_list = self.screen.ids.requests_container
     requests_list.clear_widgets()
     _list = self.app.wallet.get_sorted_requests(self.app.electrum_config) if self.app.wallet else []
     for req in _list:
         ci = self.get_card(req)
         requests_list.add_widget(ci)
     if not _list:
         msg = _('This screen shows the list of payment requests you made.')
         requests_list.add_widget(EmptyLabel(text=msg))
Ejemplo n.º 53
0
 def choose_blockchain_dialog(self, dt):
     from uix.dialogs.choice_dialog import ChoiceDialog
     chains = self.network.get_blockchains()
     def cb(name):
         for index, b in self.network.blockchains.items():
             if name == self.network.get_blockchain_name(b):
                 self.network.follow_chain(index)
                 #self.block
     names = [self.network.blockchains[b].get_name() for b in chains]
     if len(names) >1:
         ChoiceDialog(_('Choose your chain'), names, '', cb).open()
Ejemplo n.º 54
0
 def on_complete(ok, msg):
     if ok:
         self.show_info(_('Payment sent.'))
         if self.send_screen:
             self.send_screen.do_clear()
         if pr:
             self.wallet.invoices.set_paid(pr, tx.txid())
             self.wallet.invoices.save()
             self.update_tab('invoices')
     else:
         self.show_error(msg)
Ejemplo n.º 55
0
    def broadcast(self, tx, pr=None):
        def on_complete(ok, msg):
            if ok:
                self.show_info(_('Payment sent.'))
                if self.send_screen:
                    self.send_screen.do_clear()
                if pr:
                    self.wallet.invoices.set_paid(pr, tx.txid())
                    self.wallet.invoices.save()
                    self.update_tab('invoices')
            else:
                self.show_error(msg)

        if self.network and self.network.is_connected():
            self.show_info(_('Sending'))
            threading.Thread(target=self._broadcast_thread,
                             args=(tx, on_complete)).start()
        else:
            self.show_info(
                _('Cannot broadcast transaction') + ':\n' + _('Not connected'))
Ejemplo n.º 56
0
 def on_pr(self, pr):
     if not self.wallet:
         self.show_error(_('No wallet loaded.'))
         return
     if pr.verify(self.wallet.contacts):
         key = self.wallet.invoices.add(pr)
         if self.invoices_screen:
             self.invoices_screen.update()
         status = self.wallet.invoices.get_status(key)
         if status == PR_PAID:
             self.show_error("invoice already paid")
             self.send_screen.do_clear()
         else:
             if pr.has_expired():
                 self.show_error(_('Payment request has expired'))
             else:
                 self.switch_to('send')
                 self.send_screen.set_request(pr)
     else:
         self.show_error("invoice error:" + pr.error)
         self.send_screen.do_clear()
Ejemplo n.º 57
0
    def restore_seed(self):
        def on_seed(_dlg, btn):
            _dlg.close()
            if btn is _dlg.ids.back:
                self.run('new')
                return
            text = _dlg.get_text()
            self.run('enter_pin', (text, ))

        msg = _('Please type your seed phrase using the virtual keyboard.')
        RestoreSeedDialog(test=Wallet.is_seed, message=msg,
                          on_release=on_seed).open()
Ejemplo n.º 58
0
    def __init__(self, obj, action_list):
        Bubble.__init__(self)
        self.obj = obj
        for k, v in action_list:
            l = MenuItem()
            l.text = _(k)

            def func(f=v):
                Clock.schedule_once(lambda dt: f(obj), 0.15)

            l.on_release = func
            self.ids.buttons.add_widget(l)
Ejemplo n.º 59
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()
Ejemplo n.º 60
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 Litecoin address or a payment request'))
             return
         if not bitcoin.is_address(address):
             self.app.show_error(_('Invalid Litecoin 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 = [(bitcoin.TYPE_ADDRESS, address, amount)]
     message = self.screen.message
     amount = sum(map(lambda x:x[2], outputs))
     if self.app.electrum_config.get('use_rbf'):
         from .dialogs.question import Question
         d = Question(_('Should this transaction be replaceable?'), lambda b: self._do_send(amount, message, outputs, b))
         d.open()
     else:
         self._do_send(amount, message, outputs, False)