Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ task:
install_script:
- apt-get update
# qml test reqs:
- apt-get -y install libgl1 libegl1 libxkbcommon0 libdbus-1-3
- apt-get -y install libgl1 libegl1 libxkbcommon0 libdbus-1-3 libleveldb-dev
- pip install -r $ELECTRUM_REQUIREMENTS_CI
# electrum itself:
- export ELECTRUM_ECC_DONT_COMPILE=1
Expand Down
1 change: 1 addition & 0 deletions contrib/requirements/requirements-ci.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pytest
coverage
coveralls
plyvel
2 changes: 1 addition & 1 deletion electrum/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class GuiImportError(ImportError):
from .version import ELECTRUM_VERSION
from .util import format_satoshis
from .wallet import Wallet
from .storage import WalletStorage
from .stored_dict import WalletStorage
from .coinchooser import COIN_CHOOSERS
from .network import Network, pick_random_server
from .interface import Interface
Expand Down
18 changes: 12 additions & 6 deletions electrum/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ async def list_wallets(self):
"""List wallets open in daemon"""
return [
{
'path': w.db.storage.path,
'path': w.storage.get_path() if w.storage else None,
'synchronized': w.is_up_to_date(),
'unlocked': not w.has_password() or (w.get_unlocked_password() is not None),
}
Expand All @@ -298,29 +298,32 @@ async def close_wallet(self, wallet_path=None):
return await self.daemon._stop_wallet(wallet_path)

@command('')
async def create(self, passphrase=None, password=None, encrypt_file=True, seed_type=None, wallet_path=None):
async def create(self, passphrase=None, password=None, encrypt_file=True, seed_type=None, wallet_path=None, use_levelDB=False):
"""Create a new wallet.
If you want to be prompted for an argument, type '?' or ':' (concealed)

arg:str:passphrase:Seed extension
arg:str:seed_type:The type of wallet to create, e.g. 'standard' or 'segwit'
arg:bool:encrypt_file:Whether the file on disk should be encrypted with the provided password
arg:bool:use_levelDB:Create levelDB storage. Note that LevelDB storage does not support file encryption. The password will only encrypt the keystore.
"""
d = create_new_wallet(
path=wallet_path,
passphrase=passphrase,
password=password,
encrypt_file=encrypt_file,
seed_type=seed_type,
use_levelDB=use_levelDB,
config=self.config)
wallet = d['wallet']
return {
'seed': d['seed'],
'path': d['wallet'].storage.path,
'path': wallet.storage.get_path(),
'msg': d['msg'],
}

@command('')
async def restore(self, text, passphrase=None, password=None, encrypt_file=True, wallet_path=None):
async def restore(self, text, passphrase=None, password=None, encrypt_file=True, wallet_path=None, use_levelDB=False):
"""Restore a wallet from text. Text can be a seed phrase, a master
public key, a master private key, a list of bitcoin addresses
or bitcoin private keys.
Expand All @@ -329,6 +332,7 @@ async def restore(self, text, passphrase=None, password=None, encrypt_file=True,
arg:str:text:seed phrase
arg:str:passphrase:Seed extension
arg:bool:encrypt_file:Whether the file on disk should be encrypted with the provided password
arg:bool:use_levelDB:Create levelDB storage. Note that LevelDB storage does not support file encryption. The password will only encrypt the keystore.
"""
# TODO create a separate command that blocks until wallet is synced
d = restore_wallet_from_text(
Expand All @@ -337,9 +341,11 @@ async def restore(self, text, passphrase=None, password=None, encrypt_file=True,
passphrase=passphrase,
password=password,
encrypt_file=encrypt_file,
use_levelDB=use_levelDB,
config=self.config)
wallet = d['wallet']
return {
'path': d['wallet'].storage.path,
'path': wallet.storage.get_path(),
'msg': d['msg'],
}

Expand All @@ -356,7 +362,7 @@ async def password(self, password=None, new_password=None, encrypt_file=None, wa
if encrypt_file is None:
if not password and new_password:
# currently no password, setting one now: we encrypt by default
encrypt_file = True
encrypt_file = wallet.storage.supports_file_encryption()
else:
encrypt_file = wallet.storage.is_encrypted()
wallet.update_password(password, new_password, encrypt_storage=encrypt_file)
Expand Down
9 changes: 4 additions & 5 deletions electrum/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
log_exceptions, randrange, OldTaskGroup, UserFacingException, JsonRPCError, os_chmod
)
from .wallet import Wallet, Abstract_Wallet
from .storage import WalletStorage
from .stored_dict import WalletStorage
from .wallet_db import WalletDB, WalletUnfinished
from .commands import known_commands, Commands
from .simple_config import SimpleConfig
Expand Down Expand Up @@ -551,8 +551,7 @@ def _load_wallet(
if not password:
raise InvalidPassword('No password given')
storage.decrypt(password)
# read data, pass it to db
db = WalletDB(storage.read(), storage=storage, upgrade=upgrade)
db = WalletDB(storage.get_stored_dict(), upgrade=upgrade)
if db.get_action():
raise WalletUnfinished(db)
wallet = Wallet(db, config=config)
Expand Down Expand Up @@ -612,8 +611,8 @@ async def _stop_wallet(self, path: str) -> bool:
return False
await wallet.stop()
if self.config.get('wallet_path') is None:
wallet_paths = [w.db.storage.path for w in self._wallets.values()
if w.db.storage and w.db.storage.path]
wallet_paths = [w.storage.path for w in self._wallets.values()
if w.storage and w.storage.path]
if self.config.CURRENT_WALLET == path and wallet_paths:
self.config.CURRENT_WALLET = wallet_paths[0]
return True
Expand Down
3 changes: 2 additions & 1 deletion electrum/gui/qml/qedaemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
from electrum.lnchannel import ChannelState
from electrum.bitcoin import is_address
from electrum.bitcoin import verify_usermessage_with_address
from electrum.storage import StorageReadWriteError, WalletStorage
from electrum.storage import StorageReadWriteError
from electrum.stored_dict import WalletStorage

from .auth import AuthMixin, auth_protect
from .qefx import QEFX
Expand Down
3 changes: 2 additions & 1 deletion electrum/gui/qml/qewallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,8 @@ def setPassword(self, password):

try:
self._logger.info('setting new password')
self.wallet.update_password(current_password, password, encrypt_storage=True)
encrypt_storage = self.wallet.storage.supports_file_encryption()
self.wallet.update_password(current_password, password, encrypt_storage=encrypt_storage)
# restore the invariant that all loaded wallets in qml must be unlocked:
self.wallet.unlock(password)
return True
Expand Down
2 changes: 2 additions & 0 deletions electrum/gui/qt/history_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ def get_data_for_role(self, index: QModelIndex, role: Qt.ItemDataRole) -> QVaria
assert index.isValid()
col = index.column()
window = self.model.window
if not window.isVisible():
return
tx_item = self.get_data()
is_lightning = tx_item.get('lightning', False)
if not is_lightning and 'txid' not in tx_item:
Expand Down
6 changes: 5 additions & 1 deletion electrum/gui/qt/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -1950,8 +1950,12 @@ def on_password(hw_dev_pw):
self.update_lock_menu()

def _update_wallet_password(self, *, old_password, new_password, xpub_encrypt=False):
encrypt_storage = self.wallet.storage.supports_file_encryption()
try:
self.wallet.update_password(old_password, new_password, encrypt_storage=True, xpub_encrypt=xpub_encrypt)
self.wallet.update_password(
old_password, new_password,
encrypt_storage=encrypt_storage,
xpub_encrypt=xpub_encrypt)
except InvalidPassword as e:
self.show_error(str(e))
return
Expand Down
4 changes: 2 additions & 2 deletions electrum/gui/qt/wizard/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ def __init__(self, parent, wizard):

path = wizard._path

if os.path.isdir(path):
raise Exception("wallet path cannot point to a directory")
#if os.path.isdir(path):
# raise Exception("wallet path cannot point to a directory")

self.wallet_exists = False
self.wallet_is_open = False
Expand Down
2 changes: 1 addition & 1 deletion electrum/invoices.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def get_id(self) -> str:
else: # on-chain
return get_id_from_onchain_outputs(outputs=self.get_outputs(), timestamp=self.time)

def as_dict(self, status):
def export(self, status):
d = {
'is_lightning': self.is_lightning(),
'amount_BTC': format_satoshis(self.get_amount_sat()),
Expand Down
Loading