Add 'create transaction' from deseeded wallet to Lite gui

This commit is contained in:
Maran 2013-03-10 12:52:39 +01:00
parent c5047d4168
commit 18bcf5b206
1 changed files with 30 additions and 17 deletions

View File

@ -17,6 +17,7 @@ from electrum.bitcoin import is_valid
from i18n import _ from i18n import _
import decimal import decimal
import exchange_rate import exchange_rate
import json
import os.path import os.path
import random import random
import re import re
@ -293,7 +294,11 @@ class MiniWindow(QDialog):
self.amount_input.setAttribute(Qt.WA_MacShowFocusRect, 0) self.amount_input.setAttribute(Qt.WA_MacShowFocusRect, 0)
self.amount_input.textChanged.connect(self.amount_input_changed) self.amount_input.textChanged.connect(self.amount_input_changed)
self.send_button = QPushButton(_("&Send")) if self.actuator.wallet.seed:
self.send_button = QPushButton(_("&Send"))
else:
self.send_button = QPushButton(_("&Create"))
self.send_button.setObjectName("send_button") self.send_button.setObjectName("send_button")
self.send_button.setDisabled(True); self.send_button.setDisabled(True);
self.send_button.clicked.connect(self.send) self.send_button.clicked.connect(self.send)
@ -856,24 +861,32 @@ class MiniActuator:
QMessageBox.warning(parent_window, _('Error'), str(error), _('OK')) QMessageBox.warning(parent_window, _('Error'), str(error), _('OK'))
return False return False
h = self.wallet.send_tx(tx) if tx.is_complete:
h = self.wallet.send_tx(tx)
self.waiting_dialog(lambda: False if self.wallet.tx_event.isSet() else _("Sending transaction, please wait...")) self.waiting_dialog(lambda: False if self.wallet.tx_event.isSet() else _("Sending transaction, please wait..."))
status, message = self.wallet.receive_tx(h)
if not status:
import tempfile
dumpf = tempfile.NamedTemporaryFile(delete=False)
dumpf.write(tx)
dumpf.close()
print "Dumped error tx to", dumpf.name
QMessageBox.warning(parent_window, _('Error'), message, _('OK'))
return False
status, message = self.wallet.receive_tx(h) TransactionWindow(message, self)
else:
if not status: filename = 'unsigned_tx_%s' % (time.mktime(time.gmtime()))
import tempfile try:
dumpf = tempfile.NamedTemporaryFile(delete=False) fileName = QFileDialog.getSaveFileName(QWidget(), _("Select a transaction filename"), os.path.expanduser('~/%s' % (filename)))
dumpf.write(tx) with open(fileName,'w') as f:
dumpf.close() f.write(json.dumps(tx.as_dict(),indent=4) + '\n')
print "Dumped error tx to", dumpf.name QMessageBox.information(QWidget(), _('Unsigned transaction created'), _("Unsigned transaction was saved to file:") + " " +fileName, _('OK'))
QMessageBox.warning(parent_window, _('Error'), message, _('OK')) except BaseException as e:
return False QMessageBox.warning(QWidget(), _('Error'), _('Could not write transaction to file: %s' % e), _('OK'))
TransactionWindow(message, self)
# QMessageBox.information(parent_window, '',
# _('Your transaction has been sent.') + '\n' + message, _('OK'))
return True return True
def fetch_destination(self, address): def fetch_destination(self, address):