Commit Graph

373 Commits

Author SHA1 Message Date
ThomasV
d3476b6ba0 fix deadlock: self.lock should be taken before self.transaction_lock
(self.lock is taken in self.get_tx.height)
2022-03-23 19:27:49 +01:00
SomberNight
5149ee02a5 wallet: fix delete_address removing too many transactions
See testcase:
- imported wallet with addr1 and addr2
- three txs: tx1 funds addr1, tx2 funds addr2, tx3 spends all
- if we rm addr1 from the wallet,
  - previously both tx1 and tx3 was removed (as tx3 is a child of tx1)
  - now only tx1 is removed (tx3 still relates to the wallet via addr2)

fixes https://github.com/spesmilo/electrum/issues/7587
2022-03-21 19:30:08 +01:00
SomberNight
d154e368f1 wallet: fix clear_requests and clear_invoices
these are StoredDicts, subdicts in wallet_db.data, so reassigning the name does not work
2022-03-16 12:51:03 +01:00
SomberNight
376fc01b27 keystore.sign_message: add optional script_type argument
this is used by trezor
(and also by bitbox02, which was using a workaround previously)

fixes https://github.com/spesmilo/electrum/issues/7670
2022-02-22 19:20:03 +01:00
sgmoore
a84eab964c Minor grammar fixes
Minor grammar fixes at lines 1403 and 1467.
2022-02-16 07:07:43 -08:00
SomberNight
c9c094cfab requirements: bump min aiorpcx to 0.22.0
aiorpcx 0.20 changed the behaviour/API of TaskGroups.
When used as a context manager, TaskGroups no longer propagate
exceptions raised by their tasks. Instead, the calling code has
to explicitly check the results of tasks and decide whether to re-raise
any exceptions.
This is a significant change, and so this commit introduces "OldTaskGroup",
which should behave as the TaskGroup class of old aiorpcx. All existing
usages of TaskGroup are replaced with OldTaskGroup.

closes https://github.com/spesmilo/electrum/issues/7446
2022-02-15 18:22:44 +01:00
ThomasV
baff4fa625 save_backup: do not remove deterministic LN key (see #7513) 2021-09-26 12:18:25 +02:00
SomberNight
0b05edc705 wallet payreqs: trivial clean-up 2021-09-19 17:25:57 +02:00
SomberNight
acbb363240 follow-up prev: some clean-ups
re https://github.com/spesmilo/electrum/pull/7492
2021-09-15 16:41:41 +02:00
Siddhant Chawla
65c3a892cf Multiple max spends functionality added (#7492)
this implements https://github.com/spesmilo/electrum/issues/7054
2021-09-15 14:35:15 +00:00
SomberNight
d94d443082 wallet: fire "request_status" event also when conf number changes 2021-07-11 16:57:01 +02:00
SomberNight
6a049d9901 wallet: make sure payment requests are persisted
Fixes: after adding a payment request, if the process was killed,
the payreq might get lost. In case of using the GUI, neither the
callee nor the caller called wallet.save_db().

Unclear where wallet.save_db() should be called...
Now each method tries to persist their changes by default,
but as an optimisation, the caller can pass write_to_disk=False
e.g. when calling multiple such methods and then call wallet.save_db() itself.

If we had partial writes, which would either rm the need for wallet.save_db()
or at least make it cheaper, this code might get simpler...

related: https://github.com/spesmilo/electrum/pull/6435
related: https://github.com/spesmilo/electrum/issues/4823
2021-07-05 18:39:10 +02:00
SomberNight
fbd8c5f7b0 imported wallets: respect "use_change" option; default off
Imported wallets used to send change back to the "from address".
We keep this behaviour as default.

There has already been an option "Use change addresses" (exposed in GUI),
ignored so far by imported wallets (was only used by HD wallets).
With this change, imported wallets no longer ignore that option, and if set,
they will send change to a random unused imported address, instead of back to "from address".
If all addresses are used, it falls back to sending change back to the "from address".

see: https://github.com/spesmilo/electrum/pull/7330
see: https://github.com/spesmilo/electrum/issues/5353
2021-06-11 20:12:43 +02:00
SomberNight
8941ba90bd (trivial) wallet: rename parameter of a method
Re get_change_addresses_for_new_transaction,
"allow_reuse" is a confusing parameter name:
it means whether we allow reusing already used change addresses to send new change to.
However, if the method returns [], we will instead reuse the "from address" and send change there.
So it quite unclear without thinking it through what "allow_reuse" means as it could be either
of the two (and they are ~opposite scenarios).
The new name is long but at least it is clear.
2021-06-11 18:23:25 +02:00
ThomasV
0f4f5e5fb7 Merge pull request #7341 from SomberNight/202106_issue7339
wallet: fix channels backups in .backup files
2021-06-09 17:38:50 +02:00
SomberNight
53d6eeb3f3 wallet: rm get_txout_address method 2021-06-08 16:45:30 +02:00
SomberNight
34c2cb5220 wallet: fix channels backups in .backup files
This is a regression from 64a931f21e,
which introduced "onchain_channel_backups", and renamed
the old "channel_backups" key to "imported_channel_backups".

The `save_backup` method was not changed to use the new "imported_channel_backups" key,
so the channel backups are in the backup file but they are ignored.
2021-06-08 16:21:43 +02:00
SomberNight
7e6d65ec11 wallet: RBF batching to only consider RBF-opted-in txs, even if local
This is easier to understand; the special case is not worth it.

related https://github.com/spesmilo/electrum/issues/7298
2021-06-07 20:11:56 +02:00
SomberNight
6c69c73a9f wallet: add address corruption tests for imported wallets too
related: https://github.com/spesmilo/electrum/issues/7338
2021-06-07 18:30:24 +02:00
SomberNight
cad4e77853 fix prev 2021-05-15 06:57:59 +02:00
SomberNight
b2169b745e wallet: (fix) "batch_rbf" must not mutate LN funding txs
The "Batch RBF transactions" feature mutates existing "local" and "unconfirmed RBF"
transactions when creating new transactions: it simply adds the new outputs to the
existing txs (and updates the change).
The "RBF" flag is only enforced for unconfirmed txs, not for local txs.
The bug was that given a local LN funding tx, when creating a new channel
with "batch_rbf" enabled, we would modify the existing local tx, and
broadcast that.

related: #7298
2021-05-15 06:31:03 +02:00
SomberNight
67c6f0e1bd wallet: make sure we don't create zero input txs
fixes #7207
2021-04-14 19:08:04 +02:00
ThomasV
73482bb335 fix #7160 2021-04-02 15:07:08 +02:00
SomberNight
92226b077a qt tx dialog: handle fiat fee for zero-fee tx
fix #7166
2021-04-01 17:02:34 +02:00
ThomasV
bf6ecb6418 make init_lightning callable at runtime, without reloading the wallet 2021-03-31 10:57:36 +02:00
SomberNight
537ec92460 wallet: change init_lightning to sometimes create deterministic LN keys 2021-03-30 21:53:18 +02:00
SomberNight
35bc461fe1 keystore: encapsulate "can_have_deterministic_lightning_xprv" logic 2021-03-30 21:31:37 +02:00
ThomasV
bbdfde5b41 fix capital gains 2021-03-30 17:32:43 +02:00
ThomasV
3fc85725aa Merge pull request #7135 from SomberNight/202103_get_utxos_at_height
wallet: implement get_utxos at specific block height
2021-03-29 11:03:11 +02:00
ThomasV
e93becf33a wallet.add_transaction: prevent channel backup from being added twice 2021-03-27 14:29:10 +01:00
ThomasV
f14b7d5a12 check_password_for_directory: safeguards 2021-03-25 16:12:24 +01:00
SomberNight
c2c3ece455 wallet: implement get_utxos at specific block height
This allows looking up what UTXOs the wallet had at a specific time in the past.
2021-03-24 19:37:37 +01:00
ThomasV
cd6a468fb9 Android: unify password as soon as we know it is possible 2021-03-23 17:49:27 +01:00
ThomasV
2fee920f43 On Android, if channels are not recoverable, display channel backup when a new channel is created.
Remove the 'android_backups' setting, which was unpractical.
2021-03-19 13:17:58 +01:00
ThomasV
64a931f21e Deterministic NodeID:
- use_recoverable_channel is a user setting, available
   only in standard wallets with a 'segwit' seed_type
 - if enabled, 'lightning_xprv' is derived from seed
 - otherwise, wallets use the existing 'lightning_privkey2'

Recoverable channels:
 - channel recovery data is added funding tx using an OP_RETURN
 - recovery data = 4 magic bytes + node id[0:16]
 - recovery data is chacha20 encrypted using funding_address as nonce.
   (this will allow to fund multiple channels in the same tx)

GUI:
  - whether channels are recoverable is shown in wallet info dialog.
  - if the wallet can have recoverable channels but has an old node_id,
    users are told to close their channels and restore from seed
    to have that feature.
2021-03-19 10:17:02 +01:00
ThomasV
3ed2173a04 remove newlines in get_tx_fee_warning, it does not render well on kivy 2021-03-15 09:26:16 +01:00
ThomasV
2ad49bbc5b Kivy: Show fee dialog before opening a new channel.
Remove fee and rbf from settings, as they are now always proposed
2021-03-13 09:34:19 +01:00
ThomasV
018f09f2af use mktx_for_open_channel in commands module. fix indentation 2021-03-12 19:05:25 +01:00
SomberNight
897f90d6e8 wallet: factor out "what key to use for invoice"
fix: qt request list was not using the correct key
2021-03-12 17:29:54 +01:00
ThomasV
90b228de83 fix wallet get_full_history: add onchain tx for channels not opened by us 2021-03-12 12:15:39 +01:00
SomberNight
de6f5a8e03 {daemon,wallet}|.stop: small clean-up 2021-03-10 18:07:15 +01:00
SomberNight
8de52bf523 wallet: (trivial) use kwargs for get_tx_item_fiat 2021-03-09 18:22:30 +01:00
SomberNight
3c019c2f9c daemon/wallet/network: make stop() methods async 2021-03-09 17:52:36 +01:00
ThomasV
652d10aa5f Remove LNBackups object: no longer needed since LNWorker is instantiated by default. 2021-03-09 11:52:04 +01:00
SomberNight
e25602ab3b wallet: don't put partial tx as UTXO into psbt
if there is a chain of unsigned txs, we cannot populate NON_WITNESS_UTXO

closes #7080
closes #7009
closes #6482
2021-03-04 13:20:49 +01:00
SomberNight
f9f49daad7 tx dialog: uniform high fee warnings between GUIs 2021-02-26 19:02:24 +01:00
SomberNight
058d9ab6bb wallet.bump_fee: add new strategy: decrease payment amounts
- Rename bump_fee "methods" to "strategies".
- Refactor strategies so that bump_fee can use any subset of them in any permutation.
- Adds a new strategy which decreases the payment outputs (instead of change).
2021-02-25 15:32:07 +01:00
SomberNight
d800f88bfc (trivial) wallet: fix over-indentation 2021-02-24 19:01:02 +01:00
Marius Baisan
55fdddb0b8 Add back the 'to_height' and 'from_height' to onchain_history command
Exclude unconfirmed transactions from --to_height and include them into --from_height.
The reason being that an unconfirmed transaction will end up eventually into the last
block which most of the time will be higher than --from_height
2021-02-19 13:12:09 +01:00
SomberNight
1dea8393d7 wallet: follow-up b080df9cff 2021-02-16 22:28:11 +01:00