Commit graph

4537 commits

Author SHA1 Message Date
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
Matt Corallo
26b1674da8 Only do backtrace builds on stable to fix MSRV break in CI 2022-12-15 22:15:55 +00:00
Matt Corallo
40b78eab2d
Merge pull request #1918 from TheBlueMatt/2022-12-one-blinded-path
Unify blinding nomenclature to call them "paths" not "routes".
2022-12-15 00:49:41 +00:00
Jeffrey Czyz
8e36737dac
Refund parsing tests
Tests for checking refund semantics when parsing invoice_request bytes
as defined by BOLT 12.
2022-12-14 16:22:44 -06:00
Jeffrey Czyz
77c082229b
Refund building tests
Tests for checking invoice_request message semantics when building a
refund as defined by BOLT 12.
2022-12-14 16:22:24 -06:00
Jeffrey Czyz
73e743fb53
Builder for creating refunds
Add a builder for creating refunds given a payer_id and other required
fields. Other settings are optional and duplicative settings will
override previous settings. Building produces a semantically valid
`invoice_request` message representing the refund, which then may be
communicated out of band (e.g., via QR code).
2022-12-14 16:20:53 -06:00
Jeffrey Czyz
d47763af57
Refund parsing from bech32 strings
Implement Bech32Encode for Refund, which supports creating and parsing
QR codes for the merchant-pays-user (i.e., offer for money) flow.
2022-12-14 16:20:53 -06:00
Jeffrey Czyz
92a53dd7aa
Refund encoding and parsing
Define an interface for BOLT 12 refunds (i.e., an `invoice_request`
message without an `offer_node_id`). A refund is more generally an
"offer for money". While it is encoded using the same TLV streams as an
`invoice_request` message, it has different semantics.
2022-12-14 16:20:40 -06:00
Matt Corallo
8dbf6dba7d Update references to "blinded route" to "blinded path"
Finishing the work from the previous two commits.
2022-12-14 21:14:38 +00:00
Matt Corallo
a0d38d7eb9 Rename blinded_route variables and module to blinded_path
Following up on the previous commit, this also renames variables
and the module used to `blinded_path`.
2022-12-14 21:14:38 +00:00
Matt Corallo
9b6de781d8 Unify blinding nomenclature to call them "paths" not "routes".
Currently the `onion_message` module exposes the blinded route
object as *both* `BlindedRoute` and `BlindedPath`. This is somewhat
confusing, and given they are really paths, not routes (at least in
the sense that a route could be multi-path, though for OMs they are
not), here we unify to only call them paths.
2022-12-14 21:07:55 +00:00
Jeffrey Czyz
7e81f8dcb4
Remove Option from OfferContents::signing_pubkey
Refunds (i.e., `invoice_request` without an `offer`) will have its own
contents type, so OfferContents::signing_pubkey can be required.
2022-12-13 16:05:59 -06:00