1
0
Commit Graph

270 Commits

Author SHA1 Message Date
SomberNight
5d1df96020 tests: clear util.callback_mgr between test cases
util.callback_mgr.callbacks was not getting properly cleared between tests.
Every time an Abstract_Wallet or an LNWorker (or many other subclasses of EventListener) is instantiated,
self.register_callbacks() is called in __init__, which puts callbacks into util.callback_mgr.callbacks.
These are only cleaned up if we explicitly call Abstract_Wallet.stop() or LNWorker.stop() later, which we usually do not do in the tests.

As a result, when running multiple unit tests in a row, lots of objects created in a given testcase are never GC-ed and leak into subsequent tests. This is not only a memory leak, but wastes compute too: when events are triggered and cbs get called, these old objects also have their cbs called.

After running all (~1061) unit tests, I observe util.callback_mgr.callbacks had 30 events with a total of 3156 callbacks stored.

On my laptop, running all unit tests previously took ~115 sec, and now it takes ~73 sec.
2025-09-26 15:53:41 +00:00
ghost43
de7612b3b1 Merge pull request #10216 from SomberNight/202509_adb_spv
adb: change API of util.TxMinedInfo: height() is now always SPV-ed
2025-09-24 13:50:14 +00:00
SomberNight
b944371ffd adb: change API of util.TxMinedInfo: height() is now always SPV-ed 2025-09-24 13:46:24 +00:00
SomberNight
6a9c94ff0b wallet: anchor reserve: handle wallet.use_change being off
fixes https://github.com/spesmilo/electrum/issues/10231
2025-09-24 13:38:08 +00:00
SomberNight
e97d8754c4 tests: restore from old "hex" seed 2025-09-08 17:12:24 +00:00
SomberNight
d01e6b8101 qt confirm_tx_dialog: fix wallet.get_candidates_for_batching
I don't understand what the "coins not used" comment meant here.
It was added in the change away from the old config.WALLET_BATCH_RBF option
(ab14c3e138).

The `coins` param *is used* in wallet.get_candidates_for_batching.
Without setting that, the returned set of candidates was restricted to
only base txs that had a large enough change output to cover *all* the newly added outputs.
Instead, it is desirable to allow adding new inputs.
2025-09-05 19:42:56 +00:00
SomberNight
92bdc4d4ca daemon: load_wallet: add force_check_password arg, and use it in qml
- fix: qml gui errors when trying to open a wallets with only keystore-encryption
  - fixes https://github.com/spesmilo/electrum/issues/10171
- qml gui to prompt for password on wallet open even if wallet is not storage-encrypted
2025-08-23 16:54:48 +00:00
SomberNight
9e7c332b06 lnworker: rewrite payment_bundles: lower cpu-time-complexity 2025-08-23 02:41:46 +00:00
SomberNight
8d8d1dba0f util.format_satoshis: floating-point paranoia 2025-08-22 13:30:26 +00:00
ThomasV
0949d9755c Merge pull request #10165 from spesmilo/swaps_prepayment
reverse swaps: in the CLI, replace 'server_mining_fee' with
2025-08-22 10:37:53 +02:00
ThomasV
864932c79a reverse swaps: in the CLI, replace 'server_mining_fee' with
'prepayment', which corresponds to the trusted part of the
lightning payment.

We use 2*sm.mining_fee, where 'mining_fee' is the flat part of
the server fee. However, future protocol should probably allow
to set a value that does not depend on 'mining_fee'.
(note that LND uses a hardcoded amount).
2025-08-21 19:47:00 +02:00
SomberNight
74cd2b4ac3 commands: use format_satoshis consistently. don't use sci-notation
old behaviour:
```
>>> from electrum.commands import format_satoshis
>>> format_satoshis(1)
'1E-8'
```
2025-08-21 17:38:27 +00:00
ThomasV
07d69bd876 Merge pull request #10161 from spesmilo/txbatcher_do_not_remove_local_tx
txbatcher: be careful when removing local transactions
2025-08-21 19:10:49 +02:00
f321x
990a56b9dc tests: regtest: add swapserver mining fee argument 2025-08-21 14:23:26 +02:00
f321x
8c8d142307 tests: unittest get_submarine_swap_providers cli 2025-08-21 14:23:24 +02:00
ThomasV
5f30f2a0c0 txbatcher: be careful when removing local transactions
1. Do not remove local transaction in find_base_tx.

This logic was intended to cleanup claim transactions that are
never broadcast (for example, if the counterparty gets a refund)
(see 1bf1de36cb)

However, this code is too unspecific and may result in fund loss,
because the transaction being removed may contain outgoing payments.
For example, if the electrum server is not responsive, the tx will
be seen as local and deleted. In that case, another payment will
be attempted, thus paying twice.

2. Do not remove tx after try_broadcasting returns False.

The server might be lying to us. We can only remove the local tx
if there is a base_tx, because the next tx we create will try to
spend the same output.
2025-08-21 10:26:35 +02:00
ghost43
8feaa4bb66 Merge pull request #10141 from SomberNight/202508_kswizard_multisig
wizard: enable_keystore: fix for multisig
2025-08-18 14:27:45 +00:00
SomberNight
2318cf7369 keystore: Old_KeyStore: fix check_password(None) if ks has password
check_password(None) should raise InvalidPassword when called on a keystore that has a password.

regression from f86bdc86a2

fixes https://github.com/spesmilo/electrum/issues/10142
2025-08-16 18:08:10 +00:00
SomberNight
dc999aa948 wizard: enable_keystore: fix for multisig
regression from 66c0fec1ea
2025-08-15 20:52:49 +00:00
SomberNight
14494c13dc qt wizard: start: merge "start_viewstate" and "initial_data" 2025-08-15 20:46:24 +00:00
SomberNight
43987c5ca0 wizard: make start() kwarg-only
I want to see where initial_data arg is actually set from.
Looks like hardly anywhere(?)
It is really hard to see because the wizard is crazy-dynamic, there's polymorphism and mixins everywhere.
2025-08-15 20:35:29 +00:00
ghost43
8a8ab26d44 Merge pull request #10140 from SomberNight/202508_test_keystore_wizard
wallet: enable/disable_keystore: some more fixes and tests
2025-08-15 18:16:38 +00:00
SomberNight
5997494c46 tests: wizard: add test "adding unrelated seed to xpub-only ks raises" 2025-08-15 17:39:57 +00:00
SomberNight
cd63be233b wallet: disable_keystore() not to destroy get_key_origin_info() 2025-08-15 17:29:55 +00:00
SomberNight
f025a75356 tests: wizard: use real bip39 seeds 2025-08-15 17:19:22 +00:00
SomberNight
0ceb54b61f wallet: enable/disable_keystore: rm functionality from 2fa wallets
was already not working, but does not even really make sense without larger changes
2025-08-15 16:18:13 +00:00
ghost43
1ae3d0a0bf Merge pull request #10131 from SomberNight/202508_commands_onchain_history
commands: add back from_height/to_height params to onchain_history
2025-08-15 13:36:25 +00:00
ghost43
5a9f54fba0 Merge pull request #10133 from f321x/qml_timestamp_precision
qml: reduce tx history timestamp precision
2025-08-14 17:26:08 +00:00
SomberNight
0fea61ac3a tests: wizard: KeystoreWizard: also test disable_keystore() 2025-08-14 17:06:52 +00:00
SomberNight
6554ec674e tests: wizard: KeystoreWizard: add test case for old seed 2025-08-14 16:44:57 +00:00
SomberNight
e3d1c6aefd wallet: enable/disable_keystore: trivial clean-up 2025-08-14 16:16:31 +00:00
SomberNight
34f0450798 tests: commands: onchain_history: add test for "show_fiat" param 2025-08-14 15:26:59 +00:00
f321x
292ade8953 tests: unittest QETransactionListModel date format
adds unittests for the date formatting and categorization in
QETransactionListModel
2025-08-14 10:10:42 +02:00
SomberNight
d7c76b991b commands: add back from_height/to_height params to onchain_history
closes https://github.com/spesmilo/electrum/issues/10119

also:
- wallet.get_onchain_history was broken with from_height/to_height args
- "show_fees" param is and was non-existent. fees are always added to output
- MyEncoder(json.JSONEncoder) changed a bit:
  - I am pretty sure cutting the last 3 chars was intended to cut off the seconds
  - however that was making incorrect assumptions about what datetime.isoformat() returns
    - which depends on whether microsecond precision is available or whether an explicit timezone is set
  - this now makes it clear that we want minutes-resolution, but still leaves the timezone-ambiguity
2025-08-13 15:09:04 +00:00
Sander van Grieken
e1d5d803e9 wizard: fix missing 'wallet_password' and 'wallet_password_hardware' views on abstract KeystoreWizard
(these were implicitly defined by the Qt subclass) and test wallet keystore enable.
2025-08-13 16:25:01 +02:00
Sander van Grieken
0c5403b91e wizard: add initial tests for KeystoreWizard for electrum and bip39 seeds, hww 2025-08-13 14:40:18 +02:00
SomberNight
acc52e392c tests: wizard: imported addrs: validate each addr with "is_address()"
This was already done *in the GUIs*, but the backend should definitely
do at least sanity-check-level validation like this.
2025-08-12 18:42:35 +00:00
SomberNight
19b2567da8 tests: bitcoin: merge testnet/mainnet address_to_script tests
and add an extra explicit mixed-case bech32 test case
2025-08-12 18:28:09 +00:00
SomberNight
dad18c030c tests: wizard: add test cases for imported wallets 2025-08-12 17:47:03 +00:00
SomberNight
d78782c6ae tests: wizard: add test cases for multisig 2025-08-12 15:44:28 +00:00
SomberNight
fe3ebb31ec tests: wizard: add test case for "restore from slip39" 2025-08-12 15:43:17 +00:00
SomberNight
30a646f80a tests: wizard: add test case for "restore from xpub" 2025-08-12 15:41:31 +00:00
ghost43
186b8ec2ab Merge pull request #10111 from SomberNight/202508_iface_cache_broadcast_tx
interface: don't request same tx from server that we just broadcast to it
2025-08-08 17:28:34 +00:00
SomberNight
4f1cc8b9cb tests: set low wallet.gap_limit_for_change to speed up tests 2025-08-08 16:36:39 +00:00
SomberNight
98c4c9709f tests: interface: more aggressive clean-up 2025-08-08 14:35:03 +00:00
SomberNight
cd8bbcd2bb tests: don't block forever if a prior unit test raised during setUp 2025-08-08 14:35:00 +00:00
SomberNight
05da50178b interface: don't request same tx from server that we just broadcast to it
Often when the wallet creates a tx, the flow is:
- create unsigned tx
- sign tx
- broadcast tx, but don't save it in history
- server sends notification that status of a subscribed address changed
- client calls scripthash.get_history
- client sees txid in scripthash.get_history response
- client calls blockchain.transaction.get to request missing tx

Instead, now when we broadcast a tx on an interface, we cache that tx *for that interface*,
and just before calling blockchain.transaction.get, we lookup in the cache.
Hence this will often save a network request.
2025-08-08 14:34:56 +00:00
SomberNight
d47f38b0e0 tests: interface: impl get_tx/broadcast_tx for electrum server 2025-08-08 14:34:46 +00:00
SomberNight
8efc2aab5e tests: interface: implement toy electrum server 2025-08-08 14:33:38 +00:00
ghost43
4684cdbd17 Merge pull request #10067 from f321x/max_cltv_lnpay
cli: add max_cltv, max_fee_msat parameters to lnpay
2025-08-01 15:14:44 +00:00