Exemplo n.º 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 item in self.wallet.get_history():
            tx_hash, conf, value, timestamp, balance = item
            if conf:
                try:
                    time_str = datetime.datetime.fromtimestamp(
                        timestamp).isoformat(' ')[:-3]
                except Exception:
                    time_str = "------"
            else:
                time_str = 'pending'

            label, is_default_label = self.wallet.get_label(tx_hash)
            if len(label) > 40:
                label = label[0:37] + '...'
            self.history.append(
                format_str %
                (time_str, label, format_satoshis(value, whitespaces=True),
                 format_satoshis(balance, whitespaces=True)))
Exemplo n.º 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"
        b = 0
        messages = []

        for item in self.wallet.get_history():
            tx_hash, confirmations, value, timestamp, balance = item
            if confirmations:
                try:
                    time_str = datetime.datetime.fromtimestamp(
                        timestamp).isoformat(' ')[:-3]
                except Exception:
                    time_str = "unknown"
            else:
                time_str = 'pending'

            label, is_default_label = self.wallet.get_label(tx_hash)
            messages.append(
                format_str %
                (time_str, label, format_satoshis(value, whitespaces=True),
                 format_satoshis(balance, whitespaces=True)))

        self.print_list(
            messages[::-1], format_str %
            (_("Date"), _("Description"), _("Amount"), _("Balance")))
Exemplo n.º 3
0
    def get_tx_details(self, tx_hash):
        import datetime
        if not tx_hash: return ''
        tx = self.wallet.transactions.get(tx_hash)
        tx.deserialize()
        is_relevant, is_mine, v, fee = self.wallet.get_wallet_delta(tx)
        conf, timestamp = self.wallet.get_confirmations(tx_hash)

        if timestamp:
            time_str = datetime.datetime.fromtimestamp(timestamp).isoformat(' ')[:-3]
        else:
            time_str = 'pending'

        inputs = map(lambda x: x.get('address'), tx.inputs)
        outputs = map(lambda x: x[0], tx.get_outputs())
        tx_details = "Transaction Details" +"\n\n" \
            + "Transaction ID:\n" + tx_hash + "\n\n" \
            + "Status: %d confirmations\n"%conf
        if is_mine:
            if fee: 
                tx_details += "Amount sent: %s\n"% format_satoshis(v-fee, False) \
                              + "Transaction fee: %s\n"% format_satoshis(fee, False)
            else:
                tx_details += "Amount sent: %s\n"% format_satoshis(v, False) \
                              + "Transaction fee: unknown\n"
        else:
            tx_details += "Amount received: %s\n"% format_satoshis(v, False) \

        tx_details += "Date: %s\n\n"%time_str \
            + "Inputs:\n-"+ '\n-'.join(inputs) + "\n\n" \
            + "Outputs:\n-"+ '\n-'.join(outputs)

        return tx_details
Exemplo n.º 4
0
    def update_history_tab(self):
        cursor = self.history_treeview.get_cursor()[0]
        self.history_list.clear()

        for item in self.wallet.get_history():
            tx_hash, conf, value, timestamp, balance = item
            if conf > 0:
                try:
                    time_str = datetime.datetime.fromtimestamp( timestamp).isoformat(' ')[:-3]
                except Exception:
                    time_str = "------"
                conf_icon = Gtk.STOCK_APPLY
            elif conf == -1:
                time_str = 'unverified'
                conf_icon = None
            else:
                time_str = 'pending'
                conf_icon = Gtk.STOCK_EXECUTE

            label, is_default_label = self.wallet.get_label(tx_hash)
            tooltip = tx_hash + "\n%d confirmations"%conf if tx_hash else ''
            details = self.get_tx_details(tx_hash)

            self.history_list.prepend( [tx_hash, conf_icon, time_str, label, is_default_label,
                                        format_satoshis(value,True,self.num_zeros, whitespaces=True),
                                        format_satoshis(balance,False,self.num_zeros, whitespaces=True), tooltip, details] )
        if cursor: self.history_treeview.set_cursor( cursor )
Exemplo n.º 5
0
    def update_status_bar(self):

        if self.funds_error:
            text = "Not enough funds"
        elif self.network.is_connected():
            host, port, _,_,_ = self.network.get_parameters()
            port = int(port)
            height = self.network.get_local_height()
            self.network_button.set_tooltip_text("Connected to %s:%d.\n%d blocks"%(host, port, height))
            if not self.wallet.up_to_date:
                self.status_image.set_from_stock(Gtk.STOCK_REFRESH, Gtk.IconSize.MENU)
                text = "Synchronizing..."
            else:
                self.status_image.set_from_stock(Gtk.STOCK_YES, Gtk.IconSize.MENU)
                c, u, x = self.wallet.get_balance()
                text = "Balance: %s "%(format_satoshis(c, False, self.num_zeros))
                if u:
                    text += "[%s unconfirmed]"%(format_satoshis(u, True, self.num_zeros).strip())
                if x:
                    text += "[%s unmatured]"%(format_satoshis(x, True, self.num_zeros).strip())
        else:
            self.status_image.set_from_stock(Gtk.STOCK_NO, Gtk.IconSize.MENU)
            self.network_button.set_tooltip_text("Not connected.")
            text = "Not connected"

        self.status_bar.pop(self.context_id) 
        self.status_bar.push(self.context_id, text)

        if self.wallet.up_to_date and self.wallet_updated:
            self.update_history_tab()
            self.update_receiving_tab()
            # addressbook too...
            self.info.set_text( self.network.banner )
            self.wallet_updated = False
Exemplo n.º 6
0
 def update_receiving_tab(self):
     self.recv_list.clear()
     for address in self.wallet.addresses(True):
         Type = "R"
         c = u = 0
         if self.wallet.is_change(address): Type = "C"
         if address in self.wallet.imported_keys.keys():
             Type = "I"
         c, u, x = self.wallet.get_addr_balance(address)
         if address in self.wallet.frozen_addresses: Type = Type + "F"
         label = self.wallet.labels.get(address)
         h = self.wallet.history.get(address,[])
         n = len(h)
         tx = "0" if n==0 else "%d"%n
         self.recv_list.append((address, label, tx, format_satoshis(c+u+x, False, self.num_zeros), Type ))
Exemplo n.º 7
0
 def settings_dialog(self):
     out = self.run_dialog(
         'Settings',
         [{
             'label': 'Default GUI',
             'type': 'list',
             'choices': ['classic', 'lite', 'gtk', 'text'],
             'value': self.config.get('gui')
         }, {
             'label': 'Default fee',
             'type': 'satoshis',
             'value': format_satoshis(self.wallet.fee_per_kb).strip()
         }],
         buttons=1)
     if out:
         if out.get('Default GUI'):
             self.config.set_key('gui', out['Default GUI'], True)
         if out.get('Default fee'):
             fee = int(Decimal(out['Default fee']) * 10000000)
             self.config.set_key('fee_per_kb', fee, True)
Exemplo n.º 8
0
    def do_plot(self, wallet, history):
        balance_Val = []
        fee_val = []
        value_val = []
        datenums = []
        unknown_trans = 0
        pending_trans = 0
        counter_trans = 0
        balance = 0
        for item in history:
            tx_hash, confirmations, value, timestamp = item
            balance += value
            if confirmations:
                if timestamp is not None:
                    try:
                        datenums.append(
                            md.date2num(
                                datetime.datetime.fromtimestamp(timestamp)))
                        balance_string = format_satoshis(balance, False)
                        balance_Val.append(
                            float((format_satoshis(balance, False))) * 1000.0)
                    except [RuntimeError, TypeError, NameError] as reason:
                        unknown_trans += 1
                        pass
                else:
                    unknown_trans += 1
            else:
                pending_trans += 1

            value_string = format_satoshis(value, True)
            value_val.append(float(value_string) * 1000.0)

            if tx_hash:
                label, is_default_label = wallet.get_label(tx_hash)
                label = label.encode('utf-8')
            else:
                label = ""

        f, axarr = plt.subplots(2, sharex=True)

        plt.subplots_adjust(bottom=0.2)
        plt.xticks(rotation=25)
        ax = plt.gca()
        x = 19
        test11 = "Unknown transactions =  " + str(
            unknown_trans) + " Pending transactions =  " + str(
                pending_trans) + " ."
        box1 = TextArea(" Test : Number of pending transactions",
                        textprops=dict(color="k"))
        box1.set_text(test11)

        box = HPacker(children=[box1], align="center", pad=0.1, sep=15)

        anchored_box = AnchoredOffsetbox(
            loc=3,
            child=box,
            pad=0.5,
            frameon=True,
            bbox_to_anchor=(0.5, 1.02),
            bbox_transform=ax.transAxes,
            borderpad=0.5,
        )

        ax.add_artist(anchored_box)

        plt.ylabel('mORA')
        plt.xlabel('Dates')
        xfmt = md.DateFormatter('%Y-%m-%d')
        ax.xaxis.set_major_formatter(xfmt)

        axarr[0].plot(datenums,
                      balance_Val,
                      marker='o',
                      linestyle='-',
                      color='blue',
                      label='Balance')
        axarr[0].legend(loc='upper left')
        axarr[0].set_title('History Transactions')

        xfmt = md.DateFormatter('%Y-%m-%d')
        ax.xaxis.set_major_formatter(xfmt)
        axarr[1].plot(datenums,
                      value_val,
                      marker='o',
                      linestyle='-',
                      color='green',
                      label='Value')

        axarr[1].legend(loc='upper left')
        #   plt.annotate('unknown transaction = %d \n pending transactions = %d' %(unknown_trans,pending_trans),xy=(0.7,0.05),xycoords='axes fraction',size=12)
        plt.show()