1
0
SomberNight 8829b7cd63 wallet: fix deadlock in on_event_adb_added_verified_tx
wallet.lock -> wallet.transaction_lock order must be respected.

deadlock example:
```
# ThreadID: 19100
File: ...\Python\Python310\lib\threading.py", line 966, in _bootstrap
  self._bootstrap_inner()
File: ...\Python\Python310\lib\threading.py", line 1009, in _bootstrap_inner
  self.run()
File: ...\Python\Python310\lib\threading.py", line 946, in run
  self._target(*self._args, **self._kwargs)
File: "...\electrum\electrum\util.py", line 1552, in run_event_loop
  loop.run_until_complete(stopping_fut)
File: ...\Python\Python310\lib\asyncio\base_events.py", line 633, in run_until_complete
  self.run_forever()
File: ...\Python\Python310\lib\asyncio\windows_events.py", line 321, in run_forever
  super().run_forever()
File: ...\Python\Python310\lib\asyncio\base_events.py", line 600, in run_forever
  self._run_once()
File: ...\Python\Python310\lib\asyncio\base_events.py", line 1896, in _run_once
  handle._run()
File: ...\Python\Python310\lib\asyncio\events.py", line 80, in _run
  self._context.run(self._callback, *self._args)
File: "...\electrum\electrum\wallet.py", line 494, in on_event_adb_added_verified_tx
  self._update_invoices_and_reqs_touched_by_tx(tx_hash)
File: "...\electrum\electrum\wallet.py", line 2454, in _update_invoices_and_reqs_touched_by_tx
  status = self.get_invoice_status(request)
File: "...\electrum\electrum\wallet.py", line 2333, in get_invoice_status
  paid, conf = self.is_onchain_invoice_paid(invoice)
File: "...\electrum\electrum\wallet.py", line 1120, in is_onchain_invoice_paid
  is_paid, conf_needed, relevant_txs = self._is_onchain_invoice_paid(invoice)
File: "...\electrum\electrum\wallet.py", line 1095, in _is_onchain_invoice_paid
  with self.lock, self.transaction_lock:
File: "...\electrum\electrum\address_synchronizer.py", line 70, in acquire
  return self._lock.acquire(*args, **kwargs)

# ThreadID: 20040
File: "C:\Program Files\JetBrains\PyCharm Community Edition 2021.3.3\plugins\python-ce\helpers\pycharm\_jb_pytest_runner.py", line 51, in <module>
  sys.exit(pytest.main(args, plugins_to_load + [Plugin]))
File: "...\Python\Python310\site-packages\_pytest\config\__init__.py", line 164, in main
  ret: Union[ExitCode, int] = config.hook.pytest_cmdline_main(
File: ...\Python\Python310\lib\site-packages\pluggy\_hooks.py", line 265, in __call__
  return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
File: ...\Python\Python310\lib\site-packages\pluggy\_manager.py", line 80, in _hookexec
  return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
File: ...\Python\Python310\lib\site-packages\pluggy\_callers.py", line 39, in _multicall
  res = hook_impl.function(*args)
File: "...\Python\Python310\site-packages\_pytest\main.py", line 315, in pytest_cmdline_main
  return wrap_session(config, _main)
File: "...\Python\Python310\site-packages\_pytest\main.py", line 268, in wrap_session
  session.exitstatus = doit(config, session) or 0
File: "...\Python\Python310\site-packages\_pytest\main.py", line 322, in _main
  config.hook.pytest_runtestloop(session=session)
File: ...\Python\Python310\lib\site-packages\pluggy\_hooks.py", line 265, in __call__
  return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
File: ...\Python\Python310\lib\site-packages\pluggy\_manager.py", line 80, in _hookexec
  return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
File: ...\Python\Python310\lib\site-packages\pluggy\_callers.py", line 39, in _multicall
  res = hook_impl.function(*args)
File: "...\Python\Python310\site-packages\_pytest\main.py", line 347, in pytest_runtestloop
  item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
File: ...\Python\Python310\lib\site-packages\pluggy\_hooks.py", line 265, in __call__
  return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
File: ...\Python\Python310\lib\site-packages\pluggy\_manager.py", line 80, in _hookexec
  return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
File: ...\Python\Python310\lib\site-packages\pluggy\_callers.py", line 39, in _multicall
  res = hook_impl.function(*args)
File: "...\Python\Python310\site-packages\_pytest\runner.py", line 111, in pytest_runtest_protocol
  runtestprotocol(item, nextitem=nextitem)
File: "...\Python\Python310\site-packages\_pytest\runner.py", line 130, in runtestprotocol
  reports.append(call_and_report(item, "call", log))
File: "...\Python\Python310\site-packages\_pytest\runner.py", line 219, in call_and_report
  call = call_runtest_hook(item, when, **kwds)
File: "...\Python\Python310\site-packages\_pytest\runner.py", line 258, in call_runtest_hook
  return CallInfo.from_call(
File: "...\Python\Python310\site-packages\_pytest\runner.py", line 338, in from_call
  result: Optional[TResult] = func()
File: "...\Python\Python310\site-packages\_pytest\runner.py", line 259, in <lambda>
  lambda: ihook(item=item, **kwds), when=when, reraise=reraise
File: ...\Python\Python310\lib\site-packages\pluggy\_hooks.py", line 265, in __call__
  return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
File: ...\Python\Python310\lib\site-packages\pluggy\_manager.py", line 80, in _hookexec
  return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
File: ...\Python\Python310\lib\site-packages\pluggy\_callers.py", line 39, in _multicall
  res = hook_impl.function(*args)
File: "...\Python\Python310\site-packages\_pytest\runner.py", line 166, in pytest_runtest_call
  item.runtest()
File: "...\Python\Python310\site-packages\_pytest\unittest.py", line 327, in runtest
  self._testcase(result=self)  # type: ignore[arg-type]
File: ...\Python\Python310\lib\unittest\case.py", line 650, in __call__
  return self.run(*args, **kwds)
File: ...\Python\Python310\lib\unittest\case.py", line 591, in run
  self._callTestMethod(testMethod)
File: ...\Python\Python310\lib\unittest\case.py", line 549, in _callTestMethod
  method()
File: "...\electrum\electrum\tests\test_invoices.py", line 120, in test_wallet_without_ln_creates_payreq_and_gets_paid_onchain
  self.assertEqual(PR_PAID, wallet1.get_invoice_status(pr))
File: "...\electrum\electrum\wallet.py", line 2333, in get_invoice_status
  paid, conf = self.is_onchain_invoice_paid(invoice)
File: "...\electrum\electrum\wallet.py", line 1120, in is_onchain_invoice_paid
  is_paid, conf_needed, relevant_txs = self._is_onchain_invoice_paid(invoice)
File: "...\electrum\electrum\wallet.py", line 1095, in _is_onchain_invoice_paid
  with self.lock, self.transaction_lock:
File: "...\electrum\electrum\address_synchronizer.py", line 70, in acquire
  return self._lock.acquire(*args, **kwargs)
```
2023-01-12 18:19:04 +00:00
2021-09-13 16:20:54 +00:00
2022-08-10 17:32:23 +02:00
2022-10-28 12:07:30 +02:00
2015-11-09 22:53:27 +09:00
2016-02-24 10:20:30 +01:00
2022-06-10 14:34:20 +02:00
2023-01-03 12:41:40 +01:00
2022-04-28 18:28:09 +02:00

Electrum - Lightweight Bitcoin client

Licence: MIT Licence
Author: Thomas Voegtlin
Language: Python (>= 3.8)
Homepage: https://electrum.org/

Build Status Test coverage statistics Help translate Electrum online

Getting started

(If you've come here looking to simply run Electrum, you may download it here.)

Electrum itself is pure Python, and so are most of the required dependencies, but not everything. The following sections describe how to run from source, but here is a TL;DR:

$ sudo apt-get install libsecp256k1-0
$ python3 -m pip install --user ".[gui,crypto]"

Not pure-python dependencies

If you want to use the Qt interface, install the Qt dependencies:

$ sudo apt-get install python3-pyqt5

For elliptic curve operations, libsecp256k1 is a required dependency:

$ sudo apt-get install libsecp256k1-0

Alternatively, when running from a cloned repository, a script is provided to build libsecp256k1 yourself:

$ sudo apt-get install automake libtool
$ ./contrib/make_libsecp256k1.sh

Due to the need for fast symmetric ciphers, cryptography is required. Install from your package manager (or from pip):

$ sudo apt-get install python3-cryptography

If you would like hardware wallet support, see this.

Running from tar.gz

If you downloaded the official package (tar.gz), you can run Electrum from its root directory without installing it on your system; all the pure python dependencies are included in the 'packages' directory. To run Electrum from its root directory, just do:

$ ./run_electrum

You can also install Electrum on your system, by running this command:

$ sudo apt-get install python3-setuptools python3-pip
$ python3 -m pip install --user .

This will download and install the Python dependencies used by Electrum instead of using the 'packages' directory. It will also place an executable named electrum in ~/.local/bin, so make sure that is on your PATH variable.

Development version (git clone)

(For OS-specific instructions, see here for Windows, and for macOS)

Check out the code from GitHub:

$ git clone https://github.com/spesmilo/electrum.git
$ cd electrum
$ git submodule update --init

Run install (this should install dependencies):

$ python3 -m pip install --user -e .

Create translations (optional):

$ sudo apt-get install python-requests gettext
$ ./contrib/pull_locale

Finally, to start Electrum:

$ ./run_electrum

Run tests

Run unit tests with pytest:

$ pytest electrum/tests -v

To run a single file, specify it directly like this:

$ pytest electrum/tests/test_bitcoin.py -v

Creating Binaries

Contributing

Any help testing the software, reporting or fixing bugs, reviewing pull requests and recent changes, writing tests, or helping with outstanding issues is very welcome. Implementing new features, or improving/refactoring the codebase, is of course also welcome, but to avoid wasted effort, especially for larger changes, we encourage discussing these on the issue tracker or IRC first.

Besides GitHub, most communication about Electrum development happens on IRC, in the #electrum channel on Libera Chat. The easiest way to participate on IRC is with the web client, web.libera.chat.

Languages
Python 89.1%
QML 8.4%
Shell 2%
Dockerfile 0.2%
Java 0.2%
Other 0.1%