1
0
Commit Graph

221 Commits

Author SHA1 Message Date
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
SomberNight
09e412baf8 tests: enable verbose stderr logging
note: print() statements and stderr logging don't have a consistent printing order.
Either can buffer log lines and flush them later, and the buffers are independent.
2025-06-09 17:40:27 +00:00
SomberNight
ffb12b2833 tests: test_network: shorten lines 2025-06-09 17:22:49 +00:00
SomberNight
9016c36df0 tests: test_network.py: rm test_fork_conflict, no longer applicable
Just prior to this commit, test_fork_conflict and test_fork_noconflict were essentially identical copies.
The only diff was that test_fork_conflict set the global blockchain.blockchains,
but this was not even affecting its behaviour anymore.

Originally when this test was added, we had the concept of chain fork conflicting with each other:
we could not handle three-way chain-splits. As in, there could only be a single fork forking away
from the main chain at any given height.
see 7221fb3231

However, this restriction was removed and generalised later:
141ff99580
After which the "test_fork_conflict" test did not make sense anymore.
2025-06-09 15:46:02 +00:00
SomberNight
dbb9673139 interface: faster chain resolution: add headers_cache
We try to predict the next headers the interface will ask for,
and request them ahead of time, to be kept in the headers_cache.

This saves network latency/round-trips, for a bit more memory usage
and in some cases for more bandwidth.
Note that due to PaddedRSTransport.WAIT_FOR_BUFFER_GROWTH_SECONDS,
latency saved here can be longer than "real" network latency.

This speeds up
- binary search greatly,
- backwards search to a small degree
  (although not that much as its algorithm should be changed a bit to make it cache-friendly)
- catch-up greatly, if it's <10 blocks behind

What remains is to speed up catch-up in case we are behind by many thousands of block.
That behaviour is left unchanged here. The issue there is that we request chunks sequentially.
So e.g. 1 chunk (2016 blocks) per 1 second.
2025-06-09 15:36:04 +00:00
SomberNight
27599ac537 interface: small clean-up. intro ChainResolutionMode.
- type hints
- minor API changes
- no functional changes
2025-06-06 16:42:15 +00:00
ThomasV
1bf1de36cb txbatcher:
- add base_tx to wallet before broadcasting
 - remove base_tx in find_base_tx, it is local
 - add unit test in test_tx_batcher
2025-06-06 10:16:32 +02:00
ThomasV
8019ceb568 test_daemon: add test the wallet can be loaded by basename 2025-06-05 09:08:53 +02:00
ThomasV
37914d5af0 cmdline: use 'wallet_path' argument to pass wallet_path 2025-06-05 09:06:29 +02:00
SomberNight
3e4601c61d base64.b64decode: always set validate=True
Notably verifymessage and decrypt(message) were silently ignoring trailing garbage
or inserted non-base64 characters present in signatures/ciphertext.
(both the CLI commands and in the GUI)
I think it is much cleaner and preferable to treat such signatures/ciphertext as invalid.

In fact I find it surprising that base64.b64decode(validate=False) is the default.
Perhaps we should create a helper function for it that set validate=True and use that.
2025-06-03 18:58:05 +00:00
ThomasV
c13932452a test_lnpeer: add mock get_invoice method 2025-06-02 16:27:24 +02:00
ThomasV
9e225d1269 Replace config GUI_LAST_WALLET with CURRENT_WALLET
- CURRENT_WALLET is set when a single wallet is loaded in memory, and it
   remains set after Electrum stops running.
 - If several wallets are loaded at the same time, CURRENT_WALLET is unset,
   and RPCs must specify the wallet explicitly (using --wallet for the CLI)
 - The fallback to 'default_wallet' essentially only applies when
   creating a new wallet file
2025-06-02 14:05:53 +02:00
ThomasV
a23f370a43 follow-up ae7a1073cf
(todo: move these methods into lnworker)
2025-06-01 14:03:29 +02:00
ThomasV
40de52e829 regtest: make test_fw_fail morer reliable 2025-06-01 13:42:26 +02:00
ThomasV
ae7a1073cf Merge pull request #9685 from f321x/hold_invoice_cli
cli: add hold invoice cli functionality
2025-06-01 12:03:46 +02:00
ThomasV
43ca469774 Merge pull request #9555 from tianzedavid/master
chore: fix some typos
2025-05-30 14:36:12 +02:00
ThomasV
f0930ffc1d Merge pull request #9839 from SomberNight/202505_transaction_verify_sig_2
transaction: add method verify_sig_for_txin
2025-05-30 14:32:27 +02:00
ThomasV
e580373c82 test_redeem_offered_htlcs: reduce bob's target because they might send anchor output sweeping tx 2025-05-29 19:27:06 +02:00
SomberNight
db759765d6 adb.get_tx_height: allow future txs to be partially signed
If the full tx is missing, we should force mempool/confirmed txs to be LOCAL height,
however future txs should not be forced to LOCAL, they should remain FUTURE.

follow-up 197933debf
2025-05-27 18:19:01 +00:00