Commit graph

7823 commits

Author SHA1 Message Date
Matt Corallo
91a60c8256 impl Borrow<[u8]> for ChannelId
We do this for `Payment*` in `lightning-types` and its needed for
the `hex_conservaitve` `impl_fmt_traits` macro which we'll use in
the next commit.
2024-09-09 15:30:09 +00:00
Matt Corallo
eba329cfaf
Merge pull request #3304 from TheBlueMatt/2024-09-tokio-util-msrv
Fix MSRV builds of `lightning-transaction-sync` in CI
2024-09-09 13:38:44 +00:00
Matt Corallo
35bc575cd8 Reduce features on lightning-transaction-sync's tokio dev-dep
This should marginally reduce the chance of MSRV or other issues in
the future, and is just good practice.
2024-09-08 21:42:36 +00:00
Matt Corallo
7e22b78af9 Test lightning-transaction-sync in our no-dev-deps MSRV test
Now that `lightning-transaction-sync` is in the workspace and
covered by our MSRV we should be testing it in our
`msrv-no-dev-deps-check` test crate.
2024-09-08 21:21:35 +00:00
Matt Corallo
868a5956a4 Fix MSRV test of lightning-transaction-sync with esplora-async
`lightning-transaction-sync`'s `esplora-async` dependency
indirectly depends on `tokio-util`, which, like tokio, recently
bumped its MSRV.

Here we update `ci/ci-tests.sh` to pin `tokio-util` to make MSRV
builds pass.
2024-09-08 21:21:35 +00:00
Matt Corallo
d35239ca62
Merge pull request #3290 from tnull/2024-09-add-tx-sync-copyright
Add copyright notices to `lightning-transaction-sync` modules
2024-09-04 14:13:37 +00:00
Elias Rohrer
c15968c5f4
Add copyright notices to lightning-transaction-sync modules 2024-09-04 13:02:45 +02:00
Matt Corallo
b023eed99c
Merge pull request #3278 from TheBlueMatt/2024-08-124-relnotes
Add an 0.0.124 CHANGELOG entry
2024-09-03 18:35:17 +00:00
Matt Corallo
c9de257498 Update versions to 0.0.124 and invoice 0.32 types 0.1 release 2024-09-03 18:18:52 +00:00
Matt Corallo
f52148f4c2 Add an 0.0.124 CHANGELOG entry 2024-09-03 18:18:52 +00:00
Matt Corallo
187a2cb45e
Merge pull request #3285 from TheBlueMatt/2024-08-tx-too-small
Correct handling of added `OP_RETURN` outputs
2024-09-03 17:53:08 +00:00
Matt Corallo
660f5c2af7
Merge pull request #3284 from TheBlueMatt/2024-08-bindings-imports-suck 2024-09-03 15:20:16 +00:00
Matt Corallo
5f5c275ea3 Correct ANCHOR_INPUT_WITNESS_WEIGHT constant
`ANCHOR_INPUT_WITNESS_WEIGHT` is too high by two weight units,
likely it was calculated to include the SegWit marker bytes, but
it is used to describe an `Input::satisfaction_weight`, which does
not expect the marker bytes.

This corrects that oversight, reducing the constant by two and
adding the marker bytes back in our own internal weight
calculations. It also fixes a second issue where the constant was
too low by one when `grind_signatures` is not set, as that may
result in a signature being one byte longer than we expect.
2024-09-03 15:09:32 +00:00
Matt Corallo
5a2372ce8e Add a test for the past few commits
This adds a single test for coin selection which exercises the
issues fixed in the past three commits.
2024-09-03 14:15:28 +00:00
Matt Corallo
b3644dcdb5 Drop bogus debug assertion that we don't overpay on fees
We should always select at least as many coins as is required to
meet the feerate target, but its perfectly fine if we overshoot.
Specifically, we may overshoot deliberately if we choose to burn
change to fee instead.
2024-09-03 14:15:28 +00:00
Matt Corallo
d383ac49a2 Handle under-coin-selecting due to an added OP_RETURN output
When we do coin selection for channel close anchor spends, we may
do coin selection targeting exactly the input values we need.
However, if coin selection does not include a change output, we may
add an OP_RETURN output, which may cause us to end up with less
fee than we wanted on the resulting package.

Here we address this issue by running coin selection twice - first
without seeking the extra weight of the OP_RETURN output, and again
if we find that we under-selected.
2024-09-03 14:15:28 +00:00
Matt Corallo
ff00c63171 Ensure we never try to broadcast a transaction <= 64 bytes
While these are consensus-valid, they have been nonstandard for
quite some time and will not relay nor confirm.
2024-09-03 14:13:43 +00:00
Matt Corallo
704078ac87 Specify imports manually in types::features::sealed
There's not a lot of reason to do this, but sadly the bindings
don't currently resolve wildcard imports at all, and I don't want
to deal with implementing it right now.
2024-09-01 01:08:38 +00:00
Matt Corallo
74ae8e9ef2
Merge pull request #3282 from TheBlueMatt/2024-08-fix-bench-logging
Dont output logs when benchmarking
2024-08-30 21:24:51 +00:00
Matt Corallo
ac4815abb6 Dont output logs when benchmarking
In 11ab302087 we accidentally removed
the `not(ldk_bench)` bound before outputting logs to stderr, which
we restore here. Instead of simply ignoring logs in benchmarks,
which we did previously, we instead format logs (in a way that LLVM
will not optimize out).
2024-08-30 18:42:04 +00:00
Matt Corallo
cdcab1ce1b Remove log level filtering in tests
There's no reason why we should be filtering our logs during tests.
It seems mostly like the `TestLogger` was written more as a sample
logger than a test logger, but these days we have samples, so we
should just drop the filtering and show everything.
2024-08-30 17:37:59 +00:00
Matt Corallo
7e513f97dd
Merge pull request #3280 from TheBlueMatt/2024-08-124rc
Bump versions to rc1
2024-08-29 20:52:03 +00:00
Matt Corallo
e5e700c486
Merge pull request #3279 from TheBlueMatt/2024-08-no-pub-usize
Use `u64` for `required_unknown_bits_from` indexes, not `usize`
2024-08-29 20:06:28 +00:00
Matt Corallo
856c980594 Bump versions to rc1 2024-08-29 19:40:09 +00:00
Matt Corallo
caf0daa2dd
Merge pull request #3257 from tnull/2024-08-fix-is-public
Rename instances of `is_public` to `is_announced`
2024-08-29 19:39:30 +00:00
Elias Rohrer
5928063789
Rename announced_channel to is_announced_for_forwarding
.. we rename the flag configuring whether we announce a channel or not.
2024-08-29 21:22:22 +02:00
Matt Corallo
1d810a5816 Use u64 for required_unknown_bits_from indexes, not usize
While `usize` should be fine, we're multiplying the index by 8 so
if we have a jumbo feature bit fitting in a 32-bit size type may
not quite work. More importantly, this would be the first use of a
`usize` in the public API and dealing with it in bindings is
annoying so we just replace with a `u64`.
2024-08-29 16:47:54 +00:00
Matt Corallo
1122e82bf0
Merge pull request #3238 from Mirebella/clippy-checks
Added clippy ignore rules for all errors and warnings
2024-08-29 16:06:40 +00:00
Matt Corallo
bf6a53e0fd
Merge pull request #3275 from TheBlueMatt/2024-08-3259-followups
#3259 followups
2024-08-29 00:54:19 +00:00
Matt Corallo
a97807647a
Merge pull request #3276 from arik-so/arik/2024/08/apply_monitor_updates_on_archive
Process updates before archiving monitors.
2024-08-28 21:53:43 +00:00
Arik Sosman
47c8aa51a6
Process updates before archiving monitors.
Previously, `MonitorUpdatingPersister` was disregarding any unapplied
monitor updates when archiving them. This commit ensures that upon
reading monitors, their corresponding updates are also read and
applied prior to archiving.
2024-08-28 12:19:38 -07:00
Arik Sosman
61197390d6
Store Broadcaster and FeeEstimator on MonitorUpdatingPersister.
`MonitorUpdatingPersister` does not currently correctly archive
monitors because it neglects any unapplied updates. In order to start
applying these updates, the archiving methods will require access to
instances of `BroadcasterInterface` and `FeeEstimator`.

This commit requires that the `MonitorUpdatingPersister` be
instantiated with those instances, obviating the need for passing
them around, and laying the foundation for the following commit.
2024-08-28 12:19:38 -07:00
Matt Corallo
ea646ae888 Test manual funding transaction Event::DiscardFunding generation 2024-08-28 14:50:52 +00:00
Matt Corallo
683aa8350e Correct manual shutdown detection on channel closure
In 5e874c3dc9 we'd intended to not
reveal the dummy funding transaction in `Event::DiscardFunding`.
However, instead of looking at the channel that was just closed,
the logic only looks at any other channels which were funded as a
part of the same batch. Because manually-funded transactions
cannot currently be done for batch funding, this was actually dead
code, preventing the new changes from taking effect.
2024-08-28 14:35:54 +00:00
Matt Corallo
6a81d5d4bb Add additional documentation on Channel::unbroadcasted_funding 2024-08-28 13:50:17 +00:00
Matt Corallo
b7064808ac
Merge pull request #3268 from TheBlueMatt/2024-08-moar-feerate-categories
Split up `ConfirmationTarget` even more
2024-08-28 13:15:13 +00:00
Mirebella
0d71a5f9c2 Fix CI linting error 2024-08-28 09:53:51 +02:00
Mirebella
6ff1978eba Add clippy ignore rules for all errors and warnings 2024-08-28 09:47:40 +02:00
Matt Corallo
cf97cefb47 Test new ConfirmationTarget selection based on HTLC set
This updates `test_yield_anchors_events` to test both anchor
channels with and without HTLCs, and relies on overriding only the
singular expected `ConfirmationTarget` used, testing the new
`ConfirmationTarget::UrgentOnChainSweep` use.
2024-08-27 19:57:34 +00:00
Matt Corallo
80dd594099 Don't ignore events in test_yield_anchors_events
Our tests should never ignore the events generated as they provide
critical context about what's happening in LDK. Here we fix
`test_yield_anchors_events` to avoid doing so.
2024-08-27 19:57:34 +00:00
Matt Corallo
3f23e3c288 Add a constructor and per-target override to TestFeeEstimator
This will allow us to test `ConfirmationTarget`s used in functional
tests by setting an override on just the target we expect to be
used.
2024-08-27 19:57:34 +00:00
Matt Corallo
3b70bd294c Add missing pending changelog for downgrade on unsafe funding 2024-08-27 19:31:25 +00:00
Matt Corallo
1e285cb417 Only generate an Event::DiscardFunding when we need to
5e874c3dc9 changed
`Event::DiscardFunding` to not include a dummy transaction when we
were funded without a full funding tx, but in doing so started
generating `DiscardFunding` events on every channel closure rather
than only when there's actually still a pending funding broadcast.

This restores the previous behavior to only generate the event when
we should actually discard the funding tx.
2024-08-27 19:31:25 +00:00
Matt Corallo
5e62df7f20
Merge pull request #3259 from vincenzopalazzo/macros/dummy-tx
[RFC] event: store the outpoint when is_manual_broadcast
2024-08-27 19:16:57 +00:00
Vincenzo Palazzo
5e874c3dc9
event: store the outpoint when is_manual_broadcast
With [1], it's possible to specify `manual_broadcast` for
the channel funding transaction. When `is_manual_broadcast` is
set to true, the transaction in the `DiscardFunding` event is
replaced with a dummy empty transaction.

This commit checks if `is_manual_broadcast` is true and
stores the funding OutPoint in the DiscardFunding event instead.

[1] https://github.com/lightningdevkit/rust-lightning/pull/3024

Link: https://github.com/lightningdevkit/rust-lightning/issues/3164
Suggested-by: TheBlueMatt
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2024-08-27 19:50:18 +02:00
Matt Corallo
14720190b0 Split ConfirmationTarget::OnChainSweep into urgent and non-urgent
When we force-close a channel, occasionally its due to feerate
disagreements or other non-HTLC-related issues. In those cases,
there's no reason to use a very urgent feerate estimate - we don't
have any timers expiring soon.

Instead, we should give users the information they need to be more
economical on fees in this case, which we do here by splitting
`OnChainSweep` into `UrgentOnChainSweep` and
`NonUrgentOnChainSweep` `ConfirmationTarget`s.
2024-08-27 16:42:03 +00:00
Matt Corallo
f0de37ae1f Add a new ConfirmationTarget::MaximumFeeEstimate
When we broke `ConfirmationTarget` out into task-specific names, we
left `MaxDustHTLCExposure::FeeRateMultiplier` as using the "when we
broadcast feerate" as we were mostly concerned about the dust
thresholds on outbound channels where we pick the fee and drive our
own funds to dust.

In 51bf78d604, that changed to
include transaction fees on both inbound and outbound channels in
our dust exposure amount, but we continued to use
`ConfirmationTarget::OnChainSweep` for the fee estimator threshold.

While the `MaxDustHTLCExposure::FeeRateMultiplier` value is quite
conservative and shouldn't lead to force-closures unless feerate
estimates disagree by something like 500 sat/vB (with only one HTLC
active in a channel), this happened on Aug 22 when feerates spiked
from 4 sat/vB to over 1000 sat/vB in one block.

To avoid simple feerate estimate horizons causing this in the
future, here we add a new
`ConfirmationTarget::MaximumFeeEstimate` which is used for dust
calculations. This allows users to split out the estimates they use
for checking counterparty feerates from the estimates used for
actual broadcasting.
2024-08-27 16:36:54 +00:00
Matt Corallo
fd2f3dc459
Merge pull request #3273 from TheBlueMatt/2024-08-bindings-no-static
Return owned `String`s for onion message message types
2024-08-27 14:14:47 +00:00
dunxen
cf2fa9d60a
Merge pull request #3248 from jkczyz/2024-08-blinded-path-utils-refactor
Refactor `BlindedPath` construction utils
2024-08-27 13:28:43 +02:00
Matt Corallo
feffaf8bbc Return owned Strings for onion message message types
Returning a reference from a trait method is relatively difficult
to map in bindings and is currently handled by storing the object
in the trait instance, returning a reference to the local field.

This is fine when the object we're returning only needs to live as
long as the trait, but when it needs to be `'static` (as is the
case for onion message `msg_type`s), there's not really a good way
to map them at all.

Instead, here, condition on `#[cfg(c_bindings)]` we return a fully
owned `String`. This is obviously relatively less effecient, but
the extra allocation and `memcpy` isn't the end of the world,
especially given it should be released relatively quickly.

Note that this breaks doctests in with `c_bindings`.
2024-08-27 00:05:12 +00:00