示例#1
0
    def update_history(self):
        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"

        b = 0
        self.history = []
        for hist_item in self.wallet.get_history():
            if hist_item.tx_mined_status.conf:
                timestamp = hist_item.tx_mined_status.timestamp
                try:
                    time_str = datetime.datetime.fromtimestamp(
                        timestamp).isoformat(' ')[:-3]
                except Exception:
                    time_str = "------"
            else:
                time_str = 'unconfirmed'

            label = self.wallet.get_label(hist_item.txid)
            if len(label) > 40:
                label = label[0:37] + '...'
            self.history.append(
                format_str %
                (time_str, label,
                 format_satoshis(hist_item.delta, whitespaces=True),
                 format_satoshis(hist_item.balance, whitespaces=True)))
示例#2
0
    def print_history(self):
        width = [20, 40, 14, 14]
        delta = (80 - 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"
        messages = []

        for hist_item in reversed(self.wallet.get_history()):
            if hist_item.tx_mined_status.conf:
                timestamp = hist_item.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(hist_item.txid)
            messages.append(
                format_str %
                (time_str, label, format_satoshis(delta, whitespaces=True),
                 format_satoshis(hist_item.balance, whitespaces=True)))

        self.print_list(
            messages[::-1], format_str %
            (_("Date"), _("Description"), _("Amount"), _("Balance")))
示例#3
0
 def test_format_satoshis_diff_negative(self):
     self.assertEqual("-0.00001234", format_satoshis(-1234, is_diff=True))
示例#4
0
 def test_format_satoshis_diff_positive(self):
     self.assertEqual("+0.00001234", format_satoshis(1234, is_diff=True))
示例#5
0
 def test_format_satoshis_whitespaces_negative(self):
     self.assertEqual("    -0.0001234 ",
                      format_satoshis(-12340, whitespaces=True))
     self.assertEqual("    -0.00001234",
                      format_satoshis(-1234, whitespaces=True))
示例#6
0
 def test_format_satoshis_whitespaces(self):
     self.assertEqual("     0.0001234 ",
                      format_satoshis(12340, whitespaces=True))
     self.assertEqual("     0.00001234",
                      format_satoshis(1234, whitespaces=True))
示例#7
0
 def test_format_satoshis_decimal(self):
     self.assertEqual("0.00001234", format_satoshis(Decimal(1234)))
示例#8
0
 def test_format_satoshis_to_mbtc(self):
     self.assertEqual("0.01234", format_satoshis(1234, decimal_point=5))
示例#9
0
 def test_format_satoshis_negative(self):
     self.assertEqual("-0.00001234", format_satoshis(-1234))
示例#10
0
 def test_format_satoshis(self):
     self.assertEqual("0.00001234", format_satoshis(1234))