1
0
Commit Graph

142 Commits

Author SHA1 Message Date
SomberNight
22a8348303 renames: use consistent naming of cltv delta vs cltv abs
to avoid confusing relative vs absolute cltvs
(see b0401a6386)
2023-10-19 16:40:05 +00:00
ThomasV
68159b3ef6 walletDB: replace 'manual_upgrades' parameter with 'upgrade', with opposite semantics 2023-09-22 15:02:07 +02:00
ThomasV
b5bc5ff9ed Separate WalletDB from storage upgrades.
Make sure that WalletDB.data is always a StoredDict.
Perform db upgrades in a separate class, since they
operate on a dict object.
2023-09-22 15:02:06 +02:00
ThomasV
b96cc82333 Make storage a field of db
This comes from the jsonpatch_new branch.
I rather have in master now, because it touches a lot of filese.
2023-08-18 08:08:31 +02:00
SomberNight
a6c36b8588 regtests: test_watchtower started failing due to newly exposed bug
local_watchtower.adb.start_network was getting called twice.

follow-up 6ac3f84095

```
20230418T014725.636141Z |    ERROR | __main__ |
Traceback (most recent call last):
  File "/home/user/wspace/electrum/./run_electrum", line 435, in main
    handle_cmd(
  File "/home/user/wspace/electrum/./run_electrum", line 469, in handle_cmd
    d = daemon.Daemon(config, fd)
  File "/home/user/wspace/electrum/electrum/util.py", line 462, in <lambda>
    return lambda *args, **kw_args: do_profile(args, kw_args)
  File "/home/user/wspace/electrum/electrum/util.py", line 458, in do_profile
    o = func(*args, **kw_args)
  File "/home/user/wspace/electrum/electrum/daemon.py", line 404, in __init__
    self.network = Network(config, daemon=self)
  File "/home/user/wspace/electrum/electrum/network.py", line 348, in __init__
    self.local_watchtower.adb.start_network(self)
  File "/home/user/wspace/electrum/electrum/address_synchronizer.py", line 185, in start_network
    assert self.network is None, "already started"
AssertionError: already started
```
2023-04-18 02:02:07 +00:00
SomberNight
446879ade0 lnwatcher.maybe_redeem: wanted_height should always be absolute
previously, if prev_height.height was <= 0, lnwatcher was calling adb.set_future_tx()
with weird wanted_height values (with ~sweep_info.csv_delay)
2023-04-04 13:37:10 +00:00
SomberNight
1530668960 qt/qml: delay starting network until after first-start-network-setup
The qt, qml, and kivy GUIs have a first-start network-setup screen
that allows the user customising the network settings before creating a wallet.
Previously the daemon used to create the network and start it, before this screen,
before the GUI even starts. If the user changed network settings, those would
be set on the already running network, potentially including restarting the network.

Now it becomes the responsibility of the GUI to start the network, allowing this
first-start customisation to take place before starting the network at all.
The qt and the qml GUIs are adapted to make use of this. Kivy, and the other
prototype GUIs are not adapted and just start the network right away, as before.
2023-03-30 00:59:02 +00:00
SomberNight
62ab6d9702 (trivial) reduce log spam during ln-channel-open 2023-03-09 15:18:09 +00:00
SomberNight
373db76ac9 util: kill bh2u
no longer useful, and the name is so confusing...
2023-02-17 11:43:11 +00:00
ThomasV
abaa42eac0 make lnwatcher less spammy 2023-01-08 13:10:12 +01:00
SomberNight
757ec53ea2 AddressSynchronizer: set diagnostic_name for better logs
fixes regression from 121d8732f1

in particular, this is needed for Synchronizer.diagnostic_name and SPV.diagnostic_name
2022-08-24 11:05:01 +00:00
ThomasV
60c493dc15 adb: trigger adb_added_tx event only if the transaction is new 2022-08-17 10:40:43 +02:00
ThomasV
fceceaec97 lnwatcher: set future_tx regardless of tx_was_added, because it is not persisted 2022-08-12 12:26:18 +02:00
ThomasV
9058000791 lnwatcher: fix adding of local tx to history 2022-08-12 12:10:09 +02:00
ThomasV
a5965933d2 Fix CTNs in should_be_closed_due_to_expiring_htlcs (fixes #7906).
Also fix sending too many fee updates.
Rename lnworker.on_channel_update, that name was misleading.
2022-08-02 18:00:39 +02:00
ThomasV
cace1b5013 lnwatcher: compare txids instead of tx objects, before calling add_transaction or set_label 2022-07-29 09:22:14 +02:00
ThomasV
4a27e4e51a fix #7895: rename parameter 2022-07-20 20:31:26 +02:00
ThomasV
02e4569086 auto-remove redeemed channel backups. fix indentation. 2022-07-12 10:13:19 +02:00
SomberNight
b6b7b0a6c0 lnwatcher.inspect_tx_candidate: handle witness being None
```
E/W | lnwatcher.LNWalletWatcher.[test_segwit_2-LNW] | Exception in trigger_callbacks: AssertionError('witness is missing! txid=49f0fe532c07ec099ea3a9540a06141f529d28244c3a7be20f54843636cd7380. rawtx=cHNidP8BAFICAAAAAbliIHcoL1ZXwvRfBrjmhEJ63isM+wBBiCoZW231T2jhAAAAAAD9////AbMsQQAAAAAAFgAURC0BRfNFWqqD+jbsTaiX0/qjrE2v2iIAAAEA/S8BAgAAAAABAVbd14mCS0q4HjYGhWppSXvBvx9POsTYDSwXAIkxJF1iAAAAAAD/////ASEtQQAAAAAAFgAUh+Ku4dqhbNrjKjcK65dsZAWV+ocEAEcwRAIgcILGbxQK7wxiq1yBY6GxGBs4A32pBzC4PUSiMY0QuVMCIGtWnoRD/2zx4BshRYeHsg7wp9ClplQWxjsBJszXEcPfAUgwRQIhAPn0dsBeyqW4U0TbOgJMMEEuKwqBXfXHryHJvOxcwKafAiBRBBFpJvYxMtjkg7aABj1yUEwBaZuAqg1a8mlbHLKnBwFHUiECRc2elI2LEqEE31/G9tC6IA4yV09nKK6nSTez2vUlVikhAxbmJytLCOgHfz1vFqKrZMhERzVCJd0AaAkBWZqMKbe6Uq4AAAAAIgYDtG0jdrMO8FbxdAepULYg1Hu8fbq6hQ7Ki35K6/TViEQQ0uN52gAAAIABAAAAgQAAAAAiAgIP7MeuyqhS6fOpbLYY/1R+Rgmc0sYyA5GHEXBYOpWSoBDS43naAAAAgAAAAAB7AAAAAA==')
Traceback (most recent call last):
  File "...\electrum\electrum\util.py", line 1176, in wrapper
    return await func(*args, **kwargs)
  File "...\electrum\electrum\lnwatcher.py", line 213, in trigger_callbacks
    await callback()
  File "...\electrum\electrum\lnwatcher.py", line 219, in check_onchain_situation
    spenders = self.inspect_tx_candidate(funding_outpoint, 0)
  File "...\electrum\electrum\lnwatcher.py", line 297, in inspect_tx_candidate
    r = self.inspect_tx_candidate(spender_txid+':%d'%i, n+1)
  File "...\electrum\electrum\lnwatcher.py", line 281, in inspect_tx_candidate
    assert witness, f"witness is missing! txid={spender_txid}. rawtx={str(spender_tx)}"
AssertionError: witness is missing! txid=49f0fe532c07ec099ea3a9540a06141f529d28244c3a7be20f54843636cd7380. rawtx=cHNidP8BAFICAAAAAbliIHcoL1ZXwvRfBrjmhEJ63isM+wBBiCoZW231T2jhAAAAAAD9////AbMsQQAAAAAAFgAURC0BRfNFWqqD+jbsTaiX0/qjrE2v2iIAAAEA/S8BAgAAAAABAVbd14mCS0q4HjYGhWppSXvBvx9POsTYDSwXAIkxJF1iAAAAAAD/////ASEtQQAAAAAAFgAUh+Ku4dqhbNrjKjcK65dsZAWV+ocEAEcwRAIgcILGbxQK7wxiq1yBY6GxGBs4A32pBzC4PUSiMY0QuVMCIGtWnoRD/2zx4BshRYeHsg7wp9ClplQWxjsBJszXEcPfAUgwRQIhAPn0dsBeyqW4U0TbOgJMMEEuKwqBXfXHryHJvOxcwKafAiBRBBFpJvYxMtjkg7aABj1yUEwBaZuAqg1a8mlbHLKnBwFHUiECRc2elI2LEqEE31/G9tC6IA4yV09nKK6nSTez2vUlVikhAxbmJytLCOgHfz1vFqKrZMhERzVCJd0AaAkBWZqMKbe6Uq4AAAAAIgYDtG0jdrMO8FbxdAepULYg1Hu8fbq6hQ7Ki35K6/TViEQQ0uN52gAAAIABAAAAgQAAAAAiAgIP7MeuyqhS6fOpbLYY/1R+Rgmc0sYyA5GHEXBYOpWSoBDS43naAAAAgAAAAAB7AAAAAA==
```
2022-07-05 14:53:33 +02:00
ThomasV
dbf055de9a EventListener class to handle callbacks
and QtEventListener for Qt
2022-06-22 02:07:46 +02:00
ThomasV
7d5125c935 lnwatcher: fix tx replacement and notifications
- revert the logic of do_breach_remedy to what it was
   before 0ca3d66d15,
   but now calling self.maybe_redeem unconditionally.
 - replace mempool transactions only if the fee increases
 - do not notify the GUI if a local tx is replaced
 - delete labels when replacing
2022-06-12 14:28:11 +02:00
ThomasV
6e7ffa29ae Move address_is_old to AddressSynchronizer.
Cache local_height at that level instead of wallet.synchronize
2022-06-10 13:07:53 +02:00
ThomasV
0ca3d66d15 persist_lnwatcher: split try_redeem into two methods:
- maybe_add_redeem_tx
 - maybe_broadcast

Before this commit, local tx that are now persisted
are bot broadcast
2022-06-10 13:07:53 +02:00
ThomasV
121d8732f1 Persist LNWatcher transactions in wallet file:
- separate AddressSynchronizer from Wallet and LNWatcher
 - the AddressSynchronizer class is referred to as 'adb' (address database)
 - Use callbacks to replace overloaded methods
2022-06-10 13:07:53 +02:00
ThomasV
672326bd12 lnwatcher: a bit less verbose 2022-05-26 12:00:11 +02:00
ThomasV
56659c550e lnwatcher: fix another broadcast-too-early error 2022-05-25 12:45:53 +02:00
ThomasV
e99a5a7703 fix lnwatcher broadcast logic, follow-up b9f01a86fe 2022-05-25 12:34:52 +02:00
ThomasV
b9f01a86fe lnwatcher: check that parent transaction is confirmed in CSV test 2022-05-24 19:13:10 +02:00
ThomasV
44f29331bf lnwatcher: in inspect_tx_candidate, match witness scripts against HTLC templates
fixes #7781
2022-04-28 13:21:10 +02:00
bitromortac
ff61020dd2 watchtower: watch new channels 2021-09-27 10:31:44 +02:00
ThomasV
763ee86028 lnwatcher: trigger 'verified' callback with the main wallet object.
This is a temporary fix; we should not use an extra synchronizer, and persist results.
2021-03-23 11:05:05 +01:00
ThomasV
aa1fcc784e wallet: store wanted_height in future_tx, instead of remaining blocks 2021-03-22 11:00:42 +01:00
ThomasV
bbb9ce2430 lnwatcher.try_redeem: output log only the first time a tx is seen 2021-03-20 09:30:15 +01:00
ThomasV
aba0bad30c lnwatcher: try_redeem must return if tx is None 2021-03-20 09:10:48 +01:00
ThomasV
cd025c5553 inspect_tx_candidate: tx output must be of address type 2021-03-17 15:55:53 +01:00
SomberNight
3c019c2f9c daemon/wallet/network: make stop() methods async 2021-03-09 17:52:36 +01:00
SomberNight
9380b331e4 LNWatcher: implement diagnostic_name; for nicer log lines 2020-09-18 20:54:09 +02:00
SomberNight
2c962abe51 network: randomise the order of address subscriptions
Before this, we were subscribing to our addresses in their bip32 order,
leaking this information to servers. While this leak seems mostly harmless,
it is trivial to fix.
2020-06-17 19:25:52 +02:00
ThomasV
782f9ed273 lnwatcher: use generic callbacks 2020-05-20 13:49:44 +02:00
SomberNight
62be1cc367 small clean-up re "extract preimage from on-chain htlc_tx"
related: #6122
2020-05-06 03:15:20 +02:00
ThomasV
8ba7e68064 fix #6122: extract preimage from on-chain htlc_tx 2020-05-03 16:03:27 +02:00
ThomasV
123b8c1792 (minor) rename chan.sweep_htlc 2020-05-02 11:42:47 +02:00
SomberNight
2b1a150c52 multi-wallet: properly stop lnworker/lnwatcher 2020-05-01 04:50:08 +02:00
ThomasV
bdb870af00 follow-up c454564ed6 2020-04-21 15:31:13 +02:00
ThomasV
9224404108 Move callback manager out of Network class 2020-04-14 18:29:51 +02:00
SomberNight
8e8ab775eb lnchannel: make AbstractChannel inherit ABC
and add some type annotations, clean up method signatures
2020-04-13 15:57:53 +02:00
ThomasV
8f41aeb783 Replace wallet backup with channel backups
- channels can be backed up individually
 - backups are added to lnwatcher
 - AbstractChannel ancestor class
2020-04-10 14:45:23 +02:00
ThomasV
aa32e31a3d follow-up previous commit 2020-04-03 18:54:02 +02:00
ThomasV
06dfe1699c LNWatcher: Distinguish between blockchain-triggered channel state
transitions, and actions taken as a result.
- state transitions are performed in lnchannel.update_onchain_state()
- peer actions are in LNWorker.on_channel_update()
2020-04-03 17:34:11 +02:00
SomberNight
79d57784c1 lnchannel: add more type hints 2020-03-30 03:49:50 +02:00