1
0
Commit Graph

17363 Commits

Author SHA1 Message Date
SomberNight
9a6ec61647 ci: also run unit tests with python 3.12 2024-02-15 14:22:31 +00:00
SomberNight
79d88dcb5f lnpeer: fix timing issue in reest_chan, for replaying unacked updates
We must not process incoming updates for a given channel until we ~finished reestablishing it.

Consider both parties have some unacked updates they want to replay during reestablish.
If Bob reacts to Alice's replayed stuff before he himself replays his stuff, madness ensues.

I think this should fix the remaining part of https://github.com/spesmilo/electrum/pull/8778
(timing issues when running the unit tests with py3.12)
2024-02-15 14:12:03 +00:00
ghost43
697968bcbb Merge pull request #7835 from SomberNight/202205_lnpeer_async_process_message
lnpeer: make `process_message` async
2024-02-15 14:04:18 +00:00
SomberNight
45e08ada61 lnpeer: make process_message async
This allows making any message handler async in lnpeer.

Note: `process_message` is only called from `_message_loop`.
There are(would be) basically three types of message handlers:
1. "traditional blocking msg handlers". non-async ones. When these handlers are called, `process_message` naturally blocks until the handler returns, which means `_message_loop` also blocks until the message is fully processed before starting the next iteration.
2. "async blocking msg handlers". async ones where we want the previous property, i.e. we want the `_message_loop` to wait until the handler finishes. We await the handler inside `process_message`, and `_message_loop` awaits `process_message`.
3. "async non-blocking msg handlers". async message handlers that can be spawned e.g. onto `Peer.taskgroup` and the loop is free to start processing subsequent messages. e.g. msg handlers that start a negotiation, such as `on_shutdown` and `on_open_channel`.

Any non-async message handler (`def on_...`) automatically goes into category 1.
An async message handler, by default, goes into category 2, "blocking";
to go into category 3 ("non-blocking"), we use the `runs_in_taskgroup` function decorator.
2024-02-15 11:20:49 +00:00
Sander van Grieken
643fbecc15 wizard: fix co-signing hardware wallets data incorrectly referenced 2024-02-14 12:42:15 +01:00
SomberNight
6172898a03 trezor: minor things for better model "safe 3" support 2024-02-14 09:48:13 +00:00
SomberNight
fffbc178cd qt wizard: hww dialogs: log some exceptions more aggressively
sort of related: https://github.com/spesmilo/electrum/issues/8892
2024-02-14 09:05:21 +00:00
SomberNight
130baf13c8 trezor: show descriptive error if trying to init device without fw
closes https://github.com/spesmilo/electrum/issues/8892
2024-02-14 08:52:23 +00:00
SomberNight
46ce5d0f3d wizard: (trivial) follow-up prev 2024-02-13 14:52:52 +00:00
SomberNight
638fdf114e wizard: don't log sensitive values: replace blacklist with whitelist
- blacklist was missing yet another item "multisig_master_pubkey"
- let's just do a whitelist. a blacklist is too risky for my liking here.
2024-02-13 13:51:53 +00:00
SomberNight
7cf22d4b9f coldcard: wallet info dlg: fix missing "Export for Coldcard" btn
regression from 711a325085

```
 47.97 | E | plugin | Plugin error. plugin: coldcard, hook: wallet_info_buttons
Traceback (most recent call last):
  File "...\electrum\electrum\plugin.py", line 261, in run_hook
    r = f(*args)
  File "...\electrum\electrum\plugins\hw_wallet\plugin.py", line 344, in wrapper
    return func(self, *args, **kwargs)
  File "...\electrum\electrum\plugins\coldcard\qt.py", line 51, in wallet_info_buttons
    wallet = main_window.wallet
AttributeError: 'WalletInfoDialog' object has no attribute 'wallet'
```
2024-02-13 13:35:19 +00:00
Sander van Grieken
66af6e6239 send_tab: set tab changes focus for multiline edit
ref #8889
2024-02-13 13:00:11 +01:00
Sander van Grieken
b3bce0299f send_tab: fix tab order #8889 2024-02-13 12:49:08 +01:00
SomberNight
b3a908f647 WalletDB: (trivial) add type hint 2024-02-12 18:26:08 +00:00
SomberNight
b6e5fe8dbe lnworker: history to include close tx for channel backups
- scenario:
  - reuse same seed between two devices, LN enabled on both
  - open channel using device1, import chan backup on device2
  - local-force-close channel using device1
  - tx1 (ctx) gets into mempool (or even mined), tx2 (sweep tx for to_local) is a local (future) tx
  - history tab on device1 shows tx1 and tx2
  - history tab on device2 was showing only tx2, and no info about tx1
    - device2 knows about tx1, it was just not showing it previously.
      With this commit, tx1 is now shown in the history.
    - note: tx1 might linger in the mempool for an indeterminate amount of time, or even become local.
      During that time, it is confusing on device2 not to show any feedback. Also,
      if tx1 becomes local, it is useful to be able to rebroadcast it.
2024-02-12 02:01:14 +00:00
SomberNight
a083b95021 util.CallbackManager: handle callbacks being cancelled
was getting log spam when running the pycharm debugger in certain cases:
```
  3.29 | E | concurrent.futures | exception calling callback for <Future at 0x1d4987bcc70 state=cancelled>
Traceback (most recent call last):
  File "...\Python310\lib\concurrent\futures\_base.py", line 342, in _invoke_callbacks
    callback(self)
  File "...\electrum\electrum\util.py", line 1785, in on_done
    if exc := fut_.exception():
  File "...\Python310\lib\concurrent\futures\_base.py", line 485, in exception
    raise CancelledError()
concurrent.futures._base.CancelledError
```
2024-02-09 13:48:51 +00:00
SomberNight
afb245c17d scripts: fix regression in quick_start.py
```
$ ./electrum/scripts/quick_start.py
Traceback (most recent call last):
  File "/home/user/wspace/electrum/./electrum/scripts/quick_start.py", line 32, in <module>
    wallet.start_network(network)
  File "/home/user/wspace/electrum/electrum/wallet.py", line 620, in start_network
    assert self.network is None, "already started"
AssertionError: already started
```
just the sanity check added in 6ac3f84095
2024-02-08 23:44:08 +00:00
Sander van Grieken
7725e88e32 tests: payment_identifier: check multiline output amounts
implicit conversion check via config.decimal_point
2024-02-08 14:06:25 +01:00
Sander van Grieken
6dd1cf0dba tests: payment_identifier: remove redundant, add some less common domain names 2024-02-08 13:55:35 +01:00
Sander van Grieken
fa46b4633f tests: payment_identifier: check multiline outputs exist, are correct number and type 2024-02-08 13:51:42 +01:00
Sander van Grieken
499b8ed375 tests: payment_identifier: add some more whitespace situations, fix script spk 2024-02-08 13:45:46 +01:00
Sander van Grieken
73be52203b tests: add tests for all supported payment identifier types.
resolve and finalize phases still TODO
2024-02-08 13:35:49 +01:00
Sander van Grieken
2dd4195ad8 qt: ChoiceWidget fix init selected_key 2024-02-08 11:42:14 +01:00
Sander van Grieken
6738e1e90f p4a: python-for-android ref 4f1a1a3a41f6bf8d28984bfd1ec8af3c5d8eb362
> qt6: replace synchronizedList with explicit synchronize block, as we still see ConcurrentModificationExceptions
  in the play store.
2024-02-07 12:08:10 +01:00
SomberNight
1736558e3d type hints: follow-up prevprev. "union types as X | Y" needs py3.10
https://peps.python.org/pep-0604/
2024-02-07 11:03:55 +00:00
SomberNight
d2ace95f96 tests: add toy test for payment_identifier.py
just to make file imported at all, and showcase issue with prev commit
would be nice have create exhaustive tests though
2024-02-07 11:00:40 +00:00
Sander van Grieken
f811db4ec8 payment_identifier: imports, typing declarations 2024-02-07 11:03:52 +01:00
Sander van Grieken
19d9467b93 qml: add typing declarations to qechanneldetails 2024-02-07 10:53:10 +01:00
accumulator
acc7b44a3e Merge pull request #8873 from accumulator/issue_8355
qml: tighten self._loading guard to encompass whole loadWallet fn
2024-02-06 13:55:26 +01:00
Sander van Grieken
2882c4be46 qt: consistency HWW wizard page translations 2024-02-06 10:59:59 +01:00
Sander van Grieken
39bc672da2 followup prev 2024-02-06 10:37:35 +01:00
Sander van Grieken
cac9c4bbb9 qt: fix various issues on send_tab, fixes #8874 2024-02-06 10:35:42 +01:00
SomberNight
ff8f8d6104 qt: sweep_key_dialog: make UI a bit more intuitive
user complained:
> when you want to sweep an address. it's very unclear to me as a noob who is getting the money
> might want a little picture with an arrow to show which direction the funds are going
2024-02-05 23:26:39 +00:00
Sander van Grieken
482ec89b5d minor, code style, imports 2024-02-05 21:25:13 +01:00
Sander van Grieken
4228911609 qml: close TxDetails on TX remove only after the 'removed_transaction' event has been received, so the
history model doesn't refresh too early (fixes #8782)
2024-02-05 21:07:33 +01:00
accumulator
620b46780b Merge pull request #8870 from accumulator/wizard_component_race
qt: wizard: move page.on_ready() to just after construction
2024-02-05 18:12:24 +01:00
Sander van Grieken
c78a90a242 qt: wizard: move page.on_ready() to just after construction to avoid triggering signal/slots that might
assume on_ready() has run
2024-02-05 18:11:43 +01:00
Sander van Grieken
c755a58661 qedaemon: remove redundant, small code style fixes 2024-02-05 18:07:12 +01:00
Sander van Grieken
5aa782a19e qml: extend self._loading guard to encompass _on_backend_wallet_loaded slot as well 2024-02-05 17:59:44 +01:00
Sander van Grieken
b361d02467 qml: tighten self._loading guard to encompass whole loadWallet fn, not just task thread.
Also make sure QEWallet is never instantiated within the task thread.
2024-02-05 17:41:56 +01:00
ghost43
a668d7850d Merge pull request #8864 from SomberNight/202402_gui_feerate_vbyte
gui: label tx sizes as "vbytes", and feerates as "sat/vbyte"
2024-02-05 16:30:07 +00:00
SomberNight
0b7e52fbbe gui: label tx sizes as "vbytes" and feerates as "sat/vbyte"
closes https://github.com/spesmilo/electrum/issues/6961
2024-02-05 16:27:27 +00:00
Sander van Grieken
0a2a22b822 qt: use selected_key instead of selected_item[0] for ChoiceWidgets 2024-02-05 14:39:03 +01:00
SomberNight
c84e55e957 wallet: (trivial) simplify class hierarchy
legacy cruft
2024-02-05 12:47:20 +00:00
Sander van Grieken
0a6b2d521b qml: move final wizard submit() to WizardComponent.finish handler 2024-02-05 11:13:58 +01:00
accumulator
019baa5a71 Merge pull request #8862 from SomberNight/202401_qml_wizard_final_accept
qml wizard: run navmap[view]['accept'] handler a final time on finish
2024-02-05 10:46:22 +01:00
SomberNight
87214c004e trezor: don't try to sign non-ismine inputs
progress towards coinjoin

related https://github.com/spesmilo/electrum/issues/8868
2024-02-05 07:21:28 +00:00
SomberNight
07dc80dd9a qml wizard: stricter validation for new wallet name
user on bitcointalk [0] tried to create wallet with name "w/o 2FA".
Before this, one would only get an error after the last page of the wizard.
With this, the "Next" button does not even get enabled if the name does not look ok.
(and as in comment, maybe we should be even stricter re what is allowed)

[0]: https://bitcointalk.org/index.php?topic=5483514.msg63584789#msg63584789
2024-02-04 08:54:40 +00:00
SomberNight
1d4e2ebed6 ConfigVar: add "converter" for getter, add use it for "proxy" key
fixes https://github.com/spesmilo/electrum/issues/8837

Alternatively we could do a config upgrade (convert_version_*) to fix that specific issue,
but they are not safe against downgrade-upgrade-again, so probably not the best choice for
crash-inducing values.
And this kind of converter is a generic solution that can be useful for other configvars later
(though for most usages I expect we will also need a converter for the setter).
2024-02-04 07:20:05 +00:00
SomberNight
3e81cd1f1d trezor: fix regression in sign_transaction for trezor one for multisig
fixes https://github.com/spesmilo/electrum/issues/8813
regression from eef9680743

We started setting the witness field in above commit to be able to provide the witnesses for already pre-signed
external inputs to the device, e.g. for a coinjoin.

Trezor One fw has pretty strict limits on the witness field: max 109 bytes,
probably because that's a ~tight upper bound for a p2wpkh witness:
  <num_witness_items> <len(sig)> <sig> <len(pubkey)> <pubkey>, it comes out to 3+73(high-S and high-R)+33.
ed1785a985/legacy/firmware/protob/messages-bitcoin.options (L35)

Trezor model T seems to have higher limits.

tx_inputs is called for the tx being signed (for_sig=True), and for its parents/prev_txes (for_sig=False).
The witness is only useful for the tx being signed, I think.

Users reported seeing a "DataError: bytes overflow" exception when using a Trezor One to sign 2of3 p2wsh multisig txs.
There were no external inputs involved so for the tx being signed all witnesses were None, however we were also
setting the witness for the inputs of prev_txes.
The witness for a 2of3 pw2sh multisig input is around ~253 bytes.

To sidestep the problem, we now only set the witness in the for_sig=True case.
Note that this means if someone tries to do a coinjoin with a Trezor One involving non-trivial external inputs,
they will run into the same limit and exception.
2024-02-04 00:14:59 +00:00