1
0
Commit Graph

114 Commits

Author SHA1 Message Date
SomberNight
d86c45edac dependencies: bump min aiorpcx, and enforce at runtime
Note that newer aiorpcx started requiring python 3.8, so we cannot use
the latest versions, until we too bump the min python version to 3.8.
We should not do that until debian stable ships python 3.8.
Also, new aiorpcx introduced some API changes which we will need to
adopt, so even if the user locally has recent enough python, we need
old aiorpcx atm.

related: https://github.com/spesmilo/electrum/issues/7118
2021-03-20 17:17:32 +01:00
SomberNight
3c019c2f9c daemon/wallet/network: make stop() methods async 2021-03-09 17:52:36 +01:00
ThomasV
1e4fa83098 Kivy: use the same password for all wallets
When the app is started, the password is checked against all
wallets in the directory.

If the test passes:
 - subsequent wallet creations will use the same password
 - subsequent password updates will be performed on all wallets
 - wallets that are not storage encrypted will encrypted
   on the next password update (even if they are watching-only)

This behaviour is restricted on Android, with a 'single_password' config variable.
Wallet creation without password is disabled if single_password is set
2021-01-13 12:24:19 +01:00
SomberNight
9e45108395 kivy: fix some resource path issues
When running kivy on Linux desktop,
running from git clone, `./run_electrum -g kivy` worked,
but `pip install -e .; electrum -g kivy` did not.
This was due to the relative paths using cwd as base.

see #6835
2020-12-10 07:30:31 +01:00
SomberNight
d40bedb2ac also support uppercase bip21 URIs
related https://github.com/btcpayserver/btcpayserver/issues/2110
2020-12-09 16:09:12 +01:00
SomberNight
5a2d588e8b dependencies: rm python-ecdsa 2020-12-08 16:38:13 +01:00
SomberNight
f74ac1a741 cli/rpc: fix 'sweep' command
fixes #6825
2020-12-08 12:21:56 +01:00
SomberNight
19f17a2bff fix main script hanging (not exiting after exception) in some cases
Previously an unhandled exception in the main script could cause the main thread to die
but the process to hang, as the event loop thread would keep running.

example:
$ ./run_electrum -o signmessage tb1qeh090ruc3cs5hry90tev4fsvrnegulw8xssdzx "mymsg" -w ~/.electrum/testnet/wallets/test_segwit_2
Traceback (most recent call last):
  File "./run_electrum", line 424, in <module>
    init_cmdline(config_options, wallet_path, False)
  File "./run_electrum", line 146, in init_cmdline
    db = WalletDB(storage.read(), manual_upgrades=False)
  File "/home/user/wspace/electrum/electrum/wallet_db.py", line 72, in __init__
    self.load_data(raw)
  File "/home/user/wspace/electrum/electrum/wallet_db.py", line 103, in load_data
    self._after_upgrade_tasks()
  File "/home/user/wspace/electrum/electrum/wallet_db.py", line 189, in _after_upgrade_tasks
    self._load_transactions()
  File "/home/user/wspace/electrum/electrum/util.py", line 406, in <lambda>
    return lambda *args, **kw_args: do_profile(args, kw_args)
  File "/home/user/wspace/electrum/electrum/util.py", line 402, in do_profile
    o = func(*args, **kw_args)
  File "/home/user/wspace/electrum/electrum/wallet_db.py", line 1139, in _load_transactions
    self.data = StoredDict(self.data, self, [])
  File "/home/user/wspace/electrum/electrum/json_db.py", line 79, in __init__
    self.__setitem__(k, v)
  File "/home/user/wspace/electrum/electrum/json_db.py", line 44, in wrapper
    return func(self, *args, **kwargs)
  File "/home/user/wspace/electrum/electrum/json_db.py", line 105, in __setitem__
    v = self.db._convert_dict(self.path, key, v)
  File "/home/user/wspace/electrum/electrum/wallet_db.py", line 1182, in _convert_dict
    v = dict((k, Invoice.from_json(x)) for k, x in v.items())
  File "/home/user/wspace/electrum/electrum/wallet_db.py", line 1182, in <genexpr>
    v = dict((k, Invoice.from_json(x)) for k, x in v.items())
  File "/home/user/wspace/electrum/electrum/invoices.py", line 110, in from_json
    return OnchainInvoice(**x)
  File "<attrs generated init electrum.invoices.OnchainInvoice>", line 8, in __init__
  File "/home/user/wspace/electrum/electrum/invoices.py", line 68, in _decode_outputs
    output = PartialTxOutput.from_legacy_tuple(*output)
  File "/home/user/wspace/electrum/electrum/transaction.py", line 131, in from_legacy_tuple
    return cls.from_address_and_value(addr, val)
  File "/home/user/wspace/electrum/electrum/transaction.py", line 104, in from_address_and_value
    return cls(scriptpubkey=bfh(bitcoin.address_to_script(address)),
  File "/home/user/wspace/electrum/electrum/bitcoin.py", line 422, in address_to_script
    raise BitcoinException(f"invalid bitcoin address: {addr}")
electrum.util.BitcoinException: invalid bitcoin address: tb1qckp4ztmstwtyxzml3dmfvegeq5mfxwu2h3q94l
2020-10-05 17:07:33 +02:00
SomberNight
7e534f4865 dependencies: rm pyaes from requirements
Since #6014, pyaes is not really needed anymore.

As we currently require either one of pycryptodomex or cryptography,
even if pyaes is available, it will not be used.
We could strip it out completely from crypto.py...

In any case, pyaes is still pulled in by some hw wallet dependencies indirectly;
but the core library no longer depends on it.
2020-09-08 16:44:20 +02:00
SomberNight
625f985f22 android: enable full logging if DEBUG build 2020-06-19 01:52:21 +02:00
JeremyRand
b72f8a8c9a RPC client: exit code 1 if RPC server returned error 2020-05-10 06:34:27 +00:00
SomberNight
f8ba660583 clean-up hw-wallet "get_password_for_storage_encryption"-related code 2020-02-28 19:47:56 +01:00
SomberNight
3d42fca86e daemon.run_gui: make sure to exit process on exception
previously, if GUI-related imports raised, the GUI would not start
but the process would not exit (e.g. asyncio event loop would go on)

Traceback (most recent call last):
  File "...\electrum\electrum\daemon.py", line 517, in run_gui
    gui = __import__('electrum.gui.' + gui_name, fromlist=['electrum'])
  File "...\electrum\electrum\gui\qt\__init__.py", line 39, in <module>
    from PyQt5.QtGui import QGuiApplication
ImportError: DLL load failed while importing QtGui: The specified module could not be found.
2020-02-19 15:45:36 +01:00
SomberNight
e42e17779d windows: dll-load 'hack' needs to be applied not only from main script
but also when running tests, or just importing electrum from an interpreter
2020-02-11 20:57:37 +01:00
SomberNight
23a93ef7ad windows: when running from source, load DLLs from main dir
Load DLLs from inner 'electrum' dir instead of '.dlls'.
To make it consistent with where we expect libsecp256k1 (.dll/.so) be.
(note that while in case of libsecp we specifically already search the main dir,
without this change, other DLLs such as libusb or libzbar would not be found there)
2020-02-11 20:57:34 +01:00
ThomasV
e1ce3aace7 Separate db from storage
- storage is content-agnostic
 - db and storage are passed to wallet contructor
2020-02-10 17:45:23 +01:00
SomberNight
93cee1ba4d windows: when running from source, with py3.8+, load DLLs from '.dlls'
Python 3.8 changed where DLLs are searched for.
see https://docs.python.org/3/whatsnew/3.8.html#bpo-36085-whatsnew
This potentially affect our binaries when we start shipping python 3.8+, however that is not being addressed here. This commit simply addresses the usecase of running from source, on Windows, using python 3.8.

On older Python, a user could build/obtain DLLs and place them anywhere on the system %PATH%, however this no longer works with py3.8, as %PATH% is no longer checked.
With py3.8, instead, we now check if there is a folder named '.dlls' in the top-level project directory, and if so, register that as an additional search path.
A user who wants to run Electrum from source on Windows using python 3.8 or later, with their custom DLLs, should manually create the '.dlls' folder and put their DLLs there. If they also want to switch between e.g. python 3.7 and 3.8, they should also include '.dlls' in the system %PATH%.

When using Electrum, interesting DLLs include at least libsecp256k1.dll, libusb-1.0.dll, libzbar-0.dll.
2019-12-14 06:44:17 +01:00
SomberNight
f73b6b5d23 keystore: cache derive_pubkey 2019-12-09 03:35:20 +01:00
ThomasV
90ce9f195b Allow user to enable lightning in the GUI. Make it a per-wallet setting. 2019-10-13 20:34:38 +02:00
SomberNight
04edad9984 config: no longer singleton. it is passed to Wallet.__init__
The few other cases that used SimpleConfig.get_instance() now
either get passed a config instance, or they try to get a reference
to something else that has a reference to a config.
(see lnsweep, qt/qrcodewidget, qt/qrtextedit)
2019-09-22 20:46:01 +02:00
ThomasV
a43be6657d follow-up on SingleConfig 2019-09-10 17:14:25 +02:00
SomberNight
251db638af only require libsecp256k1 if lightning is enabled
related: #5606
2019-09-06 15:08:15 +02:00
ThomasV
35b0b3a43c Fix CLI. Some commands require wallet_path. Return error on exception. 2019-09-06 11:06:08 +02:00
SomberNight
58681e4d07 follow-up prev (commands) 2019-09-05 18:30:04 +02:00
ThomasV
9ec9e1760a CLI: always use the daemon's cmd_runner, and pass the 'wallet'
parameter explicitly to each command that requires it.
Previous code was relying on side effects to set the wallet.
This should fix #5614
2019-09-05 17:57:51 +02:00
SomberNight
de83ab6d4a CLI: remove timeout for offline commands
e.g. when interacting with hw wallets (e.g. signmessage)
it does not make sense to time out

also, str(e) of some exceptions such as TimeoutError is ""...
2019-09-04 14:35:04 +02:00
ThomasV
747ab7a0a2 Integrate http_server (previously in electrum-merchant)
Use submodule to fetch HTML and CSS files
2019-09-04 12:20:05 +02:00
ThomasV
7f870f5e09 replace daemon 'start' subdommand with -d 2019-09-02 19:04:08 +02:00
ThomasV
e79253b5e0 Syntax change: Require --offline to run commands without a daemon.
That makes the syntax less ambiguous. It also makes it possible to
implement a CLI that does not import all the electrum modules.
2019-08-31 09:24:00 +02:00
ThomasV
0702338912 main script: rm init_daemon (dead code), call sys_exit in init_cmdline 2019-08-31 08:32:06 +02:00
ThomasV
10e186c1d3 revert ed086934e5
(this does not work well with travis)
2019-08-30 15:58:38 +02:00
ThomasV
ed086934e5 In 'daemon start', do not return until the daemon can be reached 2019-08-30 15:15:30 +02:00
ThomasV
9cfeadea70 Turn daemon subcommands into RPCs 2019-08-20 09:03:12 +02:00
ThomasV
4397767a5e minor fix 2019-08-20 09:03:12 +02:00
ThomasV
2e1829bc24 remove jsonrpclib dependency 2019-08-20 09:03:12 +02:00
ThomasV
54257cbcca Rewrite JsonRPC requests using asyncio.
- commands are async
 - the asyncio loop is started and stopped from the main script
 - the daemon's main loop runs in the main thread
 - use jsonrpcserver and jsonrpcclient instead of jsonrpclib
2019-08-20 09:03:12 +02:00
ThomasV
5e0427392f Daemon: Replace get_server with request.
This function performs a single RPC, and may raise a DaemonNotRunning exception.
2019-08-20 09:03:12 +02:00
ThomasV
b81feb6550 daemon: simplify get_fd_or_server 2019-08-20 09:03:12 +02:00
ThomasV
842fff832f enable lightning through command line option 2019-08-20 09:03:11 +02:00
ThomasV
626d09b358 add 'recḱless' option to allow using lightning on mainnet 2019-08-20 09:03:10 +02:00
ThomasV
3fd3b2a74d disable lightning on mainnet 2019-08-20 09:03:10 +02:00
ThomasV
62e6ca50e1 do not log client-side RPC executions 2019-06-25 15:26:24 +02:00
SomberNight
7cba46c317 deprecation warnings: only show when running from source 2019-05-28 21:38:27 +02:00
SomberNight
6940c424d1 logging: cli options to filter for modules using -v
old style "-v" still works

filtering examples:
-v=debug,network=error,interface=error      // effectively blacklists network and interface
-v=warning,network=debug,interface=debug    // effectively whitelists network and interface
2019-05-02 15:19:10 +02:00
SomberNight
3385a94753 logging: basics 2019-05-02 15:19:03 +02:00
cluelessperson
4d64e132d7 standardized logging base with ISO8601, UTC, rotating file logs, and more! 2019-05-02 15:07:15 +02:00
SomberNight
4f70da6e15 make sure DeprecationWarnings are shown 2019-03-27 18:09:26 +01:00
ThomasV
13f3f71125 daemon: in detached modde, redirect strandard file descriptors 2019-03-12 08:32:27 +01:00
SomberNight
0de954546a test python version in main script
for better error text on old python

related: #5008, #5129
2019-02-15 22:06:10 +01:00
SomberNight
8b775fd24a contrib: import 'requests' in try-except 2018-12-13 23:25:52 +01:00