fix tx signing with watching only wallets

This commit is contained in:
ThomasV 2013-11-12 11:14:16 +01:00
parent df76aac2db
commit 7ead6d18f2
4 changed files with 22 additions and 12 deletions

View File

@ -910,14 +910,16 @@ class ElectrumWindow(QMainWindow):
else: else:
QMessageBox.warning(self, _('Error'), msg, _('OK')) QMessageBox.warning(self, _('Error'), msg, _('OK'))
else: else:
filename = label + '.txn' if label else 'unsigned_%s.txn' % (time.mktime(time.gmtime()))
try: self.show_transaction(tx)
fileName = self.getSaveFileName(_("Select a transaction filename"), filename, "*.txn") #filename = label + '.txn' if label else 'unsigned_%s.txn' % (time.mktime(time.gmtime()))
with open(fileName,'w') as f: #try:
f.write(json.dumps(tx.as_dict(),indent=4) + '\n') # fileName = self.getSaveFileName(_("Select a transaction filename"), filename, "*.txn")
QMessageBox.information(self, _('Unsigned transaction created'), _("Unsigned transaction was saved to file:") + " " +fileName, _('OK')) # with open(fileName,'w') as f:
except Exception: # f.write(json.dumps(tx.as_dict(),indent=4) + '\n')
QMessageBox.warning(self, _('Error'), _('Could not write transaction to file'), _('OK')) # QMessageBox.information(self, _('Unsigned transaction created'), _("Unsigned transaction was saved to file:") + " " +fileName, _('OK'))
#except Exception:
# QMessageBox.warning(self, _('Error'), _('Could not write transaction to file'), _('OK'))
# add recipient to addressbook # add recipient to addressbook
if to_address not in self.wallet.addressbook and not self.wallet.is_mine(to_address): if to_address not in self.wallet.addressbook and not self.wallet.is_mine(to_address):

View File

@ -106,7 +106,8 @@ class TxDialog(QDialog):
def save(self): def save(self):
fileName = self.parent.getSaveFileName(_("Select where to save your signed transaction"), 'signed_%s.txn' % (self.tx.hash()[0:8]), "*.txn") name = 'signed_%s.txn' % (self.tx.hash()[0:8]) if self.tx.is_complete else 'unsigned.txn'
fileName = self.parent.getSaveFileName(_("Select where to save your signed transaction"), name, "*.txn")
if fileName: if fileName:
with open(fileName, "w+") as f: with open(fileName, "w+") as f:
f.write(json.dumps(self.tx.as_dict(),indent=4) + '\n') f.write(json.dumps(self.tx.as_dict(),indent=4) + '\n')
@ -115,13 +116,13 @@ class TxDialog(QDialog):
def update(self): def update(self):
tx_hash = self.tx.hash()
is_relevant, is_mine, v, fee = self.wallet.get_tx_value(self.tx) is_relevant, is_mine, v, fee = self.wallet.get_tx_value(self.tx)
if self.tx.is_complete: if self.tx.is_complete:
status = _("Status: Signed") status = _("Status: Signed")
self.sign_button.hide() self.sign_button.hide()
tx_hash = self.tx.hash()
if tx_hash in self.wallet.transactions.keys(): if tx_hash in self.wallet.transactions.keys():
conf, timestamp = self.wallet.verifier.get_confirmations(tx_hash) conf, timestamp = self.wallet.verifier.get_confirmations(tx_hash)
@ -138,8 +139,12 @@ class TxDialog(QDialog):
else: else:
status = _("Status: Unsigned") status = _("Status: Unsigned")
time_str = None time_str = None
self.sign_button.show() if not self.wallet.is_watching_only():
self.sign_button.show()
else:
self.sign_button.hide()
self.broadcast_button.hide() self.broadcast_button.hide()
tx_hash = 'unknown'
self.tx_hash_e.setText(tx_hash) self.tx_hash_e.setText(tx_hash)
self.status_label.setText(status) self.status_label.setText(status)

View File

@ -677,7 +677,7 @@ class Transaction:
'redeemScript':i.get('redeemScript'), 'redeemScript':i.get('redeemScript'),
'redeemPubkey':i.get('redeemPubkey'), 'redeemPubkey':i.get('redeemPubkey'),
'pubkeys':i.get('pubkeys'), 'pubkeys':i.get('pubkeys'),
'signatures':i.get('signatures'), 'signatures':i.get('signatures',[]),
} }
info.append(item) info.append(item)
return info return info

View File

@ -699,6 +699,9 @@ class Wallet:
def get_private_key(self, address, password): def get_private_key(self, address, password):
if self.is_watching_only():
return []
# first check the provided password # first check the provided password
seed = self.get_seed(password) seed = self.get_seed(password)