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
8 changes: 6 additions & 2 deletions electrum/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,20 +298,22 @@ 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
"""
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)
return {
'seed': d['seed'],
Expand All @@ -320,7 +322,7 @@ async def create(self, passphrase=None, password=None, encrypt_file=True, seed_t
}

@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 +331,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
"""
# TODO create a separate command that blocks until wallet is synced
d = restore_wallet_from_text(
Expand All @@ -337,6 +340,7 @@ 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)
return {
'path': d['wallet'].storage.path,
Expand Down
7 changes: 4 additions & 3 deletions electrum/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,8 @@ def _load_wallet(
raise InvalidPassword('No password given')
storage.decrypt(password)
# read data, pass it to db
db = WalletDB(storage.read(), storage=storage, upgrade=upgrade)
storage.init_db()
db = WalletDB(storage.get_stored_dict())
if db.get_action():
raise WalletUnfinished(db)
wallet = Wallet(db, config=config)
Expand Down Expand Up @@ -585,8 +586,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
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
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
8 changes: 4 additions & 4 deletions electrum/invoices.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import attr

from .json_db import StoredObject, stored_in
from .stored_dict import StoredObject, stored_at
from .i18n import _
from .util import age, InvoiceError, format_satoshis
from .bip21 import create_bip21_uri
Expand Down Expand Up @@ -251,7 +251,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 All @@ -268,7 +268,7 @@ def as_dict(self, status):
return d


@stored_in('invoices')
@stored_at('invoices/*')
@attr.s
class Invoice(BaseInvoice):
lightning_invoice = attr.ib(type=str, kw_only=True) # type: Optional[str]
Expand Down Expand Up @@ -318,7 +318,7 @@ def to_debug_json(self) -> Dict[str, Any]:
return d


@stored_in('payment_requests')
@stored_at('payment_requests/*')
@attr.s
class Request(BaseInvoice):
payment_hash = attr.ib(type=bytes, kw_only=True, converter=hex_to_bytes) # type: Optional[bytes]
Expand Down
Loading