Commit graph

141 commits

Author SHA1 Message Date
ThomasV
bb21e01823 (minor) call lnwatcher.add_channel from lnworker.add_channel 2020-02-14 14:15:15 +01:00
ThomasV
e3630d87b2 test_lnpeer: test_reestablish_with_old_state 2020-02-12 10:22:22 +01:00
ThomasV
3377627070 reestablish_channel: shorter varnames 2020-02-12 06:18:22 +01:00
ThomasV
69ef9aa3d7 channel_reestablish: assume that DLP is enabled, because we require it 2020-02-11 21:39:23 +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
8688a6530a reestablish_channel: do not send second channel_reestablish message if they are ahead (they should know it) 2020-02-11 20:42:16 +01:00
SomberNight
0a5ad9fda4
ecc: small API clean-up 2020-02-11 16:42:02 +01:00
ThomasV
e1ce3aace7 Separate db from storage
- storage is content-agnostic
 - db and storage are passed to wallet contructor
2020-02-10 17:45:23 +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
4ec86d36a8 faster and improved regtests
- print the test name before each test
 - start only needed agents (alice, bob, carol)
 - set settle_delay using setconfig instead of restarting daemon
 - test the watchtower ctn in test_watchtower
2020-02-02 15:07:28 +01:00
ThomasV
7472eba78c lnpeer: code factorization 2020-01-31 13:33:38 +01:00
ThomasV
757467782a Use attr.s instead of namedtuples for channel config 2020-01-31 12:19:26 +01:00
SomberNight
b99add59c3
lnworker: introduce PaymentAttemptLog NamedTuple 2019-12-10 03:17:57 +01:00
ThomasV
065e98ad35 on_open_channel: rm call to non-existing method on_channels_updated 2019-12-04 18:35:04 +01:00
SomberNight
557987d4eb
add/fix some open_channel related type hints 2019-11-23 20:28:46 +01:00
ThomasV
038036f350 minor follow-up prev commit 2019-11-23 19:56:40 +01:00
ThomasV
fd8236538a Open lightning channels with partially signed tx.
Fixes #5379.
2019-11-23 19:49:12 +01:00
SomberNight
770ae6d878
fix tests 2019-11-22 22:11:56 +01:00
SomberNight
bda9a407d9
trivial: don't print frequent-case log line in lnpeer.mark_open 2019-11-22 21:37:15 +01:00
SomberNight
268e245322
lnpeer: only set initialized after both sent AND received "init"
had a trace where we tried to send "funding_locked" before being initialized:

D | lnpeer.Peer.[iq7zhmhck54vcax2vlrdcavq2m32wao7ekh6jyeglmnuuvv3js57r4id.onion:9735] | Sending FUNDING_LOCKED
E | lnworker.LNWallet | Exception in on_update_open_channel: AttributeError("'LNTransport' object has no attribute 'sk'")
Traceback (most recent call last):
  File "...\electrum\electrum\util.py", line 999, in wrapper
    return await func(*args, **kwargs)
  File "...\electrum\electrum\lnworker.py", line 674, in on_update_open_channel
    peer.send_funding_locked(chan)
  File "...\electrum\electrum\lnpeer.py", line 876, in send_funding_locked
    self.send_message("funding_locked", channel_id=channel_id, next_per_commitment_point=per_commitment_point_second)
  File "...\electrum\electrum\lnpeer.py", line 102, in send_message
    self.transport.send_bytes(raw_msg)
  File "...\electrum\electrum\lntransport.py", line 93, in send_bytes
    lc = aead_encrypt(self.sk, self.sn(), b'', l)
AttributeError: 'LNTransport' object has no attribute 'sk'
2019-11-22 21:33:56 +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
ThomasV
b469df5283 check channel funding_tx amount and script in save_short_channel_id 2019-11-21 20:16:04 +01:00
SomberNight
216d9e3c4d
lnpeer: (fix) force_close_channel was not awaited in some cases 2019-11-21 16:37:43 +01:00
ThomasV
78813dcb7d Pass make_tx function to ConfirmTxDialog
- allow 'spend max' when opening a channel (fixes #5698)
 - display amount minus fee when 'max' buttons are pressed
 - estimate fee of channel funding using a template with dummy address
2019-11-14 10:20:19 +01:00
SomberNight
7b18c91b74
psbt follow-up: fix ln cooperative close, and minor type clean up 2019-11-07 18:28:27 +01:00
SomberNight
bafe8a2fff
integrate PSBT support natively. WIP 2019-11-04 22:24:36 +01:00
ThomasV
0966edc637 fine-grained callbacks for lightning network dialog 2019-10-12 19:15:51 +02: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
d6d644190e lnworker: return error reason in await_payment 2019-10-11 13:37:54 +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
638de63f13 lnworker: rename 'invoices' to 'payments' when they can be in both directions 2019-10-09 20:16:11 +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
ThomasV
f08e5541ae Refactor invoices in lnworker.
- use InvoiceInfo (NamedTuple) for normal operations,
   because lndecode operations can be very slow.
 - all invoices/requests are stored in wallet
 - invoice expiration detection is performed in wallet
 - CLI commands: list_invoices, add_request, add_lightning_request
 - revert 0062c6d695 because it forbids self-payments
2019-09-22 16:06:53 +02:00
SomberNight
b2920db8b8
config: enforce that SimpleConfig is singleton
related: #5629
2019-09-10 18:01:10 +02:00
ThomasV
cefa4762ba do not create multiple instances of SimpleConfig (fix #5629). Add config field to wallet 2019-09-10 08:57:40 +02:00
ThomasV
35761d1241 Save remote policy of chanel in wallet file (for private channels) 2019-09-08 19:14:28 +02:00
SomberNight
00f15d491b
lnpeer: somewhat nicer log messages 2019-09-07 07:29:22 +02:00
SomberNight
509df9ddaf
create class for ShortChannelID and use it 2019-09-06 18:09:05 +02:00
SomberNight
edf186da0d
channeldb.load_data: attempt at fixing race
closes #5525
2019-09-05 18:32:45 +02:00
SomberNight
4f741cfccc
lnpeer: longer timeouts 2019-09-05 18:31:51 +02:00
ThomasV
e286ed1c13 add_own_channel does not need to be async 2019-09-03 21:01:45 +02:00
SomberNight
956bd3baaf
lnpeer: make per-peer TaskGroup a field (as for interfaces), and use it
lnpeer (and interface) response-handling-code should not run in the
network main_taskgroup as the remote could force an exception
to be raised and that would kill the whole network instead of just the peer
2019-08-30 19:51:17 +02:00
SomberNight
f403735191
lnpeer: reestablish_channel - don't replay unacked msgs they alrdy have
e.g. Alice sends upd1, upd2, upd3, commitment_signed, upd4, upd5.
Bob receives all of these; and sends a revoke_and_ack but there is
a disconnect before Alice receives the revoke_and_ack.
During reestablish, if Bob claims to have received the commitment_signed,
Alice must not replay the msgs before that; but she should replay upd4 and upd5.
2019-08-29 12:37:25 +02:00
ThomasV
65cf0ebce8 lnpeer, minor fixes:
- pass orphaned_ids to lnworker.add_new_ids
 - fix enumeration of get_unacked_local_updates()
2019-08-20 13:27:09 +02:00
SomberNight
bce74717a6 lnpeer: in onion errors, handle channel updates both with and w/o type 2019-08-20 09:03:12 +02:00
SomberNight
beeb81e179 lnpeer: use correct failure codes in _maybe_forward_htlc 2019-08-20 09:03:12 +02:00
SomberNight
e54f0fbafa do not raise BaseException 2019-08-20 09:03:12 +02:00
SomberNight
47ee02569a lnpeer: send own outgoing channel updates to remote peer 2019-08-20 09:03:12 +02:00
SomberNight
f0588846d5 channeldb: also store "message_flags" field for channel updates
this is a breaking change for the db format.
As in comment in diff,
"It would make more sense to store the raw gossip messages in the db."
2019-08-20 09:03:12 +02:00