- Wizard
- Multiple wallets
- Themes
+- Extend GUI with history view (View -> Show History)
- Settings window
Server:
inkscape:groupmode="layer"
id="layer1">
<path
- style="opacity:1;fill:#d7d7d7;fill-opacity:1;stroke:#000000;stroke-opacity:1;stroke-width:0;stroke-miterlimit:4;stroke-dasharray:none"
+ style="opacity:0.83716047999999998;fill:#d7d7d7;fill-opacity:1;stroke:#000000;stroke-opacity:1;stroke-width:0;stroke-miterlimit:4;stroke-dasharray:none"
d="m 472.75139,908.92052 c 46.46702,-26.26397 56.56855,-68.69038 66.67007,-98.99495 10.10153,-30.30458 52.52793,-228.29448 42.42641,-347.49248 -10.10153,-119.198 -58.58885,-135.36044 -107.07617,-159.6041 -48.48732,-24.24366 -133.34014,-18.18275 -175.76654,8.08122 -42.42642,26.26397 -92.93405,60.60915 -101.01527,143.44166 -8.08122,82.83251 9.13377,276.70605 46.46702,371.73614 22.22336,56.56854 47.29278,70.95769 78.79191,84.85281 31.49913,13.89512 116.60088,16.01267 149.50257,-2.0203 z"
id="path3050"
inkscape:connector-curvature="0"
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import re, sys
+import re
+import sys
+# import argparse
+import optparse
+
try:
from lib.util import print_error
except ImportError:
except ImportError:
from electrum import Wallet, WalletSynchronizer, format_satoshis, mnemonic, prompt_password
-from optparse import OptionParser
from decimal import Decimal
known_commands = {
'import':
'Imports a key pair\nSyntax: import <address>:<privatekey>',
'signmessage':
- 'Signs a message with a key\nSyntax: signmessage <address> <message>',
+ 'Signs a message with a key\nSyntax: signmessage <address> <message>\nIf you want to lead or end a message with spaces, or want double spaces inside the message make sure you quote the string. I.e. " Hello This is a weird String "',
'verifymessage':
- 'Verifies a signature\nSyntax: verifymessage <address> <signature> <message>',
+ 'Verifies a signature\nSyntax: verifymessage <address> <signature> <message>\nIf you want to lead or end a message with spaces, or want double spaces inside the message make sure you quote the string. I.e. " Hello This is a weird String "',
'eval':
"Run python eval() on an object\nSyntax: eval <expression>\nExample: eval \"wallet.aliases\"",
'deseed':
if __name__ == '__main__':
usage = "usage: %prog [options] command\nCommands: "+ (', '.join(known_commands))
- parser = OptionParser(usage=usage)
+ parser = optparse.OptionParser(prog=usage)
parser.add_option("-g", "--gui", dest="gui", default="lite", help="gui")
parser.add_option("-w", "--wallet", dest="wallet_path", help="wallet path (default: electrum.dat)")
parser.add_option("-o", "--offline", action="store_true", dest="offline", default=False, help="remain offline")
else:
cmd = args[0]
firstarg = args[1] if len(args) > 1 else ''
-
+
+ #this entire if/else block is just concerned with importing the
+ #right GUI toolkit based the GUI command line option given
if cmd == 'gui':
if options.gui=='gtk':
error_message.showMessage("<p>Sorry, Electrum requires Qt >= 4.7 to run.</p><p>Check your distributions packages or download it at http://qt.nokia.com/downloads</p>")
app.exec_()
sys.exit(0)
-
+
+ #use the lite version if no toolkit specified
try:
import lib.gui_lite as gui
except ImportError:
import electrum.gui_lite as gui
else:
- print_error("Error: Unknown GUI: " + options.gui)
- exit(1)
+ sys.exit("Error: Unknown GUI: " + options.gui)
gui = gui.ElectrumGui(wallet)
WalletSynchronizer(wallet,True).start()
cmd2 = firstarg
if cmd2 not in known_commands:
parser.print_help()
- print
print "Type 'electrum help <command>' to see the help for a specific command"
print "Type 'electrum --help' to see the list of options"
print "List of commands:", ', '.join(known_commands)
d = ast.literal_eval( data )
seed = d['seed']
imported_keys = d.get('imported_keys',{})
- except IOError:
+ except:
sys.exit("Error: Error with seed file")
mpk = wallet.master_public_key
elif cmd == 'password':
try:
seed = wallet.pw_decode( wallet.seed, password)
- except StandardError:
+ except ValueError:
sys.exit("Error: Password does not decrypt this wallet.")
new_password = prompt_password('New password:')
try:
wallet.verify_message(address, signature, message)
print True
- except:
+ except BaseException as e:
+ print "Verification error: {0}".format(e)
print False
elif cmd == 'freeze':
connection = httplib.HTTPSConnection('intersango.com')
connection.request("GET", "/api/ticker.php")
response = connection.getresponse()
- if response.status == 404:
+ if response.reason == httplib.responses[httplib.NOT_FOUND]:
return
response = json.loads(response.read())
# 1 = BTC:GBP
# 4 = BTC:PLN
quote_currencies = {}
try:
- quote_currencies["GBP"] = self.lookup_rate(response, 1)
- quote_currencies["EUR"] = self.lookup_rate(response, 2)
- quote_currencies["USD"] = self.lookup_rate(response, 3)
+ quote_currencies["GBP"] = self._lookup_rate(response, 1)
+ quote_currencies["EUR"] = self._lookup_rate(response, 2)
+ quote_currencies["USD"] = self._lookup_rate(response, 3)
with self.lock:
self.quote_currencies = quote_currencies
self.parent.emit(SIGNAL("refresh_balance()"))
except KeyError:
pass
- def lookup_rate(self, response, quote_id):
+ def _lookup_rate(self, response, quote_id):
return decimal.Decimal(response[str(quote_id)]["last"])
if __name__ == "__main__":
self.app.exec_()
def expand(self):
+ """Hide the lite mode window and show pro-mode."""
self.mini.hide()
self.expert.show()
electrum_menu.addSeparator()
brain_seed = electrum_menu.addAction(_("&BrainWallet Info"))
brain_seed.triggered.connect(self.actuator.show_seed_dialog)
-
- electrum_menu.addAction(_("&Quit"))
+ quit_option = electrum_menu.addAction(_("&Quit"))
+ quit_option.triggered.connect(self.close)
view_menu = menubar.addMenu(_("&View"))
expert_gui = view_menu.addAction(_("&Pro Mode"))
pass
def set_quote_currency(self, currency):
+ """Set and display the fiat currency country."""
assert currency in self.quote_currencies
self.quote_currencies.remove(currency)
- self.quote_currencies = [currency] + self.quote_currencies
+ self.quote_currencies.insert(0, currency)
self.refresh_balance()
def change_quote_currency(self):
self.amount_input_changed(self.amount_input.text())
def set_balances(self, btc_balance):
+ """Set the bitcoin balance and update the amount label accordingly."""
self.btc_balance = btc_balance
quote_text = self.create_quote_text(btc_balance)
if quote_text:
self.setWindowTitle("Electrum - %s BTC" % btc_balance)
def amount_input_changed(self, amount_text):
+ """Update the number of bitcoins displayed."""
self.check_button_status()
try:
self.balance_label.show_balance()
def create_quote_text(self, btc_balance):
+ """Return a string copy of the amount fiat currency the
+ user has in bitcoins."""
quote_currency = self.quote_currencies[0]
quote_balance = self.exchanger.exchange(btc_balance, quote_currency)
if quote_balance is None:
self.amount_input.setText("")
def check_button_status(self):
+ """Check that the bitcoin address is valid and that something
+ is entered in the amount before making the send button clickable."""
+ # self.address_input.property(...) returns a qVariant, not a bool.
+ # The == is needed to properly invoke a comparison.
if (self.address_input.property("isValid") == True and
len(self.amount_input.text()) > 0):
self.send_button.setDisabled(False)
self.amount_text = ""
def mousePressEvent(self, event):
+ """Change the fiat currency selection if window background is clicked."""
if self.state != self.SHOW_CONNECTING:
self.change_quote_currency()
def set_balance_text(self, btc_balance, quote_text):
+ """Set the amount of bitcoins in the gui."""
if self.state == self.SHOW_CONNECTING:
self.state = self.SHOW_BALANCE
self.balance_text = "<span style='font-size: 18pt'>%s</span> <span style='font-size: 10pt'>BTC</span> <span style='font-size: 10pt'>%s</span>" % (btc_balance, quote_text)
QCursor.setPos(center_mouse_pos)
self.show()
-class MiniActuator(QObject):
-
+class MiniActuator:
+ """Initialize the definitions relating to themes and
+ sending/recieving bitcoins.
+ """
+
+
def __init__(self, wallet):
+ """Retrieve the gui theme used in previous session."""
super(QObject, self).__init__()
self.wallet = wallet
-
self.theme_name = self.wallet.theme
self.themes = util.load_theme_paths()
def load_theme(self):
+ """Load theme retrieved from wallet file."""
try:
theme_prefix, theme_path = self.themes[self.theme_name]
except KeyError:
qApp.setStyleSheet(style_file.read())
def theme_names(self):
+ """Sort themes."""
return sorted(self.themes.keys())
+
def selected_theme(self):
+ """Select theme."""
return self.theme_name
def change_theme(self, theme_name):
+ """Change theme."""
self.wallet.theme = self.theme_name = theme_name
self.load_theme()
def set_configured_currency(self, set_quote_currency):
+ """Set the inital fiat currency conversion country (USD/EUR/GBP) in
+ the GUI to what it was set to in the wallet."""
currency = self.wallet.conversion_currency
# currency can be none when Electrum is used for the first
# time and no setting has been created yet.
set_quote_currency(currency)
def set_config_currency(self, conversion_currency):
+ """Change the wallet fiat currency country."""
self.wallet.conversion_currency = conversion_currency
def set_servers_gui_stuff(self, servers_menu, servers_group):
self.wallet.set_server(server_line)
def copy_address(self, receive_popup):
+ """Copy the wallet addresses into the client."""
addrs = [addr for addr in self.wallet.all_addresses()
if not self.wallet.is_change(addr)]
# Select most recent addresses from gap limit
receive_popup.popup()
def send(self, address, amount, parent_window):
+ """Send bitcoins to the target address."""
dest_address = self.fetch_destination(address)
if dest_address is None or not self.wallet.is_valid(dest_address):
return recipient
def is_valid(self, address):
+ """Check if bitcoin address is valid."""
return self.wallet.is_valid(address)
def acceptbit(self, currency):
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+import sys
+import base64
+import os
+import re
+import hashlib
+import copy
+import operator
+import ast
+import threading
+import random
+import getpass
+import aes
+import ecdsa
-import sys, base64, os, re, hashlib, copy, operator, ast, threading, random, getpass
-import aes, ecdsa
from ecdsa.util import string_to_number, number_to_string
from util import print_error
__b58base = len(__b58chars)
def b58encode(v):
- """ encode v, which is a string of bytes, to base58.
- """
+ """ encode v, which is a string of bytes, to base58."""
long_value = 0L
for (i, c) in enumerate(v[::-1]):
return (__b58chars[0]*nPad) + result
def b58decode(v, length):
- """ decode v into a string of len bytes
- """
+ """ decode v into a string of len bytes."""
long_value = 0L
for (i, c) in enumerate(v[::-1]):
long_value += __b58chars.find(c) * (__b58base**i)
password2 = getpass.getpass("Confirm: ")
if password != password2:
- print_error("Error: Passwords do not match.")
- sys.exit(1)
+ sys.exit("Error: Passwords do not match.")
else:
password = raw_input(prompt)
os.chmod(self.path,stat.S_IREAD | stat.S_IWRITE)
def read(self):
- '''Read the contents of the wallet file.'''
+ """Read the contents of the wallet file."""
import interface
- upgrade_msg = """This wallet seed is deprecated. Please run upgrade.py for a diagnostic."""
self.file_exists = False
try:
- f = open(self.path,"r")
- data = f.read()
- f.close()
- except:
+ with open(self.path, "r") as f:
+ data = f.read()
+ except IOError:
return
try:
d = ast.literal_eval( data ) #parse raw data from reading wallet file
interface.old_to_new(d)
+
self.seed_version = d.get('seed_version')
self.master_public_key = d.get('master_public_key').decode('hex')
self.use_encryption = d.get('use_encryption')
self.conversion_currency = d.get('conversion_currency', 'USD')
self.theme = d.get('theme', 'Cleanlook')
except:
- raise BaseException("cannot read wallet file")
+ raise IOError("Cannot read wallet file.")
self.update_tx_history()
if self.seed_version != SEED_VERSION:
- raise BaseException(upgrade_msg)
+ raise ValueError("This wallet seed is deprecated. Please run upgrade.py for a diagnostic.")
if self.remote_url: assert self.master_public_key.encode('hex') == self.get_remote_mpk()
try:
d.decode('hex')
except:
- raise BaseException("Invalid password")
+ raise ValueError("Invalid password")
return d
else:
return s
def mktx(self, to_address, amount, label, password, fee=None, change_addr=None, from_addr= None):
if not self.is_valid(to_address):
- raise BaseException("Invalid address")
+ raise ValueError("Invalid address")
inputs, total, fee = self.choose_tx_inputs( amount, fee, from_addr )
if not inputs:
- raise BaseException("Not enough funds")
+ raise ValueError("Not enough funds")
if not self.use_change and not change_addr:
change_addr = inputs[0][0]
self.verify_message(previous, signature, "alias:%s:%s"%(alias,target))
if not self.is_valid(target):
- raise BaseException("Invalid bitcoin address")
+ raise ValueError("Invalid bitcoin address")
return target, signing_addr, auth_name
import lib.util as util
import os, sys, platform
from lib.util import print_error
-
if sys.version_info[:3] < (2,6,0):
sys.exit("Error: Electrum requires Python version >= 2.6.0...")
data_files = []
-
-if platform.system() != 'Windows' and platform.system() != 'Darwin':
+if (len(sys.argv) > 1 and (sys.argv[1] == "sdist")) or (platform.system() != 'Windows' and platform.system() != 'Darwin'):
+ print "Including all files"
data_files += [
('/usr/share/applications/',['electrum.desktop']),
('/usr/share/app-install/icons/',['electrum.png'])
data_files.append( ('/usr/share/locale/%s/LC_MESSAGES'%lang, ['locale/%s/LC_MESSAGES/electrum.mo'%lang]) )
data_files += [
- (util.appdata_dir(), ["data/background.png", "data/style.css"]),
- (os.path.join(util.appdata_dir(), "icons"), [
- "data/icons/confirmed.png",
- "data/icons/unconfirmed.png"
+ (util.appdata_dir(), ["data/noface.svg", "data/README"]),
+ (os.path.join(util.appdata_dir(), "cleanlook"), [
+ "data/cleanlook/name.cfg",
+ "data/cleanlook/style.css"
+ ]),
+ (os.path.join(util.appdata_dir(), "dark"), [
+ "data/dark/background.png",
+ "data/dark/name.cfg",
+ "data/dark/style.css"
])
]