1
0

Remove constructor method of plugins

Clean up wallet class loading.
This commit is contained in:
Neil Booth
2016-01-01 23:39:19 +09:00
parent cf4ee487cd
commit 1d07960290
6 changed files with 28 additions and 35 deletions

View File

@@ -419,9 +419,6 @@ class LedgerPlugin(BasePlugin):
self.device = self.wallet_class.device
self.handler = None
def constructor(self, s):
return BTChipWallet(s)
def is_enabled(self):
return BTCHIP

View File

@@ -129,9 +129,6 @@ class TrezorCompatiblePlugin(BasePlugin):
self.client = None
self.wallet_class.plugin = self
def constructor(self, s):
return self.wallet_class(s)
def give_error(self, message):
self.print_error(message)
raise Exception(message)

View File

@@ -31,7 +31,7 @@ from electrum.i18n import _
from electrum.plugins import hook
from electrum import wizard
from trustedcoin import TrustedCoinPlugin, Wallet_2fa, DISCLAIMER, server
from trustedcoin import TrustedCoinPlugin, DISCLAIMER, server
def need_server(wallet, tx):
from electrum.account import BIP32_Account
@@ -79,7 +79,8 @@ class Plugin(TrustedCoinPlugin):
def sign_tx(self, window, tx):
self.print_error("twofactor:sign_tx")
wallet = window.wallet
if type(wallet) is Wallet_2fa and not wallet.can_sign_without_server():
assert isinstace(wallet, self.wallet_class)
if not wallet.can_sign_without_server():
auth_code = None
if need_server(wallet, tx):
auth_code = self.auth_dialog(window)
@@ -100,7 +101,8 @@ class Plugin(TrustedCoinPlugin):
@hook
def abort_send(self, window):
wallet = window.wallet
if type(wallet) is Wallet_2fa and not wallet.can_sign_without_server():
assert isinstace(wallet, self.wallet_class)
if not wallet.can_sign_without_server():
if wallet.billing_info is None:
# request billing info before forming the transaction
waiting_dialog(self, window).wait()

View File

@@ -287,13 +287,11 @@ def make_billing_address(wallet, num):
class TrustedCoinPlugin(BasePlugin):
wallet_class = Wallet_2fa
def __init__(self, parent, config, name):
BasePlugin.__init__(self, parent, config, name)
Wallet_2fa.plugin = self
def constructor(self, s):
return Wallet_2fa(s)
self.wallet_class.plugin = self
@staticmethod
def is_valid_seed(seed):
@@ -348,7 +346,7 @@ class TrustedCoinPlugin(BasePlugin):
window.wallet.is_billing = False
def on_restore_wallet(self, wallet, wizard):
assert isinstance(wallet, Wallet_2fa)
assert isinstance(wallet, self.wallet_class)
seed = wizard.request_seed(RESTORE_MSG, is_valid=self.is_valid_seed)
password = wizard.request_password()