Commit graph

3343 commits

Author SHA1 Message Date
benthecarman
fcd1127c01
Check too many tx outputs upfront when verifying funding tx 2023-05-08 17:49:05 -05:00
Valentine Wallace
d56672c11d
Move final_cltv_expiry_delta from PaymentParams to Payee::Clear
Since blinded pay params won't have this value.
2023-05-08 18:01:43 -04:00
Valentine Wallace
746f25aed0
Add BOLT 12 features to PaymentParams 2023-05-08 18:01:43 -04:00
Valentine Wallace
91dc76721b
Move BOLT11 features from top level PaymentParams to Payee::Clear
Since blinded payees don't have this.
2023-05-08 18:01:43 -04:00
Valentine Wallace
6d62b62cec
Error if BOLT 11 features are provided for blinded payment params 2023-05-08 18:01:43 -04:00
Valentine Wallace
7f49f6bf4d
Move payee node id from top level PaymentParams to Payee::Clear
Since blinded payees don't have one
2023-05-08 18:01:41 -04:00
Valentine Wallace
f18661f6f6
Fix onion messages of size BIG_PACKET_HOP_DATA_LEN
This was previously broken and would result in an invalid HMAC error, because
we had a hardcoded assumption that OM hop data would always be of size 1300.
2023-05-08 15:02:42 -04:00
Valentine Wallace
408b12f034
Fix broken test utils in OnionMessenger and stop asserting on logs 2023-05-08 14:22:43 -04:00
Wilmer Paulino
40626958e4
Merge pull request #1794 from dunxen/2022-10-dualfunding-act-1
Dual funding and interactive tx construction wire messages
2023-05-08 10:47:51 -07:00
Matt Corallo
0a0c54cc31
Merge pull request #2269 from TheBlueMatt/2023-05-doc-events-present
Document when event fields are `Some`
2023-05-08 16:39:15 +00:00
Matt Corallo
570db8b9e6
Merge pull request #2265 from wpaulino/channel-force-closed-update-err
Prevent ChannelForceClosed monitor update error after detecting spend
2023-05-08 16:33:14 +00:00
Jeffrey Czyz
3313abb37d
Add Features::requires_unknown_bits_from
When checking features, rather than checking against which features LDK
knows about, it is more useful to check against a peer's features. Add
Features::requires_unknown_bits_from such that the given features are
used instead.
2023-05-08 10:30:08 -05:00
Jeffrey Czyz
21708b597e
Add PeerManager::init_features to DRY up code 2023-05-08 10:29:54 -05:00
Jeffrey Czyz
415973eaa3
Provide features in CustomMessageHandler
CustomMessageHandler implementations may need to advertise support for
features. Add methods to CustomMessageHandler to provide these and
combine them with features from other message handlers.
2023-05-08 10:28:14 -05:00
Jeffrey Czyz
687e587a73
Define core::ops::BitOr for Features<T>
The `lightning-custom-message` crate will need access to Features::or in
order combine features of a composite handler. Expose this via a
core::ops::BitOr implementation.
2023-05-08 10:18:47 -05:00
Duncan Dean
4e9a358baa
Add new wire messaging and events but don't handle them 2023-05-05 11:40:51 +02:00
Duncan Dean
adc1b55a6f
Add message structs required for dual-funded channels
This is the first of a set of PRs to enable the experimental dual-funded
channels feature using interactive transaction construction. This allows
both the channel initiator and channel acceptor to contribute funds
towards the channel.
2023-05-05 11:40:49 +02:00
Matt Corallo
d8c0a2beab Docuemnt when PaymentPathFailed::payment_id is Some
The `PaymentPathFailed::payment_id` field has been `Some` since
the field was added in
73f601fd3d.
2023-05-05 04:08:55 +00:00
Matt Corallo
e1394f3ea0 Document when PaymentPathSuccessful::payment_hash is filled in.
The `payment_hash` field in `PaymentPathSuccessful` is always
`Some` as long as the pening payment tracker has a `payment_hash`,
which is true for all `Pending` payments as well as all `Fulfilled`
payments starting with the commit which added
`PaymentPathSuccessful` -
3b5c370b404e2f5a8f3c35093b97406f149a9340c177c05252574083d68df0da.
2023-05-05 03:33:54 +00:00
Wilmer Paulino
1aeb8216e1
Improve logging around redundant force close monitor updates 2023-05-04 17:46:13 -07:00
Matt Corallo
96ab759e11 Mention lnd's SCB feature in the corresponding error message
It's a bit confusing when we see only "Peer sent a garbage
channel_reestablish" when a peer uses lnd's SCB feature to ask us
to broadcast the latest state. This updates the error message to be
a bit clearer.
2023-05-05 00:13:25 +00:00
Wilmer Paulino
9878edeeba
Prevent ChannelForceClosed monitor update error after detecting spend
If we detected a spend for a channel onchain prior to handling its
`ChannelForceClosed` monitor update, we'd log a concerning error
message and return an error unnecessarily. The channel has already been
closed, so handling the `ChannelForceClosed` monitor update at this
point should be a no-op.
2023-05-04 15:22:25 -07:00
Matt Corallo
e94647ca4e
Merge pull request #2111 from TheBlueMatt/2023-03-sent-persist-order-prep
Setup Support for delaying `ChannelMonitorUpdate` flight until an `Event` completes
2023-05-04 21:26:44 +00:00
Valentine Wallace
cea78f585a
Error if clear hints are provided for blinded PaymentParams 2023-05-04 10:50:53 -04:00
Valentine Wallace
06eeefc5e7
Groundwork for refactoring PaymentParams::Hints to ::Payee
Minor changes in preparation for supporting route blinding in
PaymentParameters. In the next commit, we'll be moving more
unblinded-payee-specific fields from the top level parameters into the clear
enum variant.
2023-05-04 10:31:56 -04:00
Matt Corallo
56b0c96838
Merge pull request #2246 from arik-so/2023-04-sign-module
Move keysinterface.rs to a directory-level module called sign
2023-05-03 16:53:36 +00:00
Matt Corallo
ca1d569356
Merge pull request #2219 from benthecarman/custom-closing-address
Add ability to set shutdown script when closing channel
2023-05-03 16:33:57 +00:00
Arik Sosman
6cb9919f0c
Move keysinterface.rs to a directory-level module called sign. 2023-05-02 21:48:08 -07:00
Matt Corallo
ec3de62bc7
Merge pull request #2249 from TheBlueMatt/2023-04-less-pm-bounds
Trivial PeerManager cleanups
2023-05-03 01:41:17 +00:00
Matt Corallo
14c6810e48 Expose a trait impl'd for all PeerManager for use as a bound
A while back, in tests, we added a `AChannelManager` trait, which
is implemented for all `ChannelManager`s, and can be used as a
bound when we need a `ChannelManager`, rather than having to
duplicate all the bounds of `ChannelManager` everywhere.

Here we do the same thing for `PeerManager`, but make it public and
use it to clean up `lightning-net-tokio` and
`lightning-background-processor`.

We should likely do the same for `AChannelManager`, but that's left
as a followup.
2023-05-02 22:17:25 +00:00
Matt Corallo
b0d37edb30
Merge pull request #2253 from dunxen/2023-05-removeoptionalfield
Remove `OptionalField` and make `DataLossProtect` fields mandatory
2023-05-02 22:02:04 +00:00
benthecarman
12b59b2113
Add ability to set shutdown script when closing channel 2023-05-02 15:24:16 -05:00
Wilmer Paulino
2cae6f0ccb
Merge pull request #2244 from benthecarman/signature-size
Incorporate low-R values into estimate signature size
2023-05-02 12:01:51 -07:00
Duncan Dean
f0b3961c22
Set data_loss_protect_required 2023-05-02 20:26:46 +02:00
Matt Corallo
9dfe42cf86 Store + process pending ChannelMonitorUpdates in Channel
The previous commits set up the ability for us to hold
`ChannelMonitorUpdate`s which are pending until we're ready to pass
them to users and have them be applied. However, if the
`ChannelManager` is persisted while we're waiting to give the user
a `ChannelMonitorUpdate` we'll be confused on restart - seeing our
latest `ChannelMonitor` state as stale compared to our
`ChannelManager` - a critical error.

Luckily the solution is trivial, we simply need to store the
pending `ChannelMonitorUpdate` state and load it with the
`ChannelManager` data, allowing stale monitors on load as long as
we have the missing pending updates between where we are and the
latest `ChannelMonitor` state.
2023-05-02 17:59:22 +00:00
Matt Corallo
756b5aa278 Handle EventCompletionActions after events complete
This adds handling of the new `EventCompletionAction`s after
`Event`s are handled, letting `ChannelMonitorUpdate`s which were
blocked fly after a relevant `Event`.
2023-05-02 17:59:22 +00:00
Matt Corallo
9ede794e8e Track an EventCompletionAction for after an Event is processed
This will allow us to block `ChannelMonitorUpdate`s on `Event`
processing in the next commit.

Note that this gets dangerously close to breaking forwards
compatibility - if we have an `Event` with an
`EventCompletionAction` tied to it, we persist a new, even, TLV in
the `ChannelManager`. Hopefully this should be uncommon, as it
implies an `Event` was delayed until after a full round-trip to a
peer.
2023-05-02 17:59:22 +00:00
Matt Corallo
ac5efa2755 Allow holding ChannelMonitorUpdates until later, completing one
In the coming commits, we need to delay `ChannelMonitorUpdate`s
until future actions (specifically `Event` handling). However,
because we should only notify users once of a given
`ChannelMonitorUpdate` and they must be provided in-order, we need
to track which ones have or have not been given to users and, once
updating resumes, fly the ones that haven't already made it to
users.

To do this we simply add a `bool` in the `ChannelMonitorUpdate` set
stored in the `Channel` which indicates if an update flew and
decline to provide new updates back to the `ChannelManager` if any
updates have their flown bit unset.

Further, because we'll now by releasing `ChannelMonitorUpdate`s
which were already stored in the pending list, we now need to
support getting a `Completed` result for a monitor which isn't the
only pending monitor (or even out of order), thus we also rewrite
the way monitor updates are marked completed.
2023-05-02 17:59:22 +00:00
Matt Corallo
101c09f9bf
Merge pull request #2213 from benthecarman/error-sign-provider-addrs
Allow get_shutdown_scriptpubkey and get_destination_script to return an Error
2023-05-02 17:48:05 +00:00
Duncan Dean
20cd856aa5
Remove OptionalField and move shutdown_scriptpubkey into TLV stream
As pointed out in https://github.com/lightning/bolts/pull/754/commits/6656b70,
we can move the `shutdown_scriptpubkey` field into the TLV streams of
`OpenChannel` and `AcceptChannel` without affecting the resulting encoding.

We use `WithoutLength` encoding here to ensure that we do not encode a
length prefix along with `Script` as is normally the case.
2023-05-02 10:24:16 +02:00
benthecarman
0b8bdbf968
Allow get_shutdown_scriptpubkey and get_destination_script to return an error 2023-05-02 02:39:54 -05:00
benthecarman
0517b18a01
Incorporate low-R values into estimate signature size 2023-05-02 02:18:14 -05:00
Duncan Dean
16d0f2ff4a
Make DataLossProtect fields required and remove wrappers
The fields provided by `DataLossProtect` have been mandatory since
https://github.com/lightning/bolts/pull/754/commits/6656b70, regardless
of whether `option_dataloss_protect` or `option_remote_key` feature bits
are set.

We move the fields out of `DataLossProtect` to make encoding definitions
more succinct with `impl_writeable_msg!` and to reduce boilerplate.

This paves the way for completely removing `OptionalField` in subsequent
commits.
2023-05-01 22:41:12 +02:00
Matt Corallo
524981ddf4 Move the CustomMessageHandler into the MessageHandler struct
`PeerManager` takes a `MessageHandler` struct which contains all
the known message handlers for it to pass messages to. It then,
separately, takes a `CustomMessageHandler`. This makes no sense, we
should simply include the `CustomMessageHandler` in the
`MessageHandler` struct for consistency.
2023-04-30 04:03:55 +00:00
Wilmer Paulino
0e8da58895
Merge pull request #2245 from TheBlueMatt/2023-04-ping-count-overflow
Fix overflow in `awaiting_pong_timer...` with too many peers
2023-04-28 12:15:02 -07:00
Wilmer Paulino
3a643df997
Merge pull request #2217 from alecchendev/2023-04-expose-hash-in-balance
Expose `PaymentHash` and `PaymentPreimage` in `Balance`
2023-04-28 11:11:01 -07:00
Wilmer Paulino
41e94f9404
Merge pull request #2239 from valentinewallace/2023-04-remove-redundant-final-cltv-param
Remove redundant `final_cltv_delta` param from `get_route`
2023-04-28 10:46:51 -07:00
Matt Corallo
fa33f98a42 Fix overflow in awaiting_pong_timer... with too many peers
If we have more than
127 / `MAX_BUFFER_DRAIN_TICK_INTERVALS_PER_PEER` (31) peers,
`awaiting_pong_timer_tick_intervals` can overflow before we hit
the limit. This isn't super harmful, we'll still disconnect peers
as long as they don't send *any* messages between two pings, but it
does cause us to not disconnect peers which are extremely slow in
responding to messages, e.g. because they are overloaded.
2023-04-28 16:19:04 +00:00
Matt Corallo
88c63e9dbb
Merge pull request #2230 from freddiekrugerrand/2228-validatechainhash
Check chain hash for channel announcement and update
2023-04-27 23:00:42 +00:00
Valentine Wallace
cae41c17ee
Remove redundant final_cltv_delta param from get_route
PaymentParameters already includes this value.

This set us up to better support route blinding, since there is no known
final_cltv_delta when paying to a blinded route.
2023-04-27 17:09:19 -04:00