1
0

Remove need for self.wallet for h/w wallets

This commit is contained in:
Neil Booth
2015-12-30 17:03:26 +09:00
parent 84450b9189
commit 1d51335827
9 changed files with 38 additions and 71 deletions

View File

@@ -20,9 +20,6 @@ class BTChipCmdLineHandler:
class Plugin(LedgerPlugin):
@hook
def cmdline_load_wallet(self, wallet):
self.wallet = wallet
self.wallet.plugin = self
wallet.plugin = self
if self.handler is None:
self.handler = BTChipCmdLineHandler()

View File

@@ -261,8 +261,6 @@ class BTChipWallet(BIP32_HD_Wallet):
return BIP32_HD_Wallet.sign_transaction(self, tx, password)
if tx.is_complete():
return
#if tx.error:
# raise BaseException(tx.error)
self.signing = True
inputs = []
inputsPaths = []
@@ -421,33 +419,24 @@ class LedgerPlugin(BasePlugin):
def __init__(self, parent, config, name):
BasePlugin.__init__(self, parent, config, name)
self.wallet = None
self.handler = None
def constructor(self, s):
return BTChipWallet(s)
def is_enabled(self):
if not BTCHIP:
return False
if not self.wallet:
return False
if self.wallet.storage.get('wallet_type') != 'btchip':
return False
if self.wallet.has_seed():
return False
return True
return BTCHIP:
def btchip_is_connected(self):
def btchip_is_connected(self, wallet):
try:
self.wallet.get_client().getFirmwareVersion()
wallet.get_client().getFirmwareVersion()
except:
return False
return True
@hook
def close_wallet(self):
self.wallet = None
pass
@hook
def installwizard_load_wallet(self, wallet, window):
@@ -466,11 +455,3 @@ class LedgerPlugin(BasePlugin):
QMessageBox.information(None, _('Error'), str(e), _('OK'))
return
return wallet
@hook
def sign_tx(self, window, tx):
tx.error = None
try:
self.wallet.sign_transaction(tx, None)
except Exception as e:
tx.error = str(e)

View File

@@ -4,23 +4,24 @@ import threading
from electrum.plugins import BasePlugin, hook
from ledger import LedgerPlugin
from ledger import LedgerPlugin, BTChipWallet
class Plugin(LedgerPlugin):
@hook
def load_wallet(self, wallet, window):
self.wallet = wallet
self.wallet.plugin = self
if type(wallet) != BTChipWallet:
return
wallet.plugin = self
if self.handler is None:
self.handler = BTChipQTHandler(window)
if self.btchip_is_connected():
if not self.wallet.check_proper_device():
if self.btchip_is_connected(wallet):
if not wallet.check_proper_device():
window.show_error(_("This wallet does not match your Ledger device"))
self.wallet.force_watching_only = True
wallet.force_watching_only = True
else:
window.show_error(_("Ledger device not detected.\nContinuing in watching-only mode."))
self.wallet.force_watching_only = True
wallet.force_watching_only = True
class BTChipQTHandler: