]> git.bitcoin.ninja Git - rust-lightning/log
rust-lightning
16 months agoHandle monitor completion actions for closed channels
Matt Corallo [Tue, 4 Jul 2023 15:13:32 +0000 (15:13 +0000)]
Handle monitor completion actions for closed channels

If a channel has been closed, there may still be some
`ChannelMonitorUpdate`(s) which are pending completion. These
in-flight updates may also be blocking another channel from letting
an update fly, e.g. for forwarded payments where the payment
preimage will be removed from the downstream channel after the
upstream channel has closed.

Luckily all the infrastructure to handle this case is already in
place - we just need to process the
`monitor_update_blocked_actions` for closed channels.

16 months agoMerge pull request #2369 from TheBlueMatt/2023-06-mon-event-less-race
Wilmer Paulino [Mon, 10 Jul 2023 20:01:50 +0000 (13:01 -0700)]
Merge pull request #2369 from TheBlueMatt/2023-06-mon-event-less-race

Don't drop ChannelMonitor Events until they're processed

16 months agoDon't drop `ChannelMonitor` `Event`s until they're processed 2023-06-mon-event-less-race
Matt Corallo [Tue, 20 Jun 2023 22:52:27 +0000 (22:52 +0000)]
Don't drop `ChannelMonitor` `Event`s until they're processed

We currently assume the owner of `ChannelMonitor`s won't persist
the `ChannelMonitor` while `Event`s are being processed. This is
fine, except (a) its generally hard to do so and (b) the
`ChainMonitor` doesn't even do this.

Thus, in rare cases, a user could begin processing events which
are, generated by connecting a transaction or a new best-block,
take some time to do so, and while doing so process a further chain
event, causing persistece. This could lose the event being
processed alltogether, which could lose the user funds.

This should be very rare, but may have been made slightly more
reachable with (a) the async event processing making it more
common to do networking in event handling, (b) the new future
generation in the `ChainMonitor`, which now wakes the
`background-processor` directly when chain actions happen on the
`ChainMonitor`.

16 months agoMerge pull request #2364 from TheBlueMatt/2023-06-htlc-preimage-replay
Wilmer Paulino [Mon, 10 Jul 2023 16:27:57 +0000 (09:27 -0700)]
Merge pull request #2364 from TheBlueMatt/2023-06-htlc-preimage-replay

Re-claim forwarded HTLCs on startup

16 months agoMerge pull request #2307 from benthecarman/verify-funcs
Matt Corallo [Sat, 8 Jul 2023 22:04:06 +0000 (22:04 +0000)]
Merge pull request #2307 from benthecarman/verify-funcs

Add helper functions to verify node and channel annoucements

16 months agoMerge pull request #2042 from ffaex/add_fn
Matt Corallo [Sat, 8 Jul 2023 21:47:48 +0000 (21:47 +0000)]
Merge pull request #2042 from ffaex/add_fn

added fn_add_htlc

16 months agoMerge pull request #2396 from tnull/2023-07-fix-github-actions
Matt Corallo [Sat, 8 Jul 2023 20:46:26 +0000 (20:46 +0000)]
Merge pull request #2396 from tnull/2023-07-fix-github-actions

Update CI to remove deprecated actions

16 months agoAdd helper functions to verify node and channel annoucements
benthecarman [Thu, 18 May 2023 20:43:56 +0000 (15:43 -0500)]
Add helper functions to verify node and channel annoucements

Right now the only real way to verify the node and channel
announcements is to call `update_node_from_announcement`/
`update_channel_from_announcement`. If you want to do some
processing before you add to your network graph then you need to
manually verify the signature. This adds some nice helper functions
to make it easier.

I tried to do the same for channel update but it did not seem as
easy so figured that is fine to punt on since I don't see many
people doing manual things with channel updates.

16 months agoRename `ClosingMonitorUpdateRegeneratedOnStartup` to `Closed...` 2023-06-htlc-preimage-replay
Matt Corallo [Fri, 7 Jul 2023 15:01:05 +0000 (15:01 +0000)]
Rename `ClosingMonitorUpdateRegeneratedOnStartup` to `Closed...`

Now that we also use the "Closing" `BackgroundEvent` for
already-closed channels we need to rename it and tweak the docs.

16 months agoRe-claim forwarded HTLCs on startup
Matt Corallo [Thu, 4 May 2023 21:51:18 +0000 (21:51 +0000)]
Re-claim forwarded HTLCs on startup

Because `ChannelMonitorUpdate`s can complete asynchronously and
out-of-order now, a `commitment_signed` `ChannelMonitorUpdate` from
a downstream channel could complete prior to the preimage
`ChannelMonitorUpdate` on the upstream channel. In that case, we may
not get a `update_fulfill_htlc` replay on startup. Thus, we have to
ensure any payment preimages contained in that downstream update are
re-claimed on startup.

Here we do this during the existing walk of the `ChannelMonitor`
preimages for closed channels.

16 months agoMerge pull request #2354 from alecchendev/2023-06-bump-default-dust-exp
Matt Corallo [Sat, 8 Jul 2023 02:15:10 +0000 (02:15 +0000)]
Merge pull request #2354 from alecchendev/2023-06-bump-default-dust-exp

Bump dust exposure threshold

16 months agoMerge pull request #2347 from henghonglee/issue-2304
Matt Corallo [Fri, 7 Jul 2023 21:21:09 +0000 (21:21 +0000)]
Merge pull request #2347 from henghonglee/issue-2304

Expose whether a channel is closing in ChannelDetails

16 months agoUse multiplier in dust exposure threshold calculation
Alec Chen [Thu, 6 Jul 2023 22:46:48 +0000 (17:46 -0500)]
Use multiplier in dust exposure threshold calculation

This commit makes use of the added enum to calculate the dust
exposure threshold based on the current fee rate. This also updates
tests to ensure it works as intended.

16 months agoSend fee estimator through to `get_max_htlc_dust_exposure_threshold`
Alec Chen [Tue, 20 Jun 2023 22:33:43 +0000 (17:33 -0500)]
Send fee estimator through to `get_max_htlc_dust_exposure_threshold`

16 months agoAdd max dust exposure multiplier config knob
Alec Chen [Mon, 19 Jun 2023 02:53:43 +0000 (21:53 -0500)]
Add max dust exposure multiplier config knob

With fee rates rising dramatically in mid-April 2023, thresholds for
what is considered dust have risen, often exceeding our previous dust
exposure threshold of 5k sats. This causes all payments and HTLC
forwards between 5k sats and new dust thresholds to fail.

This commit changes our max dust exposure config knob from a fixed
upper limit to a `MaxDustHTLCExposure` enum with an additional variant
to allow setting our max dust exposure to a multiplier on the current
high priority feerate.

To remain backwards compatible we'll always write the fixed limit if
it's set, or its default value in its currently reserved TLV.

We also now write an odd TLV for the new enum, so that previous
versions can safely ignore it upon downgrading, while allowing us to
make use of the new type when it's written.

16 months agoMerge pull request #2392 from TheBlueMatt/2023-07-async-mon-even-tlv
valentinewallace [Fri, 7 Jul 2023 15:45:55 +0000 (11:45 -0400)]
Merge pull request #2392 from TheBlueMatt/2023-07-async-mon-even-tlv

Move Channel's blocked monitor updates vec to an even TLV

16 months agoMerge pull request #2399 from tnull/2023-07-expose-default-message-router
valentinewallace [Fri, 7 Jul 2023 15:39:01 +0000 (11:39 -0400)]
Merge pull request #2399 from tnull/2023-07-expose-default-message-router

Expose `DefaultMessageRouter`

16 months agoExpose `DefaultMessageRouter`
Elias Rohrer [Fri, 7 Jul 2023 13:08:01 +0000 (15:08 +0200)]
Expose `DefaultMessageRouter`

16 months agoMerge pull request #2383 from henghonglee/fix-dyn
Matt Corallo [Thu, 6 Jul 2023 17:53:54 +0000 (17:53 +0000)]
Merge pull request #2383 from henghonglee/fix-dyn

Fix DefaultRouter type restrained to only MutexGuard

16 months agoUpdate Github Actions to remove deprecated actions
Elias Rohrer [Thu, 6 Jul 2023 12:30:31 +0000 (14:30 +0200)]
Update Github Actions to remove deprecated actions

16 months agoAdd ChannelShutdownState to ChannelDetails
henghonglee [Tue, 27 Jun 2023 16:54:15 +0000 (00:54 +0800)]
Add ChannelShutdownState to ChannelDetails

This commit adds the state of channel shutdown to channeldetails

16 months agoMove Channel's blocked monitor updates vec to an even TLV 2023-07-async-mon-even-tlv
Matt Corallo [Wed, 5 Jul 2023 17:20:48 +0000 (17:20 +0000)]
Move Channel's blocked monitor updates vec to an even TLV

In 9dfe42cf8681afc9c3f84e0c85a4e2a30c1156a8,
`ChannelMonitorUpdate`s were stored in `Channel` while they were
being processed. Because it was possible (though highly unlikely,
due to various locking likely blocking persistence) an update was
in-flight (even synchronously) when a `ChannelManager` was
persisted, the new updates were persisted via an odd TLV.

However, in 4041f0899f86eaf6a0a4576a91918fa54026ac46 these pending
monitor updates were moved to `ChannelManager`, with appropriate
handling there. Now the only `ChannelMonitorUpdate`s which are
stored in `Channel` are those which are explicitly blocked, which
requires the async pipeline.

Because we don't support async monitor update users downgrading to
0.0.115 or lower, we move to persisting them via an even TLV. As
the odd TLV storage has not yet been released, we can do so
trivially.

Fixes #2317.

16 months agoFix DefaultRouter type restrained to only MutexGuard
henghonglee [Thu, 29 Jun 2023 02:41:38 +0000 (10:41 +0800)]
Fix DefaultRouter type restrained to only MutexGuard

Type of DerefMut for DefaultRouter was specialized to only MutexGuard.
It should be generic around RefMut and MutexGuard. This commit fixes that

16 months agoMerge pull request #2384 from jkczyz/2023-06-message-router
Matt Corallo [Sun, 2 Jul 2023 20:11:18 +0000 (20:11 +0000)]
Merge pull request #2384 from jkczyz/2023-06-message-router

Define a default `MessageRouter` implementation

16 months agoMerge pull request #2375 from TonyGiorgio/remove-doc-future-anchor-support
Matt Corallo [Sun, 2 Jul 2023 20:10:10 +0000 (20:10 +0000)]
Merge pull request #2375 from TonyGiorgio/remove-doc-future-anchor-support

Remove doc specifying future anchor support

16 months agoDefine a default MessageRouter implementation
Jeffrey Czyz [Sun, 25 Jun 2023 19:26:17 +0000 (14:26 -0500)]
Define a default MessageRouter implementation

Otherwise, users need to define one when using "Simple" type aliases.

16 months agoMerge pull request #2386 from TheBlueMatt/2023-06-macos-msrv
Wilmer Paulino [Fri, 30 Jun 2023 14:12:00 +0000 (07:12 -0700)]
Merge pull request #2386 from TheBlueMatt/2023-06-macos-msrv

Fix 1.54- builds with the `backtrace` feature due to MSRV breakage

16 months agoFix 1.54- builds with the `backtrace` feature due to MSRV breakage 2023-06-macos-msrv
Matt Corallo [Fri, 30 Jun 2023 03:10:29 +0000 (03:10 +0000)]
Fix 1.54- builds with the `backtrace` feature due to MSRV breakage

The test-only `backtrace` feature broke on rustc prior to 1.55.

16 months agoClarify event doc specifying anchor support
Tony Giorgio [Sun, 25 Jun 2023 02:20:50 +0000 (21:20 -0500)]
Clarify event doc specifying anchor support

16 months agoMerge pull request #2322 from andrei-21/fix/instant-overflow
Matt Corallo [Thu, 29 Jun 2023 21:05:39 +0000 (21:05 +0000)]
Merge pull request #2322 from andrei-21/fix/instant-overflow

16 months agoMerge pull request #2372 from wpaulino/channelmanager-new-highest-seen-timestamp
Matt Corallo [Thu, 29 Jun 2023 04:15:46 +0000 (04:15 +0000)]
Merge pull request #2372 from wpaulino/channelmanager-new-highest-seen-timestamp

Require best block timestamp within ChannelManager::new

16 months agoUse `MonotonicTime` as `Instant` shifted by 10 years forward
Andrei [Thu, 29 Jun 2023 00:00:00 +0000 (00:00 +0000)]
Use `MonotonicTime` as `Instant` shifted by 10 years forward

Such implementation allows `MonotonicTime` to go backward up to 10
years on all platforms. On some platforms (e.g. iOS) `Instant` is
represented as `u64` of nanoseconds since the boot of the system.
Obviously such implementation does not allow to go backward before the
time of the boot.

Co-authored-by: Andrei <andrei.i@posteo.de>
Co-authored-by: Jeffrey Czyz <jkczyz@gmail.com>
16 months agoRequire best block timestamp within ChannelManager::new
Wilmer Paulino [Thu, 22 Jun 2023 22:19:15 +0000 (15:19 -0700)]
Require best block timestamp within ChannelManager::new

This ensures freshly initialized nodes can proceed to create unexpired
invoices without a call to `best_block_updated`, since an invoice's
expiration delta is applied to `highest_seen_timestamp`.

16 months agoSome minor comment/doc tweaks in new monitor update blocking code
Matt Corallo [Wed, 31 May 2023 22:51:49 +0000 (22:51 +0000)]
Some minor comment/doc tweaks in new monitor update blocking code

A few nits that came up in review to make the docs clearer, but not
anything super critical.

16 months agoMerge pull request #2374 from arik-so/2023-06-build-warning-fixes
Matt Corallo [Tue, 27 Jun 2023 14:32:25 +0000 (14:32 +0000)]
Merge pull request #2374 from arik-so/2023-06-build-warning-fixes

Fix build warnings

16 months agoFix clone warning on nightly.
Arik Sosman [Mon, 26 Jun 2023 14:17:18 +0000 (10:17 -0400)]
Fix clone warning on nightly.

16 months agoRemove redundant `mut`s in router.rs.
Arik Sosman [Sat, 24 Jun 2023 17:54:14 +0000 (10:54 -0700)]
Remove redundant `mut`s in router.rs.

16 months agoFix warning about deserialization marker.
Arik Sosman [Sat, 24 Jun 2023 05:35:14 +0000 (22:35 -0700)]
Fix warning about deserialization marker.

Specifically, the legacy deserialization
prevention marker variable was not being
read.

16 months agoFix build warning about HTLCSource::dummy().
Arik Sosman [Sat, 24 Jun 2023 05:34:14 +0000 (22:34 -0700)]
Fix build warning about HTLCSource::dummy().

16 months agoFix build warning about public_from_secret_hex.
Arik Sosman [Sat, 24 Jun 2023 05:33:55 +0000 (22:33 -0700)]
Fix build warning about public_from_secret_hex.

16 months agoMerge pull request #2368 from wpaulino/inbound-anchors-manual-acceptance v0.0.116-alpha1
Matt Corallo [Sat, 24 Jun 2023 15:44:46 +0000 (15:44 +0000)]
Merge pull request #2368 from wpaulino/inbound-anchors-manual-acceptance

Require inbound channels with anchor outputs to be accepted manually

17 months agoMerge pull request #2367 from wpaulino/remove-anchors-flag
Wilmer Paulino [Fri, 23 Jun 2023 23:17:48 +0000 (16:17 -0700)]
Merge pull request #2367 from wpaulino/remove-anchors-flag

Remove anchors config flag

17 months agoRequire inbound channels with anchor outputs to be accepted manually
Wilmer Paulino [Tue, 20 Jun 2023 19:14:48 +0000 (12:14 -0700)]
Require inbound channels with anchor outputs to be accepted manually

Since the use of channels with anchor outputs requires a reserve of
onchain funds to handle channel force closures, it would be
irresponsible to allow a node to accept inbound channel without first
consulting such reserves. To allow users to do so, we require such
channels be manually accepted.

17 months agoMerge pull request #2373 from TheBlueMatt/2023-06-116-alpha
Matt Corallo [Fri, 23 Jun 2023 22:38:47 +0000 (22:38 +0000)]
Merge pull request #2373 from TheBlueMatt/2023-06-116-alpha

17 months agoSupport manual inbound acceptance in channel creation test utils
Wilmer Paulino [Tue, 20 Jun 2023 19:11:44 +0000 (12:11 -0700)]
Support manual inbound acceptance in channel creation test utils

17 months agoMerge pull request #2362 from TheBlueMatt/2023-06-unblocked-mons-in-manager
Matt Corallo [Fri, 23 Jun 2023 20:46:26 +0000 (20:46 +0000)]
Merge pull request #2362 from TheBlueMatt/2023-06-unblocked-mons-in-manager

Move in-flight ChannelMonitorUpdates to ChannelManager

17 months agoRemove anchors config flag
Wilmer Paulino [Tue, 20 Jun 2023 18:29:00 +0000 (11:29 -0700)]
Remove anchors config flag

Now that all of the core functionality for anchor outputs has landed,
we're ready to remove the config flag that was temporarily hiding it
from our API.

17 months agoBump versions to LDK 116-alpha1 and invoice 24.0-alpha1 2023-06-116-alpha
Matt Corallo [Fri, 23 Jun 2023 19:42:08 +0000 (19:42 +0000)]
Bump versions to LDK 116-alpha1 and invoice 24.0-alpha1

17 months agoRename `Channel::pending_monitor_updates` to `blocked` 2023-06-unblocked-mons-in-manager
Matt Corallo [Tue, 20 Jun 2023 23:27:55 +0000 (23:27 +0000)]
Rename `Channel::pending_monitor_updates` to `blocked`

To differentiate between in-flight pending completion and blocked
updates.

17 months agoRename Channel's latest-monitor-update fetch method for clarity
Matt Corallo [Tue, 20 Jun 2023 02:16:03 +0000 (02:16 +0000)]
Rename Channel's latest-monitor-update fetch method for clarity

`Channel::get_latest_complete_monitor_update_id` no longer refers
to complete updates, but rather ones which were passed to the
`ChannelManager` and which the `CHannel` no longer knows about.
Thus, we rename it `get_latest_unblocked_monitor_update_id`.

17 months agoRemove the `blocked` param on `ChannelMonitorUpdates` in `Channel`
Matt Corallo [Mon, 19 Jun 2023 06:31:43 +0000 (06:31 +0000)]
Remove the `blocked` param on `ChannelMonitorUpdates` in `Channel`

Now that all `ChannelMonitorUpdate`s stored in `Channel` are
blocked we don't need a bool to track it.

17 months agoDrop the now-unused update_id param to monitor update macros
Matt Corallo [Mon, 19 Jun 2023 05:35:34 +0000 (05:35 +0000)]
Drop the now-unused update_id param to monitor update macros

17 months agoMove in-flight `ChannelMonitorUpdate`s to `ChannelManager`
Matt Corallo [Mon, 19 Jun 2023 06:26:39 +0000 (06:26 +0000)]
Move in-flight `ChannelMonitorUpdate`s to `ChannelManager`

Because `ChannelMonitorUpdate`s can be generated for a
channel which is already closed, and must still be tracked
through their completion, storing them in a `Channel`
doesn't make sense - we'd have to have a redundant place to
put them post-closure and handle both storage locations
equivalently.

Instead, here, we move to storing in-flight
`ChannelMonitorUpdate`s to the `ChannelManager`, leaving
blocked `ChannelMonitorUpdate`s in the `Channel` as they
were.

17 months agoMerge pull request #2361 from arik-so/2023-06-anchor-channel-type-features
Matt Corallo [Fri, 23 Jun 2023 19:12:15 +0000 (19:12 +0000)]
Merge pull request #2361 from arik-so/2023-06-anchor-channel-type-features

Replace `opt_anchors` with `ChannelTypeFeatures`

17 months agoSync `ChannelTransactionParameters` features to `ChannelContext`.
Arik Sosman [Wed, 21 Jun 2023 23:41:09 +0000 (16:41 -0700)]
Sync `ChannelTransactionParameters` features to `ChannelContext`.

17 months agoVerify channel type features for decoding.
Arik Sosman [Tue, 20 Jun 2023 20:17:28 +0000 (13:17 -0700)]
Verify channel type features for decoding.

17 months agoReplace `opt_anchors` with `ChannelTypeFeatures`
Arik Sosman [Mon, 19 Jun 2023 17:30:34 +0000 (10:30 -0700)]
Replace `opt_anchors` with `ChannelTypeFeatures`

This change modifies six structs that were keeping
track of anchors features with an `opt_anchors` field,
as well as another field keeping track of nonzero-fee-
anchor-support.

17 months agoMerge pull request #2365 from TheBlueMatt/2023-06-fix-fuzz-dep
valentinewallace [Thu, 22 Jun 2023 22:49:09 +0000 (18:49 -0400)]
Merge pull request #2365 from TheBlueMatt/2023-06-fix-fuzz-dep

Ensure we build if a downstream crate sets `--cfg=fuzzing`

17 months agoMethod for `ChannelTypeFeatures` serialization compatibility.
Arik Sosman [Wed, 21 Jun 2023 23:12:45 +0000 (16:12 -0700)]
Method for `ChannelTypeFeatures` serialization compatibility.

17 months agoDefine `ChannelTypeFeatures` methods for anchors logic.
Arik Sosman [Mon, 19 Jun 2023 17:28:36 +0000 (10:28 -0700)]
Define `ChannelTypeFeatures` methods for anchors logic.

Specifically, introduce a new constructor for an anchors-
supporting feature set, as well as methods that will
maintain forwards-compatible deserialization in older
versions.

17 months agoReference-rhs bitwise operations for features.
Arik Sosman [Thu, 22 Jun 2023 21:14:02 +0000 (14:14 -0700)]
Reference-rhs bitwise operations for features.

17 months agoDocument nonzero anchors in features module.
Arik Sosman [Thu, 22 Jun 2023 22:22:40 +0000 (15:22 -0700)]
Document nonzero anchors in features module.

17 months agoIntroduce nonzero fee anchors feature.
Arik Sosman [Mon, 19 Jun 2023 17:25:01 +0000 (10:25 -0700)]
Introduce nonzero fee anchors feature.

17 months agoSimplify cases in `handle_new_monitor_update` macro
Matt Corallo [Sun, 18 Jun 2023 23:56:16 +0000 (23:56 +0000)]
Simplify cases in `handle_new_monitor_update` macro

By giving up on a tiny bit of parallelism and tweaking the return
types, we can make the `handle_new_monitor_update` macro a bit
clearer - now the only cases where its called after a monitor was
updated was when the monitor was initially committed.

17 months agoDrop the now-unused `push_blockable_mon_update`
Matt Corallo [Sun, 18 Jun 2023 23:18:34 +0000 (23:18 +0000)]
Drop the now-unused `push_blockable_mon_update`

17 months agoMove most `handle_new_monitor_update` calls to pass the update
Matt Corallo [Sun, 18 Jun 2023 21:55:30 +0000 (21:55 +0000)]
Move most `handle_new_monitor_update` calls to pass the update

Most of the calls to the `handle_new_monitor_update` macro had the
exact same pattern - calling `update_monitor` followed by the
macro. Given that common pattern will grow to first pushing the
new monitor onto an in-flight set and then calling `update_monitor`
unifying the pattern into a single macro now avoids more code churn
in the coming commits.

17 months agoReturn owned `ChannelMonitorUpdate`s from `Channel`
Matt Corallo [Sun, 18 Jun 2023 21:18:03 +0000 (21:18 +0000)]
Return owned `ChannelMonitorUpdate`s from `Channel`

In the coming commits we'll move to storing in-flight
`ChannelMonitorUpdate`s in the `ChannelManager` rather in the
`Channel` (which will then only retain `ChannelMonitorUpdate`s
which have not yet been released/are blocked.

This will simplify handling of pending `ChannelMonitorUpdate` after
a channel has closed by not having to move them into the
`ChannelManager`.

17 months agoMerge pull request #2319 from valentinewallace/2023-05-forward-less-than-onion
Elias Rohrer [Wed, 21 Jun 2023 07:25:07 +0000 (09:25 +0200)]
Merge pull request #2319 from valentinewallace/2023-05-forward-less-than-onion

Allow forwarding less than the amount in the onion

17 months agoEnsure we build if a downstream crate sets `--cfg=fuzzing` 2023-06-fix-fuzz-dep
Matt Corallo [Tue, 20 Jun 2023 17:14:21 +0000 (17:14 +0000)]
Ensure we build if a downstream crate sets `--cfg=fuzzing`

Downstream crates building fur fuzzing will usually set
`--cfg=fuzzing` as a side-effect of the Rust fuzzing tooling. Thus,
we should ensure we build without failure in such cases.

We do this here by simply relying on the `_test_utils` feature,
rather than conditionally-compiling in modules based on the
`fuzzing` flag.

17 months agoDocument on claim events that amount_msat may be > invoice amount
Valentine Wallace [Thu, 15 Jun 2023 19:59:04 +0000 (15:59 -0400)]
Document on claim events that amount_msat may be > invoice amount

17 months agoCheck UpdateAddHTLC::skimmed_fee_msat on receive
Valentine Wallace [Wed, 24 May 2023 23:21:21 +0000 (19:21 -0400)]
Check UpdateAddHTLC::skimmed_fee_msat on receive

Make sure the penultimate hop took the amount of fee that they claimed to take.
Without checking this TLV, we're heavily relying on the receiving wallet code
to correctly implement logic to calculate that that the fee is as expected.

17 months agoSet UpdateAddHTLC::skimmed_fee_msat on forward
Valentine Wallace [Wed, 24 May 2023 23:15:25 +0000 (19:15 -0400)]
Set UpdateAddHTLC::skimmed_fee_msat on forward

So the receiver can verify it and approve underpaying HTLCs (see
ChannelConfig::accept_underpaying_htlcs).

17 months agoPersist update_add sender skimmed fee in Channel
Valentine Wallace [Fri, 9 Jun 2023 11:42:07 +0000 (13:42 +0200)]
Persist update_add sender skimmed fee in Channel

17 months agoTrack the sender's skimmed fee in UpdateAddHTLC
Valentine Wallace [Thu, 25 May 2023 13:57:16 +0000 (09:57 -0400)]
Track the sender's skimmed fee in UpdateAddHTLC

17 months agoAllow receiving less than the onion claims to pay
Valentine Wallace [Wed, 24 May 2023 15:53:05 +0000 (11:53 -0400)]
Allow receiving less than the onion claims to pay

Useful for penultimate hops in routes to take an extra fee, if for example they
opened a JIT channel to the payee and want them to help bear the channel open
cost.

17 months agoAdd PaymentClaimable::counterparty_skimmed_fee_msat
Valentine Wallace [Tue, 16 May 2023 20:14:40 +0000 (16:14 -0400)]
Add PaymentClaimable::counterparty_skimmed_fee_msat

See its docs

17 months agoPersist counterparty skimmed fee in ClaimableHTLC
Valentine Wallace [Thu, 15 Jun 2023 16:54:58 +0000 (12:54 -0400)]
Persist counterparty skimmed fee in ClaimableHTLC

Used to get an accurate skimmed fee in the resulting PaymentClaimable event.

17 months agoSet extra skimmed fee on intercepted forward
Valentine Wallace [Thu, 15 Jun 2023 16:37:21 +0000 (12:37 -0400)]
Set extra skimmed fee on intercepted forward

Receivers need to use this value to verify incoming payments if
ChannelConfig::accept_underpaying_htlcs is set.

17 months agoAdd config knob for accepting underpaying HTLCs
Valentine Wallace [Tue, 16 May 2023 18:18:47 +0000 (14:18 -0400)]
Add config knob for accepting underpaying HTLCs

See ChannelConfig::accept_underpaying_htlcs

17 months agoMove next hop packet pubkey calculation to outside channel lock
Valentine Wallace [Tue, 20 Jun 2023 21:40:12 +0000 (17:40 -0400)]
Move next hop packet pubkey calculation to outside channel lock

17 months agoMove PendingHTLCStatus construction inside channel lock
Valentine Wallace [Tue, 16 May 2023 20:14:40 +0000 (16:14 -0400)]
Move PendingHTLCStatus construction inside channel lock

We need the channel lock for constructing a pending HTLC's status because we
need to know if the channel accepts underpaying HTLCs in upcoming commits.

17 months agoMerge pull request #2120 from valentinewallace/2023-03-blinded-pathfinding
Matt Corallo [Tue, 20 Jun 2023 15:51:59 +0000 (15:51 +0000)]
Merge pull request #2120 from valentinewallace/2023-03-blinded-pathfinding

17 months agoMerge pull request #2089 from wpaulino/bump-transaction-event-handler
Matt Corallo [Mon, 19 Jun 2023 22:45:54 +0000 (22:45 +0000)]
Merge pull request #2089 from wpaulino/bump-transaction-event-handler

Add BumpTransaction event handler

17 months agoProvide a default CoinSelectionSource implementation via a new trait
Wilmer Paulino [Thu, 27 Apr 2023 00:44:49 +0000 (17:44 -0700)]
Provide a default CoinSelectionSource implementation via a new trait

Certain users may not care how their UTXOs are selected, or their wallet
may not expose enough controls to fully implement the
`CoinSelectionSource` trait. As an alternative, we introduce another
trait `WalletSource` they could opt to implement instead, which is much
simpler as it just returns the set of confirmed UTXOs that may be used.
This trait implementation is then consumed into a wrapper `Wallet` which
implements the `CoinSelectionSource` trait using a "smallest
above-dust-after-spend first" coin selection algorithm.

17 months agoAdd BumpTransaction event handler
Wilmer Paulino [Thu, 27 Apr 2023 00:42:35 +0000 (17:42 -0700)]
Add BumpTransaction event handler

This allows users to bump their commitments and HTLC transactions
without having to worry about all the little details to do so. Instead,
we'll just require that they implement the `CoinSelectionSource` trait
over their wallet/UTXO source, granting the event handler permission to
spend confirmed UTXOs for the transactions it'll produce.

While the event handler should in most cases produce valid transactions,
assuming the provided confirmed UTXOs are valid, it may not produce
relayable transactions due to not satisfying certain Replace-By-Fee
(RBF) mempool policy requirements. Some of these require that the
replacement transactions have a higher feerate and absolute fee than the
conflicting transactions it aims to replace. To make sure we adhere to
these requirements, we'd have to persist some state for all transactions
the event handler has produced, greatly increasing its complexity. While
we may consider implementing so in the future, we choose to go with a
simple initial version that relies on the OnchainTxHandler's bumping
frequency. For each new bumping attempt, the OnchainTxHandler proposes a
25% feerate increase to ensure transactions can propagate under
constrained mempool circumstances.

17 months agoExpose ClaimId for each claim bump in BumpTransactionEvent
Wilmer Paulino [Thu, 11 May 2023 20:50:46 +0000 (13:50 -0700)]
Expose ClaimId for each claim bump in BumpTransactionEvent

17 months agoExpose existing PackageID to API and rename to ClaimId
Wilmer Paulino [Thu, 11 May 2023 20:49:00 +0000 (13:49 -0700)]
Expose existing PackageID to API and rename to ClaimId

In a future commit, we plan to expand `BumpTransactionEvent` variants to
include the unique identifier assigned to pending output claims by the
`OnchainTxHandler` when a commitment is broadcast/confirmed. This
requires making it public in our API. We also choose to rename it to
`ClaimId` for the benefit of users, as the previous `PackageID` term
could be interpreted to be the ID of a BIP-331 transaction package.

17 months agoChange package ID computation for HTLC claims on anchor channels
Wilmer Paulino [Thu, 11 May 2023 22:39:13 +0000 (15:39 -0700)]
Change package ID computation for HTLC claims on anchor channels

While the previous way of computing the identifier was safe, it wouldn't
have been in certain scenarios if we considered splitting aggregated
packages. While this type of splitting has yet to be implemented, it may
come in the near future. To ensure we're prepared to handle such, we
opt to instead commit to all of the HTLCs to claim in the request.

17 months agoImplement routing to blinded payment paths
Valentine Wallace [Wed, 14 Jun 2023 22:14:29 +0000 (18:14 -0400)]
Implement routing to blinded payment paths

Sending to them is still disallowed, for now.

17 months agoRouter: clean up Path construction
Valentine Wallace [Thu, 15 Jun 2023 13:48:31 +0000 (09:48 -0400)]
Router: clean up Path construction

We don't need to collect a vec of Results anymore.

17 months agoAdd CandidateRouteHop::Blinded and ::OneHopBlinded variant
Valentine Wallace [Tue, 13 Jun 2023 23:37:53 +0000 (19:37 -0400)]
Add CandidateRouteHop::Blinded and ::OneHopBlinded variant

It's unclear what values 1-hop blinded paths should set their BlindedPayInfos
to, because those values are meant to refer to the fees/cltv delta on the path
*between* the intro node and the destination. We zero out these values in the
new variant's methods so they don't mess with path finding/construction.

17 months agoUpdate CandidateRouteHop::short_channel_id to be optional
Valentine Wallace [Tue, 13 Jun 2023 23:36:12 +0000 (19:36 -0400)]
Update CandidateRouteHop::short_channel_id to be optional

17 months agoMerge pull request #2351 from TheBlueMatt/2023-04-remove-legacy-recv
Matt Corallo [Sat, 17 Jun 2023 18:38:25 +0000 (18:38 +0000)]
Merge pull request #2351 from TheBlueMatt/2023-04-remove-legacy-recv

Drop `create_inbound_payment*_legacy` breaking downgrade to 0.0.103

17 months agoRouting: accommodate for blinded paths in used liquidity tracking
Valentine Wallace [Tue, 13 Jun 2023 21:47:36 +0000 (17:47 -0400)]
Routing: accommodate for blinded paths in used liquidity tracking

17 months agoReplace max_channel_saturation_power_of_half hardcode with const
Valentine Wallace [Wed, 14 Jun 2023 22:36:48 +0000 (18:36 -0400)]
Replace max_channel_saturation_power_of_half hardcode with const

17 months agoAdd utils for creating blinded PaymentParameters
Valentine Wallace [Fri, 19 May 2023 21:37:58 +0000 (17:37 -0400)]
Add utils for creating blinded PaymentParameters

17 months agoReverse (BlindedPath, BlindedPayInfo) tuple order in offers invoice.
Valentine Wallace [Fri, 16 Jun 2023 13:45:04 +0000 (09:45 -0400)]
Reverse (BlindedPath, BlindedPayInfo) tuple order in offers invoice.

To make it uniform with PaymentParameters' Payee::Blinded::route_hints.

17 months agoMerge pull request #2077 from dunxen/2023-02-splitchannelstate
Matt Corallo [Fri, 16 Jun 2023 06:01:10 +0000 (06:01 +0000)]
Merge pull request #2077 from dunxen/2023-02-splitchannelstate

Split prefunded `Channel` into `Inbound`/`Outbound` channels

17 months agoRename `inbound_is_awaiting_accept()` to `is_awaiting_accept()`
Duncan Dean [Tue, 13 Jun 2023 15:17:59 +0000 (17:17 +0200)]
Rename `inbound_is_awaiting_accept()` to `is_awaiting_accept()`

17 months agoRename `InboundV1Channel::new_from_req` to `InboundV1Channel::new`
Duncan Dean [Wed, 7 Jun 2023 18:49:26 +0000 (20:49 +0200)]
Rename `InboundV1Channel::new_from_req` to `InboundV1Channel::new`