Browse Source

new command: signtx (offline transaction signing)

283
thomasv 12 years ago
parent
commit
4e070bda57
  1. 16
      electrum
  2. 27
      lib/gui_qt.py
  3. 12
      lib/wallet.py

16
electrum

@ -67,6 +67,7 @@ options:
Syntax: mktx <recipient> <amount> [label]
options:\n --fee, -f: set transaction fee\n --fromaddr, -s: send from address -\n --changeaddr, -c: send change to address
""",
'signtx':"Sign an unsigned transaction created by a deseeded wallet\nSyntax: signtx <filename>",
'seed':
"Print the generation seed of your wallet.",
'import':
@ -93,7 +94,7 @@ options:\n --fee, -f: set transaction fee\n --fromaddr, -s: send from address
offline_commands = [ 'password', 'mktx',
offline_commands = [ 'password', 'mktx', 'signtx',
'label', 'contacts',
'help', 'validateaddress',
'signmessage', 'verifymessage',
@ -104,7 +105,7 @@ offline_commands = [ 'password', 'mktx',
'prioritize','unprioritize']
protected_commands = ['payto', 'password', 'mktx', 'seed', 'import','signmessage' ]
protected_commands = ['payto', 'password', 'mktx', 'signtx', 'seed', 'import','signmessage' ]
# get password routine
def prompt_password(prompt, confirm=True):
@ -594,6 +595,17 @@ if __name__ == '__main__':
del(wallet.history[from_addr])
wallet.save()
elif cmd == 'signtx':
import ast
filename = args[1]
f = open(filename, 'r')
d = ast.literal_eval(f.read())
f.close()
inputs = d['inputs']
outputs = d['outputs']
tx = wallet.signed_tx( inputs, outputs, password )
print_msg(tx)
elif cmd == 'sendtx':
tx = args[1]
r, h = wallet.sendtx( tx )

27
lib/gui_qt.py

@ -308,8 +308,7 @@ class ElectrumWindow(QMainWindow):
self.tabs = tabs = QTabWidget(self)
tabs.addTab(self.create_history_tab(), _('History') )
if self.wallet.seed:
tabs.addTab(self.create_send_tab(), _('Send') )
tabs.addTab(self.create_send_tab(), _('Send') )
tabs.addTab(self.create_receive_tab(), _('Receive') )
tabs.addTab(self.create_contacts_tab(), _('Contacts') )
tabs.addTab(self.create_wall_tab(), _('Wall') )
@ -772,17 +771,23 @@ class ElectrumWindow(QMainWindow):
except BaseException, e:
self.show_message(str(e))
return
h = self.wallet.send_tx(tx)
waiting_dialog(lambda: False if self.wallet.tx_event.isSet() else _("Please wait..."))
status, msg = self.wallet.receive_tx( h )
if status:
QMessageBox.information(self, '', _('Payment sent.')+'\n'+msg, _('OK'))
self.do_clear()
self.update_contacts_tab()
if self.wallet.seed:
h = self.wallet.send_tx(tx)
waiting_dialog(lambda: False if self.wallet.tx_event.isSet() else _("Please wait..."))
status, msg = self.wallet.receive_tx( h )
if status:
QMessageBox.information(self, '', _('Payment sent.')+'\n'+msg, _('OK'))
self.do_clear()
self.update_contacts_tab()
else:
QMessageBox.warning(self, _('Error'), msg, _('OK'))
else:
QMessageBox.warning(self, _('Error'), msg, _('OK'))
filename = 'unsigned_tx'
f = open(filename,'w')
f.write(tx)
f.close()
QMessageBox.information(self, _('Unsigned transaction'), _("Unsigned transaction was saved to file:") + " " +filename, _('OK'))
def set_url(self, url):

12
lib/wallet.py

@ -776,10 +776,11 @@ class Wallet:
change_addr = inputs[-1][0]
print_error( "Sending change to", change_addr )
outputs = self.add_tx_change(outputs, amount, fee, total, change_addr)
s_inputs = self.sign_inputs( inputs, outputs, password )
tx = filter( raw_tx( s_inputs, outputs ) )
if not self.seed:
return {'inputs':inputs, 'outputs':outputs}
tx = repr(self.signed_tx(inputs, outputs, password))
for address, x in outputs:
if address not in self.addressbook and not self.is_mine(address):
@ -791,6 +792,11 @@ class Wallet:
return tx
def signed_tx(self, inputs, outputs, password):
s_inputs = self.sign_inputs( inputs, outputs, password )
tx = filter( raw_tx( s_inputs, outputs ) )
return tx
def sendtx(self, tx):
# synchronous
h = self.send_tx(tx)

Loading…
Cancel
Save