From cf5661046b481ebfd8c7c6acec9d601c5b8ff231 Mon Sep 17 00:00:00 2001 From: slush Date: Mon, 7 Jan 2013 16:03:03 +0000 Subject: [PATCH] Import WalletFactory instead of Wallet WalletFactory and WalletBitkey classes --usb parameter enables experimental support for bitkey protocol --- electrum | 1 + lib/__init__.py | 3 ++- lib/wallet_bitkey.py | 28 ++++++++++++++++++++++++++++ lib/wallet_factory.py | 11 +++++++++++ 4 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 lib/wallet_bitkey.py create mode 100644 lib/wallet_factory.py diff --git a/electrum b/electrum index 1849e143b..bd5558a03 100755 --- a/electrum +++ b/electrum @@ -139,6 +139,7 @@ def arg_parser(): parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="show debugging information") parser.add_option("-P", "--portable", action="store_true", dest="portable", default=False, help="portable wallet") parser.add_option("-L", "--lang", dest="language", default=None, help="defaut language used in GUI") + parser.add_option("-u", "--usb", dest="bitkey", action="store_true", help="Turn on support for hardware wallets (EXPERIMENTAL)") return parser diff --git a/lib/__init__.py b/lib/__init__.py index 1506f3e71..dd8189437 100644 --- a/lib/__init__.py +++ b/lib/__init__.py @@ -1,7 +1,8 @@ from version import ELECTRUM_VERSION from util import format_satoshis, print_msg, print_error, set_verbosity from i18n import set_language -from wallet import Wallet, WalletSynchronizer +from wallet import WalletSynchronizer +from wallet_factory import WalletFactory as Wallet from verifier import WalletVerifier from interface import Interface, pick_random_server, DEFAULT_SERVERS from simple_config import SimpleConfig diff --git a/lib/wallet_bitkey.py b/lib/wallet_bitkey.py new file mode 100644 index 000000000..e8adf7d0e --- /dev/null +++ b/lib/wallet_bitkey.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python +# +# Electrum - lightweight Bitcoin client +# Copyright (C) 2011 thomasv@gitorious +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import os + +from wallet import Wallet +#import bitkeylib.bitkey_pb2 as proto + +from version import ELECTRUM_VERSION +SEED_VERSION = 4 # Version of bitkey algorithm + +class WalletBitkey(Wallet): + pass diff --git a/lib/wallet_factory.py b/lib/wallet_factory.py new file mode 100644 index 000000000..5f82eca33 --- /dev/null +++ b/lib/wallet_factory.py @@ -0,0 +1,11 @@ +class WalletFactory(object): + def __new__(cls, config): + if config.get('bitkey', False): + # if user requested support for Bitkey device, + # import Bitkey driver + from wallet_bitkey import WalletBitkey + return WalletBitkey(config) + + # Load standard wallet + from wallet import Wallet + return Wallet(config)