Commit graph

176 commits

Author SHA1 Message Date
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
ThomasV
aa398993cf lnrouter fixes:
- use gossip_queries_req instead of initial_routing_sync
 - add connected nodes to recent peers only after successful init
 - derive timestamp used with gossip_timestamp_filter from channel_db
 - fix query_short_channel_ids:
     1. channel IDs must be sorted with zlib
     2. limit request to 100
     3. do not abuse this to request node_announcements; it is fine not to have all nodes.
 - fix get_recent_peers:
     1. do not set last_connected_date to 'now' if we never connected a node
     2. sql query was misconstructed and was returning only one peer
 - populate FALLBACK_NODE_LIST_MAINNET with nodes that have the requested flags
2019-08-20 09:03:11 +02:00
ThomasV
e7218d798d add get_channel_ctx to CLI, for testing breaches 2019-08-20 09:03:11 +02:00
ThomasV
a698344136 cleanup tests that use regtest:
- separate setup from execution
 - install bitcoind and electrumx in travis
 - use the same framework for lnwatcher and forwarding
 - make tests runnable locally
2019-08-20 09:03:11 +02:00
ThomasV
5148397a75 test forwarding 2019-08-20 09:03:11 +02:00
ThomasV
4dc6c6c82e fix tests (follow up prev commit) 2019-08-20 09:03:11 +02:00
ThomasV
38f1436d78 post rebase fixes 2019-08-20 09:03:11 +02:00
ThomasV
bfdf0a7e88 start asyncio loop in test_lnrouter and test_lnpeer 2019-08-20 09:03:11 +02:00
Janus
95a2174789 sqlite in lnrouter: lnpeer: introduce _gossip_loop for gossip handling separated from message handling 2019-08-20 09:03:11 +02:00
Janus
dd7c4b3bab sqlite in lnrouter 2019-08-20 09:03:11 +02:00
SomberNight
7292da24e6 lnchannel: only consider payments finished when we revoke our old ctx
in the old code,
`self.hm.received_in_ctn(self.config[REMOTE].ctn + 1)`
did not really make sense as "received_in_ctn" compares the argument against the LOCAL ctn
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
SomberNight
3a2ab149b9 lnchannel: add_htlc and receive_htlc now take and return UpdateAddHtlc
also fix undefined vars in _maybe_forward_htlc and _maybe_fulfill_htlc
in lnpeer
2019-08-20 09:03:11 +02:00
ThomasV
62be0c481c lightning: Save invoices and preimages separately. Save preimages when forwarding 2019-08-20 09:03:11 +02:00
ThomasV
50b4f785a9 test_lnpeer: add names 2019-08-20 09:03:11 +02:00
ThomasV
3dce65dc73 Rename lnchan, lnchannel_verifier, lnbase
Auto-completions are a pain if files share a long prefix
2019-08-20 09:03:11 +02:00
Janus
8274a963e6 lnworker: save outgoing invoice when initiating payment 2019-08-20 09:03:11 +02:00
Janus
5f1feee331 move lightning message encoding to new lnmsg module 2019-08-20 09:03:11 +02:00
ThomasV
d5006e83e7 test_forwarding: do not set HOME 2019-08-20 09:03:11 +02:00
ThomasV
954e4c8892 lnbase: rename methods, fix tests 2019-08-20 09:03:11 +02:00
ThomasV
909f1e77de script that tests htlc forwarding 2019-08-20 09:03:11 +02:00
ThomasV
8e753f998a fix tests 2019-08-20 09:03:11 +02:00
ThomasV
b5482e4470 create transport and perform handshake before creating Peer 2019-08-20 09:03:11 +02:00
ThomasV
2af178a586 Store boolean is_received in lightning invoices. Sort lightning history with timestamp. Minor fixes 2019-08-20 09:03:11 +02:00
Janus
4e3b2b5479 tests: update lnbase test to use 4-tuple for invoices 2019-08-20 09:03:11 +02:00
Janus
d5ed4309bb revert low max_htlc_value_in_flight_msat, fix test
spec does not mention that there can be an upper bound
on max_htlc_value_in_flight_msat, so don't try to make
any node happy that has a max limit on this.
2019-08-20 09:03:11 +02:00
ThomasV
0a08ccc1c6 rename paying -> inflight 2019-08-20 09:03:11 +02:00
Janus
8fc1779b0d ln: add test_lnwatcher 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
2c1fcb2f54 ln: remove EncumberedTransaction 2019-08-20 09:03:11 +02:00
Janus
06d4224101 lnchan: remove debugging code, commented out code 2019-08-20 09:03:11 +02:00
Janus
2323118bda lnchan: only sign force_close_tx when demanded, assure consistency, fix test 2019-08-20 09:03:11 +02:00
Janus
1d8fe52fa3 lnchan: make force_close_tx() assure that tx is valid, trigger failure in test 2019-08-20 09:03:11 +02:00
ThomasV
7e34554d1e fix test_lnchan 2019-08-20 09:03:11 +02:00
Janus
133e5ec8c3 use gossip_timestamp_filter instead of request_initial_sync 2019-08-20 09:03:11 +02:00
SomberNight
595cfcbb65 move sweeping methods from lnchan.py to new file
also sweep "received" htlcs from "our" ctx
also sweep htlcs from their ctx (non-breach)
extract ctn; included_htlcs_in_their_latest_ctxs
2019-08-20 09:03:11 +02:00
ThomasV
78896897cb lnchan: replace properties with functions 2019-08-20 09:03:11 +02:00
Janus
e3409d32ef channel details with list of htlcs 2019-08-20 09:03:11 +02:00
Janus
ecac8f2880 tests/lnbase: stub on_channels_updated 2019-08-20 09:03:11 +02:00
ThomasV
3430d1aaa3 follow-up prev commit 2019-08-20 09:03:11 +02:00
Janus
1520338f37 fix ln tests 2019-08-20 09:03:11 +02:00
Janus
783cac1f23 function that returns map from commitment number to list of HTLCs 2019-08-20 09:03:11 +02:00
Janus
9cf7aa054d call force_close_channel on LNWorker, not Peer 2019-08-20 09:03:11 +02:00
Janus
0ea87278fb move force_close_channel to lnbase, test it, add FORCE_CLOSING state 2019-08-20 09:03:11 +02:00
Janus
39fa13b938 lnchan: use NamedTuple for logs instead of dict with static keys (adds, locked_in, settles, fails) 2019-08-20 09:03:10 +02:00
Janus
72187a4341 lnchan: make sign_next_commitment revert state 2019-08-20 09:03:10 +02:00
SomberNight
c0ae7b5534 after rebase clean-up 2019-08-20 09:03:10 +02:00
Janus
7e76e82152 test_lnbase: add test that pays to another local electrum 2019-08-20 09:03:10 +02:00
Janus
f5201327d1 add lnd copyright boilerplate to lnchan, test_lnchan 2019-08-20 09:03:10 +02:00