]> git.bitcoin.ninja Git - rust-lightning/log
rust-lightning
2 months agoDrop `no-std` feature
Elias Rohrer [Fri, 13 Sep 2024 11:14:40 +0000 (13:14 +0200)]
Drop `no-std` feature

We drop the `lightning/no-std` feature and just take
`hashbrown`,`possiblyrandom` and `libm` as required dependencies.

2 months agoCheck workspace members with default features individually in CI
Elias Rohrer [Wed, 4 Sep 2024 09:10:13 +0000 (11:10 +0200)]
Check workspace members with default features individually in CI

Previously, we would only check the workspace as a whole. This however
would mean that we would check/test crates with `lightning`'s default
features enabled, allowing failures-to-build under the crates own
default features to slip through, if they didn't explicitly enable
`lightning/std`, for example.

Here, we extend the CI to check the workspace as a whole but then run
checks, tests, and doc generation on the workspace members individually,
asserting that all of them build even when not built as part of the same
workspace as `lightning`.

2 months agoRe-add optional `std` feature dependencies to fix RGS and BP builds
Elias Rohrer [Wed, 4 Sep 2024 08:53:37 +0000 (10:53 +0200)]
Re-add optional `std` feature dependencies to fix RGS and BP builds

We previously removed these, leading to failure to build under default
features including `std`.

2 months agoMerge pull request #3315 from tnull/2024-09-rustfmt-crypto
Matt Corallo [Mon, 16 Sep 2024 15:02:46 +0000 (15:02 +0000)]
Merge pull request #3315 from tnull/2024-09-rustfmt-crypto

`rustfmt`: Run on `crypto` module

2 months ago`rustfmt`: Drop `crypto/mod.rs` from exclusion list
Elias Rohrer [Mon, 16 Sep 2024 10:29:54 +0000 (12:29 +0200)]
`rustfmt`: Drop `crypto/mod.rs` from exclusion list

2 months ago`rustfmt`: Run on `crypto/mod.rs`
Elias Rohrer [Mon, 16 Sep 2024 10:29:35 +0000 (12:29 +0200)]
`rustfmt`: Run on `crypto/mod.rs`

2 months ago`rustfmt`: Drop `crypto/utils.rs` from exclusion list
Elias Rohrer [Mon, 16 Sep 2024 10:29:15 +0000 (12:29 +0200)]
`rustfmt`: Drop `crypto/utils.rs` from exclusion list

2 months ago`rustfmt`: Run on `crypto/utils.rs`
Elias Rohrer [Mon, 16 Sep 2024 10:28:41 +0000 (12:28 +0200)]
`rustfmt`: Run on `crypto/utils.rs`

2 months ago`rustfmt`: Drop `crypto/streams.rs` from exclusion list
Elias Rohrer [Mon, 16 Sep 2024 10:28:09 +0000 (12:28 +0200)]
`rustfmt`: Drop `crypto/streams.rs` from exclusion list

2 months ago`rustfmt`: Run on `crypto/streams.rs`
Elias Rohrer [Mon, 16 Sep 2024 10:27:34 +0000 (12:27 +0200)]
`rustfmt`: Run on `crypto/streams.rs`

2 months ago`rustfmt`: Drop `crypto/poly1305.rs` from exclusion list
Elias Rohrer [Mon, 16 Sep 2024 10:27:00 +0000 (12:27 +0200)]
`rustfmt`: Drop `crypto/poly1305.rs` from exclusion list

2 months ago`rustfmt`: Run on `crypto/poly1305.rs`
Elias Rohrer [Mon, 16 Sep 2024 10:26:29 +0000 (12:26 +0200)]
`rustfmt`: Run on `crypto/poly1305.rs`

2 months ago`rustfmt`: Drop `crypto/chacha20poly1305.rs` from exclusion list
Elias Rohrer [Mon, 16 Sep 2024 10:24:26 +0000 (12:24 +0200)]
`rustfmt`: Drop `crypto/chacha20poly1305.rs` from exclusion list

2 months ago`rustfmt`: Run on `crypto/chacha20poly1305rfc.rs`
Elias Rohrer [Mon, 16 Sep 2024 10:24:00 +0000 (12:24 +0200)]
`rustfmt`: Run on `crypto/chacha20poly1305rfc.rs`

2 months ago`rustfmt`: Drop `crypto/chacha20.rs` from exclusion list
Elias Rohrer [Mon, 16 Sep 2024 10:23:09 +0000 (12:23 +0200)]
`rustfmt`: Drop `crypto/chacha20.rs` from exclusion list

2 months ago`rustfmt`: Run on `crypto/chacha20.rs`
Elias Rohrer [Mon, 16 Sep 2024 10:22:48 +0000 (12:22 +0200)]
`rustfmt`: Run on `crypto/chacha20.rs`

2 months agoMerge pull request #3314 from G8XSU/event-logging
Elias Rohrer [Mon, 16 Sep 2024 09:14:27 +0000 (11:14 +0200)]
Merge pull request #3314 from G8XSU/event-logging

Add logging around event processing.

2 months agoMerge pull request #3140 from valentinewallace/2024-06-pay-static-invoice
Matt Corallo [Sun, 15 Sep 2024 16:58:46 +0000 (16:58 +0000)]
Merge pull request #3140 from valentinewallace/2024-06-pay-static-invoice

Support paying static invoices

2 months agoAdd logging around event processing.
G8XSU [Fri, 13 Sep 2024 18:30:49 +0000 (11:30 -0700)]
Add logging around event processing.

Currently we don't have any visibility if BackgroundProcessor
takes considerably more of time to process events, adding logs
to help debug such issues.

2 months agoRemove payment_release_secret from async payments messages.
Valentine Wallace [Wed, 11 Sep 2024 14:20:58 +0000 (10:20 -0400)]
Remove payment_release_secret from async payments messages.

This field isn't necessary because we already authenticate the messages via the
blinded reply paths payment_id, nonce and HMAC.

2 months agoDocument PendingOutboundPayment::{Static}InvoiceReceived semantics.
Valentine Wallace [Tue, 10 Sep 2024 22:50:04 +0000 (18:50 -0400)]
Document PendingOutboundPayment::{Static}InvoiceReceived semantics.

While these variants may sound similar, they are very different. One is so
temporary it's never even persisted to disk, the other is a state we will stay
in for hours or days. See added docs for more info.

2 months agoAdd new Bolt12PaymentError for failed blinded path creation.
Valentine Wallace [Fri, 6 Sep 2024 19:28:43 +0000 (15:28 -0400)]
Add new Bolt12PaymentError for failed blinded path creation.

Currently used when initiating an async payment via held_htlc_available OM. This
OM needs a reply path back to us, so use this error for our invoice_error OM if
we fail to create said reply path.

2 months agoVerify inbound ReleaseHeldHtlc messages via hmac.
Valentine Wallace [Thu, 5 Sep 2024 21:32:08 +0000 (17:32 -0400)]
Verify inbound ReleaseHeldHtlc messages via hmac.

See AsyncPaymentsContext::hmac, but this prevents the recipient from
deanonymizing us. Without this, if they are able to guess the correct payment
id, then they could create a blinded path to us and confirm our identity.

We also move the PAYMENT_HASH_HMAC_INPUT const to use &[7; 16], which is safe
because this const was added since the last release. This ordering reads more
smoothly.

2 months agoRename Payment{Hash,Id} hmac creation/verification methods for offers.
Valentine Wallace [Thu, 5 Sep 2024 20:40:51 +0000 (16:40 -0400)]
Rename Payment{Hash,Id} hmac creation/verification methods for offers.

We want to specify that these methods are only to be used in an outbound offers
payment context, because we'll be adding similar methods for the outbound async
payments context in upcoming commits.

2 months agoDon't trigger manager persistence on unexpected release_htlc message.
Valentine Wallace [Thu, 29 Aug 2024 19:37:24 +0000 (15:37 -0400)]
Don't trigger manager persistence on unexpected release_htlc message.

If someone sends us an unexpected or duplicate release_held_htlc onion message,
we should simply ignore it and not persist the entire ChannelManager in
response.

2 months agoCorrect docs on payment id in RecentPaymentDetails.
Valentine Wallace [Tue, 20 Aug 2024 19:45:24 +0000 (15:45 -0400)]
Correct docs on payment id in RecentPaymentDetails.

2 months agoSupport abandoning pending outbound async payments.
Valentine Wallace [Thu, 20 Jun 2024 20:28:36 +0000 (16:28 -0400)]
Support abandoning pending outbound async payments.

Async payments may have very high expires because we may be waiting for days
for the recipient to come online, so it's important that users be able to
abandon these payments early if needed.

2 months agoTimeout expired outbound async payments.
Valentine Wallace [Thu, 20 Jun 2024 19:21:20 +0000 (15:21 -0400)]
Timeout expired outbound async payments.

2 months agoSupport sending async payments as an always-online sender.
Valentine Wallace [Wed, 4 Sep 2024 19:24:26 +0000 (15:24 -0400)]
Support sending async payments as an always-online sender.

Async receive is not yet supported.

Here we process inbound release_htlc onion messages, check that they actually
correspond to one of our outbound payments, and actually forward the HTLCs.
Valid release_htlc receipt indicates that the recipient has now come online to
receive.

2 months agoSplit off send_payment_for_bolt12_invoice_internal util.
Valentine Wallace [Wed, 4 Sep 2024 19:00:38 +0000 (15:00 -0400)]
Split off send_payment_for_bolt12_invoice_internal util.

This new util will be able to send to both static and non-static BOLT 12
invoices.

2 months agoSet max path len on receipt of static invoice.
Valentine Wallace [Thu, 29 Aug 2024 19:12:41 +0000 (15:12 -0400)]
Set max path len on receipt of static invoice.

Because we may receive a static invoice to pay days before the recipient
actually comes back online to receive the payment, it's good to do as many
checks as we can up-front. Here we ensure that the blinded paths provided
in the invoice won't cause us to exceed the maximum onion packet size.

2 months agoError on static invoice with unknown required features.
Valentine Wallace [Thu, 29 Aug 2024 19:00:08 +0000 (15:00 -0400)]
Error on static invoice with unknown required features.

2 months agoDRY handling when initiating payment to BOLT 12 invoice.
Valentine Wallace [Thu, 29 Aug 2024 18:53:12 +0000 (14:53 -0400)]
DRY handling when initiating payment to BOLT 12 invoice.

2 months agoSupport initiating an async payment to a static invoice.
Valentine Wallace [Thu, 29 Aug 2024 18:37:45 +0000 (14:37 -0400)]
Support initiating an async payment to a static invoice.

Supported when the sender is an always-online node. Here we send the initial
held_htlc_available onion message upon receipt of a static invoice, next we'll
need to actually send HTLCs upon getting a response to said OM.

2 months agoRelease pending async payments to PeerManager.
Valentine Wallace [Thu, 29 Aug 2024 18:25:40 +0000 (14:25 -0400)]
Release pending async payments to PeerManager.

2 months agoPass full message context into ChanMan blinded path util.
Valentine Wallace [Wed, 10 Jul 2024 18:58:11 +0000 (14:58 -0400)]
Pass full message context into ChanMan blinded path util.

Allows us to repurpose this util to create blinded paths in an async payments
message context while maintaining support for the offers context.

2 months agoStore async payment data in PendingOutboundPayment.
Valentine Wallace [Wed, 10 Jul 2024 18:55:34 +0000 (14:55 -0400)]
Store async payment data in PendingOutboundPayment.

Adds a pending outbound payment variant for async payments, which indicates
that we have received a static invoice to pay and have generated a keysend preimage
for the eventual payment. When the recipient comes back online, we'll
transition from this new state to Retryable and actually forward the HTLCs.

2 months agoSupport creating PaymentParameters from static invoices.
Valentine Wallace [Thu, 13 Jun 2024 21:12:03 +0000 (17:12 -0400)]
Support creating PaymentParameters from static invoices.

2 months agoSupport checking that a static invoice matches an outbound invreq.
Valentine Wallace [Thu, 13 Jun 2024 20:16:47 +0000 (16:16 -0400)]
Support checking that a static invoice matches an outbound invreq.

Useful for ensuring that an inbound static invoice matches one of our outbound
invreqs, otherwise it is an unexpected invoice and should be ignored and not
paid.

2 months agoMerge pull request #3243 from dunxen/2024-08-reremove-balancemsat
Matt Corallo [Fri, 13 Sep 2024 14:09:17 +0000 (14:09 +0000)]
Merge pull request #3243 from dunxen/2024-08-reremove-balancemsat

Remove AvailableBalances::balance_msat

2 months agoMerge pull request #3302 from TheBlueMatt/2024-09-atomic-cleanups
Elias Rohrer [Thu, 12 Sep 2024 16:48:09 +0000 (18:48 +0200)]
Merge pull request #3302 from TheBlueMatt/2024-09-atomic-cleanups

Simplify and fix AtomicCounter

2 months agoStore AsyncPaymentsMessages for later sending
Valentine Wallace [Thu, 13 Jun 2024 15:25:20 +0000 (11:25 -0400)]
Store AsyncPaymentsMessages for later sending

Upcoming commits will support sending and receiving held_htlc_available and
release_held_htlc messages. These messages need to be enqueued so that they can
be released in ChannelManager's implementation of AsyncPaymentsMessageHandler
to OnionMessenger for sending.

2 months agoPass context into held_htlc_available message handling.
Valentine Wallace [Wed, 10 Jul 2024 17:58:53 +0000 (13:58 -0400)]
Pass context into held_htlc_available message handling.

Useful for using the payment_id within to look up the corresponding outbound
async payment so we know we can safely release the HTLCs to the now-onlinen
recipient.

2 months agoAdd MessageContext for async payments.
Valentine Wallace [Wed, 10 Jul 2024 17:54:05 +0000 (13:54 -0400)]
Add MessageContext for async payments.

This context will be used in reply paths for outbound held_htlc_available
messages, so we can authenticate the corresponding release_held_htlc messages.

2 months agoTweak debug_assert message for parsed onion messages.
Valentine Wallace [Fri, 12 Jul 2024 20:19:53 +0000 (16:19 -0400)]
Tweak debug_assert message for parsed onion messages.

More specific.

2 months agoMerge pull request #3010 from shaavan/issue2836
Matt Corallo [Thu, 12 Sep 2024 15:12:39 +0000 (15:12 +0000)]
Merge pull request #3010 from shaavan/issue2836

Introduce Retry InvoiceRequest Flow

2 months agoRename `AtomicCounter::get_increment` to simply `next` 2024-09-atomic-cleanups
Matt Corallo [Mon, 9 Sep 2024 13:42:54 +0000 (13:42 +0000)]
Rename `AtomicCounter::get_increment` to simply `next`

Its a counter, `next` is super clear, `get_increment` is a bit
less so.

2 months agoSimplify and fix `AtomicCounter`
Matt Corallo [Sun, 8 Sep 2024 19:05:28 +0000 (19:05 +0000)]
Simplify and fix `AtomicCounter`

`AtomicCounter` was slightly race-y on 32-bit platforms because it
increments the high `AtomicUsize` independently from the low
`AtomicUsize`, leading to a potential race where another thread
could observe the low increment but not the high increment and see
a value of 0 twice.

This isn't a big deal because (a) most platforms are 64-bit these
days, (b) 32-bit platforms aren't super likely to have their
counter overflow 32 bits anyway, and (c) the two writes are
back-to-back so having another thread read during that window is
very unlikely.

However, we can also optimize the counter somewhat by using the
`target_has_atomic = "64"` cfg flag, which we do here, allowing us
to use `AtomicU64` even on 32-bit platforms where 64-bit atomics
are available.

This changes some test behavior slightly, which requires
adaptation.

Fixes #3000

2 months agoIntroduce handle_message_received test
shaavan [Thu, 11 Jul 2024 14:55:32 +0000 (20:25 +0530)]
Introduce handle_message_received test

- Add a test to verify the functionality of the handle_message_received
  function.
- Ensure the test covers scenarios where InvoiceRequest messages are retried
  for PendingOutboundPayments after a simulated connection loss.

2 months agoIntroduce message_received in ChannelMessageHandler
shaavan [Mon, 10 Jun 2024 11:46:08 +0000 (17:16 +0530)]
Introduce message_received in ChannelMessageHandler

- Introduce the `message_received` function to manage the
  behavior when a message is received from any peer.
- This function is used within `ChannelManager` to retry `InvoiceRequest`
  messages if we haven't received the corresponding invoice yet.
- This change makes the offer communication robust against sudden
  connection drops where the initial attempt to send the message
  might have failed.

2 months agoIntroduce enqueue_invoice_request Function
shaavan [Thu, 25 Jul 2024 10:09:26 +0000 (15:39 +0530)]
Introduce enqueue_invoice_request Function

1. Separate the logic of forming `invoice_request` messages from
   `invoice_request` and `reply_paths` and enqueueing them into a
   separate function.
2. This logic will be reused in the following commit when reforming
   `invoice_request` messages for retrying.

2 months agoIntroduce RetryableInvoiceRequest in AwaitingInvoice
shaavan [Mon, 10 Jun 2024 11:52:09 +0000 (17:22 +0530)]
Introduce RetryableInvoiceRequest in AwaitingInvoice

1. To enable the retry of the Invoice Request message, it's necessary
   to store the essential data required to recreate the message.
2. A new struct is introduced to manage this data, ensuring the
   InvoiceRequest message can be reliably recreated for retries.
3. The addition of an `awaiting_invoice` flag allows tracking of
   retryable invoice requests, preventing the need to lock the
   `pending_outbound_payment` mutex.

2 months agoMerge pull request #3291 from tnull/2024-09-add-their-node-id-routing-msg-handler
Matt Corallo [Wed, 11 Sep 2024 22:25:41 +0000 (22:25 +0000)]
Merge pull request #3291 from tnull/2024-09-add-their-node-id-routing-msg-handler

Add node id to remaining `RoutingMessageHandler::handle_` methods

2 months agoMerge pull request #3163 from shaavan/invoice_reply_path
Matt Corallo [Wed, 11 Sep 2024 20:17:54 +0000 (20:17 +0000)]
Merge pull request #3163 from shaavan/invoice_reply_path

Introduce Reply Paths for BOLT12 Invoice in Offers Flow.

2 months agoDon't rely on route-fetching rand in `blinded_path_with_custom_tlv`
Matt Corallo [Sun, 8 Sep 2024 20:13:40 +0000 (20:13 +0000)]
Don't rely on route-fetching rand in `blinded_path_with_custom_tlv`

`blinded_path_with_custom_tlv` indirectly relied on route CLTV
randomization when sending because nodes were at substantially
different block heights after setup. Instead we make sure all nodes
are at the same height which makes the test more robust.

2 months agoDrop `Debug` on `InMemorySigner` (and `EntropySource`)
Matt Corallo [Wed, 11 Sep 2024 20:00:26 +0000 (20:00 +0000)]
Drop `Debug` on `InMemorySigner` (and `EntropySource`)

`InMemorySigner` has various private keys in it which makes
`Debug` either useless or dangerous (because most keys won't log
anything, but if they did we'd risk logging private key material).

2 months agoRefactor: Take `their_node_id` by value across all handler interfaces
Elias Rohrer [Wed, 11 Sep 2024 14:06:44 +0000 (16:06 +0200)]
Refactor: Take `their_node_id` by value across all handler interfaces

In order to maintain interface consistency, we refactor all message
handler interfaces to take `PublicKey` rather than `&PublicKey`, as the
difference in efficiency should be negigible and the former is easier to
handle in binding languages.

Over time, we also want to move (no pun intended) towards all messaging
interfaces using move semantics, so dropping the reference for
`PublicKey` is the first step in this direction.

2 months agoAdd node id to remaining `RoutingMessageHandler::handle_` methods
Elias Rohrer [Wed, 4 Sep 2024 13:39:20 +0000 (15:39 +0200)]
Add node id to remaining `RoutingMessageHandler::handle_` methods

Previously, some `RoutingMessageHandler::handle_` methods (in particular
the ones handling node and channel announcements, as well as channel
updates, omitted the `their_node_id` argument. This didn't allow
implementors to discern *who* sent a particular method.

Here, we add `their_node_id: Option<&PublicKey>` to have them learn who
sent a message, and set `None` if our own node it the originator of a
broadcast operation.

2 months agoUpdate Offers Test to Verify BOLT12 Invoice Reply Paths
shaavan [Thu, 29 Aug 2024 11:36:18 +0000 (17:06 +0530)]
Update Offers Test to Verify BOLT12 Invoice Reply Paths

1. Updated the Offers Test to check the reply paths in BOLT12 Invoices.
2. Changed the `extract_invoice` return type from `Option<BlindedMessagePath>`
   to `BlindedMessagePath` since all BOLT12Invoices now have a corresponding
   reply path by default.

2 months agoAdd reply_path to BOLT12Invoices in Offers Flow
shaavan [Fri, 6 Sep 2024 12:21:37 +0000 (17:51 +0530)]
Add reply_path to BOLT12Invoices in Offers Flow

1. Introduced reply_path in BOLT12Invoices to address a gap in error handling.
   Previously, if a BOLT12Invoice sent in the offers flow generated an Invoice Error,
   the payer had no way to send this error back to the payee.
2. By adding a reply_path to the Invoice Message, the payer can now communicate
   any errors back to the payee, ensuring better error handling and communication
   within the offers flow.

2 months agoAdd HMAC, and nonce to OffersContext::InboundPayment
shaavan [Fri, 6 Sep 2024 12:01:13 +0000 (17:31 +0530)]
Add HMAC, and nonce to OffersContext::InboundPayment

Introduce HMAC and nonce calculation when sending Invoice with
reply path, so that if we receive InvoiceError back for the
corresponding Invoice we can verify the payment hash before logging it.

2 months agoMerge pull request #3309 from TheBlueMatt/2024-09-always-print-why
Matt Corallo [Tue, 10 Sep 2024 19:47:15 +0000 (19:47 +0000)]
Merge pull request #3309 from TheBlueMatt/2024-09-always-print-why

Always print why we disconnect explicitly

2 months agoMerge pull request #3305 from TheBlueMatt/2024-09-no-redundant-gossip-validation
valentinewallace [Tue, 10 Sep 2024 16:49:06 +0000 (12:49 -0400)]
Merge pull request #3305 from TheBlueMatt/2024-09-no-redundant-gossip-validation

Avoid redundant `{channel,node}_announcement` signature checks

2 months agoAlways print why we disconnect explicitly 2024-09-always-print-why
Matt Corallo [Tue, 10 Sep 2024 14:26:57 +0000 (14:26 +0000)]
Always print why we disconnect explicitly

...and drop the old, confusing, "protocol error" message when we
get a duplicate connection from a peer.

This should slightly further disambiguate disconnection reasons,
which are a key debugging tool for assigning blame.

2 months agoMerge pull request #3306 from TheBlueMatt/2024-09-chan-id-hex
Elias Rohrer [Tue, 10 Sep 2024 10:33:38 +0000 (12:33 +0200)]
Merge pull request #3306 from TheBlueMatt/2024-09-chan-id-hex

Write ChannelIds out as hex in Debug output

2 months agoIntroduce Verification trait.
shaavan [Tue, 10 Sep 2024 10:07:10 +0000 (15:37 +0530)]
Introduce Verification trait.

- The trait defines the public method one may define for creating and
  verifying the HMAC.
- Using a pub trait to define these method allows the flexibility for
  other `OffersMessageHandler` construct to construct the HMAC and
authenticate the message.

2 months agoMerge pull request #3296 from alecchendev/2024-09-async-close-sign-followup
Matt Corallo [Mon, 9 Sep 2024 23:59:25 +0000 (23:59 +0000)]
Merge pull request #3296 from alecchendev/2024-09-async-close-sign-followup

Finish closing channel after async closing signed

2 months agoAvoid redundant `{channel,node}_announcement` signature checks 2024-09-no-redundant-gossip-validation
Matt Corallo [Sun, 8 Sep 2024 22:33:57 +0000 (22:33 +0000)]
Avoid redundant `{channel,node}_announcement` signature checks

If we receive `{channel,node}_announcement` messages which we
already have, we first validate their signatures and then look in
our graph and discover that we should discard the messages. This
avoids a second lock in `node_announcement` handling but does not
impact our locking in `channel_announcement` handling. It also
avoids lock contention in cases where the signatures are invalid,
but that should be exceedingly rare.

For nodes with relatively few peers, this is a fine state to be in,
however for nodes with many peers, we may see the same messages
hundreds of times. This causes a rather substantial waste of CPU
resources validating gossip messages.

Instead, here, we change to checking our network graph first and
then validate the signatures only if we don't already have the
message.

2 months agoRemove AvailableBalances::balance_msat
Duncan Dean [Thu, 15 Aug 2024 08:15:30 +0000 (10:15 +0200)]
Remove AvailableBalances::balance_msat

The ChannelMonitor::get_claimable_balances and ChainMonitor::get_claimable_balances
methods provide a more straightforward approach to the balance of a channel, which
satisfies most use cases. The computation of AvailableBalances::balance_msat is
complex and originally had a different purpose that is not applicable
anymore.

Co-authored-by: Willem Van Lint <noreply@wvanlint.dev>
2 months agoFinish closing channel after async closing signed
Alec Chen [Thu, 5 Sep 2024 23:58:01 +0000 (18:58 -0500)]
Finish closing channel after async closing signed

In addressing a followup to test reconnection during closing negotation
with async signing, we change things to only return a `ShutdownResult`
when we actually finish shutting down the channel, i.e. we have the
signature ready to send the final closing signed. This slightly
simplifies the logic where we would shutdown our channel
prematurely before we got the final signature. This also means
that we don't push multiple `ChannelClosed` events if we receive closing
signed, reconnect, and receive closing signed again.

2 months agoClean up imports in `lightning-types` 2024-09-chan-id-hex
Matt Corallo [Mon, 9 Sep 2024 15:32:12 +0000 (15:32 +0000)]
Clean up imports in `lightning-types`

To remove the now-redundant `hex_conservative` explicit dependency.

2 months agoWrite `ChannelId`s out as hex in `Debug` output
Matt Corallo [Mon, 9 Sep 2024 15:30:54 +0000 (15:30 +0000)]
Write `ChannelId`s out as hex in `Debug` output

`ChannelId`s are almost always referenced as hex, so having debug
output print the raw bytes is somewhat annoying. Instead, we should
dump them as hex the same way we do for `Display`.

This uses the `hex_conservative` `impl_fmt_macros` which does all
the work for us, like we use for `lightning_types`.

2 months agoimpl `Borrow<[u8]>` for `ChannelId`
Matt Corallo [Mon, 9 Sep 2024 15:30:09 +0000 (15:30 +0000)]
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.

2 months agoMerge pull request #3304 from TheBlueMatt/2024-09-tokio-util-msrv
Matt Corallo [Mon, 9 Sep 2024 13:38:44 +0000 (13:38 +0000)]
Merge pull request #3304 from TheBlueMatt/2024-09-tokio-util-msrv

Fix MSRV builds of `lightning-transaction-sync` in CI

2 months agoReduce features on `lightning-transaction-sync`'s `tokio` dev-dep 2024-09-tokio-util-msrv
Matt Corallo [Sun, 8 Sep 2024 21:41:51 +0000 (21:41 +0000)]
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.

2 months agoTest `lightning-transaction-sync` in our no-dev-deps MSRV test
Matt Corallo [Sun, 8 Sep 2024 21:14:13 +0000 (21:14 +0000)]
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.

2 months agoFix MSRV test of `lightning-transaction-sync` with `esplora-async`
Matt Corallo [Sun, 8 Sep 2024 21:09:20 +0000 (21:09 +0000)]
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.

2 months agoHMAC Construction and Verification for PaymentHash
shaavan [Fri, 6 Sep 2024 12:01:08 +0000 (17:31 +0530)]
HMAC Construction and Verification for PaymentHash

When a InvoiceError is received for a sent BOLT12Invoice, the
corresponding PaymentHash is to be logged. Introduce hmac construction
and verification function for PaymentHash for this purpose.

2 months agoMerge pull request #3290 from tnull/2024-09-add-tx-sync-copyright
Matt Corallo [Wed, 4 Sep 2024 14:13:37 +0000 (14:13 +0000)]
Merge pull request #3290 from tnull/2024-09-add-tx-sync-copyright

Add copyright notices to `lightning-transaction-sync` modules

2 months agoAdd copyright notices to `lightning-transaction-sync` modules
Elias Rohrer [Wed, 4 Sep 2024 11:02:45 +0000 (13:02 +0200)]
Add copyright notices to `lightning-transaction-sync` modules

2 months agoMerge pull request #3278 from TheBlueMatt/2024-08-124-relnotes v0.0.124
Matt Corallo [Tue, 3 Sep 2024 18:35:17 +0000 (18:35 +0000)]
Merge pull request #3278 from TheBlueMatt/2024-08-124-relnotes

Add an 0.0.124 CHANGELOG entry

2 months agoUpdate versions to 0.0.124 and invoice 0.32 types 0.1 release 2024-08-124-relnotes
Matt Corallo [Fri, 30 Aug 2024 15:05:24 +0000 (15:05 +0000)]
Update versions to 0.0.124 and invoice 0.32 types 0.1 release

2 months agoAdd an 0.0.124 CHANGELOG entry
Matt Corallo [Wed, 28 Aug 2024 15:32:59 +0000 (15:32 +0000)]
Add an 0.0.124 CHANGELOG entry

2 months agoMerge pull request #3285 from TheBlueMatt/2024-08-tx-too-small
Matt Corallo [Tue, 3 Sep 2024 17:53:08 +0000 (17:53 +0000)]
Merge pull request #3285 from TheBlueMatt/2024-08-tx-too-small

Correct handling of added `OP_RETURN` outputs

2 months agoMerge pull request #3284 from TheBlueMatt/2024-08-bindings-imports-suck
Matt Corallo [Tue, 3 Sep 2024 15:20:16 +0000 (15:20 +0000)]
Merge pull request #3284 from TheBlueMatt/2024-08-bindings-imports-suck

2 months agoCorrect `ANCHOR_INPUT_WITNESS_WEIGHT` constant 2024-08-tx-too-small
Matt Corallo [Tue, 3 Sep 2024 15:09:32 +0000 (15:09 +0000)]
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.

2 months agoAdd a test for the past few commits
Matt Corallo [Fri, 30 Aug 2024 03:42:13 +0000 (03:42 +0000)]
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.

2 months agoDrop bogus debug assertion that we don't overpay on fees
Matt Corallo [Thu, 29 Aug 2024 22:47:32 +0000 (22:47 +0000)]
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.

2 months agoHandle under-coin-selecting due to an added OP_RETURN output
Matt Corallo [Thu, 29 Aug 2024 20:43:10 +0000 (20:43 +0000)]
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.

2 months agoEnsure we never try to broadcast a transaction <= 64 bytes
Matt Corallo [Thu, 22 Aug 2024 15:14:44 +0000 (15:14 +0000)]
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.

2 months agoSpecify imports manually in `types::features::sealed` 2024-08-bindings-imports-suck
Matt Corallo [Sun, 1 Sep 2024 01:08:38 +0000 (01:08 +0000)]
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.

2 months agoMerge pull request #3282 from TheBlueMatt/2024-08-fix-bench-logging
Matt Corallo [Fri, 30 Aug 2024 21:24:51 +0000 (21:24 +0000)]
Merge pull request #3282 from TheBlueMatt/2024-08-fix-bench-logging

Dont output logs when benchmarking

2 months agoDont output logs when benchmarking 2024-08-fix-bench-logging
Matt Corallo [Fri, 30 Aug 2024 17:38:37 +0000 (17:38 +0000)]
Dont output logs when benchmarking

In 11ab302087622b546d116fc9679f601667d18c4d 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).

2 months agoRemove log level filtering in tests
Matt Corallo [Mon, 19 Aug 2024 21:07:46 +0000 (21:07 +0000)]
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.

2 months agoMerge pull request #3280 from TheBlueMatt/2024-08-124rc v0.0.124-rc1
Matt Corallo [Thu, 29 Aug 2024 20:52:03 +0000 (20:52 +0000)]
Merge pull request #3280 from TheBlueMatt/2024-08-124rc

Bump versions to rc1

2 months agoMerge pull request #3279 from TheBlueMatt/2024-08-no-pub-usize
Matt Corallo [Thu, 29 Aug 2024 20:06:28 +0000 (20:06 +0000)]
Merge pull request #3279 from TheBlueMatt/2024-08-no-pub-usize

Use `u64` for `required_unknown_bits_from` indexes, not `usize`

2 months agoBump versions to rc1 2024-08-124rc
Matt Corallo [Thu, 29 Aug 2024 19:39:22 +0000 (19:39 +0000)]
Bump versions to rc1

2 months agoMerge pull request #3257 from tnull/2024-08-fix-is-public
Matt Corallo [Thu, 29 Aug 2024 19:39:30 +0000 (19:39 +0000)]
Merge pull request #3257 from tnull/2024-08-fix-is-public

Rename instances of `is_public` to `is_announced`

2 months agoRename `announced_channel` to `is_announced_for_forwarding`
Elias Rohrer [Thu, 29 Aug 2024 18:16:51 +0000 (20:16 +0200)]
Rename `announced_channel` to `is_announced_for_forwarding`

.. we rename the flag configuring whether we announce a channel or not.

2 months agoUse `u64` for `required_unknown_bits_from` indexes, not `usize` 2024-08-no-pub-usize
Matt Corallo [Thu, 29 Aug 2024 16:45:27 +0000 (16:45 +0000)]
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`.