Commit graph

11462 commits

Author SHA1 Message Date
SomberNight
940fc86749 lnpeer: reestablish_channel - fix data_loss_protect edge case 2019-08-20 09:03:12 +02:00
SomberNight
107f271e58 move all ctn book-keeping to lnhtlc (from lnchannel) 2019-08-20 09:03:12 +02:00
SomberNight
44761972cb lnchannel: ctx output-ordering: identical htlcs are ordered by CLTV 2019-08-20 09:03:12 +02:00
SomberNight
b1f606eaed lnchannel: start using "latest" and "next" instead of "current" and "pending"
"current" used to be "oldest_unrevoked"; and pending was "oldest_unrevoked + 1"
but this was very confusing...
so now we have "oldest_unrevoked", "latest", and "next"
where "next" is "latest + 1"
"oldest_unrevoked" and "latest" are either the same or are offset by 1
(but caller should know which one they need)

rm "got_sig_for_next" - it was a redundant sanity check, that really
just complicated things

rm "local_commitment", "remote_commitment", "set_local_commitment",
"set_remote_commitment" - just use "get_latest_commitment" instead
2019-08-20 09:03:12 +02:00
SomberNight
e32807d29d lnworker: only reestablish channels after on-chain state is synchronized 2019-08-20 09:03:12 +02:00
SomberNight
944e4f0ba0 implement data_loss_protect
so that we can spend their_ctx_to_remote even when we lost our state
but have an old backup
2019-08-20 09:03:12 +02:00
SomberNight
fdf8d8609b lnpeer: make feature-bit testing easier
so that we can always test like: self.localfeatures & FEATURE_BIT_OPT
2019-08-20 09:03:12 +02:00
SomberNight
014b921393 lnpeer: reestablish_channel - replay un-acked local updates
Replay un-acked local updates (including commitment_signed) byte-for-byte.
If we have sent them a commitment signature that they "lost" (due to disconnect),
we need to make sure we replay the same local updates, as otherwise they could
end up with two (or more) signed valid commitment transactions at the same ctn.
Multiple valid ctxs at the same ctn is a major headache for pre-signing spending txns,
e.g. for watchtowers, hence we must ensure these ctxs coincide.
2019-08-20 09:03:12 +02:00
SomberNight
e81ae1921b lnpeer: reestablish_channel - discard unsigned remote updates 2019-08-20 09:03:12 +02:00
SomberNight
c046f2cc1c lnhtlc: move 'next_htlc_id' from ChannelConfig to lnhtlc log 2019-08-20 09:03:12 +02:00
SomberNight
c8b19aec2a lnpeer: make reestablish_channel saner
clear up expectations about ctns
2019-08-20 09:03:12 +02:00
SomberNight
a3fd6b3ce8 lnhtlc: rename ctx_pending to revack_pending, and persist it 2019-08-20 09:03:12 +02:00
SomberNight
cd4268c521 lnworker: small clean-up of short_channel_id format 2019-08-20 09:03:12 +02:00
SomberNight
bdbc662a36 lnpeer: channel_reestablished is now a queue (instead of future) 2019-08-20 09:03:12 +02:00
SomberNight
0d84873a75 lnchannel: trivial clean-up 2019-08-20 09:03:12 +02:00
ThomasV
57ec8f51c8 lnpay: check whether invoice has been paid 2019-08-20 09:03:12 +02:00
ThomasV
4b2336304f kivy fix: get_latest_feerate 2019-08-20 09:03:12 +02:00
ThomasV
f9a2e7eeb4 lnworker.get_invoice_status: test if invoice is expired 2019-08-20 09:03:12 +02:00
ThomasV
cac1e87286 use aiohttp+jsonrpcclient to sync with remote watchtower 2019-08-20 09:03:12 +02:00
ThomasV
740381e993 fix: remove unused parameter to add_sweep_tx 2019-08-20 09:03:12 +02:00
ThomasV
fa3eefa479 refactor a few lnchannel methods 2019-08-20 09:03:12 +02:00
ThomasV
cd7ed4c59c fix: constraints.feerate -> get_latest_feerate 2019-08-20 09:03:12 +02:00
ThomasV
f7c05f2602 Synchronize watchtower asynchronously:
- remove remote_commitment_to_be_revoked
- pass old ctns to lnsweep.create_sweeptxs_for_watchtower
- store the ctn of sweeptxs in sweepStore database
- request the highest ctn from sweepstore using get_ctn
- send sweeptxs asynchronously in LNWallet.sync_with_watchtower
2019-08-20 09:03:12 +02:00
SomberNight
f060e53912 (trivial) fix type annotation 2019-08-20 09:03:12 +02:00
SomberNight
087994e39a lnchannel: move fee update logic to lnhtlc (and hopefully fix it) 2019-08-20 09:03:12 +02:00
ThomasV
3d7f7dfc82 revamp fee updates (draft) 2019-08-20 09:03:12 +02:00
SomberNight
7431aac5cd lnhtlc: (fix) was locking in too many updates during commit/revoke 2019-08-20 09:03:12 +02:00
SomberNight
4ccfa39fdd cli: fix add_peer cmd 2019-08-20 09:03:12 +02:00
ThomasV
9045d7b293 cleanup revoke_current_commitment 2019-08-20 09:03:12 +02:00
ThomasV
e43a3bc63a follow-up prev commit: pass is_mine to _edge_cost 2019-08-20 09:03:12 +02:00
ThomasV
b55f9e9e6a Do not route through channels for which we did not receive
both updates, because this often means one of the nodes is
offline.
2019-08-20 09:03:12 +02:00
ThomasV
30e942bead fix: delete from channel_db 2019-08-20 09:03:12 +02:00
ThomasV
32fcad5bc3 channel_db: update channels_for_node when removing channel 2019-08-20 09:03:12 +02:00
ThomasV
2be68ac4d2 Use one LNWatcher instance per wallet 2019-08-20 09:03:12 +02:00
ThomasV
4d76e84218 improve regtest.sh with wait functions 2019-08-20 09:03:12 +02:00
ThomasV
6b90d501ab fix type: list 2019-08-20 09:03:12 +02:00
ThomasV
94fe28b576 regtest: remove cost limit 2019-08-20 09:03:12 +02:00
ThomasV
c7b9bdc5f5 lnwatcher: wait until lnwatcher is fully synchronized before check_onchain_situation 2019-08-20 09:03:12 +02:00
ThomasV
a8ce8109be Perform breach remedy without sweepstore:
- add functions to lnsweep
 - lnworker: analyze candidate ctx and htlc_tx
 - watchtower will be optional
 - add test for breach remedy with spent htlcs
 - save tx name as label
2019-08-20 09:03:12 +02:00
ThomasV
238f3c949c get rid of sql_alchemy 2019-08-20 09:03:12 +02:00
ThomasV
0eab1692d6 Do not store message payloads in channel db.
Use single primary key for addresses.
2019-08-20 09:03:12 +02:00
ThomasV
f2d58d0e3f optimize channel_db:
- use python objects mirrored by sql database
 - write sql to file asynchronously
 - the sql decorator is awaited in sweepstore, not in channel_db
2019-08-20 09:03:12 +02:00
ThomasV
180f6d34be separate channel_db module 2019-08-20 09:03:12 +02:00
ThomasV
06b5299b0f comment out convert, add logging statement 2019-08-20 09:03:12 +02:00
ThomasV
a54cb30cf3 kivy: simplify open_channel dialog 2019-08-20 09:03:12 +02:00
SomberNight
c15267e1f6 pycryptodomex for android 2019-08-20 09:03:12 +02:00
ThomasV
115113f492 remove expensive sql request, python set comparison is faster 2019-08-20 09:03:12 +02:00
ThomasV
af7d7e883c Rework wallet history methods:
- wallet.get_full_history returns onchain and lightning
 - capital gains are returned by get_detailed_history
 - display lightning history in kivy
 - command line: separate lightning and onchain history
2019-08-20 09:03:12 +02:00
SomberNight
7e8be3d2e7 lnpeer: some exception handling clean up
main_loop should dump traces of unexpected exceptions to log.
Coroutines/functions invoked inside main_loop should simply propagate it
up the chain.
Typical exceptions are handled in handle_disconnect without dumping the trace.
2019-08-20 09:03:12 +02:00
SomberNight
efc8948c00 lnworker: set DATA_LOSS_PROTECT flag for LNGossip too
otherwise peers disconnect
2019-08-20 09:03:12 +02:00