1
0
Commit Graph

17400 Commits

Author SHA1 Message Date
SomberNight
96f28607f2 keystore: "old"-type seeds cannot have a passphrase
related: https://github.com/spesmilo/electrum/pull/8906
2024-02-21 14:30:13 +00:00
Sander van Grieken
da1727b2f7 trustedcoin: validate numeric format of OTP user entry (fixes #8905) 2024-02-21 13:33:46 +01:00
ThomasV
9799603779 Merge pull request #8888 from SomberNight/202402_jsonrpc_errors
cli/rpc: nicer error messages and error-passing
2024-02-21 13:20:28 +01:00
ThomasV
e2db5ca2ef Merge pull request #8871 from SomberNight/202402_slip19_trezor
support SLIP-19 ownership proofs, for trezor-based Standard_Wallets
2024-02-21 13:06:28 +01:00
SomberNight
a749fd7789 qt tx_dialog: share btn: add option to add slip-19 ownership proofs 2024-02-21 11:58:52 +00:00
SomberNight
b7ed016f3c qt tx_dialog: share btn: replace nested menus with checkboxes
Incidentally, the checkboxes are using the config, so their state is persisted.
2024-02-21 11:56:18 +00:00
SomberNight
0925f15280 wallet/keystore: add apis for "add_slip_19_ownership_proofs_to_tx"
- implement it specifically for the "singlesig trezor" case
- aimed to be generic enough that support for more complex scripts
  and other keystores could be added later
2024-02-21 11:56:13 +00:00
Sander van Grieken
dc3ff908b8 followup prev 2024-02-21 12:03:37 +01:00
Sander van Grieken
d12ce00417 followup prev 2024-02-21 11:28:42 +01:00
Sander van Grieken
6d2dfc9759 android: limit size of text pasted from clipboard, to avoid TransactionTooLargeException
https://developer.android.com/reference/android/os/TransactionTooLargeException.html
2024-02-21 11:22:00 +01:00
Sander van Grieken
de9c0249c7 qml: icons, styling 2024-02-19 14:38:29 +01:00
SomberNight
27bb28e35b tests: follow-up move of folder
follow-up https://github.com/spesmilo/electrum/pull/8897
2024-02-19 12:00:08 +00:00
Sander van Grieken
6ecbb8eb3f tests: add test for payment_identifier.invoice_from_payment_identifier() 2024-02-19 11:54:32 +01:00
accumulator
d968c6245c Merge pull request #8897 from accumulator/move_tests_to_root
tests: move /electrum/tests to /tests
2024-02-19 10:51:42 +01:00
Sander van Grieken
2b95223e2b qml: handle invoice removed from backend from qeinvoicelistmodel status update timer (fixes #8898) 2024-02-19 10:48:24 +01:00
Sander van Grieken
ef87fbd3e5 payment_identifier: return onchain invoice when GUI requests MAX amount (fixes #8900) 2024-02-19 10:35:55 +01:00
Sander van Grieken
4c6421e162 tests: fix CI regtest new path 2024-02-16 17:41:34 +01:00
Sander van Grieken
0faf6928c0 tests: explicit sync on self.app instance ready and make sure _testcase_event is cleared before
QMetaObject.invokeMethod as that can race if it gets inadvertently executed synchronously.
2024-02-16 16:56:14 +01:00
Sander van Grieken
73fee69f5c tests: move /electrum/tests to /tests 2024-02-16 15:40:45 +01:00
ghost43
e11d7b37f2 Merge pull request #8865 from SomberNight/202402_server_bookmarks
network: implement basic "add server as bookmark" functionality
2024-02-16 12:06:18 +00:00
accumulator
1b75e3883e Merge pull request #8845 from accumulator/feepicker
qml: consolidate fee slider ui in various places to a single FeePicker control
2024-02-16 13:01:34 +01:00
Sander van Grieken
016e500993 qml: FeePicker parameterize enable display of tx info and picker, use this for CPFP
to put picker in Total section
2024-02-16 12:56:18 +01:00
Sander van Grieken
c0b892720e qml: consolidate fee slider ui in various places to a single FeePicker control 2024-02-16 10:09:56 +01:00
Sander van Grieken
57270e3bf3 tests: qt_util: disable timer in qt testcases 2024-02-15 16:27:01 +01:00
Sander van Grieken
d8654361af peer_wire.csv: remove msgtype gossip_queries options, as the extract-formats.py tool
does not generate these anymore since aad959a297
2024-02-15 16:10:25 +01:00
SomberNight
ea4481a8dd android readme: de-dupe "qml_gui" requirements
follow-up https://github.com/spesmilo/electrum/pull/8881
2024-02-15 14:53:51 +00:00
ghost43
5582b753e5 Merge pull request #8881 from accumulator/qobject_test
add a simple test framework for testing QObjects and their signal/slot mechanism
2024-02-15 14:46:50 +00:00
ghost43
1d0706abd8 Merge pull request #8778 from SomberNight/202312_ci_py312
ci: also run unit tests with python 3.12
2024-02-15 14:40:35 +00:00
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
Sander van Grieken
a626d1bf42 tests: add test for QEAmount(from_invoice=..) and (m)satsStr properties 2024-02-15 13:36:10 +01: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
bd492fbd14 cli/rpc: nicer error messages and error-passing
Previously, generally, in case of any error, commands would raise a generic "Exception()" and the CLI/RPC would convert that and return it as `str(e)`.

With this change, we now distinguish "user-facing exceptions" (e.g. "Password required" or "wallet not loaded") and "internal errors" (e.g. bugs).
- for "user-facing exceptions", the behaviour is unchanged
- for "internal errors", we now pass around the traceback (e.g. from daemon server to rpc client) and show it to the user (previously, assuming there was a daemon running, the user could only retrieve the exception from the log of that daemon). These errors use a new jsonrpc error code int (code 2).

As the logic only changes for "internal errors", I deem this change not to be compatibility-breaking.

----------
Examples follow.
Consider the following two commands:
```
@command('')
async def errorgood(self):
	from electrum.util import UserFacingException
	raise UserFacingException("heyheyhey")

@command('')
async def errorbad(self):
	raise Exception("heyheyhey")
```

----------
(before change)

CLI with daemon:
```
$ ./run_electrum --testnet daemon -d
starting daemon (PID 9221)
$ ./run_electrum --testnet errorgood
heyheyhey
$ ./run_electrum --testnet errorbad
heyheyhey
$ ./run_electrum --testnet stop
Daemon stopped
```

CLI without daemon:
```
$ ./run_electrum --testnet -o errorgood
heyheyhey
$ ./run_electrum --testnet -o errorbad
heyheyhey
```

RPC:
```
$ curl --data-binary '{"id":"curltext","jsonrpc":"2.0","method":"errorgood","params":[]}' http://user:pass@127.0.0.1:7777
{"id": "curltext", "jsonrpc": "2.0", "error": {"code": 1, "message": "heyheyhey"}}
$ curl --data-binary '{"id":"curltext","jsonrpc":"2.0","method":"errorbad","params":[]}' http://user:pass@127.0.0.1:7777
{"id": "curltext", "jsonrpc": "2.0", "error": {"code": 1, "message": "heyheyhey"}}
```

----------
(after change)

CLI with daemon:
```
$ ./run_electrum --testnet daemon -d
starting daemon (PID 9254)
$ ./run_electrum --testnet errorgood
heyheyhey
$ ./run_electrum --testnet errorbad
(inside daemon): Traceback (most recent call last):
  File "/home/user/wspace/electrum/electrum/daemon.py", line 254, in handle
    response['result'] = await f(*params)
  File "/home/user/wspace/electrum/electrum/daemon.py", line 361, in run_cmdline
    result = await func(*args, **kwargs)
  File "/home/user/wspace/electrum/electrum/commands.py", line 163, in func_wrapper
    return await func(*args, **kwargs)
  File "/home/user/wspace/electrum/electrum/commands.py", line 217, in errorbad
    raise Exception("heyheyhey")
Exception: heyheyhey

internal error while executing RPC
$ ./run_electrum --testnet stop
Daemon stopped
```

CLI without daemon:
```
$ ./run_electrum --testnet -o errorgood
heyheyhey
$ ./run_electrum --testnet -o errorbad
  0.78 | E | __main__ | error running command (without daemon)
Traceback (most recent call last):
  File "/home/user/wspace/electrum/./run_electrum", line 534, in handle_cmd
    result = fut.result()
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 458, in result
    return self.__get_result()
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
    raise self._exception
  File "/home/user/wspace/electrum/./run_electrum", line 255, in run_offline_command
    result = await func(*args, **kwargs)
  File "/home/user/wspace/electrum/electrum/commands.py", line 163, in func_wrapper
    return await func(*args, **kwargs)
  File "/home/user/wspace/electrum/electrum/commands.py", line 217, in errorbad
    raise Exception("heyheyhey")
Exception: heyheyhey
```

RPC:
```
$ curl --data-binary '{"id":"curltext","jsonrpc":"2.0","method":"errorgood","params":[]}' http://user:pass@127.0.0.1:7777
{"id": "curltext", "jsonrpc": "2.0", "error": {"code": 1, "message": "heyheyhey"}}
$ curl --data-binary '{"id":"curltext","jsonrpc":"2.0","method":"errorbad","params":[]}' http://user:pass@127.0.0.1:7777
{"id": "curltext", "jsonrpc": "2.0", "error": {"code": 2, "message": "internal error while executing RPC", "data": {"exception": "Exception('heyheyhey')", "traceback": "Traceback (most recent call last):\n  File \"/home/user/wspace/electrum/electrum/daemon.py\", line 254, in handle\n    response['result'] = await f(*params)\n  File \"/home/user/wspace/electrum/electrum/commands.py\", line 163, in func_wrapper\n    return await func(*args, **kwargs)\n  File \"/home/user/wspace/electrum/electrum/commands.py\", line 217, in errorbad\n    raise Exception(\"heyheyhey\")\nException: heyheyhey\n"}}}
```
2024-02-12 19:02:02 +00:00
SomberNight
b3a908f647 WalletDB: (trivial) add type hint 2024-02-12 18:26:08 +00:00
Sander van Grieken
3582c79160 stub QVideoSink import as it requires many dependencies but isn't used on android currently 2024-02-12 11:49:43 +01:00
Sander van Grieken
71dbf76cd0 add new 'qml_gui' extra to setup.py and include it for tox 2024-02-12 11:29:05 +01:00
Sander van Grieken
46e0c6e8ae tests: print traceback of original exception when testcase fails 2024-02-12 10:38:40 +01:00
Sander van Grieken
08a06ae4aa don't prefix utility classes and functions file with test_ 2024-02-12 10:10:36 +01: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
Sander van Grieken
058305acca add a simple test framework for testing QObjects and their signal/slot mechanism 2024-02-09 15:45:52 +01:00