Esempio n. 1
0
    def print_history(self):
        messages = []

        def_dip2 = not self.wallet.psman.unsupported
        show_dip2 = self.config.get('show_dip2_tx_type', def_dip2)
        if show_dip2:
            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")
        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")
        for hist_item in reversed(self.wallet.get_history(config=self.config)):
            if hist_item.tx_mined_status.conf:
                timestamp = hist_item.tx_mined_status.timestamp
                try:
                    dttm = datetime.fromtimestamp(timestamp)
                    time_str = dttm.isoformat(' ')[:-3]
                except Exception:
                    time_str = "unknown"
            elif hist_item.islock:
                dttm = datetime.fromtimestamp(hist_item.islock)
                time_str = dttm.isoformat(' ')[:-3]
            else:
                time_str = 'unconfirmed'

            label = self.wallet.get_label_for_txid(hist_item.txid)
            if show_dip2:
                tx_type = hist_item.tx_type
                tx_type_name = SPEC_TX_NAMES.get(tx_type, str(tx_type))
                msg = format_str % (
                    time_str, tx_type_name, label,
                    format_satoshis(hist_item.delta, whitespaces=True),
                    format_satoshis(hist_item.balance, whitespaces=True))
            else:
                msg = format_str % (
                    time_str, label,
                    format_satoshis(hist_item.delta, whitespaces=True),
                    format_satoshis(hist_item.balance, whitespaces=True))
            messages.append(msg)
        if show_dip2:
            self.print_list(
                messages[::-1],
                format_str % (_("Date"), 'Type', _("Description"), _("Amount"),
                              _("Balance")))
        else:
            self.print_list(
                messages[::-1], format_str %
                (_("Date"), _("Description"), _("Amount"), _("Balance")))
Esempio n. 2
0
 def set_extra_data(self, tx_type, extra_payload, mn_alias=None):
     self.tx_type, self.extra_payload = tx_type, extra_payload
     self.mn_alias = mn_alias
     tx_type_name = SPEC_TX_NAMES.get(tx_type, str(tx_type))
     if self.mn_alias:
         self.setText('Tx Type: %s, MN alias: %s\n\n%s' % (tx_type_name,
                                                           mn_alias,
                                                           extra_payload))
     else:
         self.setText('Tx Type: %s\n\n%s' % (tx_type_name, extra_payload))
Esempio n. 3
0
    def print_history(self):
        messages = []

        hist_list = reversed(self.wallet.get_history(config=self.config))
        show_dip2 = self.config.get('show_dip2_tx_type', False)
        if show_dip2:
            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")
        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")
        for (tx_hash, tx_type, tx_mined_status, delta, balance,
             islock) 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 = "unknown"
            elif islock:
                dttm = datetime.fromtimestamp(islock)
                time_str = dttm.isoformat(' ')[:-3]
            else:
                time_str = 'unconfirmed'

            label = self.wallet.get_label(tx_hash)
            if show_dip2:
                tx_type_name = SPEC_TX_NAMES.get(tx_type, str(tx_type))
                msg = format_str % (time_str, tx_type_name, label,
                                    format_satoshis(delta, whitespaces=True),
                                    format_satoshis(balance, whitespaces=True))
                messages.append(msg)
            else:
                msg = format_str % (time_str, label,
                                    format_satoshis(delta, whitespaces=True),
                                    format_satoshis(balance, whitespaces=True))
                messages.append(msg)
        if show_dip2:
            self.print_list(
                messages[::-1],
                format_str % (_("Date"), 'DIP2', _("Description"), _("Amount"),
                              _("Balance")))
        else:
            self.print_list(
                messages[::-1], format_str %
                (_("Date"), _("Description"), _("Amount"), _("Balance")))
Esempio n. 4
0
 def process_tx_groups(self, history):
     txs = []
     group_txs = []
     expanded_groups = set()
     selected_node = None
     selected_txid = self.selected_txid
     for hist_dict in history.values():
         h = copy.deepcopy(dict(hist_dict))
         txid = h['txid']
         group_txid = h['group_txid']
         group_data = h['group_data']
         if group_txid is None and not group_data:
             h['group_icon'] = self.group_icn_empty
             txs.append(h)
             if selected_txid and selected_txid == txid:
                 selected_node = len(txs) - 1
         elif group_txid:
             if not group_txs:
                 h['group_icon'] = self.group_icn_tail
             else:
                 h['group_icon'] = self.group_icn_mid
             group_txs.append(h)
         else:
             value, balance, group_txids = group_data
             h['value'] = value
             h['balance'] = balance
             h['group_icon'] = self.group_icn_head
             h['group_txid'] = txid
             for expanded_txid in self.expanded_groups:
                 if expanded_txid in group_txids:
                     expanded_groups.add(txid)
             if txid in expanded_groups:
                 txs.extend(group_txs)
                 h['group_icon'] = self.group_icn_head
                 txs.append(h)
                 if selected_txid and selected_txid in group_txids:
                     idx = group_txids.index(selected_txid)
                     selected_node = len(txs) - 1 - idx
             else:
                 tx_type = PSTxTypes.PS_MIXING_TXS
                 h['tx_type'] = SPEC_TX_NAMES.get(tx_type, str(tx_type))
                 h['label'] = _('Group of {} Txs').format(len(group_txids))
                 h['group_icon'] = self.group_icn_all
                 txs.append(h)
                 if selected_txid and selected_txid in group_txids:
                     selected_node = len(txs) - 1
                     self.selected_txid = selected_txid = txid
             group_txs = []
     if selected_node is None:
         self.selected_txid = ''
     self.expanded_groups = expanded_groups
     return selected_node, txs
Esempio n. 5
0
    def update_history(self):
        self.history = []
        self.txid = []
        for hist_item in self.wallet.get_history(config=self.config):
            if hist_item.tx_mined_status.conf:
                timestamp = hist_item.tx_mined_status.timestamp
                try:
                    dttm = datetime.fromtimestamp(timestamp)
                    time_str = dttm.isoformat(' ')[:-3]
                except Exception:
                    time_str = "------"
            elif hist_item.islock:
                dttm = datetime.fromtimestamp(hist_item.islock)
                time_str = dttm.isoformat(' ')[:-3]
            else:
                time_str = 'unconfirmed'

            label = self.wallet.get_label_for_txid(hist_item.txid)
            self.txid.insert(0, hist_item.txid)
            if self.show_dip2:
                if len(label) > 22:
                    label = label[0:19] + '...'
                tx_type = hist_item.tx_type
                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(hist_item.delta, whitespaces=True),
                    format_satoshis(hist_item.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(hist_item.delta, whitespaces=True),
                    format_satoshis(hist_item.balance, whitespaces=True))
                self.history.append(msg)
Esempio n. 6
0
    def update_history(self):
        b = 0
        self.history = []
        hist_list = self.wallet.get_history(config=self.config)
        for (tx_hash, tx_type, tx_mined_status, value, balance,
             islock) 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)
Esempio n. 7
0
 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))