1
0
Commit Graph

239 Commits

Author SHA1 Message Date
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
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
SomberNight
6ddc975a94 follow-up prev: clean-up PaymentFeeBudget API 2025-08-01 15:06:33 +00:00
SomberNight
60eb437f99 tests: commands: fix assertRaises in test_hold_invoice_commands 2025-08-01 14:41:28 +00:00
ghost43
c23cc29caa Merge pull request #10082 from f321x/check_hold_invoice_show_htlc_cltv
cli: return closest htlc expiry from check_hold_invoice
2025-08-01 14:29:24 +00:00
f321x
23a48e7cfd test: add unittest for not spending ln reserve utxo
adds unittest to `test_wallet_vertical.py` to verify it is not using the
existing ln reserve utxo as tx input if a reserve is still required (in
opposite to using it as input and creating a new reserve as output).
2025-07-30 10:12:34 +02:00
f321x
6425f9bf75 cli: return closest htlc expiry from check_hold_invoice
Adds a `closest_htlc_expiry_height` value to the `check_hold_invoice` cli command response.
This allows to see the next absolute expiry height of the pending htlcs
of a payment. Note, htlcs will get failed before the actual expiry
height (if block_height + 144 > htlc.cltv_abs).
2025-07-25 11:44:26 +02:00
ghost43
8eb3c43603 Merge pull request #10059 from f321x/fix_issue_10057
fix: cli: check_hold_invoice showing settled invoice as unpaid
2025-07-21 15:53:54 +00:00
SomberNight
729003e557 wizard: move hw_unlock to base cls, and add test_wizard unlock_hw test 2025-07-21 03:33:43 +00:00
SomberNight
b0464cc934 refactor 'init_wallet_wizard' hook a bit. add test_wizard trezor test 2025-07-21 02:40:17 +00:00
SomberNight
7675182a34 tests: test_wizard: dedupe wallet_name 2025-07-21 00:29:56 +00:00
SomberNight
a4c8cf2e4f tests: test_wizard: add 2fa_haveseed_disable2FA case 2025-07-21 00:18:40 +00:00
SomberNight
e0d67524a1 tests: test_wizard: set wallet password and yes/no encrypt file 2025-07-21 00:07:23 +00:00
SomberNight
05d9aca8aa test_wizard: now that I ctrl+c, ctrl+v-ed lots of code, patterns emerge 2025-07-20 23:43:24 +00:00
SomberNight
2bb7500e29 test: test_wizard: add 2fa_createseed case 2025-07-20 23:34:57 +00:00
SomberNight
a3dde40c69 test: test_wizard: add "old" electrum seed tests, and bip39+seed_ext 2025-07-20 23:26:09 +00:00
SomberNight
522810d5bd test: test_wizard: duplicate test_2fa, one for passphrase, one without 2025-07-20 22:24:06 +00:00
SomberNight
bfd3c0e48c Merge branch spesmilo/pr/10016' into 202507_pr10016_qml_wizard_passphrase 2025-07-20 22:02:01 +00:00
SomberNight
e56bc4f2ae tests: test_wizard: add final check: try loading created wallet file 2025-07-20 21:41:44 +00:00
Felix
b4de29e692 Add invoice_amount_sat to check_hold_invoice response
Adds an additional value to the `check_hold_invoice` cli command: `invoice_amount_sat` which returns the requested amount value of the hold invoice.

Co-authored-by: ghost43 <somber.night@protonmail.com>
2025-07-20 18:14:59 +02:00
f321x
8f9951ebed fix: cli: check_hold_invoice showing settled invoice as unpaid
the cli command `check_hold_invoice` incorrectly assumes that
`lnworker.is_accepted_mpp(payment_hash)` is true for settled invoices,
however it is not as the received mpp entries will be removed from
the `lnworker.received_mpp_htlcs` shortly after adding the preimage to
lnworker (after the htlcs got removed from the channel).

Also renames `amount_sat` in the `check_hold_invoice` response to
`amount_sat_received` to make it more obvious that this is the currently
received amount instead of the amount the invoice of `payment_hash` has
been created with.
2025-07-20 13:23:06 +02:00
f321x
307181fe5e wizard: add unittests for passphrase flow 2025-07-15 00:19:42 +02:00
SomberNight
b16760b861 jsonpatch exception-mangling: more robust against secrets in dict keys 2025-07-14 12:53:56 +00:00
SomberNight
195d89a509 JsonDB: monkeypatch jsonpatch exceptions to avoid leaking secrets
closes https://github.com/spesmilo/electrum/issues/10001
2025-07-14 12:16:09 +00:00
SomberNight
6ce8eb12f7 regtests: add test "lnwatcher_waits_until_fees_go_down"
reproduces https://github.com/spesmilo/electrum/issues/9980
2025-07-08 13:36:01 +00:00
SomberNight
d16c625019 i18n: syntax-check translations at runtime
We often call str.format() on translated strings.
E.g. `_("time left: {} seconds").format(t1)`
If the translated string has a different format syntax, this can raise at runtime.

This PR adds some runtime checks that try to ensure the source string and the translated string
have a similar format syntax. If the checks fail, `_()` will "reject" the translation by
returning the source string.

fixes https://github.com/spesmilo/electrum/issues/10010
ref https://github.com/spesmilo/electrum/issues/10007#issue-3203378250
2025-07-07 13:54:11 +00:00
f321x
389a0a6e91 cli: use payment hash for add_hold_invoice
Allowing to create hold invoices just by providing a payment hash
instead of the preimage right from the beginning allows for additional
use cases where the recipient doesn't have access to the preimage when
creating the invoice.
2025-06-30 09:34:05 +02:00
SomberNight
b590c864ee config: fix setting CLI_TIMEOUT configvar, and add "convert_setter"s
"type_=float" behaves a bit weirdly. Was kinda broken before, still not fully "fixed" here.
With this commit, if used together with convert_setter, it at least behaves in a sane way.

```
$ ./run_electrum -o setconfig timeout 10
  1.16 | E | __main__ | error running command (without daemon)
Traceback (most recent call last):
  File "/home/user/wspace/electrum/./run_electrum", line 593, 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 268, in run_offline_command
    result = await func(*args, **kwargs)
  File "/home/user/wspace/electrum/electrum/commands.py", line 194, in func_wrapper
    return await func(*args, **kwargs)
  File "/home/user/wspace/electrum/electrum/commands.py", line 408, in setconfig
    self._setconfig(key, value)
  File "/home/user/wspace/electrum/electrum/commands.py", line 398, in _setconfig
    cv.set(value)
  File "/home/user/wspace/electrum/electrum/simple_config.py", line 126, in set
    self._config_var._set_config_value(self._config, value, save=save)
  File "/home/user/wspace/electrum/electrum/simple_config.py", line 89, in _set_config_value
    raise ValueError(
ValueError: ConfigVar.set type-check failed. key='timeout'. type=<class 'float'>. value=10
```
2025-06-25 17:15:52 +00:00
SomberNight
fa0921e33b tests: regtest: add comments to swapserver tests 2025-06-25 17:15:47 +00:00
SomberNight
c2e8188568 tests: test_network: add more header chain resolution test cases 2025-06-09 20:31:05 +00:00
SomberNight
eb69b6b516 interface: _search_headers_backwards: start at small delta
- interface.tip is the server's tip.
- consider scenario:
  - client has chain len 800_000, is up to date
  - client goes offline
  - suddenly there is a short reorg
      e.g. blocks 799_998, 799_999, 800_000 are reorged
  - client was offline for long time, finally comes back online again
  - server tip is 1_000_000, tip_header does not connect to client's local chain
  - PREVIOUSLY before commit, client would start backwards search
    - first it asks for header 800_001, which does not connect
    - then client asks for header ~600k, which checks
    - client will do long binary search to find the forkpoint
  - AFTER commit, client starts backwards search
    - first it asks for header 800_001, which does not connect
    - then client asks for header 799_999, etc
- that is, previously, on average, client did a short backwards search, followed by a long binary search
- now, on average, client does a longer backwards search, followed by a shorter binary search
  - this works much nicer with the headers_cache
  (- and thomasv said the old behaviour was not intentional)
2025-06-09 19:34:37 +00:00
SomberNight
02c6e118f0 tests: test_network: intro MockBlockchain. rewrite tests to use it.
interface.py no longer has knowledge about mocking! :P
2025-06-09 19:34:34 +00:00
SomberNight
cb1789a59c tests: test_network: try to explain test cases
no functional changes
2025-06-09 17:57:36 +00:00