Commit Graph

65 Commits

Author SHA1 Message Date
ThomasV aa51df0a1a Use attr.s for Feeupdates and Outpoints
Storage upgrade to version 23
2020-02-01 16:45:19 +01:00
SomberNight 0973b86925 lnworker: rework "is_dangerous"
"Should channel be closed due to expiring htlcs?"
2019-08-20 09:03:12 +02:00
SomberNight ce54b5411e lnhtlc: htlcs_by_direction now returns dict keyed by htlc_id 2019-08-20 09:03:12 +02:00
SomberNight a27b03be6d lnhtlc: local update raw messages must not be deleted before acked
In recv_rev() previously all unacked_local_updates were deleted
as it was assumed that all of them have been acked at that point by
the revoke_and_ack itself. However this is not necessarily the case:
see new test case.

renamed log['unacked_local_updates'] to log['unacked_local_updates2']
to avoid breaking existing wallet files
2019-08-20 09:03:12 +02:00
SomberNight 7f1b456b93 lnhtlc.discard_unsigned_remote_updates: fix 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 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 a3fd6b3ce8 lnhtlc: rename ctx_pending to revack_pending, and persist it 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
SomberNight 7431aac5cd lnhtlc: (fix) was locking in too many updates during commit/revoke 2019-08-20 09:03:12 +02:00
ThomasV 9abbd077a5 lnhtlc: use boolean instead of int in ctn_latest 2019-08-20 09:03:11 +02:00
SomberNight 69bffac86a lnhtlc: fix adding htlc between sending commitment_signed and receiving revoke_and_ack 2019-08-20 09:03:11 +02:00
SomberNight fda6fb6521 lnhtlc: handle fails asymmetrically 2019-08-20 09:03:11 +02:00
SomberNight 8632f027da lnhtlc: small clean-up / docstrings 2019-08-20 09:03:11 +02:00
SomberNight 268f05c60c lnhtlc: add type hints 2019-08-20 09:03:11 +02:00
ThomasV 82491ff083 do not duplicate ctn in channel log and config 2019-08-20 09:03:11 +02:00
ThomasV 8d28188d24 lnhtlc: remove unused field in log 2019-08-20 09:03:11 +02:00
ThomasV b215d6c4b7 lnhtlc: rename ctnheights -> ctn 2019-08-20 09:03:11 +02:00
SomberNight a565c500f6 lnhtlc: revert 0c4e7b856f8c96c4f0a33bf3e0d1c8fd8184bd36 2019-08-20 09:03:11 +02:00
ThomasV 11c0c0d5a1 lnhtlc: fix received_in_ctn (LOCAL->REMOTE) 2019-08-20 09:03:11 +02:00
Janus f618bb4a67 lnhtlc: handle settles like adds (asymmetrical across ctns) 2019-08-20 09:03:11 +02:00
Janus e56e849505 lnchan refactor
- replace undoing logic with new HTLCManager class
- separate SENT/RECEIVED
- move UpdateAddHtlc to lnutil
2019-08-20 09:03:11 +02:00
Janus 1763d02b05 rename lnhtlc->lnchan, HTLCStateMachine->Channel 2019-08-20 09:03:10 +02:00
Janus b26dc66567 lnhtlc: only store feerate once, don't store heights since we do not roll back 2019-08-20 09:03:10 +02:00
Janus e8471e483b lnhtlc: merge config and state, remove unnecessary properties 2019-08-20 09:03:10 +02:00
Janus 1d4c113a35 lnhtlc: remove lookup_htlc, use heterogeneously typed lists 2019-08-20 09:03:10 +02:00
Janus 699368b0b7 lnhtlc: save settled htlc amounts separately 2019-08-20 09:03:10 +02:00
SomberNight 029ec5a5ab make our channels private, and put routing hints in invoices we create 2019-08-20 09:03:10 +02:00
ThomasV 242ab5ae56 lightning: fix tests 2019-08-20 09:03:10 +02:00
ThomasV 6e5b36e661 lnwatcher simplification: remove ctn tests and pubkeys 2019-08-20 09:03:10 +02:00
ThomasV 11c3ca281c create sweep transaction outside of lnwatcher 2019-08-20 09:03:10 +02:00
Janus c5b7deac6b lnhtlc: don't save FeeUpdates to disk, only keep FeeUpdate in memory while in progress 2019-08-20 09:03:10 +02:00
Janus 1a7b06b690 lnhtlc: multiply weight by feerate before rounding
This resolves the error formerly manifested as:
Traceback (most recent call last):
  File "/home/janus/Skrivebord/lightning-rfc/tools/electrum/packages/jsonrpclib/SimpleJSONRPCServer.py", line 376, in _dispatch
    return func(*params)
  File "/home/janus/Skrivebord/lightning-rfc/tools/electrum/electrum/daemon.py", line 292, in run_cmdline
    result = func(*args, **kwargs)
  File "/home/janus/Skrivebord/lightning-rfc/tools/electrum/electrum/commands.py", line 87, in func_wrapper
    return func(*args, **kwargs)
  File "/home/janus/Skrivebord/lightning-rfc/tools/electrum/electrum/commands.py", line 697, in lnpay
    return f.result()
  File "/usr/lib/python3.6/concurrent/futures/_base.py", line 432, in result
    return self.__get_result()
  File "/usr/lib/python3.6/concurrent/futures/_base.py", line 384, in __get_result
    raise self._exception
  File "/home/janus/Skrivebord/lightning-rfc/tools/electrum/electrum/lnbase.py", line 887, in pay
    sig_64, htlc_sigs = chan.sign_next_commitment()
  File "/home/janus/Skrivebord/lightning-rfc/tools/electrum/electrum/lnhtlc.py", line 281, in sign_next_commitment
    htlc_tx = make_htlc_tx_with_open_channel(self, *args)
  File "/home/janus/Skrivebord/lightning-rfc/tools/electrum/electrum/lnutil.py", line 262, in make_htlc_tx_with_open_channel
    commit.txid(), commit.htlc_output_indices[original_htlc_output_index],
KeyError: 0
2019-08-20 09:03:10 +02:00
Janus a071aafcc7 lnhtlc: generalize balance/pending_commitment code over htlc direction 2019-08-20 09:03:10 +02:00
Janus e5f42a3973 lnhtlc: save settled or failed htlcs 2019-08-20 09:03:10 +02:00
Janus 5753cf9e05 ln fees: avoid resending same fee update before it has been committed to, docs 2019-08-20 09:03:10 +02:00
Janus d07adda3c0 lnhtlc: decrease next_htlc_id counter when removing htlcs when saving 2019-08-20 09:03:10 +02:00
ThomasV 1127d3f467 simplify syntax 2019-08-20 09:03:10 +02:00
Janus 878dc17acb ln: don't save htlcs that are not locked in 2019-08-20 09:03:10 +02:00
Janus 2c6925e526 lnhtlc: bip69 ordering of htlc signatues we generate 2019-08-20 09:03:10 +02:00
Janus e23e0d6c6e ln: avoid duplicated htlc filter code, support multiple htlcs better 2019-08-20 09:03:10 +02:00
Janus 50b3bc939c avoid reading from queues concurrently in pay() 2019-08-20 09:03:10 +02:00
Janus a04e37d050 keep htlc history in case a htlc fails 2019-08-20 09:03:10 +02:00
Janus cc7ef49c43 lnhtlc: also check received htlcs when validating commitment sigs 2019-08-20 09:03:10 +02:00
Janus 224226f427 ln: cooperative close with remote peer initiating 2019-08-20 09:03:10 +02:00
Janus d5d9270d0c lnhtlc: save logs and feeupdates 2019-08-20 09:03:10 +02:00
Janus eca5545004 lnhtlc: don't throw away fee updates or htlcs
also add inject_fees debug command
2019-08-20 09:03:10 +02:00
Janus 02eca03486 lnhtlc: cleanup and save settled htlcs 2019-08-20 09:03:10 +02:00