rust-lightning
11 months agoRemove spurious double comma in documentation 2023-06-fix-docs
Matt Corallo [Tue, 6 Jun 2023 00:44:06 +0000 (00:44 +0000)]
Remove spurious double comma in documentation

11 months agoRemove spurious docs which imply you cannot retry a failed payment
Matt Corallo [Mon, 5 Jun 2023 18:21:19 +0000 (18:21 +0000)]
Remove spurious docs which imply you cannot retry a failed payment

If a payment (fully) fails, users are free to retry it, its only
once a payment succeeds that a user must never retry it.

11 months agoMerge pull request #2329 from dunxen/2023-05-initgenesischeck
Matt Corallo [Mon, 5 Jun 2023 18:14:17 +0000 (18:14 +0000)]
Merge pull request #2329 from dunxen/2023-05-initgenesischeck

Add support for `networks` field in `Init` message

11 months agoSend and handle `networks` field in `Init` messages
Duncan Dean [Thu, 1 Jun 2023 10:40:57 +0000 (12:40 +0200)]
Send and handle `networks` field in `Init` messages

If the `networks` field is present in a received `Init` message, then
we need to make sure our genesis chain hash matches one of those, otherwise
we should disconnect the peer.

We now also always send our genesis chain hash in `Init` messages to
our peers.

11 months agoAdd `networks` TLV to `Init`'s TLV stream
Duncan Dean [Thu, 1 Jun 2023 08:23:55 +0000 (10:23 +0200)]
Add `networks` TLV to `Init`'s TLV stream

This was a fairly old introduction to the spec to allow nodes to indicate
to their peers what chains they are interested in (i.e. will open channels
and gossip for).

We don't do any of the handling of this message in this commit and leave
that to the very next commit, so the behaviour is effectively the same
(ignore networks preference).

11 months agoMerge pull request #2332 from danielgranhao/fix/wrong-docs-link-channel-manager-send...
Jeffrey Czyz [Fri, 2 Jun 2023 20:47:51 +0000 (15:47 -0500)]
Merge pull request #2332 from danielgranhao/fix/wrong-docs-link-channel-manager-send-payment

Fix wrong link in `ChannelManager::send_payment()` docs

11 months agoFix wrong link in `ChannelManager::send_payment()` docs
Daniel Granhão [Fri, 2 Jun 2023 16:29:52 +0000 (17:29 +0100)]
Fix wrong link in `ChannelManager::send_payment()` docs

11 months agoMerge pull request #2328 from benthecarman/partial-eq-in-mem-signer
Matt Corallo [Thu, 1 Jun 2023 19:51:24 +0000 (19:51 +0000)]
Merge pull request #2328 from benthecarman/partial-eq-in-mem-signer

Impl PartialEq and Debug for InMemorySigner

11 months agoImpl PartialEq and Debug for InMemorySigner
benthecarman [Wed, 31 May 2023 22:47:54 +0000 (17:47 -0500)]
Impl PartialEq and Debug for InMemorySigner

These are needed for being able to compare a
ChannelMonitor<InMemorySigner> and are just nice to haves for
developers.

11 months agoMerge pull request #2167 from TheBlueMatt/2023-04-monitor-e-monitor-prep
Matt Corallo [Wed, 31 May 2023 22:48:34 +0000 (22:48 +0000)]
Merge pull request #2167 from TheBlueMatt/2023-04-monitor-e-monitor-prep

Add infra to block ChannelMonitorUpdates on forwarded claims

11 months agoMerge pull request #2324 from dunxen/2023-05-rgscheckgenesishash
Matt Corallo [Wed, 31 May 2023 19:21:10 +0000 (19:21 +0000)]
Merge pull request #2324 from dunxen/2023-05-rgscheckgenesishash

Fail RGS data processing early if there is a chain hash mismatch

11 months agoAdd infra to block `ChannelMonitorUpdate`s on forwarded claims 2023-04-monitor-e-monitor-prep
Matt Corallo [Fri, 7 Apr 2023 00:31:39 +0000 (00:31 +0000)]
Add infra to block `ChannelMonitorUpdate`s on forwarded claims

When we forward a payment and receive an `update_fulfill_htlc`
message from the downstream channel, we immediately claim the HTLC
on the upstream channel, before even doing a `commitment_signed`
dance on the downstream channel. This implies that our
`ChannelMonitorUpdate`s "go out" in the right order - first we
ensure we'll get our money by writing the preimage down, then we
write the update that resolves giving money on the downstream node.

This is safe as long as `ChannelMonitorUpdate`s complete in the
order in which they are generated, but of course looking forward we
want to support asynchronous updates, which may complete in any
order.

Here we add infrastructure to handle downstream
`ChannelMonitorUpdate`s which are blocked on an upstream
preimage-containing one. We don't yet actually do the blocking which
will come in a future commit.

11 months agoReapply pending `ChannelMonitorUpdate`s on startup
Matt Corallo [Tue, 4 Apr 2023 21:45:37 +0000 (21:45 +0000)]
Reapply pending `ChannelMonitorUpdate`s on startup

If a `ChannelMonitorUpdate` was created and given to the user but
left uncompleted when the `ChannelManager` is persisted prior to a
restart, the user likely lost the `ChannelMonitorUpdate`(s). Thus,
we need to replay them for the user, which we do here using the
new `BackgroundEvent::MonitorUpdateRegeneratedOnStartup` variant.

11 months agoProcess background events when taking the total_consistency_lock
Matt Corallo [Thu, 6 Apr 2023 19:56:01 +0000 (19:56 +0000)]
Process background events when taking the total_consistency_lock

When we generated a `ChannelMonitorUpdate` during `ChannelManager`
deserialization, we must ensure that it gets processed before any
other `ChannelMonitorUpdate`s. The obvious hook for this is when
taking the `total_consistency_lock`, which makes it unlikely we'll
regress by forgetting this.

Here we add that call in the `PersistenceNotifierGuard`, with a
test-only atomic bool to test that this criteria is met.

11 months agoHandle `BackgroundEvent`s replaying non-closing monitor updates
Matt Corallo [Wed, 10 May 2023 05:39:26 +0000 (05:39 +0000)]
Handle `BackgroundEvent`s replaying non-closing monitor updates

`BackgroundEvent` was used to store `ChannelMonitorUpdate`s which
result in a channel force-close, avoiding relying on
`ChannelMonitor`s having been loaded while `ChannelManager`
block-connection methods are called during startup.

In the coming commit(s) we'll also generate non-channel-closing
`ChannelMonitorUpdate`s during startup, which will need to be
replayed prior to any other `ChannelMonitorUpdate`s generated from
normal operation.

In the next commit we'll handle that by handling `BackgroundEvent`s
immediately after locking the `total_consistency_lock`.

11 months agoMerge pull request #2293 from wpaulino/disconnect-peers-timer-tick
Matt Corallo [Tue, 30 May 2023 18:30:49 +0000 (18:30 +0000)]
Merge pull request #2293 from wpaulino/disconnect-peers-timer-tick

Disconnect peers on timer ticks to unblock channel state machine

11 months agoMake `AChannelManager` trait slightly more generic and always on
Matt Corallo [Wed, 10 May 2023 17:15:29 +0000 (17:15 +0000)]
Make `AChannelManager` trait slightly more generic and always on

Rather than letting `AChannelManager` be bounded by all traits
being `Sized` we make them explicitly `?Sized`. We also make the
trait no longer test-only as it will be used in a coming commit.

11 months agoReturn the counterparty node_id as a part of a force-shutdown res
Matt Corallo [Wed, 10 May 2023 00:45:08 +0000 (00:45 +0000)]
Return the counterparty node_id as a part of a force-shutdown res

In the coming commits we'll need the counterparty node_id when
handling a background monitor update as we may need to resume
normal channel operation as a result. Thus, we go ahead and pipe it
through from the shutdown end, as it makes the codepaths
consistent.

Sadly, the monitor-originated shutdown case doesn't allow for a
required counterparty node_id as some versions of LDK didn't have
it present in the ChannelMonitor.

11 months agoMove the `ShutdownResult` type alias to `channel.rs`
Matt Corallo [Wed, 24 May 2023 03:45:30 +0000 (03:45 +0000)]
Move the `ShutdownResult` type alias to `channel.rs`

This allows us to make the `force_shutdown` definition less verbose

11 months agoFix `held_by_thread` in `no-std` to return instead of panicing
Matt Corallo [Tue, 30 May 2023 18:11:47 +0000 (18:11 +0000)]
Fix `held_by_thread` in `no-std` to return instead of panicing

Our `no-std` locks simply panic if a lock cannot be taken as there
should be no lock contention in a single-threaded environment.
However, the `held_by_thread` debug methods were delegating to the
lock methods which resulted in a panic when asserting that a lock
*is* held by the current thread.

Instead, they are updated here to call the relevant `RefCell`
testing methods.

11 months agoMerge pull request #2323 from ariard/2023-05-remove-ariard-pgp-key
Matt Corallo [Mon, 29 May 2023 22:18:42 +0000 (22:18 +0000)]
Merge pull request #2323 from ariard/2023-05-remove-ariard-pgp-key

Remove ariard key from the security team

11 months agoFail RGS data processing early if there is a chain hash mismatch
Duncan Dean [Mon, 29 May 2023 12:43:05 +0000 (14:43 +0200)]
Fail RGS data processing early if there is a chain hash mismatch

No point in doing any extra processing if we don't even have a match
for the chain hash.

11 months agoRemove ariard key from the security team
Antoine Riard [Sun, 28 May 2023 19:58:06 +0000 (20:58 +0100)]
Remove ariard key from the security team

11 months agoDisconnect peers on timer ticks to unblock channel state machine
Wilmer Paulino [Sat, 13 May 2023 01:39:18 +0000 (18:39 -0700)]
Disconnect peers on timer ticks to unblock channel state machine

At times, we've noticed that channels with `lnd` counterparties do not
receive messages we expect to in a timely manner (or at all) after
sending them a `ChannelReestablish` upon reconnection, or a
`CommitmentSigned` message. This can block the channel state machine
from making progress, eventually leading to force closes, if any pending
HTLCs are committed and their expiration is met.

It seems common wisdom for `lnd` node operators to periodically restart
their node/reconnect to their peers, allowing them to start from a fresh
state such that the message we expect to receive hopefully gets sent. We
can achieve the same end result by disconnecting peers ourselves
(regardless of whether they're a `lnd` node), which we opt to implement
here by awaiting their response within two timer ticks.

11 months agoAdd new DisconnectPeerWithWarning variant to ErrorAction
Wilmer Paulino [Thu, 18 May 2023 19:12:15 +0000 (12:12 -0700)]
Add new DisconnectPeerWithWarning variant to ErrorAction

11 months agoRemove unreachable warning message send on UnknownRequiredFeature read
Wilmer Paulino [Thu, 18 May 2023 19:02:24 +0000 (12:02 -0700)]
Remove unreachable warning message send on UnknownRequiredFeature read

`enqueue_message` simply adds the message to the outbound queue, it
still needs to be written to the socket with `do_attempt_write_data`.
However, since we immediately return an error causing the socket to be
closed, the message never actually gets sent.

11 months agoImplement enqueue_message trait requirements on Message enum
Wilmer Paulino [Thu, 18 May 2023 16:36:18 +0000 (09:36 -0700)]
Implement enqueue_message trait requirements on Message enum

The inner structs of each enum variant already implemented them and we
plan to pass in `Message`s to `enqueue_message` in a future commit.

11 months agoMerge pull request #2316 from benthecarman/payment-err-dervies
Wilmer Paulino [Thu, 25 May 2023 16:41:59 +0000 (09:41 -0700)]
Merge pull request #2316 from benthecarman/payment-err-dervies

Derive a PartialEq and Eq for PaymentError

11 months agoDerive a PartialEq and Eq for PaymentError
benthecarman [Tue, 23 May 2023 21:18:39 +0000 (16:18 -0500)]
Derive a PartialEq and Eq for PaymentError

This lets users compare error types more easily without needing a match
statement.

11 months agoMerge pull request #2280 from TheBlueMatt/2023-05-event-deadlock
Wilmer Paulino [Wed, 24 May 2023 17:51:16 +0000 (10:51 -0700)]
Merge pull request #2280 from TheBlueMatt/2023-05-event-deadlock

Never block a thread on the `PeerManager` event handling lock

11 months agoNever block a thread on the `PeerManager` event handling lock 2023-05-event-deadlock
Matt Corallo [Tue, 9 May 2023 00:30:33 +0000 (00:30 +0000)]
Never block a thread on the `PeerManager` event handling lock

If thre's a thread currently handling `PeerManager` events, the
next thread which attempts to handle events will block on the first
and then handle events after the first completes. (later threads
will return immediately to avoid blocking more than one thread).

This works fine as long as the user has a spare thread to leave
blocked, but if they don't (e.g. are running with a single-threaded
tokio runtime) this can lead to a full deadlock.

Instead, here, we never block waiting on another event processing
thread, returning immediately after signaling that the first thread
should start over once its complete to ensure all events are
handled.

While this could lead to starvation as we cause one thread to go
around and around and around again, the risk of that should be
relatively low as event handling should be pretty quick, and it's
certainly better than deadlocking.

Fixes https://github.com/lightningdevkit/rapid-gossip-sync-server/issues/32

Atomic lock simplification suggestion from @andrei-21

11 months agoMerge pull request #2284 from dunxen/2023-05-netgraphpartialeqtotallock
Matt Corallo [Wed, 24 May 2023 00:14:25 +0000 (00:14 +0000)]
Merge pull request #2284 from dunxen/2023-05-netgraphpartialeqtotallock

Use a total lockorder for `NetworkGraph`'s `PartialEq` impl

11 months agoUse a total lockorder for `NetworkGraph`'s `PartialEq` impl
Duncan Dean [Tue, 9 May 2023 09:44:48 +0000 (11:44 +0200)]
Use a total lockorder for `NetworkGraph`'s `PartialEq` impl

`NetworkGraph`'s `PartialEq` impl before this commit was deadlock-prone.
Similarly to `ChannelMonitor`'s, `PartialEq` impl, we use position in
memory for a total lockorder. This uses the assumption that the objects
cannot move within memory while the inner locks are held.

11 months agoMerge pull request #2272 from benthecarman/package-broadcast
Matt Corallo [Sun, 21 May 2023 01:53:35 +0000 (01:53 +0000)]
Merge pull request #2272 from benthecarman/package-broadcast

Support broadcasting multiple transactions at once

11 months agoMerge pull request #2235 from TheBlueMatt/2023-04-criterion
Matt Corallo [Sat, 20 May 2023 23:02:44 +0000 (23:02 +0000)]
Merge pull request #2235 from TheBlueMatt/2023-04-criterion

Replace std's unmaintained bench with criterion

11 months agoMerge pull request #2226 from alecchendev/2023-04-persist-network-graph-on-rgs
Matt Corallo [Sat, 20 May 2023 22:55:43 +0000 (22:55 +0000)]
Merge pull request #2226 from alecchendev/2023-04-persist-network-graph-on-rgs

Update BP `NetworkGraph` and `Scorer` persist frequency

11 months agoMerge pull request #2204 from jkczyz/2023-04-custom-feature-bits
Matt Corallo [Thu, 18 May 2023 19:28:19 +0000 (19:28 +0000)]
Merge pull request #2204 from jkczyz/2023-04-custom-feature-bits

Support for custom feature bits

11 months agoMerge pull request #1841 from ariard/2022-11-revoked-balance-non-aggregable
Matt Corallo [Thu, 18 May 2023 19:24:55 +0000 (19:24 +0000)]
Merge pull request #1841 from ariard/2022-11-revoked-balance-non-aggregable

Post-anchor: do not aggregate claim of revoked output

11 months agoRemove aggregable flag from PackageTemplate constructor
Antoine Riard [Wed, 30 Nov 2022 01:48:22 +0000 (20:48 -0500)]
Remove aggregable flag from PackageTemplate constructor

11 months agoAnchor: do not aggregate claim of revoked output
Antoine Riard [Wed, 9 Nov 2022 00:12:22 +0000 (19:12 -0500)]
Anchor: do not aggregate claim of revoked output

See https://github.com/lightning/bolts/pull/803

This protect the justice claim of counterparty revoked output. As
otherwise if the all the revoked outputs claims are batched in a
single transaction, low-feerate HTLCs transactions can delay our
honest justice claim transaction until BREAKDOWN_TIMEOUT expires.

11 months agoPersist scorer upon update based on event handling
Alec Chen [Mon, 24 Apr 2023 21:37:05 +0000 (16:37 -0500)]
Persist scorer upon update based on event handling

Now that we persist the scorer upon events, we extend timer persistence
from 30 seconds to 1 hour, similar to network graph persistence.

11 months agoPrune and persist RGS network graph after initial sync
Alec Chen [Mon, 15 May 2023 23:51:05 +0000 (18:51 -0500)]
Prune and persist RGS network graph after initial sync

Previously we would wait 60 seconds after startup, however for RGS we
prune/persist after its initial sync since 60 seconds is likely too
long.

11 months agoMerge pull request #2288 from wpaulino/rust-bitcoin-30-prereqs
Matt Corallo [Mon, 15 May 2023 18:42:38 +0000 (18:42 +0000)]
Merge pull request #2288 from wpaulino/rust-bitcoin-30-prereqs

11 months agoSupport broadcasting multiple transactions at once
benthecarman [Fri, 5 May 2023 13:29:52 +0000 (08:29 -0500)]
Support broadcasting multiple transactions at once

11 months agoMerge pull request #2271 from tnull/2023-04-fix-onion-panic
Matt Corallo [Thu, 11 May 2023 21:52:47 +0000 (21:52 +0000)]
Merge pull request #2271 from tnull/2023-04-fix-onion-panic

Return error when failing onion packet construction

11 months agoMerge pull request #2286 from benthecarman/spendable-outputs-psbt
Matt Corallo [Thu, 11 May 2023 21:41:07 +0000 (21:41 +0000)]
Merge pull request #2286 from benthecarman/spendable-outputs-psbt

Create and Sign PSBTs for spendable outputs

11 months agoReturn error when failing to construc onion messages
Elias Rohrer [Wed, 5 Apr 2023 15:08:49 +0000 (17:08 +0200)]
Return error when failing to construc onion messages

Previously, we would panic when failing to construct onion messages in
certain circumstances. Here we opt to always rather error out and don't
panic if something goes wrong during OM packet construction.

11 months agoUpdate .gitignore to ignore benchmark data files 2023-04-criterion
Matt Corallo [Tue, 2 May 2023 17:13:02 +0000 (17:13 +0000)]
Update .gitignore to ignore benchmark data files

11 months agoAdd trivial README to bench to describe how to run them.
Matt Corallo [Tue, 2 May 2023 17:04:11 +0000 (17:04 +0000)]
Add trivial README to bench to describe how to run them.

11 months agoReplace std's unmaintained bench with criterion
Matt Corallo [Thu, 11 May 2023 06:03:57 +0000 (06:03 +0000)]
Replace std's unmaintained bench with criterion

Rather than using the std benchmark framework (which isn't
maintained and is unlikely to get any further maintenance), we swap
for criterion, which at least gets us a variable number of test
runs so our benchmarks don't take forever.

We also fix the RGS benchmark to pass now that the file in use is
stale compared to today's date.

11 months agoAdd an additional test/bench for routing larger amounts, score more
Matt Corallo [Thu, 11 May 2023 05:46:38 +0000 (05:46 +0000)]
Add an additional test/bench for routing larger amounts, score more

When benchmarking our router, we previously only ever tested with
amounts under 1,000 sats, which is an incredibly small amount.
While this ensures we have the maximal number of available channels
to consider, it prevents our scorer from getting exercise across
its range. Further, we only score the immediate path we are
expecting to to send over, and not randomly but rather based on the
amount sent.

Here we try to make the benchmarks a bit more realistic by adding
a new benchmark which attempts to send around 100K sats, which is
a reasonable amount to send over a channel today. We also convert
the scoring data to be randomized based on the seed as well as
attempt to (possibly) find a new route for a much larger value and
score based on that. This potentially allows us to score multiple
potential paths between the source and destination as the large
route-find may return an MPP result.

11 months agoUnify route benchmarking with route tests
Matt Corallo [Thu, 11 May 2023 05:34:00 +0000 (05:34 +0000)]
Unify route benchmarking with route tests

There's a few route tests which do the same thing as the benchmarks
as they're also a good test. However, they didn't share code, which
is somewhat wasteful, so we fix that here.

11 months agoMerge pull request #2237 from henghonglee/issue-2189-score-params
Matt Corallo [Thu, 11 May 2023 05:27:14 +0000 (05:27 +0000)]
Merge pull request #2237 from henghonglee/issue-2189-score-params

[#2189] Score Fee Params as a passed in parameter

11 months agoCreate and Sign PSBTs for spendable outputs
benthecarman [Tue, 9 May 2023 18:29:51 +0000 (13:29 -0500)]
Create and Sign PSBTs for spendable outputs

11 months agoMove functions around to colocate impl of FeeParams and DecayParams
henghonglee [Wed, 10 May 2023 05:13:42 +0000 (22:13 -0700)]
Move functions around to colocate impl of FeeParams and DecayParams

11 months agoScore's FeeParams as passed-in params on Routefinding functions
henghonglee [Sat, 6 May 2023 18:01:22 +0000 (11:01 -0700)]
Score's FeeParams as passed-in params on Routefinding functions

This PR aims to create a "stateless" scorer. Instead of passing
in fee params at construction-time, we want to parametrize the
scorer with an associated "parameter" type, which is then
passed to the router function itself, and allows passing
different parameters per route-finding call.

11 months agoUpdate missed comment in Features test
Jeffrey Czyz [Wed, 19 Apr 2023 20:15:41 +0000 (15:15 -0500)]
Update missed comment in Features test

11 months agoAdd Features::set_{required|optional}_custom_bit
Jeffrey Czyz [Wed, 19 Apr 2023 20:14:13 +0000 (15:14 -0500)]
Add Features::set_{required|optional}_custom_bit

Custom message handlers may need to set feature bits that are unknown to
LDK. Provide Features::set_required_custom_bit and
Features::set_optional_custom_bit to allow for this.

11 months agoCheck unknown features compared to handlers
Jeffrey Czyz [Wed, 19 Apr 2023 22:48:02 +0000 (17:48 -0500)]
Check unknown features compared to handlers

Each message handler provides which features it supports. A custom
message handler may support unknown features. Therefore, these features
should be checked against instead of the features known by LDK.
Additionally, fail the connection if the peer requires features unknown
to the handler. The peer should already fail the connection in the
latter case.

11 months agoFix test_restored_packages_retry serialized monitor payload
Wilmer Paulino [Wed, 10 May 2023 17:39:19 +0000 (10:39 -0700)]
Fix test_restored_packages_retry serialized monitor payload

The purpose of this payload is to ensure we retry restored packages on a
`ChannelMonitor` that has upgraded from a version that previously did
not have such retry logic. We can verify this works by checking whether
a restored package has a `height_timer` of `None` upon deserializing the
monitor payload.

In the previous commit, we added a helper that constructs blocks
whenever tests demand blocks be connected. This helper moved towards
having all connected blocks have a version of 0x2000_0000 (also known as
NO_SOFT_FORK_SIGNALLING). However, previously, it was possible for some
blocks to be connected with a slighty different version: 0x0200_0000,
resulting in different block hashes.

This block hash divergence prompted a failure in this test when
`ConnectStyle::HighlyRedundantTransactionsFirstSkippingBlocks` is used
for `nodes[0]`, since this block connection style reconfirms
transactions redundantly and the serialized monitor payload kept a
reference to the hash of the block with version 0x0200_0000, when it
should be expecting one with version 0x2000_0000.

11 months agoUse helper to create dummy blocks
Wilmer Paulino [Thu, 27 Apr 2023 20:31:04 +0000 (13:31 -0700)]
Use helper to create dummy blocks

`rust-bitcoin v0.30.0` introduces concrete variants for data members of
block `Header`s. To avoid having to update these across every use, we
introduce new helpers to create dummy blocks and headers, such that the
update process is a bit more straight-forward.

11 months agoCheck difficulty transition against `Target` instead of `Work`
Wilmer Paulino [Fri, 28 Apr 2023 09:06:23 +0000 (02:06 -0700)]
Check difficulty transition against `Target` instead of `Work`

`rust-bitcoin v0.30.0` made some changes in this area that no longer
allow us to work with the previously exposed `U256` type. While `Work`
and `Target` (they're inverses of each other) essentially represent the
same concept, it makes more sense from their API's perspective to only
expose difficulty transitions and adjustments on `Target`s.

11 months agoIgnore lightning-transaction-sync build output
Wilmer Paulino [Thu, 27 Apr 2023 21:29:04 +0000 (14:29 -0700)]
Ignore lightning-transaction-sync build output

11 months agoMerge pull request #2279 from benthecarman/ord-invoice
Wilmer Paulino [Wed, 10 May 2023 18:24:00 +0000 (11:24 -0700)]
Merge pull request #2279 from benthecarman/ord-invoice

Impl PartialOrd and Ord for Invoice

11 months agoMerge pull request #2287 from TheBlueMatt/2023-05-no-background-event-dup-persist
Matt Corallo [Wed, 10 May 2023 00:02:31 +0000 (00:02 +0000)]
Merge pull request #2287 from TheBlueMatt/2023-05-no-background-event-dup-persist

Stop persisting background shutdown monitor updates

11 months agoRename ClosingMonitorUpdate MonitorUpdateRegeneratedOnStartup 2023-05-no-background-event-dup-persist
Matt Corallo [Tue, 9 May 2023 21:24:56 +0000 (21:24 +0000)]
Rename ClosingMonitorUpdate MonitorUpdateRegeneratedOnStartup

This makes much clearer at sites generating such events that they
will be lost on restart, to reduce risk of bugs creeping in due to
lost monitor updates.

11 months agoStop persisting background shutdown monitor updates
Matt Corallo [Tue, 9 May 2023 21:02:01 +0000 (21:02 +0000)]
Stop persisting background shutdown monitor updates

In d4810087c1 we added logic to apply `ChannelMonitorUpdate`s which
were a part of a channel closure async via a background queue to
address some startup issues. When we did that we persisted those
updates to ensure we replayed them when starting next time.

However, there was no reason to - if we persisted and then
restarted even without those monitor updates we'd find a monitor
without a channel, which we'd tell to broadcast the latest
commitment transaction to force-close.

Since adding that logic, we've used the same background queue for
several purposes.

11 months agoImpl PartialOrd and Ord for Invoice
benthecarman [Tue, 9 May 2023 00:02:05 +0000 (19:02 -0500)]
Impl PartialOrd and Ord for Invoice

11 months agoMerge pull request #2281 from dunxen/2023-05-dfmsgfollowups
Matt Corallo [Tue, 9 May 2023 17:10:38 +0000 (17:10 +0000)]
Merge pull request #2281 from dunxen/2023-05-dfmsgfollowups

Dual funding message follow-ups

11 months agoMerge pull request #2270 from tnull/2023-05-improve-tx-sync-compat-notice
Matt Corallo [Tue, 9 May 2023 17:06:43 +0000 (17:06 +0000)]
Merge pull request #2270 from tnull/2023-05-improve-tx-sync-compat-notice

Make `lightning-transaction-sync` compat notice a bit more explicit

11 months agoMerge pull request #2278 from benthecarman/faster-u16-check
Wilmer Paulino [Tue, 9 May 2023 16:53:12 +0000 (09:53 -0700)]
Merge pull request #2278 from benthecarman/faster-u16-check

Check too many tx outputs upfront when verifying funding tx

11 months agoMerge pull request #2277 from valentinewallace/2023-05-fix-big-oms
valentinewallace [Tue, 9 May 2023 12:50:28 +0000 (08:50 -0400)]
Merge pull request #2277 from valentinewallace/2023-05-fix-big-oms

Fix large onion message packet generation

11 months agoMake `lightning-transaction-sync` compat notice a bit more explicit
Elias Rohrer [Fri, 5 May 2023 09:26:50 +0000 (11:26 +0200)]
Make `lightning-transaction-sync` compat notice a bit more explicit

As `lightning-transaction-sync` was introduced with 0.0.114 and depended
on prior changes in the same release cycle we deemed it reasonable to
omit the implicitly limited backwards compatibility.

It however turns out this might be confusing to users copy/pasting the
codebase. Here we therefore spell out the implicit dependency on 0.0.114
and above.

11 months agoEnforce that no bytes remain for TransactionU16LenLimited read
Duncan Dean [Tue, 9 May 2023 06:37:58 +0000 (08:37 +0200)]
Enforce that no bytes remain for TransactionU16LenLimited read

11 months agoMove TransactionU16LenLimited to ser.rs
Duncan Dean [Tue, 9 May 2023 06:19:32 +0000 (08:19 +0200)]
Move TransactionU16LenLimited to ser.rs

11 months agoMerge pull request #2258 from valentinewallace/2023-04-blinded-pathfinding-groundwork-2
Matt Corallo [Mon, 8 May 2023 23:17:42 +0000 (23:17 +0000)]
Merge pull request #2258 from valentinewallace/2023-04-blinded-pathfinding-groundwork-2

Prefactor `PaymentParameters` for blinded recipients

11 months agoCheck too many tx outputs upfront when verifying funding tx
benthecarman [Mon, 8 May 2023 22:49:05 +0000 (17:49 -0500)]
Check too many tx outputs upfront when verifying funding tx

11 months agoMove final_cltv_expiry_delta from PaymentParams to Payee::Clear
Valentine Wallace [Thu, 27 Apr 2023 21:37:38 +0000 (17:37 -0400)]
Move final_cltv_expiry_delta from PaymentParams to Payee::Clear

Since blinded pay params won't have this value.

11 months agoAdd BOLT 12 features to PaymentParams
Valentine Wallace [Wed, 3 May 2023 18:05:20 +0000 (14:05 -0400)]
Add BOLT 12 features to PaymentParams

11 months agoMove BOLT11 features from top level PaymentParams to Payee::Clear
Valentine Wallace [Wed, 3 May 2023 17:04:25 +0000 (13:04 -0400)]
Move BOLT11 features from top level PaymentParams to Payee::Clear

Since blinded payees don't have this.

11 months agoError if BOLT 11 features are provided for blinded payment params
Valentine Wallace [Sat, 29 Apr 2023 19:37:51 +0000 (15:37 -0400)]
Error if BOLT 11 features are provided for blinded payment params

11 months agoMove payee node id from top level PaymentParams to Payee::Clear
Valentine Wallace [Sat, 29 Apr 2023 21:13:02 +0000 (17:13 -0400)]
Move payee node id from top level PaymentParams to Payee::Clear

Since blinded payees don't have one

11 months agoFix onion messages of size BIG_PACKET_HOP_DATA_LEN
Valentine Wallace [Mon, 8 May 2023 18:23:56 +0000 (14:23 -0400)]
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.

11 months agoFix broken test utils in OnionMessenger and stop asserting on logs
Valentine Wallace [Fri, 5 May 2023 17:33:08 +0000 (13:33 -0400)]
Fix broken test utils in OnionMessenger and stop asserting on logs

11 months agoMerge pull request #1794 from dunxen/2022-10-dualfunding-act-1
Wilmer Paulino [Mon, 8 May 2023 17:47:51 +0000 (10:47 -0700)]
Merge pull request #1794 from dunxen/2022-10-dualfunding-act-1

Dual funding and interactive tx construction wire messages

11 months agoMerge pull request #2269 from TheBlueMatt/2023-05-doc-events-present
Matt Corallo [Mon, 8 May 2023 16:39:15 +0000 (16:39 +0000)]
Merge pull request #2269 from TheBlueMatt/2023-05-doc-events-present

Document when event fields are `Some`

11 months agoMerge pull request #2265 from wpaulino/channel-force-closed-update-err
Matt Corallo [Mon, 8 May 2023 16:33:14 +0000 (16:33 +0000)]
Merge pull request #2265 from wpaulino/channel-force-closed-update-err

Prevent ChannelForceClosed monitor update error after detecting spend

11 months agoAdd Features::requires_unknown_bits_from
Jeffrey Czyz [Fri, 5 May 2023 18:38:50 +0000 (13:38 -0500)]
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.

11 months agoAdd PeerManager::init_features to DRY up code
Jeffrey Czyz [Tue, 18 Apr 2023 17:23:20 +0000 (12:23 -0500)]
Add PeerManager::init_features to DRY up code

11 months agoProvide features in CustomMessageHandler
Jeffrey Czyz [Thu, 13 Apr 2023 18:08:45 +0000 (13:08 -0500)]
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.

11 months agoDefine core::ops::BitOr for Features<T>
Jeffrey Czyz [Thu, 13 Apr 2023 18:06:14 +0000 (13:06 -0500)]
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.

12 months agoMerge pull request #2267 from TheBlueMatt/2023-05-better-scb-err
Matt Corallo [Sat, 6 May 2023 00:58:18 +0000 (00:58 +0000)]
Merge pull request #2267 from TheBlueMatt/2023-05-better-scb-err

Mention lnd's SCB feature in the corresponding error message

12 months agoAdd & generate dual-funding message fuzzing
Duncan Dean [Mon, 13 Mar 2023 09:44:31 +0000 (11:44 +0200)]
Add & generate dual-funding message fuzzing

12 months agoAdd new wire messaging and events but don't handle them
Duncan Dean [Tue, 1 Nov 2022 14:12:06 +0000 (16:12 +0200)]
Add new wire messaging and events but don't handle them

12 months agoAdd message structs required for dual-funded channels
Duncan Dean [Thu, 20 Oct 2022 20:56:37 +0000 (22:56 +0200)]
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.

12 months agoDocuemnt when `PaymentPathFailed::payment_id` is `Some` 2023-05-doc-events-present
Matt Corallo [Fri, 5 May 2023 04:08:55 +0000 (04:08 +0000)]
Docuemnt when `PaymentPathFailed::payment_id` is `Some`

The `PaymentPathFailed::payment_id` field has been `Some` since
the field was added in
73f601fd3d1c9defe553392264ca6dbcc53e4334.

12 months agoDocument when `PaymentPathSuccessful::payment_hash` is filled in.
Matt Corallo [Fri, 5 May 2023 03:33:54 +0000 (03:33 +0000)]
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.

12 months agoImprove logging around redundant force close monitor updates
Wilmer Paulino [Thu, 4 May 2023 22:37:25 +0000 (15:37 -0700)]
Improve logging around redundant force close monitor updates

12 months agoMention lnd's SCB feature in the corresponding error message 2023-05-better-scb-err
Matt Corallo [Fri, 5 May 2023 00:13:25 +0000 (00:13 +0000)]
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.

12 months agoPrevent ChannelForceClosed monitor update error after detecting spend
Wilmer Paulino [Thu, 4 May 2023 22:16:17 +0000 (15:16 -0700)]
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.