예제 #1
0
 def fiat_to_btc(self, fiat_amount):
     if not fiat_amount:
         return ''
     rate = self.fx.exchange_rate()
     if not rate:
         return ''
     satoshis = int(pow(10, 8) * Decimal(fiat_amount) / Decimal(rate))
     return format_satoshis_plain(satoshis, self.decimal_point())
예제 #2
0
 def get_max_amount(self):
     inputs = self.wallet.get_spendable_coins(None, self.electrum_config)
     addr = str(
         self.send_screen.screen.address) or self.wallet.dummy_address()
     outputs = [(TYPE_ADDRESS, addr, '!')]
     tx = self.wallet.make_unsigned_transaction(inputs, outputs,
                                                self.electrum_config)
     amount = tx.output_value()
     return format_satoshis_plain(amount, self.decimal_point())
예제 #3
0
    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)
예제 #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()))
예제 #5
0
 def format_amount_and_units(self, x):
     return format_satoshis_plain(
         x, self.decimal_point()) + ' ' + self.base_unit