Commit graph

153 commits

Author SHA1 Message Date
SomberNight
5b23d5ee97
lnchannel/lnhtlc: speed up balance calculation for recent ctns
Move the balance calculation from lnchannel to lnhtlc.
Maintain a running balance in lnhtlc that is coupled with _maybe_active_htlc_ids
for practicality reasons.
2020-03-07 05:05:05 +01:00
SomberNight
ec7473789e
lnhtlc: speed-up methods for recent ctns
we maintain a set of interesting htlc_ids
2020-03-06 21:54:05 +01:00
ThomasV
888a6d726e Propagate exceptions raise by force_close to the GUI.
Define 'try_force_closing' for cases where we do not
want exceptions to be raised.
2020-03-06 12:18:33 +01:00
ThomasV
15fb8c0415 allow transition from FORCE_CLOSING to REDEEMED. define REDEEM_AFTER_DOUBLE_SPENT_DELAY 2020-03-06 11:40:08 +01:00
ThomasV
28452e2d46 do not try to reestablish channel if state is FORCE_CLOSING 2020-03-06 11:25:34 +01:00
ThomasV
eaf4810220 (minor) fix typo 2020-03-06 09:59:43 +01:00
ThomasV
34e236c9b6 CLI: show channel reserves and unsettled balances. fixes #5817 2020-03-06 09:57:37 +01:00
SomberNight
fa0ef9c548
ln: store network addresses for channel counterparties in channels
So we can reconnect to them without relying on gossip db.
2020-03-06 04:04:17 +01:00
ThomasV
8f3fcdd1a8 Fix detection of payments.
1. In lnhtlc, sent_in_ctn and failed_in_ctn need to look at the
remote ctx, and they need to be called when we receive a revocation,
not when we send one.

2. In lnchannel, we use 3 lnworker callbacks:
   - payment sent/payment failed (called when we receive a revocation)
   - payment received (called when we send a revocation)

3. Make revoke_current_commitment return a single value.
The second value was only used in tests, there is no need
to bloat the code with that
2020-03-05 07:03:09 +01:00
ThomasV
b9eaba3e85 replace await_local/remote 2020-03-05 07:03:09 +01:00
ThomasV
cfc20845a2 lnworker: dissociate htlc forwarding and fulfillment 2020-03-02 11:54:08 +01:00
ThomasV
da67fda92a HTLC switch:
- fulfills/fails/forwards HTLCs
- onion_packets are saved when update_add_htlc is received
2020-03-02 11:19:04 +01:00
ThomasV
34400c0710 Set channel state to OPENING as soon as we receive 'funding_signed',
instead of when the funding transaction has been broadcast, because
we have no reliable way to know when it will be broadcast.
2020-02-27 18:12:20 +01:00
ThomasV
f5053cc242 follow-up e54c69b861: we must settle HTCLs after during shutdown 2020-02-27 14:40:58 +01:00
SomberNight
e54c69b861
add lnchannel.can_send_ctx_updates. just drop illegal updates for now 2020-02-26 20:35:46 +01:00
ThomasV
87fe2c7d7a define channel.has_pending_changes method 2020-02-26 19:08:48 +01:00
ThomasV
1c5dc79298 shutdown:
- resend shutdown on reestablish
 - wait until no more pending updates before sending shutdown
2020-02-26 16:06:28 +01:00
ThomasV
e85fb25146 lnpeer: verify signature in closing_signed 2020-02-26 12:58:40 +01:00
ThomasV
2927478192 lnpeer: closing fee negociation:
- use fee_rate from config
 - set upper bound on fee
 - add test_close to test_lnpeer
2020-02-25 15:23:15 +01:00
SomberNight
931d961721
lnpeer/lnwatcher: include channel id in log lines 2020-02-24 16:32:18 +01:00
ThomasV
7908f4b203 follow-up previous commit 2020-02-24 13:02:11 +01:00
ThomasV
5785c2fa2f Fix #5975: Forget or redeem channels that are never funded.
- initiator: wait until double spent
 - non-initiator: wait until timeout
2020-02-24 12:45:10 +01:00
ThomasV
20d8da7e24 db upgrade: store channel tx height and timestamps in 'channels' 2020-02-24 10:07:55 +01:00
ThomasV
54ef6db762 do not try to reestablish channels in PREOPENING state (per BOLT2). 2020-02-23 14:54:04 +01:00
ThomasV
7771daf94e qt: add menu item to view closing transaction of channel 2020-02-22 12:28:07 +01:00
ThomasV
938d918e55 sweep_ctx: do not log if channel was not force closed 2020-02-22 09:27:34 +01:00
ThomasV
2255b07157 support option_static_remotekey 2020-02-20 21:02:01 +01:00
ThomasV
238fb46d87 Lightning: Show sending and receiving capacity. Fixes #5967 2020-02-19 16:11:55 +01:00
ThomasV
e05cd2006a fix get_payments 2020-02-18 17:40:13 +01:00
SomberNight
46d8080c76
ln gossip: don't put own channels into db; always pass them to fn calls
Previously we would put fake chan announcement and fake outgoing chan upd
for own channels into db (to make path finding work). See Peer.add_own_channel().
Now, instead of above, we pass a "my_channels" param to the relevant ChannelDB methods.
2020-02-17 20:38:41 +01:00
ThomasV
472c0defee fix lnchannel.get_payments: unsettled htlcs may have overwritten the returned results. 2020-02-17 12:19:18 +01:00
ThomasV
938fab86d1 detect redeemed channels (fix #5963) 2020-02-16 19:07:20 +01:00
SomberNight
a6e3a244e8
add comment re lnchannel channel_states 2020-02-14 16:15:25 +01:00
ThomasV
2a7b5081c9 channel states: make sure that closing_txid is saved if channel is closed 2020-02-14 13:25:04 +01:00
ThomasV
beee880dba fix data_loss_protect (missing return, json conversion) 2020-02-12 14:19:31 +01:00
ThomasV
9ccfa318f8 add new peer_state for the case where we are waiting for the remote party to force close a channel 2020-02-11 20:55:52 +01:00
ThomasV
dbceed2647 Restructure wallet storage:
- Perform json deserializations in wallet_db
 - use StoredDict class that keeps tracks of its modifications
2020-02-04 13:35:58 +01:00
ThomasV
aa51df0a1a Use attr.s for Feeupdates and Outpoints
Storage upgrade to version 23
2020-02-01 16:45:19 +01:00
ThomasV
757467782a Use attr.s instead of namedtuples for channel config 2020-01-31 12:19:26 +01:00
SomberNight
bda9a407d9
trivial: don't print frequent-case log line in lnpeer.mark_open 2019-11-22 21:37:15 +01:00
ThomasV
61dfcba092 Refactor channel states:
- persisted states are saved
 - state transitions are checked
 - transient states are stored in channel.peer_state
 - new channel states: 'PREOPENING', 'FUNDED' and 'REDEEMED'
 - upgrade storage to version 21
2019-11-22 20:14:54 +01:00
SomberNight
bafe8a2fff
integrate PSBT support natively. WIP 2019-11-04 22:24:36 +01:00
ThomasV
dd0be1541e Improve handling of lightning payment status:
- Move 'handle_error_code_from_failed_htlc' to channel_db,
and call it from pay_to_route, because it should not be
called when HTLCs are forwarded.
- Replace 'payment_received' and 'payment_status'
callbacks with 'invoice_status' and 'request_status'.
- Show payment error logs in the Qt GUI
- In the invoices list, show paid invoices for which
we still have the log.
2019-10-11 17:51:33 +02:00
ThomasV
0557738a6b follow-up previous commit 2019-10-11 12:54:00 +02:00
ThomasV
c4ab1e6fad Encapsulate lightning payment events:
- make LNWorker.pending_payments private
 - public methods: payment_sent, payment_received, await_payment
2019-10-11 10:18:28 +02:00
ThomasV
788d54f9a6 remove another instance of lnworker accessed in lnchannel 2019-10-09 19:54:43 +02:00
ThomasV
8331f0049c Remove lnpeer.payment_preimages:
- we can await lnworker.pending_payments instead, because the preimage is saved
 - also, remove one instance of lnworker being accessed from lnchannel
2019-10-09 19:40:25 +02:00
SomberNight
04edad9984
config: no longer singleton. it is passed to Wallet.__init__
The few other cases that used SimpleConfig.get_instance() now
either get passed a config instance, or they try to get a reference
to something else that has a reference to a config.
(see lnsweep, qt/qrcodewidget, qt/qrtextedit)
2019-09-22 20:46:01 +02:00
SomberNight
b2920db8b8
config: enforce that SimpleConfig is singleton
related: #5629
2019-09-10 18:01:10 +02:00
SomberNight
befa8ea771
transaction: kill "name", "csv_delay", "cltv_expiry" fields 2019-09-09 19:38:35 +02:00