Commit Graph

768 Commits

Author SHA1 Message Date
Ilya Artemov 44570bfa3b Bump minimum required version of ledger_bitcoin (build-time and runtime) 2026-04-24 09:09:00 +02:00
Ilya Artemov b3808b7920 Using GET_MASTER_FINGERPRINT for Legacy Client to get the root public key fingerprint 2026-04-16 15:02:07 +02:00
f321x fd230cf9d1 plugin: nwc: handle 'null' params in request
Some clients send 'params: null' instead of 'params: {}' or no
params key at all.
2026-04-07 09:52:13 +02:00
ThomasV 7a6a39d1aa add comments about xpub encryption 2026-04-02 14:46:50 +02:00
f321x b9a24ae1cf plugin: nwc: handle missing params dict in request
Even though the NIP-47 specification kind of defines that requests should
always pass a params dict in their request i witnessed way too often
that clients don't include it in some requests where it is technically
not neccessary and we fail on it.
Handling this gracefully improves compatibility without obvious
downsides.
2026-03-27 15:05:15 +01:00
f321x cb023e22e4 qml: 2fa: make 2fa setup qr code clickable
This will make the 2fa app open when the user clicks on the qr code,
much more convenient than manually copy pasting the secret.
2026-03-24 14:50:45 +01:00
f321x 37159e47a2 qml: 2fa: make it possible to copy 2fa secret
The 2fa secret is not selectable or copyable, this is very inconveniant
when setting up a new 2fa wallet as the user has to somehow manually
write the secret e.g. on a paper to then enter it again in their 2fa
app. This makes the secret string copyable by clicking on it.
2026-03-24 14:50:42 +01:00
ThomasV b19820dc9d adb.get_spender: subscribe to outputs explicitly, instead of as a side effect
This allows to subscribe only if we need it (for channel closing tx and htlcs)
2026-03-19 14:41:31 +01:00
f321x f56e6318e3 swaps: make SwapManager.percentage Decimal
If SwapManager.percentage was a 0.2 float, rounding differences would
cause an exception in the fee calculation inverse sanity check when entering 20
000 sats into the SwapDialog. By making self.percentage a decimal we can
prevent this kind of issue.

```
File "/home/user/code/vibecoding_vm/electrum/electrum/gui/qt/swap_dialog.py", line 294, in on_send_edited
    recv_amount = self.swap_manager.get_recv_amount(send_amount, is_reverse=self.is_reverse)
  File "/home/user/code/vibecoding_vm/electrum/electrum/submarine_swaps.py", line 1320, in get_recv_amount
    if abs(send_amount - inverted_send_amount) > 1:
           ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for -: 'int' and 'NoneType'
```
2026-03-19 09:17:34 +01:00
f321x 022a1bf0e7 swapserver: cli: skip pending swaps in history commands
skip pending swaps in the swapserver history/summary cli commands.
They are not relevant and don't contain all required informations yet.

Fixes https://github.com/spesmilo/electrum/issues/10521
Fixes https://github.com/spesmilo/electrum/issues/10525

```
 File "/home/electrum/electrum-fork/electrum/daemon.py", line 268, in handle
   response['result'] = await f(*params)
                        ^^^^^^^^^^^^^^^^
 File "/home/electrum/electrum-fork/electrum/daemon.py", line 381, in run_cmdline
   result = await func(*args, **kwargs)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/home/electrum/electrum-fork/electrum/commands.py", line 207, in func_wrapper
 File "/home/electrum/electrum-fork/electrum/commands.py", line 2349, in func_wrapper
   group = parser.add_argument_group('network options')
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/home/electrum/electrum-fork/electrum/plugins/swapserver/__init__.py", line 79, in get_summary
   swap_history = await get_history(self)
                  ^^^^^^^^^^^^^^^^^^^^^^^
 File "/home/electrum/electrum-fork/electrum/commands.py", line 207, in func_wrapper
 File "/home/electrum/electrum-fork/electrum/commands.py", line 2349, in func_wrapper
   group = parser.add_argument_group('network options')
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/home/electrum/electrum-fork/electrum/plugins/swapserver/__init__.py", line 60, in get_history
   'date': swap['date'].strftime("%Y-%m-%d"),
           ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'strftime'
```
2026-03-16 14:53:26 +01:00
SomberNight c2f3729424 plugins: timelock_recovery: move checksum func to base class
don't import qt from tests unless it is qt being tested
2026-03-16 00:41:33 +00:00
Oren 2f3f397a70 Fix checksum following BIP-128 standard
Non-Ascii characters should not be converted for
checksum calculation.
This will give consistent hash to BIP-128 and its
Javascript code example.

Timelock-Recovery Plans that contained only ascii
characters are not affected.

Also, 8 hex-chars is enough for a checksum.
2026-03-15 10:56:14 +02:00
f321x f64923b472 plugin: nwc: lookup_invoice: fix exc, include b11
Fixes exception in lookup_invoice:
```
 62.69 | E | plugins.nwc.nwcserver.NWCServer | Error handling nwc request
Traceback (most recent call last):
  File "/home/user/code/vibecoding_vm/electrum/electrum/plugins/nwc/nwcserver.py", line 381, in run_request_task
    await task
  File "/home/user/code/vibecoding_vm/electrum/electrum/util.py", line 1211, in wrapper
    return await func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/code/vibecoding_vm/electrum/electrum/plugins/nwc/nwcserver.py", line 526, in handle_lookup_invoice
    info = self.wallet.lnworker.get_payment_info(invoice.payment_hash, direction=RECEIVED)
                                                 ^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Invoice' object has no attribute 'payment_hash'
```

Always includes bolt11 invoice in response, even if the client already
sent it to us in the request. It doesn't seem useful and is marked
optional in the spec but https://sandbox.albylabs.com considers the
response invalid if the invoice is not included.
2026-03-06 14:42:42 +01:00
f321x f53203d171 plugin: nwc: consider inflight htlcs in get_payment_info
Also consider htlcs that are still inflight when calculating
the amount/fee of a payment to prevent calculating an incorrect
payment value/fee when calling get_payment_info directly after
a payment succeeds (one htlc settled, but others could still be
inflight).
This assumes that once a payments htlc got settled all other inflight
htlcs will also get settled.
2026-03-06 12:09:07 +01:00
f321x 9b4d4d61bb plugin: nwc: add update timer to connection list 2026-03-06 12:09:05 +01:00
f321x 8ccdc3f7af plugin: nwc: consider routing fees for payment budget
Include the lightning routing fees into the payment budget accounting
to prevent untrusted nwc clients from exceeding the budget by crafting
a high fee route.
2026-03-06 12:09:03 +01:00
f321x 8dddb5d538 plugin: nwc: unify budget_allows_spend and add_to_budget
There is now only add_to_budget which will return None if the budget
doesn't allow for this spend. It will always add the spend to the
budget, even if the user has no budget so it can be used for display
purposes (and simpler code, only one path).
2026-03-06 12:08:58 +01:00
f321x 835ab39d77 plugin: nwc: bump version to 0.0.2
these changes deserve a new version
2026-03-03 18:04:54 +01:00
f321x ea1e2c8240 plugin: nwc: add 'state' field to responses
NIP-47 got extended to include an optional 'state' field in responses.
Implementing this acutally fixes an issue of Alby Go showing succeeded
payments as failed that appeared recently.
2026-03-03 18:04:52 +01:00
f321x 5222374046 plugin: nwc: improved budget accounting
Increase the payment budget before attempting the payment
and decrease again if the payment fails. This prevents a race
where multiple concurrent payments could pass the budget check
before the budget is incremented through any of the other payments.

A lock around the budget is not suitable either as then one long
stuck payment (hold invoice) would render the budget inaccessible for
all other payment attempts.
2026-03-03 18:04:51 +01:00
f321x 3956bff068 plugin: nwc: do budget accounting in msat
Keep track of the spent amount in msat instead of sat to prevent
issues due to rounding.
The budget is still specified in sat.
2026-03-03 18:04:47 +01:00
f321x 0dc08fdf24 plugin: nwc: handle encryption scheme signaling
NIP-47 now defines how client/server should communicate their supported
encryption schemes. For backwards compatibility its not strictly
neccessary to implement this but it seems cleaner to explicitly handle
it.
2026-03-03 11:27:09 +01:00
f321x 4c703ea278 plugin: nwc: remove multi_pay_invoice rpc
It got removed from the spec so we don't need to support it anymore.
https://github.com/nostr-protocol/nips/pull/2210
2026-03-03 11:22:07 +01:00
f321x 4556d59fc0 plugin: nwc: qt: fix thread safety bug
Call `NWCServer.event_handler_task.cancel()` on asyncio thread.

```
 File "/home/user/Documents/electrum/electrum/plugins/nwc/nwcserver.py", line 281, in restart_event_handler
   self.event_handler_task.cancel()
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
 File "/usr/lib64/python3.14/asyncio/base_events.py", line 829, in call_soon
   self._check_thread()
   ~~~~~~~~~~~~~~~~~~^^
 File "/usr/lib64/python3.14/asyncio/base_events.py", line 866, in _check_thread
   raise RuntimeError(
       "Non-thread-safe operation invoked on an event loop other "
       "than the current one")
RuntimeError: Non-thread-safe operation invoked on an event loop other than the current one
```
2026-02-16 09:28:16 +01:00
SomberNight 0c33994d70 plugins: hardware: HardwareHandlerBase.show_error() takes str, not exc
This is just a minor conceptual clean-up,
runtime behaviour is not being changed, as ultimately, much later in the exec flow,
the msg object being passed around is cast to str already.
(e.g. see str(text) at https://github.com/spesmilo/electrum/blob/4f7b6e897710338e8a4cfb8fa97c305218bdff88/electrum/gui/qt/util.py#L375-L379)
2026-02-12 17:04:20 +00:00
ghost43 6083808191 Merge pull request #10461 from romanz/ts5
Support TS5 in `TrezorClientBase.device_model_name()`
2026-02-04 02:26:26 +00:00
Roman Zeyde 38a0acffb4 Support TS5 in TrezorClientBase.device_model_name() 2026-02-03 21:37:29 +01:00
Ben Gridley 2c058c97eb add support for Nano Gen5 2026-02-01 16:35:04 -07:00
ThomasV 0c29c5006e Merge pull request #10394 from f321x/cosigner_wallet_event_listener
bugfixes: set psbt_nostr event on aio loop and use correct cb in TxEditor
2026-01-13 13:45:06 +01:00
SomberNight 2172dadf62 hw plugins: coldcard: fix compat with ckcc-protocol v1.5.0
fixes https://github.com/spesmilo/electrum/issues/10386
2026-01-05 16:28:23 +00:00
SomberNight f1f4fc0939 hw plugins: coldcard: log error when I forget to set udev rules
so that next time I check that before changing cables, usb hubs, and VMs o.O
2026-01-05 16:06:24 +00:00
f321x e033a5e67b psbt_nostr: add EventListener comment to CosignerWallet
I got confused how on_event_proxy_set can even work if CosignerWallet
doesn't inherit from EventListener until i figured out its children use
the EventListener too. To avoid this confusion i added two comments.
2026-01-05 16:36:05 +01:00
f321x 0d380218a6 bug: psbt_nostr: set CosignerWallet.pending on aio loop
Fixes:
```
Traceback (most recent call last):
  File "/home/user/code/electrum-fork/electrum/plugins/psbt_nostr/qt.py", line 149, in on_receive
    self.mark_pending_event_rcvd(event_id)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/home/user/code/electrum-fork/electrum/plugins/psbt_nostr/psbt_nostr.py", line 254, in mark_pending_event_rcvd
    self.pending.set()
    ~~~~~~~~~~~~~~~~^^
  File "/usr/lib64/python3.14/asyncio/locks.py", line 192, in set
    fut.set_result(True)
    ~~~~~~~~~~~~~~^^^^^^
  File "/usr/lib64/python3.14/asyncio/base_events.py", line 829, in call_soon
    self._check_thread()
    ~~~~~~~~~~~~~~~~~~^^
  File "/usr/lib64/python3.14/asyncio/base_events.py", line 866, in _check_thread
    raise RuntimeError(
        "Non-thread-safe operation invoked on an event loop other "
        "than the current one")
RuntimeError: Non-thread-safe operation invoked on an event loop other than the current one
```
2026-01-05 16:02:14 +01:00
f321x 095debcded plugin: timelock recovery: more i18n 2025-12-15 11:52:57 +01:00
ghost43 0b886cf7a8 Merge pull request #10272 from accumulator/timelock_recovery_destination_validation
timelock_recovery: recovery destination checks for address is_mine or script output
2025-12-11 19:08:09 +00:00
f321x aa47a960a7 ledger: throw UserFacingException for OSError
Throws UserFacingException if the communication with the ledger fails
due to an OSError. This happens e.g. if the Bitcoin app has been closed.
We shouldn't get crash reports for errors due to disconnection.
2025-12-10 16:48:17 +01:00
ghost43 f8fc2b63e3 Merge pull request #10271 from f321x/fix_save_payment_info
lightning: fix self payments (e.g. rebalance)
2025-12-05 17:19:39 +00:00
SomberNight 75ac8bcee1 plugins: nwc: don't mutate aionostr Event
I want to change the Event class to be immutable.
2025-12-04 00:47:32 +00:00
f321x 923d48f9db lnworker: differentiate PaymentInfo by direction
Allows storing two different payment info of the same payment hash by
including the direction into the db key.
We create and store PaymentInfo for sending attempts and for requests (receiving),
if we try to pay ourself (e.g. through a channel rebalance) the checks
in `save_payment_info` would prevent this and throw an exception.
By storing the PaymentInfos of outgoing and incoming payments separately in
the db this collision is avoided and it makes it easier to reason about
which PaymentInfo belongs where.
2025-12-01 18:39:56 +01:00
Sander van Grieken 0f2a41e078 simple_config: factor out self.decimal_point and self.get_decimal_point() in favor of self.BTC_AMOUNTS_DECIMAL_POINT 2025-11-27 12:38:49 +01:00
ThomasV 9f50d2a61d Merge pull request #10276 from f321x/2fa_conf_qt
trustedcoin: qt: set higher minimumHeight for QR component
2025-11-27 10:39:42 +01:00
ThomasV d36b753cfe remove plugin payserver (moved to spesmilo/electrum-payserver) 2025-11-25 11:40:25 +01:00
ThomasV 9c4c7f01ac daemon: pass cmdname to register_method
This allows plugins to use already existing names without Electrum complaining about collisions
2025-11-04 12:42:54 +01:00
f321x f402cb3cd1 plugin: watchtower: call start_watching() threadsafe
Launch `WatchtowerPlugin.watchtower.start_watching()` through
asyncio.run_coroutine_threadsafe instead of ensure_future to prevent the
following exception from happening when running python with
`PYTHONASYNCIODEBUG=1`.

```

20251103T165007.087746Z |    ERROR | plugin.Plugins | cannot initialize plugin watchtower: Error loading watchtower plugin: RuntimeError('Non-thread-safe operation invoked on an event loop other than the current one')
Traceback (most recent call last):
  File "/home/user/code/electrum-fork/electrum/plugin.py", line 629, in load_plugin_by_name
    plugin = module.Plugin(self, self.config, name)
  File "/home/user/code/electrum-fork/electrum/plugins/watchtower/watchtower.py", line 59, in __init__
    asyncio.ensure_future(self.watchtower.start_watching())
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.14/asyncio/tasks.py", line 732, in ensure_future
    return loop.create_task(coro_or_future)
           ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.14/asyncio/base_events.py", line 468, in create_task
    return self._task_factory(self, coro, **kwargs)
           ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/code/electrum-fork/electrum/util.py", line 1773, in factory
    task = asyncio.Task(coro, loop=loop_, **kwargs)
  File "/usr/lib64/python3.14/asyncio/base_events.py", line 829, in call_soon
    self._check_thread()
    ~~~~~~~~~~~~~~~~~~^^
  File "/usr/lib64/python3.14/asyncio/base_events.py", line 866, in _check_thread
    raise RuntimeError(
        "Non-thread-safe operation invoked on an event loop other "
        "than the current one")
RuntimeError: Non-thread-safe operation invoked on an event loop other than the current one

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/user/code/electrum-fork/electrum/plugin.py", line 184, in load_plugins
    self.load_plugin_by_name(name)
    ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/home/user/code/electrum-fork/electrum/plugin.py", line 631, in load_plugin_by_name
    raise Exception(f"Error loading {name} plugin: {repr(e)}") from e
Exception: Error loading watchtower plugin: RuntimeError('Non-thread-safe operation invoked on an event loop other than the current one')

```
2025-11-03 17:54:48 +01:00
f321x d954ddf0bd trustedcoin: qt: set higher minimumHeight for QR component
The default minimumHeight for wizard components is a bit small for the
2fa confirmation component as it only shows the QR code but not the
input field. This seems to confuse users as its not intuitive to scroll
down if there is no large text shown (as for example in the ToS component).
This change increases the minimumHeight and restores it to the previous
height once the user leaves the component again.
2025-10-22 14:12:15 +02:00
Sander van Grieken dc417a4f99 timelock_recovery: recovery destination checks for address is_mine or script output
note: validation in frontend should be added to backend code as well
2025-10-20 15:27:38 +02:00
f321x 286fc4b86e lnworker: enforce creation of PaymentInfo for b11
Enforce that the information used to create a bolt11 invoice using
`get_bolt11_invoice()` is similar to the related instance of PaymentInfo
by requiring a PaymentInfo as argument for `get_bolt11_invoice()`.
This way the invoice cannot differ from the created PaymentInfo.
This allows to use the information in PaymentInfo for validation of
incoming htlcs more reliably.

To cover all required information for the creation of a b11 invoice the
PaymentInfo class has to be extended with a expiry and
min_final_cltv_expiry. This requires a db upgrade.
2025-09-30 09:54:35 +02:00
SomberNight b944371ffd adb: change API of util.TxMinedInfo: height() is now always SPV-ed 2025-09-24 13:46:24 +00:00
f321x 708aefb036 swapserver: add commands for stats
Adds two command to the swapserver plugin to retrieve some stats so swap
providers can see more easily what is going on on their swapserver.
2025-09-05 15:39:51 +02:00
f321x 5f0180910c qml: add padding to ElDialog for android e2e 2025-08-27 15:17:16 +02:00