mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-02 02:05:19 +00:00
new command: signtx (offline transaction signing)
This commit is contained in:
parent
c763445734
commit
4e070bda57
3 changed files with 39 additions and 16 deletions
16
electrum
16
electrum
|
@ -67,6 +67,7 @@ options:
|
||||||
Syntax: mktx <recipient> <amount> [label]
|
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
|
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':
|
'seed':
|
||||||
"Print the generation seed of your wallet.",
|
"Print the generation seed of your wallet.",
|
||||||
'import':
|
'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',
|
'label', 'contacts',
|
||||||
'help', 'validateaddress',
|
'help', 'validateaddress',
|
||||||
'signmessage', 'verifymessage',
|
'signmessage', 'verifymessage',
|
||||||
|
@ -104,7 +105,7 @@ offline_commands = [ 'password', 'mktx',
|
||||||
'prioritize','unprioritize']
|
'prioritize','unprioritize']
|
||||||
|
|
||||||
|
|
||||||
protected_commands = ['payto', 'password', 'mktx', 'seed', 'import','signmessage' ]
|
protected_commands = ['payto', 'password', 'mktx', 'signtx', 'seed', 'import','signmessage' ]
|
||||||
|
|
||||||
# get password routine
|
# get password routine
|
||||||
def prompt_password(prompt, confirm=True):
|
def prompt_password(prompt, confirm=True):
|
||||||
|
@ -594,6 +595,17 @@ if __name__ == '__main__':
|
||||||
del(wallet.history[from_addr])
|
del(wallet.history[from_addr])
|
||||||
wallet.save()
|
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':
|
elif cmd == 'sendtx':
|
||||||
tx = args[1]
|
tx = args[1]
|
||||||
r, h = wallet.sendtx( tx )
|
r, h = wallet.sendtx( tx )
|
||||||
|
|
|
@ -308,8 +308,7 @@ class ElectrumWindow(QMainWindow):
|
||||||
|
|
||||||
self.tabs = tabs = QTabWidget(self)
|
self.tabs = tabs = QTabWidget(self)
|
||||||
tabs.addTab(self.create_history_tab(), _('History') )
|
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_receive_tab(), _('Receive') )
|
||||||
tabs.addTab(self.create_contacts_tab(), _('Contacts') )
|
tabs.addTab(self.create_contacts_tab(), _('Contacts') )
|
||||||
tabs.addTab(self.create_wall_tab(), _('Wall') )
|
tabs.addTab(self.create_wall_tab(), _('Wall') )
|
||||||
|
@ -772,17 +771,23 @@ class ElectrumWindow(QMainWindow):
|
||||||
except BaseException, e:
|
except BaseException, e:
|
||||||
self.show_message(str(e))
|
self.show_message(str(e))
|
||||||
return
|
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:
|
if self.wallet.seed:
|
||||||
QMessageBox.information(self, '', _('Payment sent.')+'\n'+msg, _('OK'))
|
h = self.wallet.send_tx(tx)
|
||||||
self.do_clear()
|
waiting_dialog(lambda: False if self.wallet.tx_event.isSet() else _("Please wait..."))
|
||||||
self.update_contacts_tab()
|
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:
|
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):
|
def set_url(self, url):
|
||||||
|
|
|
@ -776,10 +776,11 @@ class Wallet:
|
||||||
change_addr = inputs[-1][0]
|
change_addr = inputs[-1][0]
|
||||||
print_error( "Sending change to", change_addr )
|
print_error( "Sending change to", change_addr )
|
||||||
outputs = self.add_tx_change(outputs, amount, fee, total, 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:
|
for address, x in outputs:
|
||||||
if address not in self.addressbook and not self.is_mine(address):
|
if address not in self.addressbook and not self.is_mine(address):
|
||||||
|
@ -791,6 +792,11 @@ class Wallet:
|
||||||
|
|
||||||
return tx
|
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):
|
def sendtx(self, tx):
|
||||||
# synchronous
|
# synchronous
|
||||||
h = self.send_tx(tx)
|
h = self.send_tx(tx)
|
||||||
|
|
Loading…
Add table
Reference in a new issue