예제 #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_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())
예제 #2
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)
예제 #3
0
 def update(self):
     self.menu_actions = [(_('Use'), self.do_show),
                          (_('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
     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.show_used == 1 and (balance or is_used):
             continue
         if self.show_used == 2 and balance == 0:
             continue
         if self.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))
예제 #4
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())
예제 #5
0
 def update_status(self, *dt):
     self.num_blocks = self.network.get_local_height()
     if not self.wallet:
         self.status = _("No Wallet")
         return
     if self.network is None or not self.network.is_running():
         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:
             status = _("Synchronizing...")
         elif server_lag > 1:
             status = _("Server lagging")
         else:
             status = ''
     else:
         status = _("Disconnected")
     self.status = self.wallet.basename() + (' [size=15dp](%s)[/size]' %
                                             status if status else '')
     # balance
     c, u, x = self.wallet.get_balance()
     text = self.format_amount(c + x + u)
     self.balance = str(
         text.strip()) + ' [size=22dp]%s[/size]' % self.base_unit
     self.fiat_balance = self.fx.format_amount(
         c + u + x) + ' [size=22dp]%s[/size]' % self.fx.ccy
예제 #6
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.'))
예제 #7
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.denariium_config)
     for pr in _list:
         ci = self.get_card(pr)
         requests_list.add_widget(ci)
예제 #8
0
 def __init__(self, wizard, **kwargs):
     super(RestoreSeedDialog, self).__init__(wizard, **kwargs)
     self._test = kwargs['test']
     from denariium.mnemonic import Mnemonic
     from denariium.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
예제 #9
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
예제 #10
0
 def invoices_dialog(self, screen):
     from .uix.dialogs.invoices import InvoicesDialog
     if len(self.wallet.invoices.sorted_list()) == 0:
         self.show_info(' '.join([
             _('No saved invoices.'),
             _('Signed invoices are saved automatically when you scan them.'
               ),
             _('You may also save unsigned requests or contact addresses using the save button.'
               )
         ]))
         return
     popup = InvoicesDialog(self, screen, None)
     popup.update()
     popup.open()
예제 #11
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))
예제 #12
0
    def __init__(self, **kwargs):
        # initialize variables
        self._clipboard = Clipboard
        self.info_bubble = None
        self.nfcscanner = None
        self.tabs = None
        self.is_exit = False
        self.wallet = None

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

        title = _('Denariium 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.daemon = self.gui_object.daemon
        self.fx = self.daemon.fx

        # 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_update_history = Clock.create_trigger(self.update_history, .5)
        # cached dialogs
        self._settings_dialog = None
        self._password_dialog = None
예제 #13
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
예제 #14
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()
예제 #15
0
 def get_card(self, tx_hash, height, conf, timestamp, value, balance):
     status, status_str = self.app.wallet.get_tx_status(
         tx_hash, height, conf, timestamp)
     icon = "atlas://gui/kivy/theming/light/" + TX_ICONS[status]
     label = self.app.wallet.get_label(tx_hash) if tx_hash else _(
         'Pruned transaction outputs')
     date = timestamp_to_datetime(timestamp)
     ri = self.cards.get(tx_hash)
     if ri is None:
         ri = Factory.HistoryItem()
         ri.screen = self
         ri.tx_hash = tx_hash
         self.cards[tx_hash] = ri
     ri.icon = icon
     ri.date = status_str
     ri.message = label
     ri.confirmations = 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 and date:
             ri.quote_text = self.app.fx.historical_value_str(
                 value, date) + ' ' + self.app.fx.ccy
     return ri
예제 #16
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 ''
예제 #17
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.')))
예제 #18
0
 def requests_dialog(self, screen):
     from .uix.dialogs.requests import RequestsDialog
     if len(self.wallet.get_sorted_requests(self.denariium_config)) == 0:
         self.show_info(_('No saved requests.'))
         return
     popup = RequestsDialog(self, screen, None)
     popup.update()
     popup.open()
예제 #19
0
 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()
예제 #20
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()
예제 #21
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')
예제 #22
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
     Clock.schedule_once(lambda dt: self.add_exchanges())
예제 #23
0
    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.denariium_config)
        if is_used:
            ci.status = _('Used')
        else:
            ci.status = _('Funded') if balance > 0 else _('Unused')
        return ci
예제 #24
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()
예제 #25
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
예제 #26
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'))
예제 #27
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())
예제 #28
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,))
예제 #29
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)
예제 #30
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)