]> git.bitcoin.ninja Git - rust-lightning/log
rust-lightning
19 months agoMerge pull request #2101 from TheBlueMatt/2023-03-one-less-sig
Matt Corallo [Thu, 6 Apr 2023 18:07:55 +0000 (18:07 +0000)]
Merge pull request #2101 from TheBlueMatt/2023-03-one-less-sig

Support future removal of redundant per-HTLC signatures in `CMU`s

19 months agoMerge pull request #2145 from TheBlueMatt/2023-04-async-bp-cleanups
Matt Corallo [Wed, 5 Apr 2023 16:55:51 +0000 (16:55 +0000)]
Merge pull request #2145 from TheBlueMatt/2023-04-async-bp-cleanups

Add test coverage of async BP and fix minor bug

19 months agoAdd an async version of BP's test_channel_manager_persist_error 2023-04-async-bp-cleanups
Matt Corallo [Mon, 3 Apr 2023 20:47:02 +0000 (20:47 +0000)]
Add an async version of BP's test_channel_manager_persist_error

This gives us coverage of an async BP returning an error.

19 months agoMake BP's `not_pruning_network_graph_until...` test dual async-sync
Matt Corallo [Mon, 3 Apr 2023 20:34:13 +0000 (20:34 +0000)]
Make BP's `not_pruning_network_graph_until...` test dual async-sync

19 months agoMake BP's `test_payment_path_scoring` dual sync/async.
Matt Corallo [Mon, 3 Apr 2023 20:19:49 +0000 (20:19 +0000)]
Make BP's `test_payment_path_scoring` dual sync/async.

This finally gives us a bit of test coverage of the async BP, which
was embarrassingly missing until now.

19 months agoEnsure `background-processor` exits after any sleep future says to
Matt Corallo [Mon, 3 Apr 2023 20:15:04 +0000 (20:15 +0000)]
Ensure `background-processor` exits after any sleep future says to

If the user's sleep future passed to an async background processor
only returns true for exiting once and then reverts back to false,
we should exit anyway when we get a chance to. We do to this here
by always ensuring we check the exit flag even when only polling
sleep futures with no intent to (yet) exit. This is utilized in the
tests added in the coming commit(s).

19 months agoDon't immediately exit BP if `ChannelManager` is persistable
Matt Corallo [Mon, 3 Apr 2023 20:11:30 +0000 (20:11 +0000)]
Don't immediately exit BP if `ChannelManager` is persistable

If `ChannelManager` is persistable before the async background
processor even starts, it may not even get around to overwriting
the `should_exit` flag before testing it, and the default value is
(incorrectly) true, causing an immediate unconditional exit.

The default value should simply be false.

Fixes #2140

19 months agoMake `lightning-background-processor` test failures more debugable
Matt Corallo [Mon, 3 Apr 2023 18:38:26 +0000 (18:38 +0000)]
Make `lightning-background-processor` test failures more debugable

Instead of asserting a `Result` `is_ok`, we should always simply
`unwrap` to get a backgrace, and we should avoid doing so if the
thread is already panicking.

19 months agoMerge pull request #2150 from TonyGiorgio/esplora-0.4
valentinewallace [Tue, 4 Apr 2023 19:49:44 +0000 (15:49 -0400)]
Merge pull request #2150 from TonyGiorgio/esplora-0.4

lightning-transaction-sync: Bump esplora to 0.4

19 months agoMerge pull request #2147 from TheBlueMatt/2023-04-rgs-log-some
Matt Corallo [Tue, 4 Apr 2023 19:07:24 +0000 (19:07 +0000)]
Merge pull request #2147 from TheBlueMatt/2023-04-rgs-log-some

Add some trivial logging during RGS update processing.

19 months agolightning-transaction-sync: Bump esplora to 0.4
Tony Giorgio [Tue, 4 Apr 2023 17:28:15 +0000 (12:28 -0500)]
lightning-transaction-sync: Bump esplora to 0.4

19 months agoMerge pull request #2005 from arik-so/2023-01-taproot-message-types
Matt Corallo [Tue, 4 Apr 2023 16:38:04 +0000 (16:38 +0000)]
Merge pull request #2005 from arik-so/2023-01-taproot-message-types

Update messages for Taproot types.

19 months agoAdd some trivial logging during RGS update processing. 2023-04-rgs-log-some
Matt Corallo [Mon, 3 Apr 2023 22:29:41 +0000 (22:29 +0000)]
Add some trivial logging during RGS update processing.

Rather than being totally silent, we need to at least note that we
are processing an RGS update when doing so in the logs, which we do
here.

Fixes #1981.

19 months agoAdd Taproot CI test.
Arik Sosman [Fri, 31 Mar 2023 05:59:21 +0000 (22:59 -0700)]
Add Taproot CI test.

19 months agoUpdate the `RevokeAndACK` message for Taproot support.
Arik Sosman [Wed, 29 Mar 2023 23:35:05 +0000 (16:35 -0700)]
Update the `RevokeAndACK` message for Taproot support.

19 months agoUpdate the `CommitmentSigned` message for Taproot support.
Arik Sosman [Wed, 29 Mar 2023 22:21:30 +0000 (15:21 -0700)]
Update the `CommitmentSigned` message for Taproot support.

19 months agoUpdate the `FundingSigned` message for Taproot support.
Arik Sosman [Wed, 29 Mar 2023 22:02:34 +0000 (15:02 -0700)]
Update the `FundingSigned` message for Taproot support.

19 months agoUpdate the `FundingCreated` message for Taproot support.
Arik Sosman [Wed, 29 Mar 2023 00:33:45 +0000 (17:33 -0700)]
Update the `FundingCreated` message for Taproot support.

19 months agoUpdate the `AcceptChannel` message for Taproot support.
Arik Sosman [Tue, 28 Mar 2023 21:59:20 +0000 (14:59 -0700)]
Update the `AcceptChannel` message for Taproot support.

19 months agoIntroduce MuSig2-related types for Taproot channels.
Arik Sosman [Tue, 28 Mar 2023 21:37:01 +0000 (14:37 -0700)]
Introduce MuSig2-related types for Taproot channels.

19 months agoMerge pull request #2090 from TheBlueMatt/2023-03-mon-wake-bp
Matt Corallo [Mon, 3 Apr 2023 20:12:46 +0000 (20:12 +0000)]
Merge pull request #2090 from TheBlueMatt/2023-03-mon-wake-bp

Wake background-processor on async monitor update completion

19 months agoMerge pull request #2098 from tnull/2023-03-add-channel-pending-event
Matt Corallo [Mon, 3 Apr 2023 18:26:18 +0000 (18:26 +0000)]
Merge pull request #2098 from tnull/2023-03-add-channel-pending-event

Add `ChannelPending` event emitted upon `funding_signed`

19 months agoMerge pull request #2143 from get10101/chore/convenient-confirm
Matt Corallo [Mon, 3 Apr 2023 17:58:54 +0000 (17:58 +0000)]
Merge pull request #2143 from get10101/chore/convenient-confirm

Implement `chain::Confirm` without mandating any owned values

19 months agoAdd `ChannelPending` event emitted upon `funding_signed`
Elias Rohrer [Fri, 10 Mar 2023 15:30:37 +0000 (16:30 +0100)]
Add `ChannelPending` event emitted upon `funding_signed`

Currently, users don't have good way of being notified when channel open
negotiations have succeeded and new channels are pending confirmation on
chain. To this end, we add a new `ChannelPending` event that is emitted
when send or receive a `funding_signed` message, i.e., at the last
moment before waiting for the confirmation period.

We track whether the event had previously been emitted in `Channel` and
remove it from `internal_funding_created` entirely. Hence, we now
only emit the event after ChannelMonitorUpdate completion, or upon
channel reestablish. This mitigates a race condition where where we
wouldn't persist the event *and* wouldn't regenerate it on restart,
therefore potentially losing it, if async CMU wouldn't complete before
ChannelManager persistence.

19 months agoExpose an option to substantially reduce sleep time in futures BP 2023-03-mon-wake-bp
Matt Corallo [Tue, 14 Mar 2023 21:23:21 +0000 (21:23 +0000)]
Expose an option to substantially reduce sleep time in futures BP

Some users have suggested that waking every 100ms can be
CPU-intensive in deployments with hundreds or thousands of nodes
all running on the same machine. Thus, we add an option to the
futures-based `background-processor` to avoid waking every 100ms to
check for iOS having backgrounded our app and cut our TCP sockets.

This cuts the normal sleep time down from 100ms to 10s, for those
who turn it on.

19 months agoWake the background processor if an async monitor update completes
Matt Corallo [Thu, 9 Mar 2023 03:11:13 +0000 (03:11 +0000)]
Wake the background processor if an async monitor update completes

If the `ChainMonitor` gets an async monitor update completion, this
means the `ChannelManager` needs to be polled for event processing.
Here we wake it using the new multi-`Future`-await `Sleeper`, or
the existing `select` block in the async BP.

Fixes #2052.

19 months agoDrop the dummy no-std `Condvar` which never sleeps
Matt Corallo [Fri, 31 Mar 2023 18:08:10 +0000 (18:08 +0000)]
Drop the dummy no-std `Condvar` which never sleeps

In `no-std`, we exposed `wait` functions which rely on a dummy
`Condvar` which never actually sleeps. This is somwhat nonsensical,
not to mention confusing to users. Instead, we simply remove the
`wait` methods in `no-std` builds.

19 months agoMove the pub `wait` methods from `ChannelManager` to `Future`
Matt Corallo [Thu, 9 Mar 2023 02:48:17 +0000 (02:48 +0000)]
Move the pub `wait` methods from `ChannelManager` to `Future`

Rather than having three ways to await a `ChannelManager` being
persistable, this moves to just exposing the awaitable `Future` and
having sleep functions on that.

19 months agoImplement the ability to block on multiple futures at once
Matt Corallo [Fri, 31 Mar 2023 05:13:35 +0000 (05:13 +0000)]
Implement the ability to block on multiple futures at once

In the next commits we'll be adding a second notify pipeline - from
the `ChainMonitor` back to the background processor. This will
cause the `background-processor` to need to await multiple wakers
at once, which we cannot do in the current scheme without taking on
a full async runtime.

Building a multi-future waiter isn't so bad, and notably will allow
us to remove the existing sleep pipeline entirely, reducing the
complexity of our wakers implementation by only having one notify
path to consider.

19 months agoDo not bound callbacks by `Send` when building for `no-std`
Matt Corallo [Wed, 15 Mar 2023 17:43:29 +0000 (17:43 +0000)]
Do not bound callbacks by `Send` when building for `no-std`

`Send` is rather useless on a `no-std` target - we don't have
threads and are just needlessly restricting ourselves, so here we
skip it for the wakers callback.

19 months agoAdd `CondVar::wait_{timeout_,}while` to `debug_sync`
Matt Corallo [Mon, 20 Mar 2023 18:26:39 +0000 (18:26 +0000)]
Add `CondVar::wait_{timeout_,}while` to `debug_sync`

These are useful, but we previously couldn't use them due to our
MSRV. Now that we can, we should use them, so we expose them via
our normal debug_sync wrappers.

19 months agoImplement chain::Confirm without mandating any owned values
Lucas Soriano del Pino [Mon, 3 Apr 2023 11:12:44 +0000 (21:12 +1000)]
Implement chain::Confirm without mandating any owned values

19 months agoCorrect `lightning-net-tokio` documentation, remove stale example
Matt Corallo [Thu, 9 Mar 2023 02:52:48 +0000 (02:52 +0000)]
Correct `lightning-net-tokio` documentation, remove stale example

The `lightning-net-tokio` crate-level example contained a carryover
from when it was the primary notifier of the background processor
and now just shows an "example" of creating a method to call
another method with the same parameters and then do event
processing (which doesn't make sense, the BP should do that).

Instead, the examples are simply removed and the documentation is
tweaked to include recent changes.

19 months agoMerge pull request #2141 from TheBlueMatt/2023-03-fuck-rust
Wilmer Paulino [Fri, 31 Mar 2023 01:41:21 +0000 (18:41 -0700)]
Merge pull request #2141 from TheBlueMatt/2023-03-fuck-rust

Drop `futures` dependency from `lightning-block-sync`

19 months agoRemove `futures` dependency in `lightning-background-processor` 2023-03-fuck-rust
Matt Corallo [Thu, 30 Mar 2023 22:11:22 +0000 (22:11 +0000)]
Remove `futures` dependency in `lightning-background-processor`

As `futures` apparently makes no guarantees on MSRVs even in patch
releases we really can't rely on it at all, and while it currently
has an acceptable MSRV without the macros feature, its best to just
remove it wholesale.

Luckily, removing it is relatively trivial, even if it requires
the most trivial of unsafe tags.

19 months agoReplace `futures` `select` with our own select enum to fix MSRV
Matt Corallo [Thu, 30 Mar 2023 21:52:03 +0000 (21:52 +0000)]
Replace `futures` `select` with our own select enum to fix MSRV

`futures` recently broke our MSRV by bumping the `syn` major
version in a patch release. This makes it impractical for us to
use, instead here we replace the usage of its `select_biased` macro
with a trivial enum.

Given its simplicity we likely should have done this without ever
taking the dependency.

19 months agoAvoid connection-per-RPC-call again by caching connections
Matt Corallo [Thu, 30 Mar 2023 18:51:56 +0000 (18:51 +0000)]
Avoid connection-per-RPC-call again by caching connections

In general, only one request will be in flight at a time in
`lightning-block-sync`. Ideally we'd only have one connection, but
without using the `futures` mutex type.

Here we solve this narrowly for the one-request-at-a-time case by
caching the connection and takeing the connection out of the cache
while we work on it.

19 months agoDrop `futures` dependency from `lightning-block-sync`
Matt Corallo [Thu, 30 Mar 2023 18:33:04 +0000 (18:33 +0000)]
Drop `futures` dependency from `lightning-block-sync`

Some how I'd understood that `futures` had reasonable MSRV
guarantees (e.g. at least Debian stable), but apparently that isn't
actually the case, as they bumped it to upgrade to syn (with
apparently no actual features or bugfixes added as a result?) with
no minor version bump or any available alternative (unlike Tokio,
which does LTS releases).

Luckily its relatively easy to just drop the `futures` dependency -
it means a new connection for each request, which is annoying, but
certainly not the end of the world, and its easier than trying to
deal with pinning `futures`.

See https://github.com/rust-lang/futures-rs/pull/2733

19 months agoMerge pull request #2136 from marctyndel/2023-03-paymentforwarded-expose-amount-forwarded
Matt Corallo [Thu, 30 Mar 2023 18:15:23 +0000 (18:15 +0000)]
Merge pull request #2136 from marctyndel/2023-03-paymentforwarded-expose-amount-forwarded

Expose amount forwarded in `PaymentForwarded` event

19 months agoMerge pull request #2059 from wpaulino/broadcast-missing-anchors-event
Matt Corallo [Wed, 29 Mar 2023 21:54:58 +0000 (21:54 +0000)]
Merge pull request #2059 from wpaulino/broadcast-missing-anchors-event

Queue BackgroundEvent to force close channels upon ChannelManager::read

19 months agoadd outbound_amount_forwarded_msat field to PaymentForwarded event
Marc Tyndel [Tue, 28 Mar 2023 16:29:00 +0000 (12:29 -0400)]
add outbound_amount_forwarded_msat field to PaymentForwarded event

19 months agoMerge pull request #2062 from alecchendev/2023-02-allow-overshoot-mpp
valentinewallace [Wed, 29 Mar 2023 15:37:51 +0000 (11:37 -0400)]
Merge pull request #2062 from alecchendev/2023-02-allow-overshoot-mpp

Allow overshooting final htlc amount and expiry

19 months agoAdd pending changelog noting possible backwards compat panic
Wilmer Paulino [Tue, 28 Mar 2023 20:22:47 +0000 (13:22 -0700)]
Add pending changelog noting possible backwards compat panic

19 months agoIgnore lockorder violation on same callsite with different construction
Wilmer Paulino [Wed, 22 Mar 2023 18:46:05 +0000 (11:46 -0700)]
Ignore lockorder violation on same callsite with different construction

As long as the lock order on such locks is still valid, we should allow
them regardless of whether they were constructed at the same location or
not. Note that we can only really enforce this if we require one lock
call per line, or if we have access to symbol columns (as we do on Linux
and macOS). We opt for a smaller patch by relying on the latter.

This was previously triggered by some recent test changes to
`test_manager_serialize_deserialize_inconsistent_monitor`. When the
test ends and a node is dropped causing us to persist each, we'd detect
a possible lockorder violation deadlock across three different `Mutex`
instances that are held at the same location when serializing our
`per_peer_states` in `ChannelManager::write`.

The presumed lockorder violation happens because the first `Mutex` held
shares the same construction location with the third one, while the
second `Mutex` has a different construction location. When we hold the
second one, we consider the first as a dependency, and then consider the
second as a dependency when holding the third, causing a circular
dependency (since the third shares the same construction location as the
first).

This isn't considered a lockorder violation that could result in a
deadlock as the comment suggests inline though, since we are under a
dependent write lock which no one else can have access to.

19 months agoMerge pull request #2082 from wpaulino/bump-htlc-resolution-tx-locktime
Arik [Wed, 29 Mar 2023 00:14:59 +0000 (17:14 -0700)]
Merge pull request #2082 from wpaulino/bump-htlc-resolution-tx-locktime

Expose HTLC transaction locktime in BumpTransactionEvent::HTLCResolution

19 months agoUse onion amount `amt_to_forward` for MPP set calculation
Alec Chen [Tue, 7 Mar 2023 01:51:44 +0000 (19:51 -0600)]
Use onion amount `amt_to_forward` for MPP set calculation

If routing nodes take less fees and pay the final node more than
`amt_to_forward`, the receiver may see that `total_msat` has been met
before all of the sender's intended HTLCs have arrived. The receiver
may then prematurely claim the payment and release the payment hash,
allowing routing nodes to claim the remaining HTLCs. Using the onion
value `amt_to_forward` to determine when `total_msat` has been met
allows the sender to control the set total.

19 months agoAllow overshooting final cltv_expiry
Alec Chen [Tue, 7 Mar 2023 01:33:45 +0000 (19:33 -0600)]
Allow overshooting final cltv_expiry

Final nodes previously had stricter requirements on HTLC contents
matching onion value compared to intermediate nodes. This allowed
for probing, i.e. the last intermediate node could overshoot the
value by a small amount and conclude from the acceptance or rejection
of the HTLC whether the next node was the destination. This also
applies to the msat amount, however this change was already present.

19 months agoAllow overshooting `total_msat` for an MPP
Alec Chen [Wed, 1 Mar 2023 00:42:39 +0000 (18:42 -0600)]
Allow overshooting `total_msat` for an MPP

While retrying a failed path of an MPP, a node may want to overshoot
the `total_msat` in order to use a path with an `htlc_minimum_msat`
greater than the remaining value being sent. This commit no longer
fails MPPs that overshoot the `total_msat`, however it does fail
HTLCs with the same payment hash that are received *after* a
payment has become claimable.

19 months agoAdd `total_value_received` to `ClaimableHTLC` for claim validation
Alec Chen [Thu, 23 Mar 2023 19:34:57 +0000 (14:34 -0500)]
Add `total_value_received` to `ClaimableHTLC` for claim validation

This is pre-work for allowing nodes to overshoot onion values and
changing validation for MPP completion. This adds a field to
`ClaimableHTLC` that is separate from the onion values, which
represents the actual received amount reported in `PaymentClaimable`
which is what we want to validate against when a user goes to claim.

19 months agoExpose HTLC transaction locktime in BumpTransactionEvent::HTLCResolution
Wilmer Paulino [Tue, 7 Mar 2023 01:01:21 +0000 (17:01 -0800)]
Expose HTLC transaction locktime in BumpTransactionEvent::HTLCResolution

While users could easily figure it out based on the set of HTLC
descriptors included within, we already track it within the
`OnchainTxHandler`, so we might as well expose it to users as a
nice-to-have. It's also yet another thing they must get right to ensure
their HTLC transaction broadcasts are valid.

19 months agoSet transaction locktime on malleable packages to discourage fee sniping
Wilmer Paulino [Tue, 28 Mar 2023 19:09:13 +0000 (12:09 -0700)]
Set transaction locktime on malleable packages to discourage fee sniping

This only applies to all malleable packages on channels pre-dating
anchors and malleables packages for counterparty commitments
post-anchors. Malleables packages for holder commitments post-anchors
should have their transaction locktime applied manually by the consumer
of `BumpTransactionEvent::HTLCResolution` events.

19 months agoRe-work PackageSolvingData::absolute_tx_timelock
Wilmer Paulino [Tue, 28 Mar 2023 19:03:19 +0000 (12:03 -0700)]
Re-work PackageSolvingData::absolute_tx_timelock

Previously, this would return the earliest height the output could be
confirmed, which seems to no longer be useful. The only use of the
method was to determine whether we should delay a package to a future
block. Instead, we choose to return the absolute locktime the
transaction spending the output should have, which better corresponds to
the method name and still supports the delay functionality mentioned.

Doing so also allows us to expose the locktime required for HTLC
transactions we need to broadcast based on our own commitments for
anchor channels.

19 months agoMerge pull request #2133 from tnull/2023-03-pin-syn
Wilmer Paulino [Tue, 28 Mar 2023 17:16:39 +0000 (10:16 -0700)]
Merge pull request #2133 from tnull/2023-03-pin-syn

Pin`tokio` to fix CI

19 months agoMerge pull request #2132 from tnull/2023-03-tx-sync-even-more-robustness
Matt Corallo [Tue, 28 Mar 2023 16:42:44 +0000 (16:42 +0000)]
Merge pull request #2132 from tnull/2023-03-tx-sync-even-more-robustness

Drop `OnceCell` in `lightning-transaction-sync` tests

19 months agoMerge pull request #2083 from wpaulino/events-module
Matt Corallo [Tue, 28 Mar 2023 16:37:55 +0000 (16:37 +0000)]
Merge pull request #2083 from wpaulino/events-module

Move events.rs into its own top-level module

19 months agoPin `tokio` to fix CI
Elias Rohrer [Tue, 28 Mar 2023 10:56:38 +0000 (12:56 +0200)]
Pin `tokio` to fix CI

Recently `tokio` got updated to 1.27.0, which bumped MSRV from 1.49 to
1.56.

Here we pin `tokio` accordingly to unbreak CI.

19 months agoRemove unnecessary restriction on `esplora-client` version
Elias Rohrer [Mon, 27 Mar 2023 11:33:01 +0000 (13:33 +0200)]
Remove unnecessary restriction on `esplora-client` version

19 months agoMove test `bitcoind`/`electrsd` out of `OnceCell`
Elias Rohrer [Mon, 27 Mar 2023 11:19:15 +0000 (13:19 +0200)]
Move test `bitcoind`/`electrsd` out of `OnceCell`

`OnceCell` doesn't call `drop`, which makes the spawned
`bitcoind`/`electrsd` instances linger around after our tests have
finished. To fix this, we move them out of `OnceCell` and let every test
that needs them spawn their own instances. This additional let us drop
the `OnceCell` dev dependency.

19 months agoMerge pull request #2125 from benthecarman/invoice-expire-time
Matt Corallo [Mon, 27 Mar 2023 22:54:05 +0000 (22:54 +0000)]
Merge pull request #2125 from benthecarman/invoice-expire-time

Add helper functions for invoice expiry

19 months agoAdd helper functions for invoice expiry
benthecarman [Thu, 23 Mar 2023 20:41:55 +0000 (15:41 -0500)]
Add helper functions for invoice expiry

19 months agoMerge pull request #2110 from munjesi/docs_fixes
Matt Corallo [Mon, 27 Mar 2023 18:12:00 +0000 (18:12 +0000)]
Merge pull request #2110 from munjesi/docs_fixes

Replacing (C-not exported) in the docs

20 months agoMerge pull request #2123 from benthecarman/create-inv-desc
Jeffrey Czyz [Fri, 24 Mar 2023 20:00:10 +0000 (15:00 -0500)]
Merge pull request #2123 from benthecarman/create-inv-desc

Add generic InvoiceDescription to invoice in InvoiceBuilder

20 months agoSupport future removal of redundant per-HTLC data in `ChanMonUpd`s 2023-03-one-less-sig
Matt Corallo [Fri, 10 Mar 2023 23:32:48 +0000 (23:32 +0000)]
Support future removal of redundant per-HTLC data in `ChanMonUpd`s

`ChannelMonitorUpdate`s are our most size-sensitive objects - they
are the minimal objects which need to be written to disk on each
commitment update. Thus, we should be careful to ensure we don't
pack too much extraneous information into each one.

Here we add future support for removing the per-HTLC explicit
`Option<Signature>` and `HTLCInCommitmentUpdate` for non-dust HTLCs
in holder commitment tx updates, which are redundant with the
`HolderCommitmentTransaction`.

While we cannot remove them entirely as previous versions rely on
them, adding support for filling in the in-memory structures from
the redundant fields will let us remove them in a future version.

We also add test-only generation logic to test the new derivation.

20 months agoAdd generic InvoiceDescription to invoice in InvoiceBuilder
benthecarman [Thu, 23 Mar 2023 05:06:32 +0000 (00:06 -0500)]
Add generic InvoiceDescription to invoice in InvoiceBuilder

20 months agoAdd new sub-module for BumpTransactionEvent
Wilmer Paulino [Tue, 7 Mar 2023 22:20:31 +0000 (14:20 -0800)]
Add new sub-module for BumpTransactionEvent

Its accompanying event handler will also live here.

20 months agoMove events.rs into its own top-level module
Wilmer Paulino [Tue, 7 Mar 2023 21:57:01 +0000 (13:57 -0800)]
Move events.rs into its own top-level module

This is largely motivated by some follow-up work for anchors that will
introduce an event handler for `BumpTransaction` events, which we can
now include in this new top-level `events` module.

20 months agoMerge pull request #2114 from Evanfeenstra/force_close_msg_display
Jeffrey Czyz [Wed, 22 Mar 2023 17:32:22 +0000 (12:32 -0500)]
Merge pull request #2114 from Evanfeenstra/force_close_msg_display

use PrintableString to Display CounterpartyForceClosed peer_msg

20 months agoReplacing (C-not exported) in the docs
munjesi [Thu, 16 Mar 2023 17:35:52 +0000 (20:35 +0300)]
Replacing (C-not exported) in the docs

20 months agoSanitizedString struct to safely Display CounterpartyForceClosed peer_msg
Evan Feenstra [Sat, 18 Mar 2023 05:24:23 +0000 (22:24 -0700)]
SanitizedString struct to safely Display CounterpartyForceClosed peer_msg

20 months agoRemove unused broadcast_latest_holder_commitment_txn method
Wilmer Paulino [Tue, 28 Feb 2023 18:45:49 +0000 (10:45 -0800)]
Remove unused broadcast_latest_holder_commitment_txn method

20 months agoAvoid refusing ChannelMonitorUpdates we expect to receive after closing
Wilmer Paulino [Tue, 28 Feb 2023 18:45:48 +0000 (10:45 -0800)]
Avoid refusing ChannelMonitorUpdates we expect to receive after closing

There is no need to fill the user's logs with errors that are expected
to be hit based on specific edge cases, like providing preimages after
a monitor has seen a confirmed commitment on-chain.

This doesn't really change our behavior – we still apply and persist the
state changes resulting from processing these updates regardless of
whether they succeed or not.

20 months agoQueue BackgroundEvent to force close channels upon ChannelManager::read
Wilmer Paulino [Tue, 28 Feb 2023 18:45:48 +0000 (10:45 -0800)]
Queue BackgroundEvent to force close channels upon ChannelManager::read

This results in a new, potentially redundant, `ChannelMonitorUpdate`
that must be applied to `ChannelMonitor`s to broadcast the holder's
latest commitment transaction.

This is a behavior change for anchor channels since their commitments
may require additional fees to be attached through a child anchor
transaction. Recall that anchor transactions are only generated by the
event consumer after processing a `BumpTransactionEvent::ChannelClose`
event, which is yielded after applying a
`ChannelMonitorUpdateStep::ChannelForceClosed` monitor update. Assuming
the node operator is not watching the mempool to generate these anchor
transactions without LDK, an anchor channel which we had to fail when
deserializing our `ChannelManager` would have its commitment transaction
broadcast by itself, potentially exposing the node operator to loss of
funds if the commitment transaction's fee is not enough to be accepted
into the network's mempools.

20 months agoUse CLOSED_CHANNEL_UPDATE_ID in force closing ChannelMonitorUpdates
Wilmer Paulino [Tue, 28 Feb 2023 18:45:44 +0000 (10:45 -0800)]
Use CLOSED_CHANNEL_UPDATE_ID in force closing ChannelMonitorUpdates

Currently, all that is required to force close a channel is to broadcast
either of the available commitment transactions, but this changes with
anchor outputs – commitment transactions may need to have
additional fees attached in order to confirm in a timely manner. While
we may be able to just queue a new update using the channel's next
available update ID, this may result in a violation of the
`ChannelMonitor` API (each update ID must strictly increase by 1) if the
channel had updates that were persisted by its `ChannelMonitor`, but not
the `ChannelManager`. Therefore, we choose to re-purpose the existing
`CLOSED_CHANNEL_UPDATE_ID` update ID to also apply to
`ChannelMonitorUpdate`s that will force close their respective channel
by broadcasting the holder's latest commitment transaction.

20 months agoMerge pull request #2102 from douglaz/node_info_addresses
Matt Corallo [Tue, 21 Mar 2023 22:42:16 +0000 (22:42 +0000)]
Merge pull request #2102 from douglaz/node_info_addresses

Remove NodeAnnouncementInfo addresses

20 months agoMerge pull request #2034 from wpaulino/anchor-revoked-aggregate-claim
Matt Corallo [Tue, 21 Mar 2023 22:32:18 +0000 (22:32 +0000)]
Merge pull request #2034 from wpaulino/anchor-revoked-aggregate-claim

Add test for aggregated revoked HTLC claim on anchors channel

20 months agoMerge pull request #2100 from douglaz/docs_fixes
Matt Corallo [Tue, 21 Mar 2023 18:44:23 +0000 (18:44 +0000)]
Merge pull request #2100 from douglaz/docs_fixes

Docs improvements

20 months agoRemove redundant `addresses` field from `NodeAnnouncementInfo`
Allan Douglas R. de Oliveira [Mon, 13 Mar 2023 20:13:28 +0000 (20:13 +0000)]
Remove redundant `addresses` field from `NodeAnnouncementInfo`

...replacing it with an acessor `addresses()`.

Besides removing a redundant data structure already present on inner
`NodeAnnouncement`, this change makes it possible to discover new address types
upon deserialization thanks to `UnsignedNodeAnnouncement`'s implementation.

20 months agoDocs improvements
Allan Douglas R. de Oliveira [Tue, 14 Mar 2023 19:54:44 +0000 (19:54 +0000)]
Docs improvements

20 months agoTest anchors build in CI
Wilmer Paulino [Wed, 15 Feb 2023 00:32:45 +0000 (16:32 -0800)]
Test anchors build in CI

20 months agoAdd an `optional_vec` TLV format which makes sense, unlike vec_type
Matt Corallo [Mon, 20 Mar 2023 23:24:56 +0000 (23:24 +0000)]
Add an `optional_vec` TLV format which makes sense, unlike vec_type

`vec_type` is confusing - it is happy to have a missing entry,
"reading" an empty `Vec` instead, but always writes something,
making a serialization round-trip different.

This is a problem for writing a new `Vec` which is
backwards-incompatible, but only if filled in. In that case we'd
really like the same read behavior, but not write anything if the
`Vec` is empty. Here we introduce such semantics via a new
`optional_vec` TLV format.

20 months agoMerge pull request #2118 from TheBlueMatt/2023-03-no-useless-strings
Matt Corallo [Mon, 20 Mar 2023 22:22:56 +0000 (22:22 +0000)]
Merge pull request #2118 from TheBlueMatt/2023-03-no-useless-strings

Remove unnecessary heap allocations in log-entry-matching tests

20 months agoRemove unnecessary use in `channelmonitor` tests module 2023-03-no-useless-strings
Matt Corallo [Mon, 20 Mar 2023 20:08:29 +0000 (20:08 +0000)]
Remove unnecessary use in `channelmonitor` tests module

20 months agoRemove unnecessary heap allocations in log-entry-matching tests
Matt Corallo [Mon, 20 Mar 2023 20:07:18 +0000 (20:07 +0000)]
Remove unnecessary heap allocations in log-entry-matching tests

20 months agoAdd test for aggregated revoked HTLC claim on anchors channel
Wilmer Paulino [Wed, 15 Feb 2023 00:10:52 +0000 (16:10 -0800)]
Add test for aggregated revoked HTLC claim on anchors channel

20 months agoMaintain order of yielded claim events
Wilmer Paulino [Tue, 14 Feb 2023 23:49:37 +0000 (15:49 -0800)]
Maintain order of yielded claim events

Since the claim events are stored internally within a HashMap, they will
be yielded in a random order once dispatched. Claim events may be
invalidated if a conflicting claim has confirmed on-chain and we need to
generate a new claim event; the randomized order could result in the
new claim event being handled prior to the previous. To maintain the
order in which the claim events are generated, we track them in a Vec
instead and ensure only one instance of a PackageId only ever exists
within it.

This would have certain performance implications, but since we're
bounded by the total number of HTLCs in a commitment anyway, we're
comfortable with taking the cost.

20 months agoRename keys for OnchainTxHandler::claimable_outpoints map
Wilmer Paulino [Tue, 14 Feb 2023 23:48:44 +0000 (15:48 -0800)]
Rename keys for OnchainTxHandler::claimable_outpoints map

20 months agoClarify OnchainEvent::Claim behavior
Wilmer Paulino [Wed, 15 Feb 2023 00:24:30 +0000 (16:24 -0800)]
Clarify OnchainEvent::Claim behavior

The previous documentation was slightly incorrect, a `Claim` can also be
from the counterparty if they happened to claim the same exact set of
outputs as a claiming transaction we generated.

20 months agoAdd missing docs for BumpHTLCResolution
Wilmer Paulino [Wed, 15 Feb 2023 00:14:03 +0000 (16:14 -0800)]
Add missing docs for BumpHTLCResolution

20 months agoFix stale import behind anchors build tag
Wilmer Paulino [Tue, 14 Feb 2023 23:38:20 +0000 (15:38 -0800)]
Fix stale import behind anchors build tag

20 months agoDerive Eq on structs behind anchors build flag
Wilmer Paulino [Tue, 14 Feb 2023 23:36:37 +0000 (15:36 -0800)]
Derive Eq on structs behind anchors build flag

20 months agoImplement PartialEq manually
Wilmer Paulino [Tue, 14 Feb 2023 23:35:40 +0000 (15:35 -0800)]
Implement PartialEq manually

Since we don't store `pending_claim_events` within `OnchainTxHandler` as
they'll be regenerated on restarts, we opt to implement `PartialEq`
manually such that the field is not longer considered.

20 months agoMerge pull request #2116 from TheBlueMatt/2023-03-serde-sucks
Matt Corallo [Mon, 20 Mar 2023 18:31:12 +0000 (18:31 +0000)]
Merge pull request #2116 from TheBlueMatt/2023-03-serde-sucks

Drop `serde` dependency from `lightning-block-sync`

20 months agoDrop `serde` dependency from `lightning-block-sync` 2023-03-serde-sucks
Matt Corallo [Sun, 19 Mar 2023 23:39:56 +0000 (23:39 +0000)]
Drop `serde` dependency from `lightning-block-sync`

`serde` doesn't bother with MSRVs, so its expected to break
frequently. Yesterday, the `derive` feature had its MSRV broken in
a patch version without care.

Luckily its trivial for us to remove the `serde` dependency in
`lightning-block-sync`, using only `serde_json` for the JSON
deserialization part. It even ends up net-negative on LoC.

20 months agoMerge pull request #2024 from TheBlueMatt/2023-02-6conf-pub-hints
Matt Corallo [Sun, 19 Mar 2023 23:42:15 +0000 (23:42 +0000)]
Merge pull request #2024 from TheBlueMatt/2023-02-6conf-pub-hints

Include a route hint for public, not-yet-announced channels

20 months agoInclude a route hint for public, not-yet-announced channels 2023-02-6conf-pub-hints
Matt Corallo [Thu, 9 Feb 2023 19:02:04 +0000 (19:02 +0000)]
Include a route hint for public, not-yet-announced channels

If we have a public channel which doesn't yet have six
confirmations the network can't possibly know about it as we cannot
have announced it yet. However, because we refuse to include
route-hints if we have any public channels, we will generate
invoices that no one can pay.

Thus, if we have any public, not-yet-announced channels, include
them as a route-hint.

20 months agoMerge pull request #2107 from TheBlueMatt/2023-04-msrv-cleanup
Matt Corallo [Fri, 17 Mar 2023 19:21:49 +0000 (19:21 +0000)]
Merge pull request #2107 from TheBlueMatt/2023-04-msrv-cleanup

Bump MSRV to 1.48 and replace most of CI with a bash script

20 months agoReplace the bulk of CI with a (much simpler) bash script 2023-04-msrv-cleanup
Matt Corallo [Wed, 15 Mar 2023 19:20:08 +0000 (19:20 +0000)]
Replace the bulk of CI with a (much simpler) bash script

20 months agoMerge pull request #2094 from johncantrell97/expose-fee
Matt Corallo [Wed, 15 Mar 2023 21:16:23 +0000 (21:16 +0000)]
Merge pull request #2094 from johncantrell97/expose-fee

expose `feerate_per_kw` in `ChannelDetails`

20 months agoFix onion_message functional_tests `no-std` build
Matt Corallo [Wed, 15 Mar 2023 19:19:49 +0000 (19:19 +0000)]
Fix onion_message functional_tests `no-std` build

20 months agoRemove `build-features` CI flag now that its always true
Matt Corallo [Wed, 15 Mar 2023 18:18:01 +0000 (18:18 +0000)]
Remove `build-features` CI flag now that its always true