Commit graph

242 commits

Author SHA1 Message Date
SomberNight
bafe8a2fff
integrate PSBT support natively. WIP 2019-11-04 22:24:36 +01:00
SomberNight
75902f8e35
fix logic error in lnworker.on_channel_closed 2019-10-29 20:39:58 +01:00
ThomasV
a4944cdcb2 delete channel from db in remove_channel, becaose it is called from lnworker 2019-10-23 08:20:15 +02:00
ThomasV
2234f93d8b fix fee in lnworker.get_history (sign error) 2019-10-22 18:27:41 +02:00
ThomasV
aac0fe9ae6 kivy: show status with color. show inflight attempts. 2019-10-22 15:41:45 +02:00
SomberNight
106bc6d2b2
follow-up prev 2019-10-15 15:41:18 +02:00
fiatjaf
38622c0a99 fix expected returned peer address values when opening channel. 2019-10-15 01:05:37 -03:00
ThomasV
db833e1ba3 lnworker: less verbose 2019-10-14 10:42:41 +02:00
ThomasV
c9d403cb7b minor: callback unknown_channels (follow-up 0966edc637) 2019-10-14 10:39:52 +02:00
ThomasV
90ce9f195b Allow user to enable lightning in the GUI. Make it a per-wallet setting. 2019-10-13 20:34:38 +02:00
ThomasV
0966edc637 fine-grained callbacks for lightning network dialog 2019-10-12 19:15:51 +02:00
ThomasV
fe550c6c73 payment log: show whether channel have been blacklisted 2019-10-12 18:36:25 +02:00
ThomasV
3897cf725d move handle_error_code_from_failed_htlc to lnworker because it requires access to the network object 2019-10-12 18:22:19 +02:00
ThomasV
8f86a15f92 improve payment log dialog 2019-10-12 13:47:10 +02:00
ThomasV
5377eb907c follow-up dd0be1541e 2019-10-12 12:59:38 +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
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
638de63f13 lnworker: rename 'invoices' to 'payments' when they can be in both directions 2019-10-09 20:16:11 +02:00
ThomasV
bcb10e6e53 remove redundant test from lnworker._pay, rename pay_to_route parameter to lnaddr 2019-10-04 18:06:53 +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
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
1bc73b3475
lnworker.sync_with_remote_watchtower: use proxy 2019-09-19 18:50:57 +02:00
SomberNight
c63209fa9a
lnworker: accessing self.channels needs lock 2019-09-19 18:17:03 +02:00
ThomasV
0062c6d695 lnworker: fix detection of already paid invoices 2019-09-19 11:57:47 +02:00
ThomasV
d6d5b99944 lnworker: fee_msat is expected for all entries in history 2019-09-19 11:06:44 +02:00
ThomasV
65b88dca86 return fees in history, show them in kivy GUI 2019-09-11 17:49:40 +02:00
ThomasV
a47a2c1b72 follow-up prev 2019-09-11 17:08:03 +02:00
ThomasV
1d82093ca1 fix bug in lightning get_history: filter settled htlcs first 2019-09-11 17:06:07 +02:00
SomberNight
befa8ea771
transaction: kill "name", "csv_delay", "cltv_expiry" fields 2019-09-09 19:38:35 +02:00
ThomasV
86bd3839df follo-up 35761d1241 2019-09-08 19:25:35 +02:00
SomberNight
25c372a3e0
lnworker.invoices access now uses lock
(qt gui thread vs asyncio thread race)

Traceback (most recent call last):
  File "/home/user/wspace/electrum/electrum/gui/qt/main_window.py", line 1685, in do_send
    self.pay_lightning_invoice(self.payto_e.lightning_invoice)
  File "/home/user/wspace/electrum/electrum/gui/qt/main_window.py", line 1667, in pay_lightning_invoice
    self.invoice_list.update()
  File "/home/user/wspace/electrum/electrum/gui/qt/invoice_list.py", line 73, in update
    _list = self.parent.wallet.get_invoices()
  File "/home/user/wspace/electrum/electrum/wallet.py", line 525, in get_invoices
    out += self.lnworker.get_invoices()
  File "/home/user/wspace/electrum/electrum/util.py", line 401, in
    return lambda *args, **kw_args: do_profile(args, kw_args)
  File "/home/user/wspace/electrum/electrum/util.py", line 397, in do_profile
    o = func(*args, **kw_args)
  File "/home/user/wspace/electrum/electrum/lnworker.py", line 1007, in get_invoices
    for key, (invoice, direction, status) in self.invoices.items():
RuntimeError: dictionary changed size during iteration
2019-09-06 18:27:47 +02:00
SomberNight
509df9ddaf
create class for ShortChannelID and use it 2019-09-06 18:09:05 +02:00
SomberNight
251db638af
only require libsecp256k1 if lightning is enabled
related: #5606
2019-09-06 15:08:15 +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
SomberNight
c3504cec94
follow-up a4b24df4bb 2019-09-03 17:53:11 +02:00
ThomasV
a4b24df4bb fix json error in listrequests 2019-09-03 14:51:07 +02:00
ThomasV
a50f935aec Restructure invoices and requests (WIP)
- Terminology: use 'invoices' for outgoing payments, 'requests' for incoming payments
 - At the GUI level, try to handle invoices in a generic way.
 - Display ongoing payments in send tab.
2019-09-02 15:35:44 +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
ThomasV
5ec1db4d51 Ignore exceptions raised in lnworker.on_network_update.
Exception raised there may cancel the network's main taskgroup.
2019-08-30 12:37:34 +02:00
ThomasV
8010123c08 Display and refresh the status of incoming payment requests:
- All requests have an expiration date
 - Paid requests are automatically removed from the list
 - Unpaid, unconfirmed and expired requests are displayed
 - Fix a bug in get_payment_status, conf was off by one
2019-08-22 06:00:45 +02:00
ThomasV
54257cbcca Rewrite JsonRPC requests using asyncio.
- commands are async
 - the asyncio loop is started and stopped from the main script
 - the daemon's main loop runs in the main thread
 - use jsonrpcserver and jsonrpcclient instead of jsonrpclib
2019-08-20 09:03:12 +02:00
SomberNight
ba431495db lnworker: fix silent TypeError in _calc_routing_hints_for_invoice 2019-08-20 09:03:12 +02:00
SomberNight
0973b86925 lnworker: rework "is_dangerous"
"Should channel be closed due to expiring htlcs?"
2019-08-20 09:03:12 +02:00
ThomasV
bd5c83e906 fix race condition with channel_timestamps 2019-08-20 09:03:12 +02:00
ThomasV
b493219829 require data loss protect 2019-08-20 09:03:12 +02:00
ThomasV
9f8e2c689e test funding_txn_minimum_depth, show it in GUI 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