コード例 #1
0
    def update_history(self):
        self.history = []
        hist_list = self.wallet.get_history(config=self.config)
        for (tx_hash, tx_type, tx_mined_status, value, balance, islock,
             group_txid, group_data) in hist_list:
            if tx_mined_status.conf:
                timestamp = tx_mined_status.timestamp
                try:
                    dttm = datetime.fromtimestamp(timestamp)
                    time_str = dttm.isoformat(' ')[:-3]
                except Exception:
                    time_str = "------"
            elif islock:
                dttm = datetime.fromtimestamp(islock)
                time_str = dttm.isoformat(' ')[:-3]
            else:
                time_str = 'unconfirmed'

            label = self.wallet.get_label(tx_hash)
            if self.show_dip2:
                if len(label) > 22:
                    label = label[0:19] + '...'
                tx_type_name = SPEC_TX_NAMES.get(tx_type, str(tx_type))
                width = [20, 18, 22, 14, 14]
                delta = (self.maxx - sum(width) - 5) // 3
                format_str = ("%" + "%d" % width[0] + "s" + "%" +
                              "%d" % width[1] + "s" + "%" + "%d" %
                              (width[2] + delta) + "s" + "%" + "%d" %
                              (width[3] + delta) + "s" + "%" + "%d" %
                              (width[4] + delta) + "s")
                msg = format_str % (time_str, tx_type_name, label,
                                    format_satoshis(value, whitespaces=True),
                                    format_satoshis(balance, whitespaces=True))
                self.history.append(msg)
            else:
                if len(label) > 40:
                    label = label[0:37] + '...'
                width = [20, 40, 14, 14]
                delta = (self.maxx - sum(width) - 4) // 3
                format_str = ("%" + "%d" % width[0] + "s" + "%" + "%d" %
                              (width[1] + delta) + "s" + "%" + "%d" %
                              (width[2] + delta) + "s" + "%" + "%d" %
                              (width[3] + delta) + "s")
                msg = format_str % (time_str, label,
                                    format_satoshis(value, whitespaces=True),
                                    format_satoshis(balance, whitespaces=True))
                self.history.append(msg)
コード例 #2
0
    def print_history(self):
        messages = []

        for tx_hash, tx_type, tx_mined_status, delta, balance in reversed(
                self.wallet.get_history()):
            if tx_mined_status.conf:
                timestamp = tx_mined_status.timestamp
                try:
                    time_str = datetime.datetime.fromtimestamp(
                        timestamp).isoformat(' ')[:-3]
                except Exception:
                    time_str = "unknown"
            else:
                time_str = 'unconfirmed'

            label = self.wallet.get_label(tx_hash)
            if self.config.get('show_dip2_tx_type', False):
                tx_type_name = SPEC_TX_NAMES.get(tx_type, str(tx_type))
                width = [20, 18, 22, 14, 14]
                wdelta = (80 - sum(width) - 5) // 3
                format_str = ("%" + "%d" % width[0] + "s" + "%" +
                              "%d" % width[1] + "s" + "%" + "%d" %
                              (width[2] + wdelta) + "s" + "%" + "%d" %
                              (width[3] + wdelta) + "s" + "%" + "%d" %
                              (width[4] + wdelta) + "s")
                msg = format_str % (time_str, tx_type_name, label,
                                    format_satoshis(delta, whitespaces=True),
                                    format_satoshis(balance, whitespaces=True))
                messages.append(msg)
                self.print_list(
                    messages[::-1],
                    format_str % (_("Date"), 'DIP2', _("Description"),
                                  _("Amount"), _("Balance")))
            else:
                width = [20, 40, 14, 14]
                wdelta = (80 - sum(width) - 4) // 3
                format_str = ("%" + "%d" % width[0] + "s" + "%" + "%d" %
                              (width[1] + wdelta) + "s" + "%" + "%d" %
                              (width[2] + wdelta) + "s" + "%" + "%d" %
                              (width[3] + wdelta) + "s")
                msg = format_str % (time_str, label,
                                    format_satoshis(delta, whitespaces=True),
                                    format_satoshis(balance, whitespaces=True))
                messages.append(msg)
                self.print_list(
                    messages[::-1], format_str %
                    (_("Date"), _("Description"), _("Amount"), _("Balance")))
コード例 #3
0
ファイル: axe_qt.py プロジェクト: surabh12345/electrum-axe
 def set_extra_data(self, tx_type, extra_payload):
     self.tx_type, self.extra_payload = tx_type, extra_payload
     tx_type_name = SPEC_TX_NAMES.get(tx_type, str(tx_type))
     self.setText('Tx Type: %s\n\n%s' % (tx_type_name, extra_payload))