support mBTC in lite gui

This commit is contained in:
ThomasV 2013-09-28 11:45:39 +02:00
parent 6644fcc22e
commit 13fd5b7e3c
2 changed files with 11 additions and 10 deletions

View File

@ -209,7 +209,7 @@ class MiniWindow(QDialog):
address_layout.addWidget(self.address_input) address_layout.addWidget(self.address_input)
self.amount_input = QLineEdit() self.amount_input = QLineEdit()
self.amount_input.setPlaceholderText(_("... and amount")) self.amount_input.setPlaceholderText(_("... and amount") + " (%s)"%self.actuator.g.base_unit())
self.amount_input.setObjectName("amount_input") self.amount_input.setObjectName("amount_input")
self.amount_input.setFocusPolicy(Qt.ClickFocus) self.amount_input.setFocusPolicy(Qt.ClickFocus)
@ -415,11 +415,11 @@ class MiniWindow(QDialog):
self.check_button_status() self.check_button_status()
try: try:
amount = D(str(amount_text)) amount = D(str(amount_text)) * (10**self.actuator.g.decimal_point)
except decimal.InvalidOperation: except decimal.InvalidOperation:
self.balance_label.show_balance() self.balance_label.show_balance()
else: else:
quote_text = self.create_quote_text(amount * bitcoin(1)) quote_text = self.create_quote_text(amount)
if quote_text: if quote_text:
self.balance_label.set_amount_text(quote_text) self.balance_label.set_amount_text(quote_text)
self.balance_label.show_amount() self.balance_label.show_amount()
@ -444,7 +444,7 @@ class MiniWindow(QDialog):
"""Check that the bitcoin address is valid and that something """Check that the bitcoin address is valid and that something
is entered in the amount before making the send button clickable.""" is entered in the amount before making the send button clickable."""
try: try:
value = D(str(self.amount_input.text())) * 10**8 value = D(str(self.amount_input.text())) * (10**self.actuator.g.decimal_point)
except decimal.InvalidOperation: except decimal.InvalidOperation:
value = None value = None
# self.address_input.property(...) returns a qVariant, not a bool. # self.address_input.property(...) returns a qVariant, not a bool.
@ -495,8 +495,7 @@ class MiniWindow(QDialog):
for item in tx_history[-10:]: for item in tx_history[-10:]:
tx_hash, conf, is_mine, value, fee, balance, timestamp = item tx_hash, conf, is_mine, value, fee, balance, timestamp = item
label = self.actuator.g.wallet.get_label(tx_hash)[0] label = self.actuator.g.wallet.get_label(tx_hash)[0]
#amount = D(value) / 10**8 v_str = self.actuator.g.format_amount(value, True)
v_str = format_satoshis(value, True)
self.history_list.append(label, v_str, age(timestamp)) self.history_list.append(label, v_str, age(timestamp))
@ -731,9 +730,9 @@ class MiniActuator:
_('Invalid Bitcoin Address') + ':\n' + address, _('OK')) _('Invalid Bitcoin Address') + ':\n' + address, _('OK'))
return False return False
convert_amount = lambda amount: \ amount = D(unicode(amount)) * (10*self.g.decimal_point)
int(D(unicode(amount)) * bitcoin(1)) print "amount", amount
amount = convert_amount(amount) return
if self.g.wallet.use_encryption: if self.g.wallet.use_encryption:
password_dialog = PasswordDialog(parent_window) password_dialog = PasswordDialog(parent_window)

View File

@ -938,6 +938,9 @@ class ElectrumWindow(QMainWindow):
def set_url(self, url): def set_url(self, url):
address, amount, label, message, signature, identity, url = util.parse_url(url) address, amount, label, message, signature, identity, url = util.parse_url(url)
if amount and self.base_unit() == 'mBTC': amount = str( 1000* Decimal(amount))
if self.mini: if self.mini:
self.mini.set_payment_fields(address, amount) self.mini.set_payment_fields(address, amount)
@ -956,7 +959,6 @@ class ElectrumWindow(QMainWindow):
self.message_e.setText(message) self.message_e.setText(message)
if amount: if amount:
if self.base_unit() == 'mBTC': amount = str( 1000* Decimal(amount))
self.amount_e.setText(amount) self.amount_e.setText(amount)
if identity: if identity: