Commit Graph

289 Commits

Author SHA1 Message Date
Matt Corallo
4a58e9ad83 Add PeerManager::disconnect_all_peers to avoid complexity in BP
In the coming commits simply calling `timer_tick_occurred` will no
longer disconnect all peers, so its helpful to have a utility
method.
2021-10-26 02:04:34 +00:00
Matt Corallo
d0c3fb745d Fix cargo doc on older rustc
Apparently at least rustc 1.48 doesn't support `Self` in doc links,
so we make it explicit.
2021-10-22 19:34:18 +00:00
Matt Corallo
f2e47e0db2 Bump crate versions to 0.0.102 and lightning-invoice 0.10 2021-10-18 18:32:36 +00:00
Matt Corallo
0dfb24e661 Move Persist trait to chainmonitor as that's the only reference 2021-10-14 00:16:50 +00:00
Jeffrey Czyz
d7c8c8c572
Speed up test_timer_tick_called 2021-10-13 10:25:18 -05:00
Matt Corallo
43fe3d55f1 Bump Crate versions to 0.0.101 (and invoice to 0.9) 2021-09-23 18:22:59 +00:00
Antoine Riard
6ce7f3e1ce Add ChannelClosed generation at cooperative/force-close/error processing
When we detect a channel `is_shutdown()` or call on it
`force_shutdown()`, we notify the user with a Event::ChannelClosed
informing about the id and closure reason.
2021-09-21 15:46:42 -04:00
Jeffrey Czyz
992df51001
Update NetworkGraph in BackgroundProcessor
Decorate the user-supplied EventHandler with NetGraphMsgHandler in
the BackgroundProcessor. The resulting handler will intercept
PaymentFailed events in order to update the NetworkGraph in the
background before delegating to the user's event handler.
2021-09-15 11:53:13 -05:00
Jeffrey Czyz
e2f088c371
Expand and format BackgroundProcessor docs 2021-09-15 11:53:12 -05:00
Jeffrey Czyz
a6e650630d
Pass Event by reference to EventHandler
Passing an Event by reference rather and by move gives more flexibility
for composing event handlers without needing to clone events.
2021-09-09 22:57:51 -05:00
Matt Corallo
45853b3a95
Merge pull request #1031 from p2pderivatives/dlc-version-generic
Dlc version generic
2021-08-25 17:22:20 +00:00
Tibo-lg
2e5e40e0b2 Add custom message handler to peer manager 2021-08-25 13:22:09 +09:00
Joseph Goulden
af4eb23a1c test: increase ping timeout when running in debug mode 2021-08-20 15:48:40 +01:00
Matt Corallo
11f78798d3 Update versions to 0.0.100 and lightning-invoice to 0.8 2021-08-17 18:55:07 +00:00
Matt Corallo
03439ec99f Automatically update fees on outbound channels as fees change
Previously we'd been expecting to implement anchor outputs before
shipping 0.1, thus reworking our channel fee update process
entirely and leaving it as a future task. However, due to the
difficulty of working with on-chain anchor pools, we are now likely
to ship 0.1 without requiring anchor outputs.

In either case, there isn't a lot of reason to require that users
call an explicit "prevailing feerates have changed" function now
that we have a timer method which is called regularly. Further, we
really should be the ones deciding on the channel feerate in terms
of the users' FeeEstimator, instead of requiring users implement a
second fee-providing interface by calling an update_fee method.

Finally, there is no reason for an update_fee method to be
channel-specific, as we should be updating all (outbound) channel
fees at once.

Thus, we move the update_fee handling to the background, calling it
on the regular 1-minute timer. We also update the regular 1-minute
timer to fire on startup as well as every minute to ensure we get
fee updates even on mobile clients that are rarely, if ever, open
for more than one minute.
2021-08-13 21:54:50 +00:00
Matt Corallo
767f12030b
Merge pull request #1019 from jkczyz/2021-07-shutdown-pubkey
Fetch shutdown script based on `commit_upfront_shutdown_pubkey`
2021-08-09 21:41:02 +00:00
Jeffrey Czyz
89fa27432a
Connect nodes in remaining tests
Similar to 2745bd5ac7, this ensures that
ChannelManager knows about the features its peers.
2021-08-09 15:55:26 -05:00
Matt Corallo
03537cc346
Merge pull request #1035 from TheBlueMatt/2021-08-faster-pings
Suggest faster ping in `PeerManager::timer_tick_occurred` docs
2021-08-09 18:52:25 +00:00
Matt Corallo
0f1a3b1698 Handle being asleep for more than double our ping time gracefully
If we've been asleep for double our ping time, for whatever reason,
disconnect all open sockets.
2021-08-09 18:11:19 +00:00
Matt Corallo
a00eec1865 Update lightning-background-processor to ping every five seconds
This updates lightning-background-processor calls to
PeerManager::timer_tick_occurred to match the new suggested rate in
the documentation.
2021-08-09 18:11:19 +00:00
Matt Corallo
5307b5e8ce Make BackgroundProcessor #[must_use] to avoid dropping immediately
It is easy for users to have a bug where they drop a
`BackgroundProcessor` immediately, causing it to start and then
immediately stop. Instead, add a `#[must_use]` tag to provide a
compiler warning for such instances.
2021-08-05 20:24:21 +00:00
Matt Corallo
3f229052ea Bump dependencies to bitcoin 0.27 and bech32 0.8 2021-07-31 18:29:07 +00:00
Jeffrey Czyz
e260cfcd9b
Add join method to BackgroundProcessor
The previous commit wraps the background thread's JoinHandle in an
Option. Providing a dedicated method to join hides this implementation
detail from users.
2021-07-28 16:30:51 -05:00
Jeffrey Czyz
4f05db6af8
Stop BackgroundProcessor's thread on drop
Without stopping the thread when BackgroundProcessor is dropped, it will
run free. In the context of language bindings, it is difficult to know
how long references held by the thread should live. Implement Drop to
stop the thread just as is done when explicitly calling stop().
2021-07-18 13:11:01 -05:00
Jeffrey Czyz
d9fa8f1c38
Correctly assert BackgroundProcessor error
The specific error from the ChannelManager persister is not asserted for
in test_persist_error. Rather, any error will do. Update the test to use
BackgroundProcessor::stop and assert for the expected value.
2021-07-18 12:59:27 -05:00
Matt Corallo
c9a8b26d58 Bump most crate versions to 0.0.99 and lightning-invoice to 0.7.0 2021-07-09 16:34:46 +00:00
Matt Corallo
c620944f16 Make the base fee configurable in ChannelConfig
Currently the base fee we apply is always the expected cost to
claim an HTLC on-chain in case of closure. This results in
significantly higher than market rate fees [1], and doesn't really
match the actual forwarding trust model anyway - as long as
channel counterparties are honest, our HTLCs shouldn't end up
on-chain no matter what the HTLC sender/recipient do.

While some users may wish to use a feerate that implies they will
not lose funds even if they go to chain (assuming no flood-and-loot
style attacks), they should do so by calculating fees themselves;
since they're already charging well above market-rate,
over-estimating some won't have a large impact.

Worse, we current re-calculate fees at forward-time, not based on
the fee we set in the channel_update. This means that the fees
others expect to pay us (and which they calculate their route based
on), is not what we actually want to charge, and that any attempt
to forward through us is inherently race-y.

This commit adds a configuration knob to set the base fee
explicitly, defaulting to 1 sat, which appears to be market-rate
today.

[1] Note that due to an msat-vs-sat bug we currently actually
    charge 1000x *less* than the calculated cost.
2021-07-09 00:50:30 +00:00
Matt Corallo
99938455f7
Merge pull request #949 from TheBlueMatt/2021-06-send-priv-update
Send channel_update messages to direct peers on private channels
2021-07-07 20:17:10 +00:00
Matt Corallo
e3968e0993 Send channel_update messages to direct peers on private channels
If we are a public node and have a private channel, our
counterparty needs to know the fees which we will charge to forward
payments to them. Without sending them a channel_update, they have
no way to learn that information, resulting in the channel being
effectively useless for outbound-from-us payments.

This commit fixes our lack of channel_update messages to private
channel counterparties, ensuring we always send them a
channel_update after the channel funding is confirmed.
2021-07-07 19:45:33 +00:00
Matt Corallo
da298e498f Expose the current best chain tip from ChannelManager + Monitors
Fixes #979
2021-07-06 00:18:27 +00:00
Matt Corallo
9c9081dfcb Bump versions to 0.0.98, lightning-invoice to 0.6.0 2021-06-08 21:08:29 +00:00
Matt Corallo
e60ccbb1a8 Delay DelayedPaymentOutput spendable events until the CSV delay 2021-06-01 22:32:56 +00:00
Matt Corallo
90e984e797 Track the blocks a node has connected in the TestBroadcaster 2021-05-28 23:56:44 +00:00
Jeffrey Czyz
f63fd83fd6
Process ChainMonitor events in the background 2021-05-25 00:28:59 -07:00
Jeffrey Czyz
501b54300c
Process ChannelManager events in the background 2021-05-25 00:28:58 -07:00
Jeffrey Czyz
7c465d69dc
Refactor EventsProvider to take an EventHandler 2021-05-24 14:16:16 -07:00
Matt Corallo
f551d5946b Bump versions to 0.0.14, lightning-invoice 0.5 2021-05-01 00:43:15 +00:00
Valentine Wallace
6f5d81631a
Make _test_utils depend on bitcoinconsensus feature 2021-04-29 18:39:47 -04:00
Matt Corallo
452b72078e Rename background-processor to lightning-... to match other crates 2021-04-15 15:23:05 -04:00