electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit f3ff9b5cf6153beee32bacaeb18117329cdf77ee
parent 44dd7713e5fdc3333899cca070f03f7b6d72c380
Author: thomasv <thomasv@gitorious>
Date:   Mon,  1 Oct 2012 18:14:50 +0200

make proxy an optional parameter

Diffstat:
Melectrum | 6+++---
Mlib/interface.py | 12++++++------
2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/electrum b/electrum @@ -116,11 +116,11 @@ 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("-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("-r", "--remote", dest="remote_url", default=None, help="URL of a remote wallet") - parser.add_option("-p", "--proxy", dest="proxy", default=simple_config.config["proxy"], help="set proxy [type:]host[:port], where type is socks4,socks5 or http") + parser.add_option("-p", "--proxy", dest="proxy", default=None, help="set proxy [type:]host[:port], where type is socks4,socks5 or http") options, args = parser.parse_args() - if type(options.proxy) == type(''): - options.proxy = parse_proxy_options(options.proxy) + if options.proxy: + options.proxy = parse_proxy_options(options.proxy) wallet = Wallet() wallet.set_path(options.wallet_path) diff --git a/lib/interface.py b/lib/interface.py @@ -28,7 +28,7 @@ DEFAULT_SERVERS = [ 'ecdsa.org:50001:t', 'electrum.novit.ro:50001:t', 'electrum.bytesized-hosting.com:50001:t'] # list of default servers -proxy_modes = ['none', 'socks4', 'socks5', 'http' ] +proxy_modes = ['socks4', 'socks5', 'http'] def replace_keys(obj, old_key, new_key): if isinstance(obj, dict): @@ -65,7 +65,7 @@ def parse_proxy_options(s): return proxy class Interface(threading.Thread): - def __init__(self, host, port, proxy): + def __init__(self, host, port, proxy=None): threading.Thread.__init__(self) self.daemon = True self.host = host @@ -136,7 +136,7 @@ class Interface(threading.Thread): class PollingInterface(Interface): """ non-persistent connection. synchronous calls""" - def __init__(self, host, port, proxy): + def __init__(self, host, port, proxy=None): Interface.__init__(self, host, port, proxy) self.session_id = None @@ -188,7 +188,7 @@ class HttpStratumInterface(PollingInterface): def send(self, messages): import urllib2, json, time, cookielib - if self.proxy["mode"] != "none": + if self.proxy: import socks socks.setdefaultproxy(proxy_modes.index(self.proxy["mode"]), self.proxy["host"], int(self.proxy["port"]) ) socks.wrapmodule(urllib2) @@ -250,12 +250,12 @@ class HttpStratumInterface(PollingInterface): class TcpStratumInterface(Interface): """json-rpc over persistent TCP connection, asynchronous""" - def __init__(self, host, port, proxy): + def __init__(self, host, port, proxy=None): Interface.__init__(self, host, port, proxy) def init_socket(self): global proxy_modes - if self.proxy["mode"] == "none": + if self.proxy is None: self.s = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) else: import socks