Commit graph

4315 commits

Author SHA1 Message Date
Matt Corallo
4d914b5b36
Merge pull request #1851 from TheBlueMatt/2022-11-fix-broken-futures-----again
Unset the needs-notify bit in a Notifier when a Future is fetched
2022-11-16 17:34:37 +00:00
Matt Corallo
a1404aac63 Accept feerate increases even if they aren't high enough for us
LND nodes have very broken fee estimators, causing them to suggest
feerates that don't even meet a current mempool minimum feerate
when fees go up over the course of hours. This can cause us to
reject their feerate estimates as they're not high enough, even
though their new feerate is higher than what we had already (which
is the feerate we'll use to broadcast a closing transaction). This
implies we force-close the channel and broadcast something with a
feerate lower than our counterparty was offering.

Here we simply accept such feerates as they are better than what we
had. We really should also close the channel, but only after we
get their signature on the new feerate. That should happen by
checking channel feerates every time we see a new block so is
orthogonal to this code.

Ultimately the fix is anchor outputs plus package-based relay in
Bitcoin Core, however we're still quite some ways from that, so
worth needlessly closing channels for now.
2022-11-16 03:54:00 +00:00
Matt Corallo
0a1e48f9c7 Await Future::poll Completed before unsetting notify-required
When we mark a future as complete, if the user is using the
`std::future::Future` impl to get notified, we shouldn't just
assume we have completed the `Future` when we call the `Waker`. A
`Future` may have been `drop`'d at that point (or may not be
`poll`'d again) even though we wake the `Waker`.

Because we now have a `callbacks_made` flag, we can fix this rather
trivially, simply not setting the flag until the `Future` is
`poll`'d `Complete`.
2022-11-16 00:21:43 +00:00
Matt Corallo
5f053e43af Wipe Notifier FutureState when returning from a waiter.
When we return from one of the wait functions in `Notifier`, we
should also ensure that the next `Future` doesn't start in the
`complete` state, as we have already notified the user, as far as
we're concerned.

This is technically a regression from the previous commit, but as
it is a logically separate change it is in its own commit.
2022-11-16 00:21:43 +00:00
Matt Corallo
7527e4b7df Unset the needs-notify bit in a Notifier when a Future is fetched
If a `Notifier` gets `notify()`ed and the a `Future` is fetched,
even though the `Future` is marked completed from the start and
the user may pass callbacks which are called, we'll never wipe the
needs-notify bit in the `Notifier`.

The solution is to keep track of the `FutureState` in the returned
`Future` even though its `complete` from the start, adding a new
flag in the `FutureState` which indicates callbacks have been made
and checking that flag when waiting or returning a second `Future`.
2022-11-16 00:21:43 +00:00
Matt Corallo
bcf8687301 Remove excess module
This appears to have been added with the intent of having a sealed
trait, which was never committed.
2022-11-16 00:21:41 +00:00
Matt Corallo
97b210dd97 Move restart-related tests to their own file 2022-11-15 22:38:12 +00:00
Matt Corallo
e359c40143 Replace manual node reloading with a macro/function in tests
Fixes #1696
2022-11-15 22:38:11 +00:00
Matt Corallo
8d8ee55463
Merge pull request #1790 from tnull/2022-10-inbound-user-channel-id-randomization
Randomize `user_channel_id` for inbound channels
2022-11-15 22:35:17 +00:00
Elias Rohrer
dc3ff5489a
Make user_channel_id a u128
We increase the `user_channel_id` type from `u64` to `u128`. In order to
maintain backwards compatibility, we have to de-/serialize it as two
separate `u64`s in `Event` as well as in the `Channel` itself.
2022-11-15 20:41:09 +01:00
Elias Rohrer
b2f8df0b61
Randomize user_channel_id for inbound channels
Previously, all inbound channels defaulted to a `user_channel_id` of 0,
which didn't allow for them being discerned on that basis. Here, we
simply randomize the identifier to fix this and enable the use of
`user_channel_id` as a true identifier for channels (assuming an equally
reasonable value is chosen for outbound channels and given upon
`create_channel()`).
2022-11-15 15:10:38 +01:00
Elias Rohrer
aa10f6464e
Introduce init_and_read_tlv_fields macro
We introduce a new macro that inits and reads tlv fields and DRY up
`impl_writeable_tlv_based` and other macros.
2022-11-15 15:10:23 +01:00
Matt Corallo
838d486983
Merge pull request #1845 from TheBlueMatt/2022-11-future-wake-fix
Fix persistence-required futures always completing instantly
2022-11-11 06:09:03 +00:00
Matt Corallo
49c9f1885d
Merge pull request #1806 from arik-so/2022-10-background-processor-deparametrization
Remove generic `Signer` parameter where it can be inferred from `KeysInterface`
2022-11-11 06:08:51 +00:00
Matt Corallo
f382f56cbb Fix persistence-required futures always completing instantly
After the first persistence-required `Future` wakeup, we'll always
complete additional futures instantly as we don't clear the
"need wake" bit. Instead, we need to just assume that if a future
was generated (and not immediately drop'd) that its sufficient to
notify the user.
2022-11-11 02:03:52 +00:00
Matt Corallo
593d8c4610
Merge pull request #1413 from ViktorTigerstrom/2022-04-default-to-bolt4-tlv-onions
Drop support for creating BOLT 4 Legacy onion format payloads
2022-11-11 00:49:45 +00:00
Viktor Tigerström
3ecc5aee4a Add test for only creating tlv format onions 2022-11-10 23:34:25 +01:00
Viktor Tigerström
f4e6d4a653 Remove OnionHopDataFormat::Legacy 2022-11-10 23:34:25 +01:00
Viktor Tigerström
7a50154d87 Update BOLT4 onion test vectors 2022-11-10 23:34:25 +01:00
Matt Corallo
2a3c99c7d0
Merge pull request #1787 from wpaulino/async-event-handler
Handle events asynchronously in the BackgroundProcessor's async variant
2022-11-10 21:51:16 +00:00
Wilmer Paulino
d3f1e25f65
Note async versions of event handling within EventsProvider 2022-11-10 11:00:02 -08:00
Wilmer Paulino
9787b28e89
Drop DecoratingEventHandler in favor of inline closure 2022-11-10 10:57:20 -08:00
Wilmer Paulino
8d20ebc376
Handle events asynchronously in the BackgroundProcessor's async variant 2022-11-10 10:57:16 -08:00
Wilmer Paulino
55b714c01d
Implement async versions of process_pending_events 2022-11-10 10:57:12 -08:00
Wilmer Paulino
05cb467234
Consume events by value in EventHandler's handle_event 2022-11-10 10:57:09 -08:00
Wilmer Paulino
f0059f5083
Use BaseEventHandler to expose async event handling on InvoicePayer
We introduce a new sealed trait BaseEventHandler that has a blanket
implementation for any T. Since the trait cannot be implemented outside
of the crate, this allow us to expose specific implementations of
InvoicePayer that allow for synchronous and asynchronous event handling.
2022-11-10 10:57:06 -08:00
Wilmer Paulino
b0d0f3d749
Apply network graph updates through NetworkUpdate's instead of Event's 2022-11-10 10:56:59 -08:00
valentinewallace
15b79f8fb5
Merge pull request #1844 from valentinewallace/2022-11-htlc-interception-refactor-followup
Rename `PendingHTLCInfo` fields to include msat suffix
2022-11-10 11:36:28 -05:00
Matt Corallo
384c4dc775
Merge pull request #1843 from TheBlueMatt/2022-11-fix-bp-exit-docs
Correct async `lightning-background-processor` exit check docs
2022-11-10 00:42:20 +00:00
Arik Sosman
1c8a06cf61
Remove generic Signer parameter where it can be inferred from KeysInterface 2022-11-09 16:15:11 -08:00
Matt Corallo
b6fce3d9cc
Merge pull request #1796 from tnull/2022-10-track-confirmation-block-hash
Track confirmation block hash and return via `Confirm::get_relevant_txids`
2022-11-09 20:24:10 +00:00
Valentine Wallace
246d33d99b
Rename PendingHTLCInfo fields to include msat suffix 2022-11-09 14:33:34 -05:00
Matt Corallo
97a6a6b2f8
Merge pull request #1842 from jkczyz/2022-11-channel-monitor-docs
Fix outdated `ChannelMonitor` docs
2022-11-09 19:16:00 +00:00
Matt Corallo
fcf73f0f45 Add a separate PaymentSendFailure for idempotency violation
When a user attempts to send a payment but it fails due to
idempotency key violation, they need to know that this was the
reason as they need to handle the error programmatically
differently from other errors.

Here we simply add a new `PaymentSendFailure` enum variant for
`DuplicatePayment` to allow for that.
2022-11-09 18:44:27 +00:00
Matt Corallo
c90aac26ad Rename PaymentSendFailure::AllFailedRetrySafe ...ResendSafe
It was pointed out that its quite confusing that
`AllFailedRetrySafe` does not allow you to call `retry_payment`,
though the documentation on it does specify this. Instead, we
simply rename it to `AllFailedResendSafe` to indicate that the
action that is safe to take is *resending*, not *retrying*.
2022-11-09 18:44:27 +00:00
Matt Corallo
71739dbe04 Correct async lightning-background-processor exit check docs
The check to stop the background processor is true -> break, not
false -> break. This simply updates the docs and leaves the code
as-is.
2022-11-09 18:39:51 +00:00
Matt Corallo
d03640082b
Merge pull request #1840 from valentinewallace/2022-11-htlc-intercept-prefactor
Pre-refactor for HTLC Interception
2022-11-09 17:48:55 +00:00
Jeffrey Czyz
d4c3e16556
Fix outdated ChannelMonitor docs
ChannelMonitor::get_and_clear_pending_events docs references a method
that had been refactored and is no longer accurate.
2022-11-09 11:19:00 -06:00
valentinewallace
30b9807b28
Merge pull request #1834 from dunxen/2022-11-expose-pending-monitor-updates
Add public method to list pending monitor updates from `ChainMonitor`
2022-11-09 11:15:06 -05:00
Elias Rohrer
9685d6c272
Track block hash, return via get_relevant_txids
Previously, `Confirm::get_relevant_txids()` only returned a list of
transactions that have to be monitored for reorganization out of the
chain. This interface however required double bookkeeping: while we
internally keep track of the best block, height, etc, it would also
require the user to keep track which transaction was previously
confirmed in which block and to take actions based on any change, e.g,
to reconfirm them when the block would be reorged-out and the
transactions had been reconfirmed in another block.

Here, we track the confirmation block hash internally and return it via
`Confirm::get_relevant_txids()` to the user, which alleviates the
requirement for double bookkeeping: the user can now simply check
whether the given transaction is still confirmed and in the given block,
and take action if not.

We also split `update_claims_view`: Previously it was one, now it's two
methods: `update_claims_view_from_matched_txn` and
`update_claims_view_from_requests`.
2022-11-09 11:12:35 +01:00
Duncan Dean
7f4ac0ea81
Add public method to list pending monitor updates from ChainMonitor
Users have requested the feature to list pending monitor updates from
`ChainMonitor` so this adds that.
2022-11-09 06:58:12 +02:00
Matt Corallo
f1428fdf12
Merge pull request #1719 from jkczyz/2022-09-offer-encoding
BOLT 12 `offer` encoding and building
2022-11-08 23:54:55 +00:00
Valentine Wallace
c7935497fc
Fix scid_utils::is_valid* false positive
cargo bench was able to find an scid of 0 as a valid fake scid
2022-11-08 16:02:07 -05:00
Valentine Wallace
203394ff94
Track incoming amount in PendingHTLCInfo
Used in upcoming commit(s) when we generate the PaymentIntercepted event for
intercepted payments.

Co-authored-by: John Cantrell <johncantrell97@gmail.com>
Co-authored-by: Valentine Wallace <vwallace@protonmail.com>
2022-11-08 15:51:10 -05:00
Valentine Wallace
b3d257d70f
Delete unnecessary whitespace in process_pending_forwards
Only whitespace diff
2022-11-08 15:48:53 -05:00
Valentine Wallace
582b827a4d
Refactor HTLCForwardInfo::AddHTLC for intercept forwards
In upcoming commit(s), we'll want to store intercepted HTLC forwards in
ChannelManager before the user signals that they should be forwarded.  It
wouldn't make sense to store a HTLCForwardInfo as-is because the FailHTLC
variant doesn't make sense, so we refactor out the ::AddHTLC contents into its
own struct for storage.

Co-authored-by: John Cantrell <johncantrell97@gmail.com>
Co-authored-by: Valentine Wallace <vwallace@protonmail.com>
2022-11-08 15:48:32 -05:00
Arik
554fc02ed2
Merge pull request #1833 from johncantrell97/2022-11-rgs-handle-removed-channel
Ignore RGS channel updates for unknown channels
2022-11-08 11:55:48 -08:00
Jeffrey Czyz
8ba09e068b
Builder for creating offers
Add a builder for creating offers given a required description and
node_id. Other settings are optional and duplicative settings will
override previous settings for non-Vec fields.
2022-11-08 13:18:15 -06:00
Matt Corallo
9363137603
Merge pull request #1837 from tnull/2022-10-fix-meeting-time
Fix LDK Dev Meeting time
2022-11-08 18:07:26 +00:00
Elias Rohrer
5412435ecd
Fix LDK Dev Meeting time and typo 2022-11-08 10:44:22 +01:00