Commit graph

3524 commits

Author SHA1 Message Date
Duncan Dean
637e03a3de
Move inbound channel methods into InboundV1Channel's impl 2023-06-15 22:31:37 +02:00
Duncan Dean
4a0cd5cf55
Move outbound channel methods into OutboundV1Channel's impl 2023-06-15 22:20:14 +02:00
Duncan Dean
4b1e2865cf
Create and use methods for counting channels
This commit also adds two new maps to `PeerState` for keeping track
of `OutboundV1Channel`s and `InboundV1Channel`s so that further
commits are a bit easier to review.
2023-06-15 12:55:40 +02:00
Duncan Dean
4ad67cfe18
Refactor channel map update macros for use with ChannelContext 2023-06-15 12:55:37 +02:00
Duncan Dean
2ea27e02cd
Move Channel::force_shutdown to ChannelContext impl 2023-06-15 12:51:45 +02:00
Duncan Dean
baadeb7374
Move inbound channel constructor into InboundV1Channel impl 2023-06-15 12:51:44 +02:00
Duncan Dean
e6c2f04f15
Move outbound channel constructor into OutboundV1Channel impl 2023-06-15 12:51:43 +02:00
Duncan Dean
883e0566ef
Introduce InboundV1Channel & OutboundV1Channel 2023-06-15 12:51:34 +02:00
Duncan Dean
10125269d2
Move channel constants up 2023-06-14 16:04:30 +02:00
Duncan Dean
e3f0c55182
Make ChannelManager::issue_channel_close_events take a ChannelContext 2023-06-14 16:04:28 +02:00
Duncan Dean
25c1ad8e19
Convert ChannelDetails::from_channel to ChannelDetails::from_channel_context
This rename and refactor is so that we can get channel details from a
`ChannelContext` which is a common object to all channels.
2023-06-14 16:04:27 +02:00
Duncan Dean
60706d6338
Move Channel::get_available_balances to ChannelContext impl 2023-06-14 16:04:26 +02:00
Duncan Dean
9f4e71452a
Move Channel::next_*_commit_tx_fee_msat methods to ChannelContext impl 2023-06-14 16:04:25 +02:00
Duncan Dean
08ee72be9d
Move Channel::commit_tx_fee_msat to file-level utilities 2023-06-14 16:04:24 +02:00
Duncan Dean
ed6a5bb151
Move Channel::get_*_pending_htlc_stats to ChannelContext impl 2023-06-14 16:04:23 +02:00
Duncan Dean
2774aa26d9
Prepare some methods for upcoming moves to ChannelContext
To reduce interleaving in commits, we introduce a `context` variable
in methods to be moved in upcoming commits so there is minimal change
with the moves.
2023-06-14 16:04:22 +02:00
Duncan Dean
3ff94fae55
Move Channel::get_feerate_sat_per_1000_weight and other methods
This is one of a series of commits to make sure methods are moved by
chunks so they are easily reviewable in diffs. Unfortunately they are
not purely move-only as fields to be updated for things to
compile, but these should be quite clear.

This commit also uses the `context` field where needed for compilation
and tests to pass due to the above change.

f s/tarcontext.get_/target_/
2023-06-14 16:04:21 +02:00
Duncan Dean
0d739eeb22
Move Channel::build_holder_transaction_keys and some other methods
This is one of a series of commits to make sure methods are moved by
chunks so they are easily reviewable in diffs. Unfortunately they are
not purely move-only as fields need to be updated for things to
compile, but these should be quite clear.

This commit also uses the `context` field where needed for compilation
and tests to pass due to the above change.
2023-06-14 16:04:14 +02:00
Duncan Dean
497aeb006f
Move Channel::build_commitment_transaction to ChannelContext impl
This is one of a series of commits to make sure methods are moved by
chunks so they are easily reviewable in diffs. Unfortunately they are
not purely move-only as fields need to be updated for things to
compile, but these should be quite clear.

This commit also uses the `context` field where needed for compilation
and tests to pass due to the above change.
2023-06-14 13:42:27 +02:00
Duncan Dean
ede8324397
Move Channel::channel_id and some other methods to ChannelContext impl
This is one of a series of commits to make sure methods are moved by
chunks so they are easily reviewable in diffs. Unfortunately they are
not purely move-only as fields need to be updated for things to
compile, but these should be quite clear.

This commit also uses the `context` field where needed for compilation
and tests to pass due to the above change.
2023-06-14 13:42:26 +02:00
Duncan Dean
1ee0a66d21
Move Channel::get_update_time_counter and some other methods
This is one of a series of commits to make sure methods are moved by
chunks so they are easily reviewable in diffs. Unfortunately they are
not purely move-only as fields need to be updated for things to
compile, but these should be quite clear.

This commit also uses these methods through the `context` field where
needed for compilation and tests to pass due to the above change.
2023-06-14 13:42:24 +02:00
Duncan Dean
1503ebbc0e
Move Channel::opt_anchors to ChannelContext impl & move some util fns
This is one of a series of commits to make sure methods are moved by
chunks so they are easily reviewable in diffs. Unfortunately they are
not purely move-only as fields need to be updated for things to
compile, but these should be quite clear.
2023-06-14 13:42:23 +02:00
Duncan Dean
883afb38d4
Move Channel fields into ChannelContext struct
This is a first step for simplifying the channel state and introducing
new unfunded channel types that hold similar state before being promoted
to funded channels.

Essentially, we want the outer `Channel` type (and upcoming channel types)
to wrap the context so we can apply typestate patterns to the that wrapper
while also deduplicating code for common state and other internal fields.
2023-06-14 13:42:22 +02:00
Jeffrey Czyz
3fd6b44043
Reduce log level of potential noisy log statement 2023-06-13 13:07:49 -05:00
Jeffrey Czyz
fac5f4b86b
Test onion message replies 2023-06-13 13:07:48 -05:00
Jeffrey Czyz
ceb90386a9
Split TestCustomMessage into Request and Response
This will allow for testing onion message replies.
2023-06-13 13:07:48 -05:00
Jeffrey Czyz
c83d5bf162
Remove unnecessary Sized bound 2023-06-13 13:07:48 -05:00
Jeffrey Czyz
c17c2ae3c0
Support onion message replies in OnionMessenger
Modify onion message handlers to return an optional response message for
OnionMessenger to reply with.
2023-06-13 13:07:47 -05:00
Jeffrey Czyz
a71000f35d
MessageRouter trait for OnionMessenger
Add a trait for finding routes for onion messages and parameterize
OnionMessenger with it. This allows OnionMessenger to reply to messages
that it handles via one of its handlers (e.g., OffersMessageHandler).
2023-06-13 13:07:47 -05:00
Jeffrey Czyz
f15da3d294
Add OnionMessagePath wrapper struct
To avoid confusion in the upcoming MessageRouter trait, introduce an
OnionMessagePath struct that wraps the intermediate nodes and the
destination. Use this in OnionMessenger::send_onion_message.
2023-06-13 13:07:47 -05:00
Jeffrey Czyz
f521e4cceb
OffersMessageHandler trait for OnionMessenger
Add a trait for handling BOLT 12 Offers messages to OnionMessenger and a
skeleton implementation of it for ChannelManager. This allows users to
either provide their own custom handling Offers messages or rely on a
version provided by LDK using stateless verification.
2023-06-13 13:07:47 -05:00
Jeffrey Czyz
cff88aa509
Avoid an unnecessary unwrap 2023-06-13 13:07:47 -05:00
Jeffrey Czyz
a799fc9b30
Onion message payload for BOLT 12 Offers
BOLT 12 Offers makes use of onion messages to request and respond with
invoices. Add these types and an error type to OnionMessageContents
along with the necessary parsing and encoding.
2023-06-13 13:07:47 -05:00
Jeffrey Czyz
7533a3c42f
Pass logger to onion payload decoder
In an upcoming commit, messages for BOLT 12 offers are read from the
onion payload. Passing a logger allows for logging semantic errors when
parsing the messages.
2023-06-13 13:07:46 -05:00
Jeffrey Czyz
9b3a35a133
Add InvoiceError message
If an InvoiceRequest or an Invoice delivered via an onion message cannot
be handled, the recipient should reply with an InvoiceError if a reply
path was given. Define the message and conversion from SemanticError.
2023-06-13 13:07:46 -05:00
Jeffrey Czyz
1feddaeafd
Support WithoutLength for UntrustedString 2023-06-13 13:07:41 -05:00
Valentine Wallace
6b6d549854
Fix oops'd docs on PaymentParameters::with_max_channel_saturation 2023-06-12 17:27:03 -04:00
Valentine Wallace
d017657bcd
Fix panic on pathfinding to blinded recipient
The previous dummy payee id was an invalid pubkey
2023-06-12 17:27:03 -04:00
Matt Corallo
942d77699b Stop writing old user_payment_id field not read since 0.0.103
Since we're breaking downgrade compatibility to LDK version 0.0.103
and before, we might as well go ahead and remove other code we have
for compatibility.
2023-06-12 18:46:41 +00:00
Matt Corallo
6535627a3e Drop create_inbound_payment*_legacy breaking downgrade to 0.0.103
0.0.103 is now downright ancient, and certainly shouldn't exist in
production anywhere today. Thus, it seems fine to remove the
ability to create legacy stateful inbound payment entries.

Users downgrading to 0.0.103 will thus not be able to claim any
payments created on modern LDK, though we still retain the ability
to claim such payments at least for one more release.
2023-06-12 16:43:01 +00:00
Matt Corallo
42e2f1d1a6
Merge pull request #2156 from alecchendev/2023-04-mpp-keysend
Support MPP Keysend
2023-06-10 19:48:54 +00:00
Alec Chen
9db962c719
Add test for duplicate keysend payment
The logic has been changed around duplicate keysend payments such that
it's no longer explicitly clear that we reject duplicate keysend
payments now that we handle receiving multi-part keysends. This test
catches that. Note that this also tests that we reject MPP keysends when
our config states we should, and that we reject MPP keysends without
payemnt secrets when our config states we support MPP keysends.
2023-06-09 11:27:09 -05:00
Alec Chen
8dde17773a
Support receiving MPP keysend
This commit refactors a significant portion of the receive validation in
`ChannelManager::process_pending_htlc_forwards` now that we repurpose
previous MPP validation logic to accomodate keysends. This also removes
a previous restriction on claiming, as well as tests sending and
receiving MPP keysends.
2023-06-09 11:27:07 -05:00
Alec Chen
4be3adb51f
Track MPP data while receiving keysends
This commit adds the field `payment_data: FinalOnionHopData` to
`ReceiveKeysend` which will allow us to check for payment secrets and
total amounts which is needed to support receiving MPP keysends. This
field is non-backwards compatible since we wouldn't be able to handle
an MPP keysend properly if we were to downgrade to a prior version.

We also no longer reject keysends with payment secrets if we support MPP
keysend.
2023-06-09 11:27:06 -05:00
Alec Chen
07def9292a
Help users support sending MPP keysend
When routing a keysend payment, the user may want to signal to the
router whether to find multi-path routes in the
`PaymentParameters::for_keysend` helper, without going through manual
construction. Since some implementations do not support MPP keysend, we
have the user make the choice here rather than making it the default.

Some implementations will reject keysend payments with payment secrets,
so this commit also adds docs to `RecipientOnionFields` to communicate
this to the user.
2023-06-09 11:26:58 -05:00
Matt Corallo
b6787a4f36
Merge pull request #2334 from jkczyz/2023-06-bolt12-test-vectors
Update BOLT 12 test vectors
2023-06-08 18:51:05 +00:00
Wilmer Paulino
99985c6209
Merge pull request #2333 from benthecarman/chan-mon-bal-helper
Add helper for getting claimable balance
2023-06-07 18:06:01 -07:00
Matt Corallo
f09c37082c
Merge pull request #2342 from vladimirfomene/2023-06-use-untrustedstring-in-error-logs
Use PrintableString for displaying errors in PeerManager
2023-06-07 23:06:15 +00:00
Jeffrey Czyz
ecd283ea23
Include signature check in BOLT 12 signature test
The BOLT 12 test vectors had inadvertently left out a signature, but it
has since been added. Include a signature check in the corresponding
test for completeness.
2023-06-07 16:57:24 -05:00
Jeffrey Czyz
8540985351
Update BOLT 12 test vectors
The previous test vectors contained recurrences and older TLV types, and
therefore couldn't be parsed. Update the tests with the latest test
vectors from the spec and stop ignoring the tests.
2023-06-07 16:56:56 -05:00