Commit Graph

710 Commits

Author SHA1 Message Date
ghost43
89734b3bd4 Merge pull request #10242 from f321x/return_preimage_cli
cli: add command to export preimage, return preimage from check_hold_invoice
2025-10-09 15:31:04 +00:00
SomberNight
58676219f4 wallet: (trivial) mark calc_unused_change_addresses as private 2025-10-07 17:45:38 +00:00
f321x
b57f867c2f cli: add command to export preimage
..also export preimage in check_hold_invoice return value if available.

I intentionally did not return the preimage in the returned dict of
wallet.export_requests as this seems risky to do considering some users
of the cli might forward the response to a payer and the payserver
exposes it too.

Closes https://github.com/spesmilo/electrum/issues/10176
2025-09-30 10:37:20 +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
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
f321x
b6a4ebecda wallet: fix AttributeError when getting help text
Fixes AttributeError when trying to get `num_sats_can_receive()` in
wallets without lnworker. Fixes https://github.com/spesmilo/electrum/issues/8100#issuecomment-3294556043.

```
Traceback (most recent call last):
  File "/usr/lib/python3.13/site-packages/electrum/gui/qt/request_list.py", line 103, in selection_changed
    self.receive_tab.update_current_request()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/lib/python3.13/site-packages/electrum/gui/qt/receive_tab.py", line 237, in update_current_request
    help_texts = self.wallet.get_help_texts_for_receive_request(req)
  File "/usr/lib/python3.13/site-packages/electrum/wallet.py", line 3446, in get_help_texts_for_receive_request
    can_receive = self.lnworker.num_sats_can_receive()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'num_sats_can_receive'
```
2025-09-16 09:38:01 +02:00
SomberNight
47f1a2d7a2 wallet.get_full_history: rm "include_fiat" arg, infer it from fx
ref https://github.com/spesmilo/electrum/pull/10209#discussion_r2334228490
2025-09-09 17:24:59 +00:00
ghost43
df45233c2f Merge pull request #10209 from f321x/fix_fiat_history_export
qt: add missing fiat values in csv/json history export
2025-09-09 16:56:21 +00:00
ghost43
b4a6de46f4 Merge pull request #10188 from f321x/capacity_warning_zero_amount
qt: receive dialog: also propose swaps for 0 amount invoices
2025-09-09 16:16:23 +00:00
f321x
c438f1dfe7 wallet history: also add fiat value to child tx
Makes `get_full_history` also add the fiat values to the children of a
tx, not only to the group itself.
2025-09-08 09:54:01 +02: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
75195b667a keystore: get_private_keys should not return None
closes https://github.com/spesmilo/electrum/issues/10200
2025-09-05 16:10:33 +00:00
f321x
a62dbb5650 qt: receive tab: also suggest swap for 0 amnt req
Also suggest a submarine swap if the user creates a 0 amount invoice and
has 0 sat incoming liquidity as it won't be possible to receive
anything.
Users potentially just open a channel, then want to create a lightning invoice
without amount like they are used to from onchain addresses, and then
wonder why receiving doesn't work. So we should at least propose a swap
if there is no inbound liquidity at all.
2025-09-01 11:41:02 +02:00
SomberNight
8d8d1dba0f util.format_satoshis: floating-point paranoia 2025-08-22 13:30:26 +00:00
SomberNight
74d2c6386a wallet: sweep_preparations to raise UserFacingException on p2sh/etc
closes https://github.com/spesmilo/electrum/issues/10145
2025-08-18 17:02:34 +00:00
SomberNight
392400295e wallet.get_tx_fee_warning: fix rounding error for sub-1 sat/vbyte fees
```
>>> Decimal("0.1") < 100/1000
True
```

ref https://bitcointalk.org/index.php?topic=5554840.msg65694417#msg65694417
2025-08-15 18:26:19 +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
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
SomberNight
0fea61ac3a tests: wizard: KeystoreWizard: also test disable_keystore() 2025-08-14 17:06:52 +00:00
SomberNight
e3d1c6aefd wallet: enable/disable_keystore: trivial clean-up 2025-08-14 16:16:31 +00: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
SomberNight
4800a2d9c6 wallet: follow-up prev: always set wallet.gap_limit_for_change
even for Imported_Wallet
2025-08-08 16:36:32 +00:00
Filiprogrammer
3e8af98145 wallet: make gap limit for change configurable
Add the ability to configure the gap limit for change addresses while
retaining that value in the wallet database.

----

extracted from https://github.com/spesmilo/electrum/pull/8726

Co-authored-by: SomberNight <somber.night@protonmail.com>
2025-08-08 16:36:27 +00:00
SomberNight
302ee2444b wallet: refactor get_change_addresses_for_new_transaction 2025-08-08 15:30:33 +00:00
SomberNight
608980c050 wallet: more locking in delete_address
in particular, the "Cannot delete last remaining address from wallet" check should run
inside the lock

- tangentially related: https://github.com/spesmilo/electrum/issues/10104#issuecomment-3151165340
2025-08-04 15:14:10 +00:00
Sander van Grieken
1695948874 wallet: type hints 2025-08-04 13:44:05 +02:00
f321x
30b146033d gui: detect if reserve inputs have been removed from tx
Adapts the gui(s) to detect if an existing reserve input has not been
used as input for the transaction even though the user tried to spend
max. This allows to show the lightning reserve warning not only for
reserve change outputs but also for existing reserve inputs that have
been ignored for this max spend transaction.
Still keeps the `is_utxo_reserve` flag on `PartialTxOutput` as it is
used in the qml gui.
2025-07-29 15:40:51 +02:00
f321x
ead2c7c8de wallet: don't add reserve input if reserve utxo exists
Right now if a ln reserve is required and there is already a reserve
sized utxo available, `make_unsigned_transaction()` will still add the
reserve as input to a 'spend max' transaction and add a reserve change
output. This seems wasteful, this patch instead just removes the input
so it is not spent at all.
2025-07-29 15:35:55 +02:00
SomberNight
463e447439 wallet.can_have_lightning: more explicit impl
Watching-only wallets can have a keystore.
It was actually keystore.may_have_password() that was filtering them out but that was not really obvious.
Better to be explicit I think.
2025-07-18 11:49:50 +00:00
SomberNight
e658fa4e04 qml: QETxFinalizer: handle txid being None
fixes https://github.com/spesmilo/electrum/issues/10042
2025-07-18 01:11:19 +00:00
SomberNight
85fc95c71b wallet_db: add configvar for partial_writes, disable by default
Adds a new configvar `WALLET_PARTIAL_WRITES` to enable/disable partial writes for the walletDB.
This is a further restriction on top of the existing restrictions,
e.g. wallet files still need to have file encryption disabled for partial writes.
It defaults to off, so even for unencrypted wallets we disable partial writes for now.

This is used as a stopgap measure until we fix the issues found with the partial writes impl
(see https://github.com/spesmilo/electrum/issues/10000).
2025-07-15 14:03:48 +00:00
SomberNight
3c82b00c5e WalletDB() usage: trivial refactors and fixes
split off from https://github.com/spesmilo/electrum/pull/10027
2025-07-15 12:30:06 +00:00
SomberNight
ba670cc9dc wallet: add struct PiechartBalance 2025-06-29 22:25:56 +00:00
SomberNight
f846a16f07 plugins: psbt_nostr: add comment about testnet/mainnet separation 2025-06-10 15:01:24 +00:00
ThomasV
d3921ca25b fix lnwatcher callback (follow-up 5610a94537) 2025-06-06 17:18:09 +02:00
ThomasV
420cd1e5ed make wallet stop and restart-able 2025-06-05 19:12:47 +02:00
ThomasV
853b793bef rm verbosity_shortcuts option (unused, redundant) 2025-05-29 16:20:41 +02:00
ThomasV
b110179409 fix #9870 2025-05-28 10:42:59 +02:00
ThomasV
b0131c96f0 wallet.bump_fee: do not change nsequence of already existing inputs
Fixes tx rejection by network if the original tx has a csv:
> non-mandatory-script-verify-flag (Locktime requirement not satisfied)

Also add unit test
2025-05-26 14:52:37 +02:00
ThomasV
bd20d6e0af follow-up 51ced92f44 2025-05-24 17:34:00 +02:00
ThomasV
51ced92f44 Qt: let user enable/disable keystores with seed or hw wallet 2025-05-24 11:18:07 +02:00
ThomasV
45c35c0b00 allow password encryption in hardware wallets 2025-05-23 18:42:54 +02:00
SomberNight
3b37a920d6 adb/wallet: merge transaction_lock and lock
The distinction was no longer clear.
2025-05-21 18:43:33 +00:00
ThomasV
a66439eea5 CLI: add preimage to get_invoice
This should make regtest extract_preimage more reliable
2025-05-18 15:25:06 +02:00
SomberNight
f3551f3c25 commands: add cmd wait_for_sync 2025-05-15 19:42:34 +00:00
ThomasV
8c31ed648a simplify default label of tx 2025-05-12 13:46:27 +02:00
ThomasV
dfb7a8ab5a Merge pull request #9791 from f321x/structured_plugin_storage
plugins: structure plugin storage in wallet db and prune uninstalled plugins data
2025-05-06 13:18:29 +02:00