use json istead of ast
This commit is contained in:
parent
22a5226673
commit
50d029e61c
|
@ -934,14 +934,10 @@ class ElectrumWindow(QMainWindow):
|
||||||
QMessageBox.warning(self, _('Error'), msg, _('OK'))
|
QMessageBox.warning(self, _('Error'), msg, _('OK'))
|
||||||
else:
|
else:
|
||||||
filename = 'unsigned_tx_%s' % (time.mktime(time.gmtime()))
|
filename = 'unsigned_tx_%s' % (time.mktime(time.gmtime()))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
fileName = QFileDialog.getSaveFileName(QWidget(), _("Select a transaction filename"), os.path.expanduser('~/%s' % (filename)))
|
fileName = QFileDialog.getSaveFileName(QWidget(), _("Select a transaction filename"), os.path.expanduser('~/%s' % (filename)))
|
||||||
f = open(fileName,'w')
|
with open(fileName,'w') as f:
|
||||||
import json
|
f.write(json.dumps(tx.as_dict(),indent=4) + '\n')
|
||||||
out = json.dumps({"hex":str(tx), "complete":tx.is_complete, 'input_info':repr(tx.input_info).replace(' ','')}, indent=4)
|
|
||||||
f.write(out + '\n')
|
|
||||||
f.close()
|
|
||||||
QMessageBox.information(self, _('Unsigned transaction created'), _("Unsigned transaction was saved to file:") + " " +fileName, _('OK'))
|
QMessageBox.information(self, _('Unsigned transaction created'), _("Unsigned transaction was saved to file:") + " " +fileName, _('OK'))
|
||||||
except:
|
except:
|
||||||
QMessageBox.warning(self, _('Error'), _('Could not write transaction to file'), _('OK'))
|
QMessageBox.warning(self, _('Error'), _('Could not write transaction to file'), _('OK'))
|
||||||
|
@ -1801,7 +1797,7 @@ class ElectrumWindow(QMainWindow):
|
||||||
|
|
||||||
|
|
||||||
def sign_raw_transaction(self):
|
def sign_raw_transaction(self):
|
||||||
input_info = ast.literal_eval(self.raw_tx["input_info"])
|
input_info = json.loads(self.raw_tx["input_info"])
|
||||||
tx = Transaction(self.raw_tx["hex"])
|
tx = Transaction(self.raw_tx["hex"])
|
||||||
|
|
||||||
if self.wallet.use_encryption:
|
if self.wallet.use_encryption:
|
||||||
|
@ -1814,12 +1810,11 @@ class ElectrumWindow(QMainWindow):
|
||||||
try:
|
try:
|
||||||
self.wallet.signrawtransaction(tx, input_info, [], password)
|
self.wallet.signrawtransaction(tx, input_info, [], password)
|
||||||
|
|
||||||
fileName = QFileDialog.getSaveFileName(QWidget(), _("Select where to save your signed transaction"), os.path.expanduser('~/%s' % (tx.hash())))
|
fileName = QFileDialog.getSaveFileName(QWidget(), _("Select where to save your signed transaction"), os.path.expanduser('~/signed_tx_%s' % (tx.hash()[0:8])))
|
||||||
tx_hash = tx.as_dict()
|
|
||||||
if fileName:
|
if fileName:
|
||||||
with open(fileName, "w+") as transaction_file:
|
with open(fileName, "w+") as f:
|
||||||
transaction_file.write(str(json.dumps(tx_hash)))
|
f.write(json.dumps(tx.as_dict(),indent=4) + '\n')
|
||||||
self.show_message("Transaction signed succesfully")
|
self.show_message(_("Transaction saved succesfully"))
|
||||||
except BaseException, e:
|
except BaseException, e:
|
||||||
self.show_message(str(e))
|
self.show_message(str(e))
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue