first sketch of qt gui
This commit is contained in:
parent
1d15286015
commit
9829253ecf
|
@ -31,7 +31,7 @@ urldecode = lambda x: _ud.sub(lambda m: chr(int(m.group(1), 16)), x)
|
||||||
from wallet import format_satoshis
|
from wallet import format_satoshis
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
known_commands = ['help', 'validateaddress', 'balance', 'contacts', 'create', 'payto', 'sendtx', 'password', 'newaddress', 'addresses', 'history', 'label', 'gui', 'mktx','seed','import','signmessage','verifymessage','eval']
|
known_commands = ['help', 'validateaddress', 'balance', 'contacts', 'create', 'payto', 'sendtx', 'password', 'newaddress', 'addresses', 'history', 'label', 'mktx','seed','import','signmessage','verifymessage','eval', 'gtk','qt']
|
||||||
|
|
||||||
usage = "usage: %prog [options] command args\nCommands: "+ (', '.join(known_commands))
|
usage = "usage: %prog [options] command args\nCommands: "+ (', '.join(known_commands))
|
||||||
|
|
||||||
|
@ -44,23 +44,30 @@ if __name__ == '__main__':
|
||||||
parser.add_option("-s", "--fromaddr", dest="from_addr", default=None, help="set source address for payto/mktx. if it isn't in the wallet, it will ask for the private key unless supplied in the format public_key:private_key. It's not saved in the wallet.")
|
parser.add_option("-s", "--fromaddr", dest="from_addr", default=None, help="set source address for payto/mktx. if it isn't in the wallet, it will ask for the private key unless supplied in the format public_key:private_key. It's not saved in the wallet.")
|
||||||
parser.add_option("-c", "--changeaddr", dest="change_addr", default=None, help="set the change address for payto/mktx. default is a spare address, or the source address if it's not in the wallet")
|
parser.add_option("-c", "--changeaddr", dest="change_addr", default=None, help="set the change address for payto/mktx. default is a spare address, or the source address if it's not in the wallet")
|
||||||
options, args = parser.parse_args()
|
options, args = parser.parse_args()
|
||||||
try:
|
|
||||||
cmd = args[0]
|
|
||||||
except:
|
|
||||||
cmd = "gui"
|
|
||||||
try:
|
|
||||||
firstarg = args[1]
|
|
||||||
except:
|
|
||||||
firstarg = ''
|
|
||||||
|
|
||||||
interface = Interface()
|
interface = Interface()
|
||||||
wallet = Wallet(interface)
|
wallet = Wallet(interface)
|
||||||
wallet.set_path(options.wallet_path)
|
wallet.set_path(options.wallet_path)
|
||||||
|
|
||||||
if cmd == 'gui' or re.match('^bitcoin:', cmd):
|
cmd = args[0] if len(args) > 0 else 'gtk'
|
||||||
import gui
|
firstarg = args[1] if len(args) > 1 else ''
|
||||||
|
|
||||||
|
|
||||||
|
if cmd in ['gtk','qt'] or re.match('^bitcoin:', cmd):
|
||||||
|
if cmd == 'qt':
|
||||||
|
import gui_qt as gui
|
||||||
|
else:
|
||||||
|
import gui
|
||||||
|
|
||||||
interface.get_servers()
|
interface.get_servers()
|
||||||
gui.init_wallet(wallet)
|
try:
|
||||||
|
found = wallet.read()
|
||||||
|
if not found:
|
||||||
|
gui.restore_create_dialog(wallet)
|
||||||
|
except BaseException, e:
|
||||||
|
show_message(e.message)
|
||||||
|
exit(1)
|
||||||
|
|
||||||
gui = gui.BitcoinGUI(wallet)
|
gui = gui.BitcoinGUI(wallet)
|
||||||
interface.start(wallet)
|
interface.start(wallet)
|
||||||
|
|
||||||
|
@ -213,7 +220,7 @@ if __name__ == '__main__':
|
||||||
print "show the transaction history"
|
print "show the transaction history"
|
||||||
elif cmd2 == 'label':
|
elif cmd2 == 'label':
|
||||||
print "assign a label to an item"
|
print "assign a label to an item"
|
||||||
elif cmd2 == 'gui':
|
elif cmd2 == 'gtk':
|
||||||
print "start the GUI"
|
print "start the GUI"
|
||||||
elif cmd2 == 'mktx':
|
elif cmd2 == 'mktx':
|
||||||
print "create a signed transaction. password protected"
|
print "create a signed transaction. password protected"
|
||||||
|
|
125
client/gui.py
125
client/gui.py
|
@ -74,81 +74,74 @@ def show_seed_dialog(wallet, password, parent):
|
||||||
dialog.run()
|
dialog.run()
|
||||||
dialog.destroy()
|
dialog.destroy()
|
||||||
|
|
||||||
def init_wallet(wallet):
|
def restore_create_dialog(wallet):
|
||||||
|
|
||||||
try:
|
# ask if the user wants to create a new wallet, or recover from a seed.
|
||||||
found = wallet.read()
|
# if he wants to recover, and nothing is found, do not create wallet
|
||||||
except BaseException, e:
|
dialog = gtk.Dialog("electrum", parent=None,
|
||||||
show_message(e.message)
|
flags=gtk.DIALOG_MODAL|gtk.DIALOG_NO_SEPARATOR,
|
||||||
exit(1)
|
buttons= ("create", 0, "restore",1, "cancel",2) )
|
||||||
|
|
||||||
if not found:
|
label = gtk.Label("Wallet file not found.\nDo you want to create a new wallet,\n or to restore an existing one?" )
|
||||||
# ask if the user wants to create a new wallet, or recover from a seed.
|
label.show()
|
||||||
# if he wants to recover, and nothing is found, do not create wallet
|
dialog.vbox.pack_start(label)
|
||||||
dialog = gtk.Dialog("electrum", parent=None,
|
dialog.show()
|
||||||
flags=gtk.DIALOG_MODAL|gtk.DIALOG_NO_SEPARATOR,
|
r = dialog.run()
|
||||||
buttons= ("create", 0, "restore",1, "cancel",2) )
|
dialog.destroy()
|
||||||
|
if r==2:
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
label = gtk.Label("Wallet file not found.\nDo you want to create a new wallet,\n or to restore an existing one?" )
|
is_recovery = (r==1)
|
||||||
label.show()
|
|
||||||
dialog.vbox.pack_start(label)
|
if not is_recovery:
|
||||||
|
|
||||||
|
wallet.new_seed(None)
|
||||||
|
|
||||||
|
# ask for the server.
|
||||||
|
run_network_dialog( wallet, parent=None )
|
||||||
|
|
||||||
|
# generate first key
|
||||||
|
wallet.synchronize()
|
||||||
|
|
||||||
|
# run a dialog indicating the seed, ask the user to remember it
|
||||||
|
show_seed_dialog(wallet, None, None)
|
||||||
|
|
||||||
|
#ask for password
|
||||||
|
change_password_dialog(wallet, None, None)
|
||||||
|
|
||||||
|
else:
|
||||||
|
# ask for the server.
|
||||||
|
run_network_dialog( wallet, parent=None )
|
||||||
|
|
||||||
|
# ask for seed and gap.
|
||||||
|
run_recovery_dialog( wallet )
|
||||||
|
|
||||||
|
dialog = gtk.MessageDialog(
|
||||||
|
parent = None,
|
||||||
|
flags = gtk.DIALOG_MODAL,
|
||||||
|
buttons = gtk.BUTTONS_CANCEL,
|
||||||
|
message_format = "Please wait..." )
|
||||||
dialog.show()
|
dialog.show()
|
||||||
r = dialog.run()
|
|
||||||
dialog.destroy()
|
|
||||||
if r==2:
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
is_recovery = (r==1)
|
def recover_thread( wallet, dialog ):
|
||||||
|
wallet.init_mpk( wallet.seed ) # not encrypted at this point
|
||||||
if not is_recovery:
|
|
||||||
|
|
||||||
wallet.new_seed(None)
|
|
||||||
|
|
||||||
# ask for the server.
|
|
||||||
run_network_dialog( wallet, parent=None )
|
|
||||||
|
|
||||||
# generate first key
|
|
||||||
wallet.synchronize()
|
wallet.synchronize()
|
||||||
|
|
||||||
# run a dialog indicating the seed, ask the user to remember it
|
if wallet.is_found():
|
||||||
show_seed_dialog(wallet, None, None)
|
# history and addressbook
|
||||||
|
wallet.update_tx_history()
|
||||||
|
wallet.fill_addressbook()
|
||||||
|
print "recovery successful"
|
||||||
|
wallet.save()
|
||||||
|
|
||||||
#ask for password
|
gobject.idle_add( dialog.destroy )
|
||||||
change_password_dialog(wallet, None, None)
|
|
||||||
|
|
||||||
else:
|
thread.start_new_thread( recover_thread, ( wallet, dialog ) )
|
||||||
# ask for the server.
|
r = dialog.run()
|
||||||
run_network_dialog( wallet, parent=None )
|
dialog.destroy()
|
||||||
|
if r==gtk.RESPONSE_CANCEL: sys.exit(1)
|
||||||
# ask for seed and gap.
|
if not wallet.is_found:
|
||||||
run_recovery_dialog( wallet )
|
show_message("No transactions found for this seed")
|
||||||
|
|
||||||
dialog = gtk.MessageDialog(
|
|
||||||
parent = None,
|
|
||||||
flags = gtk.DIALOG_MODAL,
|
|
||||||
buttons = gtk.BUTTONS_CANCEL,
|
|
||||||
message_format = "Please wait..." )
|
|
||||||
dialog.show()
|
|
||||||
|
|
||||||
def recover_thread( wallet, dialog ):
|
|
||||||
wallet.init_mpk( wallet.seed ) # not encrypted at this point
|
|
||||||
wallet.synchronize()
|
|
||||||
|
|
||||||
if wallet.is_found():
|
|
||||||
# history and addressbook
|
|
||||||
wallet.update_tx_history()
|
|
||||||
wallet.fill_addressbook()
|
|
||||||
print "recovery successful"
|
|
||||||
wallet.save()
|
|
||||||
|
|
||||||
gobject.idle_add( dialog.destroy )
|
|
||||||
|
|
||||||
thread.start_new_thread( recover_thread, ( wallet, dialog ) )
|
|
||||||
r = dialog.run()
|
|
||||||
dialog.destroy()
|
|
||||||
if r==gtk.RESPONSE_CANCEL: sys.exit(1)
|
|
||||||
if not wallet.is_found:
|
|
||||||
show_message("No transactions found for this seed")
|
|
||||||
|
|
||||||
|
|
||||||
def run_recovery_dialog(wallet):
|
def run_recovery_dialog(wallet):
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from PyQt4.QtGui import *
|
||||||
|
import PyQt4.QtCore as QtCore
|
||||||
|
|
||||||
|
def restore_create_dialog(wallet):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class BitcoinWidget(QWidget):
|
||||||
|
|
||||||
|
def __init__(self, wallet):
|
||||||
|
super(BitcoinWidget, self).__init__()
|
||||||
|
self.wallet = wallet
|
||||||
|
self.initUI()
|
||||||
|
|
||||||
|
def initUI(self):
|
||||||
|
qbtn = QPushButton('Quit', self)
|
||||||
|
qbtn.clicked.connect(QtCore.QCoreApplication.instance().quit)
|
||||||
|
qbtn.resize(qbtn.sizeHint())
|
||||||
|
qbtn.move(50, 50)
|
||||||
|
|
||||||
|
self.setGeometry(300, 300, 250, 150)
|
||||||
|
self.setWindowTitle( 'Electrum ' + self.wallet.electrum_version )
|
||||||
|
self.show()
|
||||||
|
|
||||||
|
class BitcoinGUI():
|
||||||
|
|
||||||
|
def __init__(self, wallet):
|
||||||
|
self.wallet = wallet
|
||||||
|
|
||||||
|
def main(self):
|
||||||
|
|
||||||
|
app = QApplication(sys.argv)
|
||||||
|
w = BitcoinWidget(self.wallet)
|
||||||
|
app.exec_()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue