1
0

compact serialized format for unsigned and partially signed transactions.

This commit is contained in:
ThomasV
2014-06-21 21:06:09 +02:00
parent 378633e6fa
commit 0636ef8b32
8 changed files with 251 additions and 177 deletions

View File

@@ -1024,7 +1024,7 @@ class ElectrumWindow(QMainWindow):
def sign_thread():
time.sleep(0.1)
keypairs = {}
self.wallet.add_keypairs_from_wallet(tx, keypairs, password)
self.wallet.add_keypairs(tx, keypairs, password)
self.wallet.sign_transaction(tx, keypairs, password)
return tx, fee, label
@@ -1814,7 +1814,6 @@ class ElectrumWindow(QMainWindow):
def show_qrcode(self, data, title = _("QR code")):
if not data:
return
print_error("qrcode:", data)
d = QRDialog(data, self, title)
d.exec_()
@@ -2046,24 +2045,29 @@ class ElectrumWindow(QMainWindow):
"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"))
@@ -2081,10 +2085,11 @@ class ElectrumWindow(QMainWindow):
@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):

View File

@@ -105,17 +105,15 @@ class TxDialog(QDialog):
def show_qr(self):
text = self.tx.raw.decode('hex')
try:
json_text = json.dumps(self.tx.as_dict()).replace(' ', '')
self.parent.show_qrcode(json_text, 'Transaction')
self.parent.show_qrcode(text, 'Transaction')
except Exception as e:
self.show_message(str(e))
def sign(self):
tx_dict = self.tx.as_dict()
input_info = json.loads(tx_dict["input_info"])
self.parent.sign_raw_transaction(self.tx, input_info)
self.parent.sign_raw_transaction(self.tx)
self.update()