Commit graph

5086 commits

Author SHA1 Message Date
Matt Corallo
b709bb3e35 Mark the invoice Network getter no-export
...as it is redundant with the `currency` getter if we're not using
the rust-bitcoin types natively.
2023-04-17 17:44:19 +00:00
Wilmer Paulino
15050895fd
Merge pull request #2177 from TheBlueMatt/2023-04-test-function-generics
Genericize Test Functions
2023-04-17 09:56:18 -07:00
Matt Corallo
c977def259
Merge pull request #2191 from TheBlueMatt/2023-04-fix-bucket-deser
Fix deserialization of u16 arrays
2023-04-17 15:11:53 +00:00
Matt Corallo
ac004a91aa
Merge pull request #2187 from benthecarman/invoice-serde-no-std 2023-04-17 13:28:49 +00:00
Steven Williamson
f65660945d
Replace OUR_MAX_HTLCS constant with config knob
holder_max_accepted_htlcs. Set upper bound of 483

Writes an even TLV if the value isn't 50
2023-04-16 19:28:49 -04:00
Matt Corallo
7775356c39 Fix deserialization of u16 arrays
u16 arrays are used in the historical liquidity range tracker.
Previously, we read them without applying the stride multiple,
reading bytes repeatedly and at an offset, corrupting data as we
go.

This applies the correct stride multiplayer fixing the issue.
2023-04-16 21:59:35 +00:00
benthecarman
36f610c4cf
Add CI test for compile no-std serde lightning-invoice 2023-04-16 13:44:14 -05:00
benthecarman
778c752a0b
Fix compiling lightning-invoice for no-std + serde 2023-04-15 15:38:53 -05:00
Matt Corallo
e1e38196e2
Merge pull request #2172 from TheBlueMatt/2023-04-fix-panicy-debug-assert
Remove a race-y debug assertion in new channel update handling
2023-04-14 15:00:12 +00:00
Matt Corallo
accfdae541
Merge pull request #2180 from benthecarman/impl-pk-to-node-id
Implement to and from for PublicKey and NodeId
2023-04-14 14:56:51 +00:00
benthecarman
7a37e2cd23
Impl FromStr for NodeId 2023-04-13 14:53:23 -05:00
Matt Corallo
b3ab1cb801
Merge pull request #2179 from benthecarman/use-node-alias-type
Use NodeAlias type in NodeAnnouncement
2023-04-13 19:46:30 +00:00
Matt Corallo
cfb9eb9639 Move some additional test macros into functions
This marginally reduces the quantity of code compiled in tests
further.
2023-04-13 18:40:46 +00:00
Matt Corallo
d55623601f Introduce traits to make test utils generic across the CM Holder
In our test utilities, we generally refer to a `Node` struct which
holds a `ChannelManager` and a number of other structs. However, we
use the same utilities in benchmarking, where we have a different
`Node`-like struct. This made moving from macros to functions
entirely impossible, as we end up needing multiple types in a given
context.

Thus, here, we take the pain and introduce some wrapper traits
which encapsulte what we need from `Node`, swapping some of our
macros to functions.
2023-04-13 18:40:46 +00:00
benthecarman
f78e6b956c
Use NodeAlias type in NodeAnnouncement 2023-04-13 13:09:03 -05:00
benthecarman
5ed6732b87
Implement to and from for PublicKey and NodeId 2023-04-13 12:59:42 -05:00
Matt Corallo
fb86fc2744 DRY the event handling in ChannelManager
In the coming commits we'll add some additional complexity to the
event handling flows, so best to DRY them up before we get there.
2023-04-12 17:01:45 +00:00
valentinewallace
157af6ec1c
Merge pull request #2142 from alecchendev/2023-03-expose-fail-reason-in-payment-failure
Expose a failure reason in `PaymentFailed`
2023-04-11 17:26:16 -04:00
Alec Chen
23c70642b8 Add reason to Event::PaymentFailed
This includes adding a reason to `PendingOutboundPayment::Abandoned` and
using that reason when pushing an `Event::PaymentFailed`.
2023-04-10 17:13:47 -05:00
valentinewallace
34686692e9
Merge pull request #2173 from benthecarman/convert-currency-to-netowkr
Convert Network to and from Currency
2023-04-10 12:21:16 -04:00
benthecarman
841dd1ea3a
Convert Network to and from Currency 2023-04-08 21:24:17 -05:00
Matt Corallo
29f80269b5 Remove a race-y debug assertion in new channel update handling
In 6090d9e6a8 we swapped out old
debug assertions that checked that a lock was `try_lock`able to
test that certain locks weren't held when we needed to be able to
take them in some near branch. However, another slipped in after in
the `ChannelMonitorUpdate` handling rework, which is replaced with
the new debug assertions here.
2023-04-09 01:43:39 +00:00
Arik
74328bd6e7
Merge pull request #2161 from benthecarman/prune-stale-channels-rgs
Prune stale channels from network graph after RGS sync.
2023-04-07 23:26:19 -07:00
valentinewallace
186cd047f8
Merge pull request #2158 from TheBlueMatt/2023-04-handle_err_more-check
Test for extra locks held in `handle_error` unconditionally
2023-04-07 16:19:27 -04:00
Matt Corallo
6ce239cdb9 Define the PaymentMetadata feature to be used in invoices 2023-04-07 19:57:46 +00:00
Jeffrey Czyz
1ceb41e08b
Merge pull request #2023 from futurepaul/fallback-to-address
add `Fallback` getter that returns `Address`
2023-04-07 14:39:32 -05:00
Alec Chen
432f0e678e Create PaymentFailureReason enum 2023-04-07 13:45:11 -05:00
Matt Corallo
f30dc859e7
Merge pull request #2170 from TheBlueMatt/2023-04-silent-merge-conflict
Fix silent merge conflict between new test and payment refactor
2023-04-07 18:27:33 +00:00
Wilmer Paulino
a5ecb85171
Merge pull request #2162 from jkczyz/2023-04-invoice-hash 2023-04-07 10:11:36 -07:00
Matt Corallo
8a743693ba Fix silent merge conflict between new test and payment refactor 2023-04-07 16:30:25 +00:00
Matt Corallo
568a20b832
Merge pull request #2148 from TheBlueMatt/2023-04-claim-from-closed
Allow claiming a payment if a channel with an HTLC has closed
2023-04-07 16:17:25 +00:00
Matt Corallo
1016e1f605
Merge pull request #2139 from TheBlueMatt/2023-03-metadata-prefactors
Add a new `RecipientOnionFields` and replace `PaymentSecret` with it
2023-04-07 16:14:30 +00:00
Matt Corallo
c8441d2f2d
Merge pull request #2165 from wpaulino/fix-bp-channel-pending-panic-flake
Use signal for handling ChannelPending in test_background_event_handling
2023-04-07 16:08:34 +00:00
Matt Corallo
9e6e20ff61 Split up comically long error return 2023-04-07 04:54:07 +00:00
Jeffrey Czyz
39befa16b4
Expose a BOLT 12 Invoice's signable_hash
This is useful as an identifier for downstream clients like VLS.
2023-04-06 23:15:31 -05:00
Jeffrey Czyz
821c79da98
Expose a BOLT 11 Invoice's signable_hash
Otherwise, an Invoice must first be converted to a SignedRawInvoice to
obtain the hash.
2023-04-06 23:15:25 -05:00
Jeffrey Czyz
854d650b5b
Linkify lightning-invoice docs 2023-04-06 23:13:05 -05:00
benthecarman
b336b2e92a
Lift std check to function definition 2023-04-06 20:36:17 -05:00
Wilmer Paulino
5037298361
Use signal for handling ChannelPending in test_background_event_handling
This fixes two potential panics within the test if the
`BackgroundProcessor` for `nodes[0]` consumed the `ChannelPending` event
prior to us consuming it manually in `end_open_channel`. The first panic
would happen within the event handler, since `ChannelPending` was not
being handled. The second panic would happen upon expecting the
`ChannelPending` event after handling `nodes[1]`'s `funding_signed` if
the `BackgroundProcessor` handled the event first. To ensure we still
reliably receive a `ChannelPending` event once possible, we let the
`BackgroundProcessor` consume the event and notify it.
2023-04-06 15:10:12 -07:00
Matt Corallo
5c6a39bd5b
Merge pull request #2163 from TheBlueMatt/2023-04-less-lock
Avoid holding a `per_peer_state` lock while claiming from a monitor
2023-04-06 21:53:49 +00:00
benthecarman
cff1b4bce3
Prune stale channels from network graph after RGS sync 2023-04-06 14:09:13 -05:00
Matt Corallo
4a8d01dd19 Add a claim_deadline field to PaymentClaimable with guarantees
Now that we guarantee `claim_payment` will always succeed we have
to let the user know what the deadline is. We still fail payments
if they haven't been claimed in time, which we now expose in
`PaymentClaimable`.
2023-04-06 18:12:36 +00:00
Matt Corallo
b189df579f Avoid holding a per_peer_state lock while claiming from a monitor
There's no reason to hold a lock on `per_peer_state` while we're
claiming from a since-closed channel via a `ChannelMonitorUpdate`,
which we stop doing here.
2023-04-06 18:10:06 +00:00
Matt Corallo
ba1349982b
Merge pull request #2101 from TheBlueMatt/2023-03-one-less-sig
Support future removal of redundant per-HTLC signatures in `CMU`s
2023-04-06 18:07:55 +00:00
Paul Miller
cf0a90b8c0
Fallback: add Address getter and use bitcoin types 2023-04-06 10:49:14 -05:00
Matt Corallo
2e39e08c05 Test for extra locks held in handle_error unconditionally
`handle_error` must be called without `per_peer_state` mutex or
`pending_events` mutex locks held or we may risk deadlocks.
Previously we checked this in debug builds in the error path, but
not in the success path.

As it turns out, `funding_transaction_generated`'s error path does
hold a `per_peer_state` lock, which we fix here as well as move the
tests to happen unconditionally.
2023-04-06 03:25:16 +00:00
Matt Corallo
8fcbe64128
Merge pull request #2145 from TheBlueMatt/2023-04-async-bp-cleanups
Add test coverage of async BP and fix minor bug
2023-04-05 16:55:51 +00:00
Matt Corallo
77b1a22296 Correct documentation of payment_id in events 2023-04-05 16:32:10 +00:00
Matt Corallo
36235c38f1 Pipe the new RecipientOnionFields through send pipeline
This passes the new `RecipientOnionFields` through the internal
sending APIs, ensuring we have access to the full struct when we
go to construct the sending onion so that we can include any new
fields added there.
2023-04-05 16:28:14 +00:00
Matt Corallo
bf87a59e91 Add a RecipientOnionFields argument to spontaneous payment sends
While most lightning nodes don't (currently) support providing a
payment secret or payment metadata for spontaneous payments,
there's no specific technical reason why we shouldn't support
sending those fields to a recipient.

Further, when we eventually move to allowing custom TLV entries in
the recipient's onion TLV stream, we'll want to support it for
spontaneous payments as well.

Here we simply add the new `RecipientOnionFields` struct as an
argument to the spontaneous payment send methods. We don't yet
plumb it through the payment sending logic, which will come when we
plumb the new struct through the sending logic to replace the
existing payment secret arguments.
2023-04-05 16:28:14 +00:00