|
|
@ -1680,7 +1680,7 @@ class ElectrumWindow(QMainWindow): |
|
|
|
|
|
|
|
|
|
|
|
@protected |
|
|
|
def sign_raw_transaction(self, tx, input_info, password): |
|
|
|
def sign_raw_transaction(self, tx, input_info, dialog ="", password = ""): |
|
|
|
try: |
|
|
|
self.wallet.signrawtransaction(tx, input_info, [], password) |
|
|
|
|
|
|
@ -1689,53 +1689,18 @@ class ElectrumWindow(QMainWindow): |
|
|
|
with open(fileName, "w+") as f: |
|
|
|
f.write(json.dumps(tx.as_dict(),indent=4) + '\n') |
|
|
|
self.show_message(_("Transaction saved succesfully")) |
|
|
|
if dialog: |
|
|
|
dialog.done(0) |
|
|
|
except BaseException, e: |
|
|
|
self.show_message(str(e)) |
|
|
|
|
|
|
|
|
|
|
|
def create_sign_transaction_window(self, tx_dict): |
|
|
|
tx = Transaction(tx_dict["hex"]) |
|
|
|
|
|
|
|
dialog = QDialog(self) |
|
|
|
dialog.setMinimumWidth(500) |
|
|
|
dialog.setWindowTitle(_('Sign unsigned transaction')) |
|
|
|
dialog.setModal(1) |
|
|
|
|
|
|
|
vbox = QVBoxLayout() |
|
|
|
dialog.setLayout(vbox) |
|
|
|
vbox.addWidget( self.generate_transaction_information_widget(tx) ) |
|
|
|
|
|
|
|
if tx_dict["complete"] == True: |
|
|
|
vbox.addWidget(QLabel(_("This transaction is already signed."))) |
|
|
|
else: |
|
|
|
vbox.addWidget(QLabel(_("Create a signed transaction."))) |
|
|
|
vbox.addLayout(ok_cancel_buttons(dialog)) |
|
|
|
input_info = json.loads(tx_dict["input_info"]) |
|
|
|
|
|
|
|
if dialog.exec_(): |
|
|
|
self.sign_raw_transaction(tx, input_info) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def do_sign_from_text(self): |
|
|
|
txt, ok = QInputDialog.getText(QTextEdit(), _('Sign raw transaction'), _('Transaction data in JSON') + ':') |
|
|
|
if not ok: |
|
|
|
return |
|
|
|
tx_dict = self.tx_dict_from_text(unicode(txt)) |
|
|
|
if tx_dict: |
|
|
|
self.create_sign_transaction_window(tx_dict) |
|
|
|
|
|
|
|
|
|
|
|
def do_sign_from_file(self): |
|
|
|
tx_dict = self.read_tx_from_file() |
|
|
|
if tx_dict: |
|
|
|
self.create_sign_transaction_window(tx_dict) |
|
|
|
|
|
|
|
|
|
|
|
def send_raw_transaction(self, raw_tx): |
|
|
|
def send_raw_transaction(self, raw_tx, dialog = ""): |
|
|
|
result, result_message = self.wallet.sendtx( raw_tx ) |
|
|
|
if result: |
|
|
|
self.show_message("Transaction succesfully sent: %s" % (result_message)) |
|
|
|
if dialog: |
|
|
|
dialog.done(0) |
|
|
|
else: |
|
|
|
self.show_message("There was a problem sending your transaction:\n %s" % (result_message)) |
|
|
|
|
|
|
@ -1762,53 +1727,20 @@ class ElectrumWindow(QMainWindow): |
|
|
|
l.addWidget(QLabel(_("Unsigned")), 0,1) |
|
|
|
if self.wallet.seed : |
|
|
|
b = QPushButton("Sign transaction") |
|
|
|
input_info = json.loads(tx_dict["input_info"]) |
|
|
|
b.clicked.connect(lambda: self.sign_raw_transaction(tx, input_info, dialog)) |
|
|
|
l.addWidget(b, 1, 1) |
|
|
|
else: |
|
|
|
l.addWidget(QLabel(_("Wallet is de-seeded, can't sign.")), 1,1) |
|
|
|
else: |
|
|
|
l.addWidget(QLabel(_("Signed")), 0,1) |
|
|
|
b = QPushButton("Broadcast transaction") |
|
|
|
b.clicked.connect(lambda: self.send_raw_transaction(tx, dialog)) |
|
|
|
l.addWidget(b,1,1) |
|
|
|
|
|
|
|
l.addWidget( self.generate_transaction_information_widget(tx), 2,0,2,3) |
|
|
|
|
|
|
|
if dialog.exec_(): |
|
|
|
self.send_raw_transaction(tx_dict["hex"]) |
|
|
|
|
|
|
|
def create_send_transaction_window(self, tx_dict): |
|
|
|
tx = Transaction(tx_dict["hex"]) |
|
|
|
|
|
|
|
dialog = QDialog(self) |
|
|
|
dialog.setMinimumWidth(500) |
|
|
|
dialog.setWindowTitle(_('Send raw transaction')) |
|
|
|
dialog.setModal(1) |
|
|
|
|
|
|
|
vbox = QVBoxLayout() |
|
|
|
dialog.setLayout(vbox) |
|
|
|
vbox.addWidget( self.generate_transaction_information_widget(tx)) |
|
|
|
|
|
|
|
if tx_dict["complete"] == False: |
|
|
|
vbox.addWidget(QLabel(_("This transaction is not signed yet."))) |
|
|
|
else: |
|
|
|
vbox.addWidget(QLabel(_("Broadcast this transaction"))) |
|
|
|
vbox.addLayout(ok_cancel_buttons(dialog)) |
|
|
|
|
|
|
|
if dialog.exec_(): |
|
|
|
self.send_raw_transaction(tx_dict["hex"]) |
|
|
|
|
|
|
|
def do_send_from_file(self): |
|
|
|
tx_dict = self.read_tx_from_file() |
|
|
|
if tx_dict: |
|
|
|
self.create_send_transaction_window(tx_dict) |
|
|
|
|
|
|
|
|
|
|
|
def do_send_from_text(self): |
|
|
|
txt, ok = QInputDialog.getText(QTextEdit(), _('Send raw transaction'), _('Transaction data in JSON') + ':') |
|
|
|
if not ok: |
|
|
|
return |
|
|
|
tx_dict = self.tx_dict_from_text(unicode(txt)) |
|
|
|
if tx_dict: |
|
|
|
self.create_send_transaction_window(tx_dict) |
|
|
|
dialog.exec_() |
|
|
|
|
|
|
|
|
|
|
|
@protected |
|
|
@ -2041,17 +1973,6 @@ class ElectrumWindow(QMainWindow): |
|
|
|
grid_raw.setColumnStretch(0,1) |
|
|
|
tabs.addTab(tab4, _('Raw tx') ) # move this to wallet tab |
|
|
|
|
|
|
|
if self.wallet.seed: |
|
|
|
grid_raw.addWidget(QLabel(_("Sign transaction")), 1, 0) |
|
|
|
grid_raw.addWidget(EnterButton(_("From file"), self.do_sign_from_file),1,1) |
|
|
|
grid_raw.addWidget(EnterButton(_("From text"), self.do_sign_from_text),1,2) |
|
|
|
grid_raw.addWidget(HelpButton(_("Sign an unsigned transaction generated by a watching-only wallet")),1,3) |
|
|
|
|
|
|
|
grid_raw.addWidget(QLabel(_("Send signed transaction")), 2, 0) |
|
|
|
grid_raw.addWidget(EnterButton(_("From file"), self.do_send_from_file),2,1) |
|
|
|
grid_raw.addWidget(EnterButton(_("From text"), self.do_send_from_text),2,2) |
|
|
|
grid_raw.addWidget(HelpButton(_("This will broadcast a transaction to the network.")),2,3) |
|
|
|
|
|
|
|
grid_raw.addWidget(QLabel(_("Process raw transaction")), 3, 0) |
|
|
|
grid_raw.addWidget(EnterButton(_("From file"), self.do_process_from_file),3,1) |
|
|
|
grid_raw.addWidget(EnterButton(_("From text"), self.do_process_from_file),3,2) |
|
|
|