Exemplo n.º 1
0
 def get_max_amount(self):
     from electrum_vestx.transaction import TxOutput
     if run_hook('abort_send', self):
         return ''
     inputs = self.wallet.get_spendable_coins(None, self.electrum_config)
     if not inputs:
         return ''
     addr = str(
         self.send_screen.screen.address) or self.wallet.dummy_address()
     outputs = [TxOutput(TYPE_ADDRESS, addr, '!')]
     try:
         tx = self.wallet.make_unsigned_transaction(inputs, outputs,
                                                    self.electrum_config)
     except NoDynamicFeeEstimates as e:
         Clock.schedule_once(
             lambda dt, bound_e=e: self.show_error(str(bound_e)))
         return ''
     except NotEnoughFunds:
         return ''
     except InternalAddressCorruption as e:
         self.show_error(str(e))
         send_exception_to_crash_reporter(e)
         return ''
     amount = tx.output_value()
     __, x_fee_amount = run_hook('get_tx_extra_fee', self.wallet,
                                 tx) or (None, 0)
     amount_after_all_fees = amount - x_fee_amount
     return format_satoshis_plain(amount_after_all_fees,
                                  self.decimal_point())
Exemplo n.º 2
0
 def fiat_to_btc(self, fiat_amount):
     if not fiat_amount:
         return ''
     rate = self.fx.exchange_rate()
     if rate.is_nan():
         return ''
     satoshis = int(pow(10, 8) * Decimal(fiat_amount) / Decimal(rate))
     return format_satoshis_plain(satoshis, self.decimal_point())
    def data(self, index, role = Qt.DisplayRole):
        if not index.isValid():
            return None
        if role not in [Qt.EditRole, Qt.DisplayRole, Qt.ToolTipRole, Qt.FontRole]:
            return None

        data = None
        p = self.proposals[index.row()]
        c = index.column()

        if c == self.NAME:
            data = p.proposal_name
        elif c == self.URL:
            data = p.proposal_url
        elif c == self.YES_COUNT:
            data = p.yes_count
        elif c == self.NO_COUNT:
            data = p.no_count
        elif c == self.START_BLOCK:
            data = p.start_block
            if role == Qt.FontRole:
                data = util.MONOSPACE_FONT
        elif c == self.END_BLOCK:
            data = p.end_block
            if role == Qt.FontRole:
                data = util.MONOSPACE_FONT
        elif c == self.AMOUNT:
            data = p.payment_amount
            if role in [Qt.DisplayRole, Qt.EditRole]:
                data = format_satoshis_plain(data)
        elif c == self.ADDRESS:
            data = p.address
            if role == Qt.FontRole:
                data = util.MONOSPACE_FONT
        elif c == self.TXID:
            data = p.fee_txid
            if role == Qt.FontRole:
                data = util.MONOSPACE_FONT

        return QVariant(data)
Exemplo n.º 4
0
 def setAmount(self, amount):
     if amount is None:
         self.setText(" ")  # Space forces repaint in case units changed
     else:
         self.setText(format_satoshis_plain(amount, self.decimal_point()))
Exemplo n.º 5
0
 def format_amount_and_units(self, x):
     return format_satoshis_plain(
         x, self.decimal_point()) + ' ' + self.base_unit