1
0
Commit Graph

16424 Commits

Author SHA1 Message Date
SomberNight
1b9cb47623 dependencies: rm upper limit for hidapi
Was added in 752b37a03b,
due to upstream issue https://github.com/trezor/cython-hidapi/issues/142,
which should now be fixed in 0.14.0.
2023-05-30 22:51:06 +00:00
ghost43
b6cfc12962 Merge pull request #8454 from SomberNight/202305_configvar
config: introduce ConfigVars (take 3)
2023-05-30 14:52:50 +00:00
SomberNight
328a2bb3f2 config: migrate qt gui optional tabs to config vars 2023-05-30 14:04:20 +00:00
SomberNight
dfa2b71bc3 config: trivial rename for better readability 2023-05-30 14:04:17 +00:00
SomberNight
c049b461bb bump libsecp256k1 version 2023-05-26 13:22:35 +00:00
SomberNight
24980feab7 config: introduce ConfigVars
A new config API is introduced, and ~all of the codebase is adapted to it.
The old API is kept but mainly only for dynamic usage where its extra flexibility is needed.

Using examples, the old config API looked this:
```
>>> config.get("request_expiry", 86400)
604800
>>> config.set_key("request_expiry", 86400)
>>>
```

The new config API instead:
```
>>> config.WALLET_PAYREQ_EXPIRY_SECONDS
604800
>>> config.WALLET_PAYREQ_EXPIRY_SECONDS = 86400
>>>
```

The old API operated on arbitrary string keys, the new one uses
a static ~enum-like list of variables.

With the new API:
- there is a single centralised list of config variables, as opposed to
  these being scattered all over
- no more duplication of default values (in the getters)
- there is now some (minimal for now) type-validation/conversion for
  the config values

closes https://github.com/spesmilo/electrum/pull/5640
closes https://github.com/spesmilo/electrum/pull/5649

Note: there is yet a third API added here, for certain niche/abstract use-cases,
where we need a reference to the config variable itself.
It should only be used when needed:
```
>>> var = config.cv.WALLET_PAYREQ_EXPIRY_SECONDS
>>> var
<ConfigVarWithConfig key='request_expiry'>
>>> var.get()
604800
>>> var.set(3600)
>>> var.get_default_value()
86400
>>> var.is_set()
True
>>> var.is_modifiable()
True
```
2023-05-25 17:39:48 +00:00
SomberNight
03ab33f4b2 SimpleConfig: change API of set_key(): "save" is now kwarg-only 2023-05-25 17:37:16 +00:00
ThomasV
250b14cb6e Merge pull request #8450 from SomberNight/202305_website_nojs
contrib/make_download: adapt to downloads being merged into index.html
2023-05-24 15:51:46 +02:00
SomberNight
3861b7c152 contrib/make_download: adapt to downloads being merged into index.html
see https://github.com/spesmilo/electrum-web/pull/20
2023-05-22 13:12:26 +00:00
ThomasV
fda408e4e4 Merge pull request #8444 from Har01d/add-3xpl-as-explorer
Add 3xpl.com to the list of explorers
2023-05-21 11:17:21 +02:00
SomberNight
603088a79f util: simplify profiler 2023-05-19 23:03:27 +00:00
Nikita Zhavoronkov
9f045e546f Add 3xpl.com to the list of explorers 2023-05-20 04:29:44 +06:00
SomberNight
e9475345e4 qml wizard: "confirm seed" screen to normalize whitespaces
fixes https://github.com/spesmilo/electrum/issues/8442
2023-05-17 15:19:41 +00:00
SomberNight
fd41308c6b network: log original error text in catch_server_exceptions
related: https://github.com/spesmilo/electrum/issues/8439
2023-05-16 15:10:12 +00:00
SomberNight
fc7c5dde6e qt SwapDialog: propagate errors from _create_tx
fixes https://github.com/spesmilo/electrum/issues/8430
2023-05-16 14:41:26 +00:00
accumulator
ac8a7a0784 channel_db: raise specific exception when channelDB not loaded, allowing lnworker to mark payment as failed. (#8431)
On mobile, it can take a while before channelDB is loaded. If payment is attempted before the DB
is fully loaded, this would result in a payment failure, but also leaves the payment attempt in IN_PROGRESS
state. This patch adds a more specific ChannelDBNotLoaded exception class, so we can handle this case more
gracefully, since we know the payment didn't succeed.
2023-05-16 13:08:26 +00:00
SomberNight
68eaa680f8 CLI/RPC: better error msg when running daemon on Windows
`-d` is not supported, due to missing os.fork

related: https://github.com/spesmilo/electrum/issues/5511
2023-05-16 12:28:59 +00:00
Ali Sherief
a7d3240bc2 Remove Localbitcoins provider 2023-05-16 10:06:55 +02:00
Sander van Grieken
1dd129c3e8 qml: remove logging ElCombobox 2023-05-15 16:51:49 +02:00
Sander van Grieken
5881eb3035 qml: LnurlPayRequestDialog validate amount between indicated boundaries 2023-05-15 16:47:19 +02:00
Sander van Grieken
229afdd887 qml: styling LnurlPayRequestDialog 2023-05-15 16:47:06 +02:00
Sander van Grieken
8d0fa27065 qml: remove unnecessary assert (#8420) 2023-05-15 16:45:15 +02:00
Sander van Grieken
4f252a438c qml: validate duplicate master key in WCBIP39Refine for BIP39 cosigner seeds (fixes #8432) 2023-05-15 14:45:21 +02:00
Sander van Grieken
cb13eee8a3 qml: let ElCombobox determine implicitWidth based on the dimensions of all modelitems 2023-05-15 13:43:57 +02:00
Sander van Grieken
04c9078955 qml: show pay_invoice error to user 2023-05-15 11:56:40 +02:00
Sander van Grieken
3115ce2f53 qml: show historic fiat amounts when enabled and applicable 2023-05-15 11:38:43 +02:00
Sander van Grieken
17a89efd3c lnurl: fix lightning address regex 2023-05-12 13:53:51 +02:00
Sander van Grieken
89225a9f41 qml: show result dialog after password change 2023-05-12 10:53:02 +02:00
ThomasV
a6f3ee6364 minor 4.4.3 2023-05-11 17:14:42 +02:00
SomberNight
ed3d039fa2 prepare release 4.4.3 2023-05-11 15:12:51 +00:00
SomberNight
5d8dda5170 update locale 2023-05-11 15:11:45 +00:00
ThomasV
fab94c8028 release notes for 4.4.3: note about wallet upgrade to seed version 52 2023-05-11 16:52:05 +02:00
ThomasV
ca49d73312 Merge pull request #8417 from SomberNight/202305_db_version_52
wallet_db version 52: break non-homogeneous multisig wallets
2023-05-11 16:35:42 +02:00
SomberNight
68fb996d20 wallet_db version 52: break non-homogeneous multisig wallets
- case 1: in version 4.4.1, 4.4.2, the qml GUI wizard allowed creating multisig wallets with an old_mpk as cosigner.
- case 2: in version 4.4.0, 4.4.1, 4.4.2, the qml GUI wizard allowed creating multisig wallets with mixed xpub/Ypub/Zpub.

The corresponding missing input validation was a bug in the wizard, it was unintended behaviour. Validation was added in d2cf21fc2b. Note however that there might be users who created such wallet files.

Re case 1 wallet files: there is no version of Electrum that allows spending from such a wallet. Coins received at addresses are not burned, however it is technically challenging to spend them. (unless the multisig can spend without needing the old_mpk cosigner in the quorum).

Re case 2 wallet files: it is possible to create a corresponding spending wallet for such a multisig, however it is a bit tricky. The script type for the addresses in such a heterogeneous xpub wallet is based on the xpub_type of the first keystore. So e.g. given a wallet file [Yprv1, Zpub2] it will have sh(wsh()) scripts, and the cosigner should create a wallet file [Ypub1, Zprv2] (same order).

Technically case 2 wallet files could be "fixed" automatically by converting the xpub types as part of a wallet_db upgrade. However if the wallet files also contain seeds, those cannot be converted ("standard" vs "segwit" electrum seed).
Case 1 wallet files are not possible to "fix" automatically as the cosigner using the old_mpk is not bip32 based.

It is unclear if there are *any* users out there affected by this. I suspect for case 1 it is very likely there are none (not many people have pre-2.0 electrum seeds which were never supported as part of a multisig who would also now try to create a multisig using them); for case 2 however there might be.

This commit breaks both case 1 and case 2 wallets: these wallet files can no longer be opened in new Electrum, an error message is shown and the crash reporter opens. If any potential users opt to send crash reports, at least we will know they exist and can help them recover.
2023-05-11 14:26:11 +00:00
Sander van Grieken
f8ce6c6564 qml: small screen fixes 2023-05-11 13:24:54 +02:00
SomberNight
d2cf21fc2b qml wizard: enforce homogeneous master keys in multisig
- {xpub, Ypub, Zpub} categories cannot be mixed
- old mpk must not be used in multisig
2023-05-11 10:13:51 +00:00
Sander van Grieken
f40d603e64 qml: styling bip39 refine and recovery 2023-05-10 17:16:35 +02:00
SomberNight
19759281ef qml: follow-up BtcField validator: take base unit fully into account
Not just for the fractional part, but also for the integer part.

follow-up 4df6052567
2023-05-10 13:06:38 +00:00
SomberNight
6fade55dd6 bolts: do not disconnect when receiving/sending "warning" messages
follow https://github.com/lightning/bolts/pull/1075
2023-05-10 12:22:48 +00:00
SomberNight
9e13246be8 ledger: fix Ledger_Client_Legacy.sign_transaction()
fix signing txs when using old "bitcoin app" (pre-2.1) on the ledger device

```
 33.36 | W | transaction | heyheyhey. cp1. include_sigs=True force_legacy=False use_segwit_ser=True
 33.36 | W | transaction | heyheyhey. cp2. branch1
 33.37 | E | plugins.ledger.ledger |
Traceback (most recent call last):
  File "...\electrum\electrum\plugins\ledger\ledger.py", line 669, in sign_transaction
    rawTx = tx.serialize_to_network()
  File "...\electrum\electrum\transaction.py", line 945, in serialize_to_network
    witness = ''.join(self.serialize_witness(x, estimate_size=estimate_size) for x in inputs)
  File "...\electrum\electrum\transaction.py", line 945, in <genexpr>
    witness = ''.join(self.serialize_witness(x, estimate_size=estimate_size) for x in inputs)
  File "...\electrum\electrum\transaction.py", line 839, in serialize_witness
    sol = desc.satisfy(allow_dummy=estimate_size, sigdata=txin.part_sigs)
  File "...\electrum\electrum\descriptor.py", line 378, in satisfy
    sol = self._satisfy_inner(sigdata=sigdata, allow_dummy=allow_dummy)
  File "...\electrum\electrum\descriptor.py", line 574, in _satisfy_inner
    raise MissingSolutionPiece(f"no sig for {pubkey.hex()}")
electrum.descriptor.MissingSolutionPiece: no sig for 033e92e55923ea25809790f292ee9bd410355ee02492472d9a1ff1b364874d0679
 33.38 | I | plugins.ledger.ledger | no sig for 033e92e55923ea25809790f292ee9bd410355ee02492472d9a1ff1b364874d0679
```

fixes https://github.com/spesmilo/electrum/issues/8365
regression from https://github.com/spesmilo/electrum/pull/8230
2023-05-09 16:17:04 +00:00
Sander van Grieken
a8a0b36fdb qml: code style, imports 2023-05-09 16:15:09 +02:00
Sander van Grieken
ab19ece4e0 qml: refactor TxOutput into reusable component 2023-05-09 15:50:29 +02:00
Sander van Grieken
daf1f37419 qml: add share toolbutton for outputs in TxDetails 2023-05-09 15:50:29 +02:00
Sander van Grieken
4df6052567 qml: add validators for BtcField and FiatField controls 2023-05-09 15:43:52 +02:00
Sander van Grieken
cb9ba819ec qml: remove Qt Vkbd leftovers 2023-05-09 15:43:52 +02:00
Sander van Grieken
0e0c7980dd qml: implement bip39 account detection 2023-05-09 11:40:05 +02:00
SomberNight
b40a608b74 qt: persist addresses tab toolbar "show/hide" state, like in 4.3.4 2023-05-09 01:14:11 +00:00
SomberNight
c9536180c5 lnutil.LnFeatures: limit max feature bit to 10_000
closes https://github.com/spesmilo/electrum/issues/8403

> In Python 3.10 that worked fine, however in Python 3.11 large integer check https://github.com/python/cpython/issues/95778, so now this throws an error.

Apparently this change was deemed a security fix and was backported to all supported branches of CPython (going back to 3.7). i.e. it affects ~all versions of python (if sufficiently updated with bugfix patches), not just 3.11

> Some offending node aliases:
> ```
> ergvein-fiatchannels
> test-mainnet
> arakis
> ```

The features bits set by some of these nodes:
```
(1, 7, 8, 11, 13, 14, 17, 19, 23, 27, 45, 32973, 52973)
(1, 7, 8, 11, 13, 14, 17, 19, 23, 27, 39, 45, 55, 32973, 52973)
```

> P.S. I see there are a lot of nodes with 253 bytes in their feature vectors. Any idea why that could happen?

Note that the valid [merged-into-spec features](50b2df24a2/09-features.md) currently only go as high as ~51.
However the spec does not specify how to choose feature bits for experimental stuff, so I guess some people are using values in the 50k range. The only limit imposed by the spec on the length of the features bitvector is an implicit one due to the max message size: every msg must be smaller than 65KB, and the features bitvector needs to fit inside the init message, hence it can be up to ~524K bits.
(note that the features are not stored in a sparse representation in the init message and in gossip messages, so if many nodes set such high feature bits, that would noticably impact the size of the gossip).

-----

Anyway, our current implementation of LnFeatures is subclassing IntFlag, and it looks like it does not work well for such large integers. I've managed to make IntFlags reasonably in python 3.11 by overriding __str__ and __repr__ (note that in cpython it is apparently only the base2<->base10 conversions that are slow, power-of-2 conversions are fast, so we can e.g. use `hex()`). However in python 3.10 and older, enum.py itself seems really slow for bigints, e.g. enum._decompose in python 3.10.

Try e.g. this script, which is instant in py3.11 but takes minutes in py3.10:
```py
from enum import IntFlag
class c(IntFlag):
    known_flag_1 = 1 << 0
    known_flag_2 = 1 << 1
    known_flag_3 = 1 << 2
    if hasattr(IntFlag, "_numeric_repr_"):  # python 3.11+
        _numeric_repr_ = hex
    def __repr__(self):
        return f"<{self._name_}: {hex(self._value_)}>"
    def __str__(self):
        return hex(self._value_)

a = c(2**70000-1)
q1 = repr(a)
q2 = str(a)
```

AFAICT we have two options: either we rewrite LnFeatures so that it does not use IntFlag (and enum.py), or, for the short term as workaround, we could just reject very large feature bits.
For now, I've opted to the latter, rejecting feature bits over 10k.

(note that another option is bumping the min required python to 3.11, in which case with the overrides added in this commit the performance looks perfectly fine)
2023-05-08 19:37:33 +00:00
Sander van Grieken
d12752cc42 qml: add Technical properties header for TxDetails and LightningPaymentDetails 2023-05-08 14:53:45 +02:00
SomberNight
209c9f75e0 transaction: fix add_info_from_wallet_and_network
fixes https://github.com/spesmilo/electrum/issues/8406
2023-05-07 21:50:23 +00:00