Commit Graph

677 Commits

Author SHA1 Message Date
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
f321x
e80551192b plugins: structure plugin storage in wallet
store all plugin data by plugin name in a root dictionary `plugin_data`
inside the wallet db so that plugin data can get deleted again.
Prunes the data of plugins from the wallet db on wallet stop if the
plugin is not installed anymore.
2025-05-06 13:16:49 +02:00
ThomasV
07ba0e6329 Qt: do not require password in memory
- do not require full encryption
 - do not store password on startup
 - add lock/unlock functions to qt GUI
2025-05-06 13:04:18 +02:00
Sander van Grieken
ae906fb17c wallet: imports, whitespace, typing hints 2025-04-24 10:09:48 +02:00
ThomasV
5bea2c6f6c TxBatcher: detect if base tx has been replaced.
Alow user to bump fee of txbatcher transaction from GUI
2025-04-22 14:12:05 +02:00
f321x
253ab6849a implement NIP47 plugin 2025-04-10 10:22:29 +02:00
Sander van Grieken
d28899c572 wallet,gui: improve not_enough_funds_mentioning_frozen 2025-04-09 09:32:21 +02:00
f321x
8d84008f5b disable output value rounding for 0 fee tx and remove relay fee warning from gui 2025-04-07 11:52:43 +02:00
f321x
6e8bdb346a move onchain balance calculation to wallet.py 2025-04-04 15:08:51 +02:00
ThomasV
b339b1e7e3 ln_utxo_reserve
When we send max, decrease sent amount in order to keep some
reserve utxo, in order to be able to sweep lightning channels.
2025-04-03 14:39:05 +02:00
ThomasV
1aa066ea19 wallet.py: rm unused imports 2025-03-22 13:54:29 +01:00
ThomasV
45b5bdca48 wallet: can_sign should return False for a swap claim tx, because it is handled by txbatcher 2025-03-21 16:31:11 +01:00
ThomasV
3463e68306 add accounting addresses 2025-03-17 10:47:19 +01:00
ThomasV
58be5a3ad5 Allow wallets to use non-deterministic lightning,
if they use a software keystore.

This excludes hardware wallets and watching-only wallet.
Also, this forbids creation of new channels in those wallets,
in case lightning was previously enabled.

Fixes #9440
2025-03-17 09:51:52 +01:00
ThomasV
f8714dd57a fix #9635 2025-03-16 17:01:07 +01:00
ThomasV
81d4e90f66 Merge branch 'master' into 140325-force-close-exception 2025-03-14 19:38:13 +01:00
SomberNight
977d8b1dd6 wallet: kill create_transaction 2025-03-14 17:19:41 +00:00
f321x
5edbf923cd fix sweeping anchor outputs with multiple change addresses option enabled, don't consider tx inputs sufficient value if there are no outputs so change outpu gets added 2025-03-14 18:15:04 +01:00
SomberNight
4689a0e78c wallet: towards killing create_transaction: rm "coins" logic 2025-03-14 17:14:59 +00:00
SomberNight
cab1dc5c29 wallet: towards killing create_transaction: pass through "locktime", "version" 2025-03-14 17:03:49 +00:00
SomberNight
3c3778db9c wallet: towards killing create_transaction: rm "sign" arg 2025-03-14 16:44:46 +00:00
ghost43
e62a2c43c5 Merge pull request #9634 from SomberNight/202503_is_frozen_futuretx
wallet: consider "future" coins as frozen by default
2025-03-14 14:26:07 +00:00
ThomasV
39224f003d Merge pull request #9636 from SomberNight/202503_avoid_reuse
wallet: add new config option "FREEZE_REUSED_ADDRESS_UTXOS"
2025-03-14 12:56:29 +01:00
ThomasV
3adfe9a8de Merge pull request #9598 from f321x/jit-gui-improvements
Handle zeroconf lightning requests in QT gui
2025-03-14 08:34:00 +01:00
SomberNight
d52762a2e8 wallet: add new config option "FREEZE_REUSED_ADDRESS_UTXOS"
Adds a new config option: `WALLET_FREEZE_REUSED_ADDRESS_UTXOS`.
This is based on Bitcoin Core's "avoid_reuse" wallet flag. [0]

This opt-in feature, if enabled:
> Automatically freeze coins received to already used addresses.
> This can eliminate a serious privacy issue where a malicious user can track your spends by sending small payments
> to a previously-paid address of yours that would then be included with unrelated inputs in your future payments.

Note that currently we only have a single coinchooser policy, `CoinChooserPrivacy`,
which interacts well with this option, as it spends all coins from any selected address.
However, if we later add a different coinchooser policy, which allowed "partial spends",
care should be taken re e.g. disallowing using that when this option is set.

Also note that this PR adds this as a config option, but arguably it could be wallet-specific instead,
such as `use_change`.

[0]: https://github.com/bitcoin/bitcoin/blob/master/doc/release-notes/release-notes-0.19.0.1.md#wallet

closes https://github.com/spesmilo/electrum/issues/7497
2025-03-14 00:47:42 +00:00
SomberNight
eea1eb5eb0 wallet: consider "future" coins as frozen by default 2025-03-14 00:09:04 +00:00
SomberNight
3ff794da12 wallet: (trivial) refactor is_frozen_coin 2025-03-14 00:07:26 +00:00
SomberNight
8ccd31fe49 wallet: set_frozen_state_of_coins to handle freeze=None
Internally whether a coin is frozen is tri-state:
- forced-True, set by the user
- forced-False, set by the user
- unset/default: is_frozen_coin() can decide whether the coin should be frozen

This patch lets set_frozen_state_of_coins() undo a previous explicit setting of True/False,
by calling it with a value of None.
Note: there is still no way in the GUI to undo an explicit setting of True/False.
2025-03-13 18:32:58 +00:00
f321x
5134d07b14 add zeroconf handling to qt gui 2025-03-13 11:49:50 +01:00
ThomasV
bdb7a82220 batch payment manager:
The class TxBatcher handles the creation, broadcast and replacement
of replaceable transactions. Callers (LNWatcher, SwapManager) use
methods add_payment_output and add_sweep_info. Transactions
created by TxBatcher may combine sweeps and outgoing payments.

Transactions created by TxBatcher will have their fee bumped
automatically (this was only the case for sweeps before).

TxBatcher manages several TxBatches. TxBatches are created
dynamically when needed.

The GUI does not touch txbatcher transactions:
  - wallet.get_candidates_for_batching excludes txbatcher
    transactions
  - RBF dialogs do not work with txbatcher transactions

wallet:
  - instead of reading config variables, make_unsigned_transaction
    takes new parameters: base_tx, send_change_to_lighting

tests:
  - unit tests in test_txbatcher.py (replaces test_sswaps.py)
  - force all regtests to use MPP, so that we sweep transactions
    with several HTLCs. This forces the payment manager to aggregate
    first-stage HTLC tx inputs. second-stage are not batched for now.
2025-03-13 10:17:10 +01:00
SomberNight
3f327eea07 wallet: fix wallet.make_unsigned_transaction method signature
- "fee_policy" arg is actually mandatory
- and fix test/stdio guis following fee_policy/config split

follow-up 840243e029
2025-03-11 16:15:17 +00:00
ThomasV
764cc78386 Merge pull request #9590 from f321x/jit-update-unfunded-state
Handle unfunded zeroconf channels in update_unfunded_state
2025-03-07 13:55:55 +01:00
f321x
6fd833ccfb add handling of zeroconf channels to update_unfunded_state 2025-03-07 13:53:01 +01:00
ThomasV
d5ee678b7f if a network object is there but fee estimates are not available,
raise NoDynamicFeeEstimates in FeePolicy rather than in wallet.

Also, show an error message in Qt
2025-03-06 13:13:01 +01:00