anchor channels: unlock wallet on startup if the wallet has channels
This commit is contained in:
@@ -495,6 +495,8 @@ class Daemon(Logger):
|
||||
if wallet := self._wallets.get(wallet_key):
|
||||
return wallet
|
||||
wallet = self._load_wallet(path, password, upgrade=upgrade, config=self.config)
|
||||
if wallet.requires_unlock():
|
||||
wallet.unlock(password)
|
||||
wallet.start_network(self.network)
|
||||
self.add_wallet(wallet)
|
||||
self.update_recently_opened_wallets(path)
|
||||
|
||||
@@ -251,7 +251,8 @@ class QEDaemon(AuthMixin, QObject):
|
||||
assert wallet is not None
|
||||
self._current_wallet = QEWallet.getInstanceFor(wallet)
|
||||
self.availableWallets.updateWallet(self._path)
|
||||
self._current_wallet.password = password if password else None
|
||||
if wallet.requires_unlock():
|
||||
wallet.unlock(password)
|
||||
self._loading = False
|
||||
self.loadingChanged.emit()
|
||||
self.walletLoaded.emit(self._name, self._path)
|
||||
|
||||
@@ -731,12 +731,16 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
|
||||
try:
|
||||
self._logger.info('setting new password')
|
||||
self.wallet.update_password(current_password, password, encrypt_storage=True)
|
||||
self.password = password
|
||||
self.wallet.unlock(password)
|
||||
return True
|
||||
except InvalidPassword as e:
|
||||
self._logger.exception(repr(e))
|
||||
return False
|
||||
|
||||
@property
|
||||
def password(self):
|
||||
return self.wallet.get_unlocked_password()
|
||||
|
||||
@pyqtSlot(str)
|
||||
def importAddresses(self, addresslist):
|
||||
self.wallet.import_addresses(addresslist.split())
|
||||
|
||||
@@ -1291,6 +1291,8 @@ class LNWallet(LNWorker):
|
||||
zeroconf: bool = False,
|
||||
opening_fee: int = None,
|
||||
password=None):
|
||||
if self.config.ENABLE_ANCHOR_CHANNELS:
|
||||
self.wallet.unlock(password)
|
||||
coins = self.wallet.get_spendable_coins(None)
|
||||
node_id = peer.pubkey
|
||||
funding_tx = self.mktx_for_open_channel(
|
||||
|
||||
@@ -502,6 +502,12 @@ class Abstract_Wallet(ABC, Logger, EventListener):
|
||||
def has_lightning(self) -> bool:
|
||||
return bool(self.lnworker)
|
||||
|
||||
def has_channels(self):
|
||||
return self.lnworker is not None and len(self.lnworker._channels) > 0
|
||||
|
||||
def requires_unlock(self):
|
||||
return self.config.ENABLE_ANCHOR_CHANNELS and self.has_channels()
|
||||
|
||||
def can_have_lightning(self) -> bool:
|
||||
# we want static_remotekey to be a wallet address
|
||||
return self.txin_type == 'p2wpkh'
|
||||
@@ -2977,8 +2983,8 @@ class Abstract_Wallet(ABC, Logger, EventListener):
|
||||
if self.storage and self.storage.file_exists():
|
||||
self.db.write_and_force_consolidation()
|
||||
# if wallet was previously unlocked, update password in memory
|
||||
if self._password_in_memory is not None:
|
||||
self._password_in_memory = new_pw
|
||||
if self.requires_unlock():
|
||||
self.unlock(new_pw)
|
||||
|
||||
@abstractmethod
|
||||
def _update_password_for_keystore(self, old_pw: Optional[str], new_pw: Optional[str]) -> None:
|
||||
|
||||
Reference in New Issue
Block a user