allow encrypting watch-only wallets. initial support for hw wallet storage encryption.
This commit is contained in:
@@ -194,7 +194,7 @@ class Plugin(BasePlugin):
|
||||
return
|
||||
|
||||
wallet = window.wallet
|
||||
if wallet.has_password():
|
||||
if wallet.has_keystore_encryption():
|
||||
password = window.password_dialog('An encrypted transaction was retrieved from cosigning pool.\nPlease enter your password to decrypt it.')
|
||||
if not password:
|
||||
return
|
||||
|
||||
@@ -12,7 +12,7 @@ try:
|
||||
from electrum.keystore import Hardware_KeyStore
|
||||
from ..hw_wallet import HW_PluginBase
|
||||
from electrum.util import print_error, to_string, UserCancelled
|
||||
from electrum.base_wizard import ScriptTypeNotSupported
|
||||
from electrum.base_wizard import ScriptTypeNotSupported, HWD_SETUP_NEW_WALLET
|
||||
|
||||
import time
|
||||
import hid
|
||||
@@ -670,12 +670,13 @@ class DigitalBitboxPlugin(HW_PluginBase):
|
||||
return None
|
||||
|
||||
|
||||
def setup_device(self, device_info, wizard):
|
||||
def setup_device(self, device_info, wizard, purpose):
|
||||
devmgr = self.device_manager()
|
||||
device_id = device_info.device.id_
|
||||
client = devmgr.client_by_id(device_id)
|
||||
client.handler = self.create_handler(wizard)
|
||||
client.setupRunning = True
|
||||
if purpose == HWD_SETUP_NEW_WALLET:
|
||||
client.setupRunning = True
|
||||
client.get_xpub("m/44'/0'", 'standard')
|
||||
|
||||
|
||||
|
||||
@@ -65,9 +65,14 @@ class Plugin(BasePlugin):
|
||||
tx = d.tx
|
||||
wallet = d.wallet
|
||||
window = d.main_window
|
||||
|
||||
if wallet.is_watching_only():
|
||||
d.show_critical(_('This feature is not available for watch-only wallets.'))
|
||||
return
|
||||
|
||||
# 1. get the password and sign the verification request
|
||||
password = None
|
||||
if wallet.has_password():
|
||||
if wallet.has_keystore_encryption():
|
||||
msg = _('GreenAddress requires your signature \n'
|
||||
'to verify that transaction is instant.\n'
|
||||
'Please enter your password to sign a\n'
|
||||
|
||||
@@ -51,3 +51,10 @@ class HW_PluginBase(BasePlugin):
|
||||
for keystore in wallet.get_keystores():
|
||||
if isinstance(keystore, self.keystore_class):
|
||||
self.device_manager().unpair_xpub(keystore.xpub)
|
||||
|
||||
def setup_device(self, device_info, wizard, purpose):
|
||||
"""Called when creating a new wallet or when using the device to decrypt
|
||||
an existing wallet. Select the device to use. If the device is
|
||||
uninitialized, go through the initialization process.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
@@ -70,9 +70,10 @@ class QtHandlerBase(QObject, PrintError):
|
||||
self.status_signal.emit(paired)
|
||||
|
||||
def _update_status(self, paired):
|
||||
button = self.button
|
||||
icon = button.icon_paired if paired else button.icon_unpaired
|
||||
button.setIcon(QIcon(icon))
|
||||
if hasattr(self, 'button'):
|
||||
button = self.button
|
||||
icon = button.icon_paired if paired else button.icon_unpaired
|
||||
button.setIcon(QIcon(icon))
|
||||
|
||||
def query_choice(self, msg, labels):
|
||||
self.done.clear()
|
||||
|
||||
@@ -194,10 +194,7 @@ class KeepKeyCompatiblePlugin(HW_PluginBase):
|
||||
label, language)
|
||||
wizard.loop.exit(0)
|
||||
|
||||
def setup_device(self, device_info, wizard):
|
||||
'''Called when creating a new wallet. Select the device to use. If
|
||||
the device is uninitialized, go through the intialization
|
||||
process.'''
|
||||
def setup_device(self, device_info, wizard, purpose):
|
||||
devmgr = self.device_manager()
|
||||
device_id = device_info.device.id_
|
||||
client = devmgr.client_by_id(device_id)
|
||||
|
||||
@@ -522,7 +522,7 @@ class LedgerPlugin(HW_PluginBase):
|
||||
client = Ledger_Client(client)
|
||||
return client
|
||||
|
||||
def setup_device(self, device_info, wizard):
|
||||
def setup_device(self, device_info, wizard, purpose):
|
||||
devmgr = self.device_manager()
|
||||
device_id = device_info.device.id_
|
||||
client = devmgr.client_by_id(device_id)
|
||||
|
||||
@@ -214,10 +214,7 @@ class TrezorCompatiblePlugin(HW_PluginBase):
|
||||
label, language)
|
||||
wizard.loop.exit(0)
|
||||
|
||||
def setup_device(self, device_info, wizard):
|
||||
'''Called when creating a new wallet. Select the device to use. If
|
||||
the device is uninitialized, go through the intialization
|
||||
process.'''
|
||||
def setup_device(self, device_info, wizard, purpose):
|
||||
devmgr = self.device_manager()
|
||||
device_id = device_info.device.id_
|
||||
client = devmgr.client_by_id(device_id)
|
||||
|
||||
@@ -40,6 +40,7 @@ from electrum.wallet import Multisig_Wallet, Deterministic_Wallet
|
||||
from electrum.i18n import _
|
||||
from electrum.plugins import BasePlugin, hook
|
||||
from electrum.util import NotEnoughFunds
|
||||
from electrum.storage import STO_EV_USER_PW
|
||||
|
||||
# signing_xpub is hardcoded so that the wallet can be restored from seed, without TrustedCoin's server
|
||||
signing_xpub = "xpub661MyMwAqRbcGnMkaTx2594P9EDuiEqMq25PM2aeG6UmwzaohgA6uDmNsvSUV8ubqwA3Wpste1hg69XHgjUuCD5HLcEp2QPzyV1HMrPppsL"
|
||||
@@ -420,9 +421,11 @@ class TrustedCoinPlugin(BasePlugin):
|
||||
k2 = keystore.from_xpub(xpub2)
|
||||
wizard.request_password(run_next=lambda pw, encrypt: self.on_password(wizard, pw, encrypt, k1, k2))
|
||||
|
||||
def on_password(self, wizard, password, encrypt, k1, k2):
|
||||
def on_password(self, wizard, password, encrypt_storage, k1, k2):
|
||||
k1.update_password(None, password)
|
||||
wizard.storage.set_password(password, encrypt)
|
||||
wizard.storage.set_keystore_encryption(bool(password))
|
||||
if encrypt_storage:
|
||||
wizard.storage.set_password(password, enc_version=STO_EV_USER_PW)
|
||||
wizard.storage.put('x1/', k1.dump())
|
||||
wizard.storage.put('x2/', k2.dump())
|
||||
wizard.storage.write()
|
||||
@@ -470,7 +473,7 @@ class TrustedCoinPlugin(BasePlugin):
|
||||
else:
|
||||
self.create_keystore(wizard, seed, passphrase)
|
||||
|
||||
def on_restore_pw(self, wizard, seed, passphrase, password, encrypt):
|
||||
def on_restore_pw(self, wizard, seed, passphrase, password, encrypt_storage):
|
||||
storage = wizard.storage
|
||||
xprv1, xpub1, xprv2, xpub2 = self.xkeys_from_seed(seed, passphrase)
|
||||
k1 = keystore.from_xprv(xprv1)
|
||||
@@ -484,7 +487,11 @@ class TrustedCoinPlugin(BasePlugin):
|
||||
xpub3 = make_xpub(signing_xpub, long_user_id)
|
||||
k3 = keystore.from_xpub(xpub3)
|
||||
storage.put('x3/', k3.dump())
|
||||
storage.set_password(password, encrypt)
|
||||
|
||||
storage.set_keystore_encryption(bool(password))
|
||||
if encrypt_storage:
|
||||
storage.set_password(password, enc_version=STO_EV_USER_PW)
|
||||
|
||||
wizard.wallet = Wallet_2fa(storage)
|
||||
wizard.create_addresses()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user