コード例 #1
0
    def update(self):
        format_amount = self.app.format_amount_and_units
        tx_hash, self.status_str, self.description, self.can_broadcast, self.can_rbf, amount, fee, height, conf, timestamp, exp_n = self.wallet.get_tx_info(
            self.tx)
        self.tx_hash = tx_hash or ''
        if timestamp:
            self.date_str = datetime.fromtimestamp(timestamp).isoformat(
                ' ')[:-3]
        elif exp_n:
            self.date_str = _('Within %d blocks') % exp_n if exp_n > 0 else _(
                'unknown (low fee)')
        else:
            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())
コード例 #2
0
ファイル: screens.py プロジェクト: maff1989/electrum-xzc
 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.'))
コード例 #3
0
 def change_password(self, cb):
     if self.wallet.has_password():
         self.protected(
             _("Changing PIN code.") + '\n' + _("Enter your current PIN:"),
             self._change_password, (cb, ))
     else:
         self._change_password(cb, None)
コード例 #4
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
コード例 #5
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))
コード例 #6
0
ファイル: screens.py プロジェクト: maff1989/electrum-xzc
 def update(self):
     self.menu_actions = [('Receive', self.do_show), ('Details', self.do_view)]
     wallet = self.app.wallet
     _list = wallet.get_change_addresses() if self.screen.show_change else wallet.get_receiving_addresses()
     search = self.screen.message
     container = self.screen.ids.search_container
     container.clear_widgets()
     n = 0
     for address in _list:
         label = wallet.labels.get(address, '')
         balance = sum(wallet.get_addr_balance(address))
         is_used = wallet.is_used(address)
         if self.screen.show_used == 1 and (balance or is_used):
             continue
         if self.screen.show_used == 2 and balance == 0:
             continue
         if self.screen.show_used == 3 and not is_used:
             continue
         card = self.get_card(address, balance, is_used, label)
         if search and not self.ext_search(card, search):
             continue
         container.add_widget(card)
         n += 1
     if not n:
         msg = _('No address matching your search')
         container.add_widget(EmptyLabel(text=msg))
コード例 #7
0
ファイル: settings.py プロジェクト: maff1989/electrum-xzc
 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')
コード例 #8
0
ファイル: screens.py プロジェクト: maff1989/electrum-xzc
 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()
コード例 #9
0
ファイル: fx_dialog.py プロジェクト: maff1989/electrum-xzc
 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
     Clock.schedule_once(lambda dt: self.add_exchanges())
コード例 #10
0
ファイル: screens.py プロジェクト: maff1989/electrum-xzc
 def do_delete(self, obj):
     from .dialogs.question import Question
     def cb(result):
         if result:
             self.app.wallet.remove_payment_request(obj.address, self.app.electrum_config)
             self.update()
     d = Question(_('Delete request?'), cb)
     d.open()
コード例 #11
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
コード例 #12
0
ファイル: screens.py プロジェクト: maff1989/electrum-xzc
 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()
コード例 #13
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()
コード例 #14
0
ファイル: screens.py プロジェクト: maff1989/electrum-xzc
 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())
コード例 #15
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.'
               )))
コード例 #16
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 a 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)
コード例 #17
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'))
コード例 #18
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)
コード例 #19
0
ファイル: settings.py プロジェクト: maff1989/electrum-xzc
    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'),
                                             list(base_units.keys()),
                                             self.app.base_unit, cb)
        self._unit_dialog.open()
コード例 #20
0
ファイル: screens.py プロジェクト: maff1989/electrum-xzc
 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))
コード例 #21
0
ファイル: settings.py プロジェクト: maff1989/electrum-xzc
    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()
コード例 #22
0
ファイル: settings.py プロジェクト: maff1989/electrum-xzc
    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()
コード例 #23
0
ファイル: screens.py プロジェクト: maff1989/electrum-xzc
    def get_card(self, addr, balance, is_used, label):
        ci = self.cards.get(addr)
        if ci is None:
            ci = Factory.AddressItem()
            ci.screen = self
            ci.address = addr
            self.cards[addr] = ci

        ci.memo = label
        ci.amount = self.app.format_amount_and_units(balance)
        request = self.app.wallet.get_payment_request(addr, self.app.electrum_config)
        if is_used:
            ci.status = _('Used')
        elif request:
            status, conf = self.app.wallet.get_request_status(addr)
            requested_amount = request.get('amount')
            # make sure that requested amount is > 0
            if status == PR_PAID:
                s = _('Request paid')
            elif status == PR_UNPAID:
                s = _('Request pending')
            elif status == PR_EXPIRED:
                s = _('Request expired')
            else:
                s = ''
            ci.status = s + ': ' + self.app.format_amount_and_units(requested_amount)
        else:
            ci.status = _('Funded') if balance>0 else _('Unused')
        return ci
コード例 #24
0
ファイル: screens.py プロジェクト: maff1989/electrum-xzc
 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 Zcoin address or a payment request'))
             return
         if not bitcoin.is_address(address):
             self.app.show_error(_('Invalid Zcoin 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)
コード例 #25
0
    def export_private_keys(self, pk_label, addr):
        if self.wallet.is_watching_only():
            self.show_info(
                _('This is a watching-only wallet. It does not contain private keys.'
                  ))
            return

        def show_private_key(addr, pk_label, password):
            if self.wallet.has_password() and password is None:
                return
            if not self.wallet.can_export():
                return
            try:
                key = str(self.wallet.export_private_key(addr, password)[0])
                pk_label.data = key
            except InvalidPassword:
                self.show_error("Invalid PIN")
                return

        self.protected(
            _("Enter your PIN code in order to decrypt your private key"),
            show_private_key, (addr, pk_label))
コード例 #26
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,
     ))
コード例 #27
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: self.hide(), 0.1)
                Clock.schedule_once(lambda dt: f(obj), 0.15)

            l.on_release = func
            self.ids.buttons.add_widget(l)
コード例 #28
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()
コード例 #29
0
ファイル: screens.py プロジェクト: maff1989/electrum-xzc
 def set_URI(self, text):
     import electrum_xzc as electrum
     try:
         uri = electrum.util.parse_URI(text, self.app.on_pr)
     except:
         self.app.show_info(_("Not a Zcoin 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
コード例 #30
0
ファイル: screens.py プロジェクト: maff1989/electrum-xzc
    def get_card(self, pr):
        key = pr.get_id()
        ci = self.cards.get(key)
        if ci is None:
            ci = Factory.InvoiceItem()
            ci.key = key
            ci.screen = self
            self.cards[key] = ci

        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.wallet.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')
        return ci