Commit graph

4448 commits

Author SHA1 Message Date
valentinewallace
d8a20eda5f
Merge pull request #1927 from jkczyz/2022-12-invoice-rework
Pre-work for BOLT 12 invoices
2023-01-06 11:07:17 -05:00
Jeffrey Czyz
b50fc4e32c
Define blinded hop features for use in BOLT 12
BOLT 12 invoices may contain blinded_payinfo for each hop in a blinded
path. Each blinded_payinfo contains features, whose length must be
encoded since there may be multiple hops.

Note these features are also needed in the BOLT 4 encrypted_data_tlv
stream. But since they are a single TLV record, the length must *not* be
encoded there.
2023-01-05 22:39:24 -06:00
Jeffrey Czyz
d985ced7e3
Define BOLT 12 invoice features with MPP support 2023-01-05 22:39:24 -06:00
Jeffrey Czyz
ea1a68c6e6
Use explicit WithoutLength for BOLT 12 features
Most BOLT 12 features are used as the value of a TLV record and thus
don't use an explicit length. One exception is the features inside the
blinded payinfo subtype since the TLV record contains a list of them.
However, these features are also used in the BOLT 4 encrypted_data_tlv
TLV stream as a single record, where the length is implicit.

Implement Readable and Writeable for Features wrapped in WithoutLength
such that either serialization can be used where required.
2023-01-05 22:39:24 -06:00
Jeffrey Czyz
1a437f4150
Remove Option from InvoiceRequest::signature
Refunds don't have signatures and now use their own abstraction.
Therefore, signatures can be required in invoice requests as per the
spec.
2023-01-05 22:39:24 -06:00
Jeffrey Czyz
7964b9f745
Correct documentation about Refund::payer_id
The docs incorrectly stated that Refund::payer_id is for signing, where
it is only used for identifying a node if Refund::paths is not present.
2023-01-05 22:38:31 -06:00
Matt Corallo
b79ff71fe7
Merge pull request #1812 from valentinewallace/2022-10-chanman-router-param
Parameterize `ChannelManager` by a `Router`
2023-01-05 22:09:35 +00:00
Valentine Wallace
19516c041e
Test utils: allow queueing >2 persistence update results 2023-01-05 11:29:24 -05:00
Valentine Wallace
22501c3c5e
ser_macros: rename check_tlv_order
.. to disamgibutate from check_encoded_tlv_order
2023-01-05 11:29:24 -05:00
Matt Corallo
af6fa143a1
Provide a static_value TLV field serialization type
This is useful in the type serialization definition macros to avoid
writing or reading a field at all, simply using a static value on
each reload.
2023-01-05 11:29:21 -05:00
Valentine Wallace
682bb9b0ae
Parameterize Simple*ChannelManager with DefaultRouter and ProbScorer 2023-01-05 11:29:00 -05:00
Valentine Wallace
3a1982c741
Take in-flight HTLCs by reference in Router::find_route
Useful in upcoming work when for payment retries.
2023-01-05 11:24:56 -05:00
Valentine Wallace
3a274e0415
Implement routing against the netgraph in tests 2023-01-05 11:23:45 -05:00
Matt Corallo
e1208bfd66
Merge pull request #1935 from TheBlueMatt/2022-12-no-non-time-panic
Ensure derive_channel_keys doesn't panic if per-run seed is high
2023-01-03 22:02:04 +00:00
Valentine Wallace
2e06efe2ff
Parameterize ChannelManager by a Router trait
This will be used in upcoming work to fetch routes on-the-fly for payment
retries, which will no longer be the responsibility of InvoicePayer.
2023-01-03 15:34:14 -05:00
Matt Corallo
5dde803d08 Ensure the per-channel key derivation counter doesn't role over
Previously, the `derive_channel_keys` derivation ID asserted that
the high bit of the per-channel key derivation counter doesn't
role over as it checked the 31st bit was zero. As we no longer do
that, we should ensure the assertion in `generate_channel_keys_id`
asserts that we don't role over.
2023-01-03 17:34:19 +00:00
Matt Corallo
7d84a45ae8
Merge pull request #1934 from TheBlueMatt/2022-12-113-bindings-upstream
Trivial Bindings Updates
2023-01-03 17:06:37 +00:00
Matt Corallo
dc39799c60
Merge pull request #1936 from TheBlueMatt/2023-01-in-flight-clone
`#[derive(Clone)]` for `InFlightHtlcs`
2023-01-03 16:43:18 +00:00
Matt Corallo
9414830951 #[derive(Clone)] for InFlightHtlcs
This is useful for bindings, and generally isn't a bad thing for
users to have access to.
2023-01-02 01:09:43 +00:00
Matt Corallo
34de734194 Ensure derive_channel_keys doesn't panic if per-run seed is high
b04d1b868f changed the way we
calculate the `channel_keys_id` to include the 128-bit
`user_channel_id` as well, shifting the counter up four bytes and
the `starting_time_nanos` field up into the second four bytes.

In `derive_channel_keys` we hash the full `channel_keys_id` with an
HD-derived key from our master seed. Previously, that key was
derived with an index of the per-restart counter, re-calculated by
pulling the second four bytes out of the `user_channel_id`. Because
the `channel_keys_id` fields were shifted up four bytes, that is
now a reference to the `starting_time_nanos` value. This should be
fine, the derivation doesn't really add any value here, its all
being hashed anyway, except that derivation IDs must be below 2^31.
This implies that we panic if the user passes a
`starting_time_nanos` which has the high bit set. For those using
the nanosecond part of the current time this isn't an issue - the
value cannot exceed 1_000_000, which does not have the high bit
set, however, some users may use some other per-run seed.

Thus, here we simply drop the high bit from the seed, ensuring we
don't panic. Note that this is backwards compatible as it only
changes the key derivation in cases where we previously panicked.

Ideally we'd drop the derivation entirely, but that would break
backwards compatibility of key derivation.
2022-12-28 18:11:18 +00:00
Matt Corallo
f00bc4d713 No-export &self methods on non-cloneable enum(s)
Specifically, `OnionMessageContents` is a non-cloneable enum, which
isn't stored opaque so we cannot call `&self` methods on it.
Because its methods aren't critical to the API for now, we simply
no-export them rather than trying to work out an alternative
approach.
2022-12-25 00:58:19 +00:00
Matt Corallo
9449d042b9 Store an owned Score in ScorerAccountingForInFlightHtlcs
`ScorerAccountingForInFlightHtlcs` generally stores a `Score`
reference generated by calling `LockableScore::lock`, which
actually returns an arbitrary `Score`. Given `Score` is implemented
directly on lock types, it makes sense to simply hold a fully owned
`Score` in `ScorerAccountingForInFlightHtlcs` rather than a mutable
reference to one.
2022-12-25 00:58:19 +00:00
Matt Corallo
f0c181e2f2
Merge pull request #1929 from valentinewallace/2022-12-outbound-payment-mod-followup
Outbound payment module follow-up
2022-12-21 23:08:58 +00:00
Valentine Wallace
cc60fd601f
outbound_payment: put method signature closing paren on next line
in long method signatures
2022-12-21 16:26:55 -05:00
Arik
c04d1c985f
Merge pull request #1931 from TheBlueMatt/2022-12-1910-followups
Trivial #1910 Followups
2022-12-21 11:05:09 -08:00
Matt Corallo
fa42b5ea82 Fix capitalization broken in 9d7bb73b59
9d7bb73b59 broke some capitalization
in docs for `sign_invoice`, which we fix here as well as taking
this opportunity to clean up the `sign_invoice` docs more
generally.
2022-12-21 16:39:37 +00:00
Matt Corallo
ac690e8191 Clean up use ordering introduced in 9d7bb73b59
9d7bb73b59 moved some code around
unnecessarily, which we fix here.
2022-12-21 16:38:54 +00:00
Valentine Wallace
60492d769a
Fix cfg(test) indentation 2022-12-20 21:23:54 -05:00
Valentine Wallace
8d5f7c87cb
Make add_new_pending_payment private to module
And expose it in testing only, for safety
2022-12-20 21:23:54 -05:00
valentinewallace
cbbf84b050
Merge pull request #1928 from valentinewallace/2022-12-fix-main
Fix `main` build
2022-12-20 19:31:16 -05:00
Valentine Wallace
1ded1d21bd
Fix main build 2022-12-20 17:55:06 -05:00
Matt Corallo
f7211fbf79
Merge pull request #1910 from arik-so/2022-12-keys-interface-name-split
Split KeysInterface into EntropySource, NodeSigner, and SignerProvider
2022-12-20 22:19:43 +00:00
valentinewallace
e64ebe8608
Merge pull request #1923 from valentinewallace/2022-12-outbound-payment-mod
Abstract `ChannelManager` outbound payment logic
2022-12-20 15:40:48 -05:00
Arik Sosman
9d7bb73b59
Split out KeysInterface into EntropySource, NodeSigner, and SignerProvider. 2022-12-20 10:09:11 -08:00
Valentine Wallace
afdaa64b44
Rename send_payment and retry_payment for retries
Once ChannelManager supports payment retries, it will make more sense for its
current send_payment method to be named send_payment_with_route because
retrying should be the default. Here we get a head start on this by making the
rename in outbound_payment, but not changing the public interface yet.
2022-12-19 21:08:08 -05:00
Valentine Wallace
3e89cc7e08
Reduce visibility of outbound payment methods 2022-12-19 21:08:08 -05:00
Valentine Wallace
ec55730959
Start parameters on a newline if they don't fit
Separating out this commit to keep the main refactor move-only
2022-12-19 21:08:03 -05:00
Valentine Wallace
e69a4c2636
Remove unnecessary mut in finalize_claims 2022-12-19 21:04:58 -05:00
Valentine Wallace
afd31507d9
Swap pending_outbound_payments for OutboundPayments struct
This allows us to move a lot of outbound payment logic out of ChannelManager
and into the new outbound_payment module, and helps avoid growing
ChannelManager when we add retry logic to it in upcoming work.
2022-12-19 21:04:53 -05:00
Valentine Wallace
278ebd208a
Move PaymentSendFailure into outbound_payment module
And re-export it in channelmanager.rs so it can remain public
2022-12-19 14:10:03 -05:00
Valentine Wallace
070832643f
Move PendingOutboundPayment to new outbound_payment module
We want to move all outbound payment-related things to this new module, to help
break up ChannelManager so future payment retries work doesn't increase the
size of ChannelManager.
2022-12-19 14:09:59 -05:00
Matt Corallo
e38ab09c3a
Merge pull request #1922 from wpaulino/avoid-remaining-redundant-commitment-broadcasts
Avoid redundant broadcast of local commitment transaction
2022-12-19 16:31:30 +00:00
Matt Corallo
45eb0f3186
Merge pull request #1908 from jkczyz/2022-11-refund
BOLT 12 refund encoding and building
2022-12-16 21:45:34 +00:00
Wilmer Paulino
ff48f5df4d
Avoid redundant broadcast of local commitment transaction
This change follows the rationale of commit 62236c7 and addresses the
last remaining redundant local commitment broadcast.

There's no need to broadcast our local commitment transaction if we've
already seen a confirmed one as it'll be immediately rejected as a
duplicate/conflict.

This will also help prevent dispatching spurious events for bumping
commitment and HTLC transactions through anchor outputs since the
dispatch for said events follows the same flow as our usual commitment
broadcast.
2022-12-16 11:54:26 -08:00
Matt Corallo
56afbf5064
Merge pull request #1920 from TheBlueMatt/2022-12-rel-date
Update release date on 0.0.113 in changelog
2022-12-16 18:45:09 +00:00
Matt Corallo
08d296ad77
Merge pull request #1903 from TheBlueMatt/2022-12-1867-followups
Clarify docs on `provide_channel_parameters`
2022-12-16 18:29:09 +00:00
Matt Corallo
87f15517ab Update release date on 0.0.113 in changelog 2022-12-16 15:57:11 +00:00
Arik
f6a93826e2
Merge pull request #1917 from TheBlueMatt/2022-12-0.0.113
Cut 0.0.113
2022-12-15 21:37:58 -08:00
Matt Corallo
f96ac1d341 Bump crate versions to 0.0.113/invoice 0.21 2022-12-15 22:15:55 +00:00
Matt Corallo
7658f15371 Add release notes for 0.0.113
Fixes #1890
2022-12-15 22:15:55 +00:00