import icons_rc
-from electrum.wallet import format_satoshis
+from electrum.util import format_satoshis
from electrum import Transaction
from electrum import mnemonic
from electrum import util, bitcoin, commands, Interface, Wallet
set_language(config.get('language'))
- self.funds_error = False
self.completions = QStringListModel()
self.tabs = tabs = QTabWidget(self)
def edit_label(self, is_recv):
- l = self.receive_list if is_recv else self.contacts_list
+ l = self.address_list if is_recv else self.contacts_list
item = l.currentItem()
item.setFlags(Qt.ItemIsEditable|Qt.ItemIsSelectable | Qt.ItemIsUserCheckable | Qt.ItemIsEnabled | Qt.ItemIsDragEnabled)
l.editItem( item, 1 )
for address, v in self.receive_requests.items():
amount, message = v
item = QTreeWidgetItem( [ address, message, self.format_amount(amount) if amount else ""] )
+ item.setFont(0, QFont(MONOSPACE_FONT))
self.receive_list.addTopLevelItem(item)
w.setLayout(grid)
def entry_changed( is_fee ):
- self.funds_error = False
if self.amount_e.is_shortcut:
self.amount_e.is_shortcut = False
fee = self.wallet.estimated_fee(inputs, 1)
amount = total - fee
self.amount_e.setAmount(amount)
+ self.amount_e.textEdited.emit("")
self.fee_e.setAmount(fee)
return
if not is_fee: fee = None
if amount is None:
+ self.fee_e.setAmount(None)
return
# assume that there will be 2 outputs (one for change)
inputs, total, fee = self.wallet.choose_tx_inputs(amount, fee, 2, coins = self.get_coins())
else:
palette = QPalette()
palette.setColor(self.amount_e.foregroundRole(), QColor('red'))
- self.funds_error = True
text = _( "Not enough funds" )
c, u = self.wallet.get_frozen_balance()
if c+u: text += ' (' + self.format_amount(c+u).strip() + ' ' + self.base_unit() + ' ' +_("are frozen") + ')'
# sign the tx
def sign_thread():
- time.sleep(0.1)
keypairs = {}
- self.wallet.add_keypairs_from_wallet(tx, keypairs, password)
- self.wallet.sign_transaction(tx, keypairs, password)
- return tx, fee, label
+ try:
+ self.wallet.add_keypairs(tx, keypairs, password)
+ self.wallet.sign_transaction(tx, keypairs, password)
+ except Exception as e:
+ tx.error = str(e)
+ return tx
- def sign_done(tx, fee, label):
+ def sign_done(tx):
if tx.error:
self.show_message(tx.error)
self.send_button.setDisabled(False)
self.broadcast_transaction(tx)
+ # keep a reference to WaitingDialog or the gui might crash
self.waiting_dialog = WaitingDialog(self, 'Signing..', sign_thread, sign_done)
self.waiting_dialog.start()
def show_qrcode(self, data, title = _("QR code")):
if not data:
return
- print_error("qrcode:", data)
d = QRDialog(data, self, title)
d.exec_()
"json or raw hexadecimal"
try:
txt.decode('hex')
- tx = Transaction(txt)
- return tx
- except Exception:
- pass
+ is_hex = True
+ except:
+ is_hex = False
+
+ if is_hex:
+ try:
+ return Transaction(txt)
+ except:
+ traceback.print_exc(file=sys.stdout)
+ QMessageBox.critical(None, _("Unable to parse transaction"), _("Electrum was unable to parse your transaction"))
+ return
try:
tx_dict = json.loads(str(txt))
assert "hex" in tx_dict.keys()
tx = Transaction(tx_dict["hex"])
- if tx_dict.has_key("input_info"):
- input_info = json.loads(tx_dict['input_info'])
- tx.add_input_info(input_info)
+ #if tx_dict.has_key("input_info"):
+ # input_info = json.loads(tx_dict['input_info'])
+ # tx.add_input_info(input_info)
return tx
except Exception:
traceback.print_exc(file=sys.stdout)
- pass
-
- QMessageBox.critical(None, _("Unable to parse transaction"), _("Electrum was unable to parse your transaction"))
+ QMessageBox.critical(None, _("Unable to parse transaction"), _("Electrum was unable to parse your transaction"))
@protected
- def sign_raw_transaction(self, tx, input_info, password):
+ def sign_raw_transaction(self, tx, password):
try:
- self.wallet.signrawtransaction(tx, input_info, [], password)
+ self.wallet.signrawtransaction(tx, [], password)
except Exception as e:
+ traceback.print_exc(file=sys.stdout)
QMessageBox.warning(self, _("Error"), str(e))
def do_process_from_text(self):