]> git.bitcoin.ninja Git - rust-lightning/log
rust-lightning
6 months agoMerge pull request #3028 from jkczyz/2024-04-offer-id-followups
Matt Corallo [Mon, 29 Apr 2024 18:26:44 +0000 (11:26 -0700)]
Merge pull request #3028 from jkczyz/2024-04-offer-id-followups

Follow-ups to #2970

6 months agoRemove InvoiceRequestFields::features
Jeffrey Czyz [Fri, 26 Apr 2024 17:13:12 +0000 (12:13 -0500)]
Remove InvoiceRequestFields::features

InvoiceRequestFeatures may contain a large, odd bit. Including this in
InvoiceRequestFields, which is in each BlindedPath of a Bolt12Invoice,
could cause the invoice's onion message to exceed the maximum size. The
features are already checked before sending an invoice.

6 months agoRemove InvoiceRequestFields::amount_msats
Jeffrey Czyz [Fri, 26 Apr 2024 17:03:07 +0000 (12:03 -0500)]
Remove InvoiceRequestFields::amount_msats

Event::PaymentClaimable and Event::PaymentClaimed already contain the
paid amount, so there's no need to included the requested amount in
InvoiceRequestFields.

6 months agoRemove PaymentContext from OnionPayload
Jeffrey Czyz [Fri, 26 Apr 2024 16:37:24 +0000 (11:37 -0500)]
Remove PaymentContext from OnionPayload

PaymentContext is already stored in ClaimablePayment via PaymentPurpose,
so there is no need to repeat it in each ClaimableHTLC via OnionPayload.
This avoids cloning the PaymentContext each time an HTLC is received,
other than for the first HTLC for a payment.

6 months agoMerge pull request #3003 from TheBlueMatt/2024-04-2964-followups
Gursharan Singh [Thu, 25 Apr 2024 20:19:09 +0000 (13:19 -0700)]
Merge pull request #3003 from TheBlueMatt/2024-04-2964-followups

#2964 Followups

6 months agoMerge pull request #3021 from TheBlueMatt/2024-04-drop-blocked-completed-updates
Matt Corallo [Thu, 25 Apr 2024 18:33:18 +0000 (11:33 -0700)]
Merge pull request #3021 from TheBlueMatt/2024-04-drop-blocked-completed-updates

Drop completed blocked `ChannelMonitorUpdate`s on startup

6 months agoMerge pull request #3004 from TheBlueMatt/2024-04-2761-followups
Matt Corallo [Thu, 25 Apr 2024 17:52:12 +0000 (10:52 -0700)]
Merge pull request #3004 from TheBlueMatt/2024-04-2761-followups

#2761 Followups

7 months agoDrop completed blocked `ChannelMonitorUpdate`s on startup 2024-04-drop-blocked-completed-updates
Matt Corallo [Thu, 25 Apr 2024 14:30:05 +0000 (14:30 +0000)]
Drop completed blocked `ChannelMonitorUpdate`s on startup

If a user receives a payment preimage for an outbound payment, the
`PaymentSent` event will block any eventual RAA
`ChannelMonitorUpdate` from the same channel, assuming it comes in
before the event can be processed. If this blocking kicks in, but
the flow eventually completes with the RAA `ChannelMonitorUpdate`
being persisted, but the `ChannelManager` is only persisted prior
to the event being handled, on startup we'll have a fully
up-to-date `ChannelMonitor` but a pending, blocked
`ChannelMonitorUpdate`. When the `PaymentSent` event is replayed
we'll end up trying to apply a redundant `ChannelMonitorUpdate`
which will panic.

See the test added in this commit for an implementation of this
situation.

In this commit we fix this issue by simply dropping blocked
`ChannelMonitorUpdate`s the same as we do pending ones.

7 months agoMerge pull request #3015 from tnull/2024-04-sweeper-error-on-persistence-failure
Elias Rohrer [Wed, 24 Apr 2024 14:35:51 +0000 (16:35 +0200)]
Merge pull request #3015 from tnull/2024-04-sweeper-error-on-persistence-failure

Make `OutputSweeper::track_spendable_outputs` fallible

7 months agoMake `OutputSweeper::track_spendable_outputs` fallible
Elias Rohrer [Wed, 24 Apr 2024 07:30:16 +0000 (09:30 +0200)]
Make `OutputSweeper::track_spendable_outputs` fallible

.. as otherwise we might only log an error and continue if we fail to
persist the sweeper state.

7 months agoMerge pull request #2981 from dunxen/2024-03-PR2419fixups
Matt Corallo [Tue, 23 Apr 2024 13:48:40 +0000 (06:48 -0700)]
Merge pull request #2981 from dunxen/2024-03-PR2419fixups

Fixups for #2419

7 months agoAdd intermediate `ConstructedTransaction`
Duncan Dean [Fri, 12 Apr 2024 13:37:17 +0000 (15:37 +0200)]
Add intermediate `ConstructedTransaction`

7 months agoAdd lower bound segwit input weight estimates
Duncan Dean [Tue, 9 Apr 2024 17:07:45 +0000 (19:07 +0200)]
Add lower bound segwit input weight estimates

7 months agoAdd descriptions to test cases
Duncan Dean [Mon, 8 Apr 2024 15:44:10 +0000 (17:44 +0200)]
Add descriptions to test cases

7 months agoAbort if we add a duplicate input
Duncan Dean [Tue, 26 Mar 2024 10:15:37 +0000 (12:15 +0200)]
Abort if we add a duplicate input

7 months agoMake sent_tx_* fallible and handle errors & simplify counterparty_weight_contributed...
Duncan Dean [Tue, 26 Mar 2024 10:06:33 +0000 (12:06 +0200)]
Make sent_tx_* fallible and handle errors & simplify counterparty_weight_contributed calc

7 months agoCheck if msg.script.is_witness_program() before checking version
Duncan Dean [Tue, 26 Mar 2024 09:17:05 +0000 (11:17 +0200)]
Check if msg.script.is_witness_program() before checking version

7 months agoUse HashMaps as, well, HashMaps (don't iter for key match)
Duncan Dean [Tue, 26 Mar 2024 08:57:44 +0000 (10:57 +0200)]
Use HashMaps as, well, HashMaps (don't iter for key match)

7 months agoRemove unnecessary PaymentPreimage clone
Jeffrey Czyz [Mon, 22 Apr 2024 21:43:26 +0000 (16:43 -0500)]
Remove unnecessary PaymentPreimage clone

7 months agoMerge pull request #2990 from TheBlueMatt/2024-04-log-in-flights
Gursharan Singh [Mon, 22 Apr 2024 17:29:35 +0000 (10:29 -0700)]
Merge pull request #2990 from TheBlueMatt/2024-04-log-in-flights

Log pending in-flight updates when we are missing a monitor

7 months agoDrop the rustup-specific calling in `ci/rustfmt.sh` 2024-04-2761-followups
Matt Corallo [Mon, 22 Apr 2024 13:03:14 +0000 (13:03 +0000)]
Drop the rustup-specific calling in `ci/rustfmt.sh`

The +rustversion call semantics are specific to rustup and do not
work with standard rust toolchains. However, because rustfmt
formatting differs slightly between stable and our 1.63 target, we
need to keep the +1.63.0 for rustup users.

Thus, here, we check for the presence of a `rustup` command and
pass the "+1.63.0" argument if we find one.

7 months agoInclude `channel_keys.rs` in the rustfmt list
Matt Corallo [Mon, 22 Apr 2024 13:00:38 +0000 (13:00 +0000)]
Include `channel_keys.rs` in the rustfmt list

Since its already formatted and there's not much active work going
on in it.

7 months agoOnly include `derive_add_tweak` for base key types that use it
Matt Corallo [Mon, 22 Apr 2024 12:50:58 +0000 (12:50 +0000)]
Only include `derive_add_tweak` for base key types that use it

Specifically `RevocationBasepoint` has a different derivation, so
shouldn't have a `derive_add_tweak` at all. We also use this
opportunity to link to the `from_basepoint` function in the
`derive_add_tweak` docs.

7 months agoWord-wrap new doc comment in `DelayedPaymentOutputDescriptor`
Matt Corallo [Fri, 19 Apr 2024 00:42:55 +0000 (00:42 +0000)]
Word-wrap new doc comment in `DelayedPaymentOutputDescriptor`

7 months agoUse `Sha256`s for tweaks in `sign` to enforce randomness
Matt Corallo [Fri, 19 Apr 2024 00:36:52 +0000 (00:36 +0000)]
Use `Sha256`s for tweaks in `sign` to enforce randomness

We assume that tweaks are the output of a SHA-256 hash function
(and thus that failing to create a private key from the has
negligible probability) in `add_public_key_tweak` and elsewhere.

Thus, we really shouldn't be taking byte arrays in the public API
but rather `Sha256` objects, and communicating in the docs for
`add_public_key_tweak` that we can panic if its not the output of
a hash function, both of which we do here.

7 months agoSimplify and clarify `derive_add_tweak` documentation
Matt Corallo [Fri, 19 Apr 2024 00:28:09 +0000 (00:28 +0000)]
Simplify and clarify `derive_add_tweak` documentation

7 months agoLog when a ChannelMonitor's claimable balances set goes empty 2024-04-2964-followups
Matt Corallo [Thu, 18 Apr 2024 21:42:48 +0000 (21:42 +0000)]
Log when a ChannelMonitor's claimable balances set goes empty

7 months agoDebug-log monitor update starts and completions in `ChainMonitor` 2024-04-log-in-flights
Matt Corallo [Thu, 11 Apr 2024 21:53:44 +0000 (21:53 +0000)]
Debug-log monitor update starts and completions in `ChainMonitor`

When a `ChannelMonitor[Update]` persistence completes, we rely on
logging in `ChannelManager` to hear about it. However, this won't
happen at all if there's still pending updates as no `MonitorEvent`
will be generated.

Thus, here, we add logging directly in `ChainMonitor`, ensuring we
can deduce when individual updates completed from debug logs.

7 months agoMerge pull request #3009 from tnull/2024-04-fix-sweeper-typo
Matt Corallo [Mon, 22 Apr 2024 11:36:41 +0000 (04:36 -0700)]
Merge pull request #3009 from tnull/2024-04-fix-sweeper-typo

Fix typo in `OutputSweeper`

7 months agoFix typo in `OutputSweeper`
Elias Rohrer [Mon, 22 Apr 2024 09:29:42 +0000 (11:29 +0200)]
Fix typo in `OutputSweeper`

... as 'ouputs' isn't a thing.

7 months agoMerge pull request #3005 from TheBlueMatt/2024-04-0.0.123-beta v0.0.123-beta
Matt Corallo [Fri, 19 Apr 2024 14:51:06 +0000 (07:51 -0700)]
Merge pull request #3005 from TheBlueMatt/2024-04-0.0.123-beta

Cut 0.0.123-beta

7 months agoBump crate versions to 0.0.123-beta/invoice 0.31-beta 2024-04-0.0.123-beta
Matt Corallo [Fri, 19 Apr 2024 01:03:03 +0000 (01:03 +0000)]
Bump crate versions to 0.0.123-beta/invoice 0.31-beta

7 months agoMerge pull request #2761 from yellowred/self_sufficient_psbt
Wilmer Paulino [Fri, 19 Apr 2024 00:45:56 +0000 (17:45 -0700)]
Merge pull request #2761 from yellowred/self_sufficient_psbt

Implement PSBT fields that were missing for a Signer

7 months agoImplement Script for Witness and Add Tweak in PSBT.
olegkubrakov [Tue, 19 Dec 2023 00:54:59 +0000 (16:54 -0800)]
Implement Script for Witness and Add Tweak in PSBT.

Adding Witness Script and key tweaks makes
a Partially Signed Bitcoin Transaction the single data
source needed for a Signer to produce valid signatures.
A Signer is not required to be able to generate L2 keys,
e.g delayed payment basepoint.

7 months agoCorrect `ChannelMonitor::is_fully_resolved` docs
Matt Corallo [Thu, 18 Apr 2024 21:40:41 +0000 (21:40 +0000)]
Correct `ChannelMonitor::is_fully_resolved` docs

The block count at which the monitor will become prunable was
changed by an update while the PR was pending but not propagated
to the docs.

7 months agoMerge pull request #2964 from jbesraa/prune-stale-chanmonitor
Matt Corallo [Thu, 18 Apr 2024 21:39:43 +0000 (14:39 -0700)]
Merge pull request #2964 from jbesraa/prune-stale-chanmonitor

Add `archive_fully_resolved_monitors` to `ChainMonitor`

7 months agoMerge pull request #2998 from tnull/2024-04-fix-potential-lock-race-in-CM-write
Gursharan Singh [Thu, 18 Apr 2024 20:21:08 +0000 (13:21 -0700)]
Merge pull request #2998 from tnull/2024-04-fix-potential-lock-race-in-CM-write

7 months agoMerge pull request #3001 from optout21/splicing-feature-bit-with-any
Jeffrey Czyz [Thu, 18 Apr 2024 19:24:00 +0000 (14:24 -0500)]
Merge pull request #3001 from optout21/splicing-feature-bit-with-any

Add splicing feature flag

7 months agoMerge pull request #2999 from keyuebao/keyue/update-ldk-docs
Gursharan Singh [Thu, 18 Apr 2024 17:26:07 +0000 (10:26 -0700)]
Merge pull request #2999 from keyuebao/keyue/update-ldk-docs

Update docs for ChannelClosed Event

7 months agoAdd `ChainMonitor::archive_fully_resolved_monitor_channels`
jbesraa [Wed, 27 Mar 2024 16:19:14 +0000 (18:19 +0200)]
Add `ChainMonitor::archive_fully_resolved_monitor_channels`

  Archives fully resolved channel monitors by adding them to a backup
  location and removing them from the primary storage & the monitor set.

  This is useful for pruning fully resolved monitors from the monitor
  set and primary storage so they are not reloaded on every new new
  block connection.

  We also add a new function, `archive_persisted_channel` to the
  `Persist` trait that writes the monitor to an archive storage and
  removes it from the primary storage.

7 months agoAdd `ChannelMonitor::is_fully_resolved` function
jbesraa [Fri, 29 Mar 2024 05:56:23 +0000 (08:56 +0300)]
Add `ChannelMonitor::is_fully_resolved` function

  Checks if the monitor is fully resolved. Resolved monitor is one that has claimed all of
  its ouputs and balacnes.

  This function returns true only if `get_claimable_balances` has been empty for at least
  2016 blocks.

7 months agoMerge pull request #2825 from tnull/2024-01-upstream-output-sweeper
Matt Corallo [Thu, 18 Apr 2024 15:24:47 +0000 (08:24 -0700)]
Merge pull request #2825 from tnull/2024-01-upstream-output-sweeper

Add `OutputSweeper` utility persisting and sweeping spendable outputs

7 months agoMerge pull request #2970 from jkczyz/2024-03-offer-id
Matt Corallo [Thu, 18 Apr 2024 15:21:19 +0000 (08:21 -0700)]
Merge pull request #2970 from jkczyz/2024-03-offer-id

Include a `PaymentContext` in `PaymentPurpose`

7 months agoEdit `Event::SpendableOutputs` docs to mention `OutputSweeper`
Elias Rohrer [Tue, 16 Apr 2024 12:50:51 +0000 (14:50 +0200)]
Edit `Event::SpendableOutputs` docs to mention `OutputSweeper`

7 months agoAdd basic `OutputSweeper` test in BP
Elias Rohrer [Fri, 12 Jan 2024 16:46:37 +0000 (17:46 +0100)]
Add basic `OutputSweeper` test in BP

.. we simply check that the `OutputSweeper` generates a spending tx and
that the `TrackedSpendableOutput` is pruned once it reaches
`ANTI_REORG_DELAY`.

7 months agoAllow delaying generation and broadcasting of spending txs
Elias Rohrer [Tue, 16 Apr 2024 12:19:54 +0000 (14:19 +0200)]
Allow delaying generation and broadcasting of spending txs

.. which enables users to batch output spends.

7 months agoAdd `OutputSweeper` utility persisting and sweeping spendable outputs
Elias Rohrer [Fri, 12 Jan 2024 10:36:08 +0000 (11:36 +0100)]
Add `OutputSweeper` utility persisting and sweeping spendable outputs

We add a `OutputSweeper` utility that allows to track the state of
spendable output descriptors as emitted by `Event::SpendableOutputs`.

To this end, the `OutputSweeper` persists the necessary information in
our `KVStore` and regularly tries to sweep the spendable outputs,
removing them after reaching threshold confirmations, i.e.,
`ANTI_REORG_DELAY`.

7 months agoAdd `ConfirmationTarget::OutputSpendingFee`
Elias Rohrer [Tue, 16 Apr 2024 11:41:57 +0000 (13:41 +0200)]
Add `ConfirmationTarget::OutputSpendingFee`

7 months agoUpdate PaymentPurpose's payment_preimage docs
Jeffrey Czyz [Wed, 17 Apr 2024 21:45:45 +0000 (16:45 -0500)]
Update PaymentPurpose's payment_preimage docs

Clarify that payment_preimage should only be used to claim a payment
when handling Event::PaymentClaimable, not Event::PaymentClaimed.

7 months agoInclude InvoiceRequest fields in PaymentContext
Jeffrey Czyz [Fri, 29 Mar 2024 02:31:10 +0000 (21:31 -0500)]
Include InvoiceRequest fields in PaymentContext

When receiving a payment, it's useful to know information about the
InvoiceRequest. Include this data in PaymentContext::Bolt12Offer so
users can display information about an inbound payment (e.g., the payer
note).

7 months agoTest for PaymentContext in offers_tests.rs
Jeffrey Czyz [Wed, 27 Mar 2024 01:19:32 +0000 (20:19 -0500)]
Test for PaymentContext in offers_tests.rs

7 months agoUse BOLT 12 PaymentPurpose variants
Jeffrey Czyz [Sat, 13 Apr 2024 23:20:19 +0000 (18:20 -0500)]
Use BOLT 12 PaymentPurpose variants

When constructing a PaymentPurpose in ChannelManager, use the
PaymentContext from OnionPayload to determine which variant to
construct, including those for BOLT 12 payments.

7 months agoBOLT 12 variants of PaymentPurpose
Jeffrey Czyz [Sat, 13 Apr 2024 22:29:24 +0000 (17:29 -0500)]
BOLT 12 variants of PaymentPurpose

In order to provide more context in PaymentClaimable and PaymentClaimed
events, introduce new variants of PaymentPurpose for use with BOLT 12
payments. Separate variants are used for offers and refunds. An unknown
variant is used for backwards compatibility and ease of testing, but is
otherwise not publicly constructable.

7 months agoAdd PaymentPurpose::is_keysend utility method
Jeffrey Czyz [Sat, 13 Apr 2024 02:21:00 +0000 (21:21 -0500)]
Add PaymentPurpose::is_keysend utility method

7 months agoRename InvoicePayment to Bolt11InvoicePayment
Jeffrey Czyz [Sat, 13 Apr 2024 02:17:35 +0000 (21:17 -0500)]
Rename InvoicePayment to Bolt11InvoicePayment

PaymentPurpose will be expanded to include BOLT 12 payment context.
Rename the InvoicePayment variant accordinly before new variants are
added.

7 months agoInclude Refund context in blinded payment paths
Jeffrey Czyz [Tue, 26 Mar 2024 23:57:57 +0000 (18:57 -0500)]
Include Refund context in blinded payment paths

When requesting a payment for a refund, include a context in the
Bolt12Invoice's blinded payment paths indicated it is for such. When the
eventual payment is received, the user can use the payment hash to
correlate it with the corresponding Refund.

7 months agoInclude Offer context in blinded payment paths
Jeffrey Czyz [Tue, 26 Mar 2024 23:48:39 +0000 (18:48 -0500)]
Include Offer context in blinded payment paths

When constructing blinded payment paths for a Bolt12Invoice response,
include the OfferId so that the eventual payment can be correlated with
the Offer.

7 months agoInclude OfferId in VerifiedInvoiceRequest
Jeffrey Czyz [Tue, 26 Mar 2024 23:39:06 +0000 (18:39 -0500)]
Include OfferId in VerifiedInvoiceRequest

Extract the OfferId from the offer metadata sent back in the
InvoiceRequest and include it in VerifiedInvoiceRequest. This can be
used to correspond the eventual payment for the invoice response by
including it in the invoice's blinded payment paths.

7 months agoDefine an OfferId for BOLT 12 Offers
Jeffrey Czyz [Mon, 25 Mar 2024 21:10:36 +0000 (16:10 -0500)]
Define an OfferId for BOLT 12 Offers

Use a merkle root hash of the offer TLV records to define an offer id.
Will be included in a BOLT 12 invoice's blinded payment paths in order
for the recipient to identify which offer the payment is for.

7 months agoPass PaymentContext through HTLC processing
Jeffrey Czyz [Tue, 26 Mar 2024 18:10:04 +0000 (13:10 -0500)]
Pass PaymentContext through HTLC processing

PendingInboundPayment::BlindedReceive includes a PaymentContext, which
the recipient includes in each blinded path. Included this when
processing HTLCs in ChannelManager, first into PendingHTLCRouting and
then to OnionPayload. Later, this will be included in the PaymentPurpose
when surfaced to user in PaymentClaimable and PaymentClaimed events.

7 months agoAdd PaymentContext to payment::ReceiveTlvs
Jeffrey Czyz [Tue, 26 Mar 2024 14:48:03 +0000 (09:48 -0500)]
Add PaymentContext to payment::ReceiveTlvs

Providing LDK-specific data in a BlindedPath allows for the data to be
received with the corresponding payment. This is useful as it can then
be surfaced in PaymentClaimable events where the user may correlated
with an Offer, for instance. Define a PaymentContext enum for including
various context (e.g., offer, refund, static invoice).

7 months agoReturn the invoice when requesting a refund
Jeffrey Czyz [Tue, 12 Mar 2024 00:00:40 +0000 (19:00 -0500)]
Return the invoice when requesting a refund

When sending an invoice for a refund, information from the invoice may
be useful for caller. For instance, the payment_hash can be used to
track whether the refund was paid. Return the invoice to facilitate this
use case.

7 months agoIntroduce `ChangeDestinationSource` trait
Elias Rohrer [Tue, 16 Apr 2024 09:12:43 +0000 (11:12 +0200)]
Introduce `ChangeDestinationSource` trait

.. which users should implement on their on-chain wallet to allow us to
retrieve a new change destination script.

7 months agoIntroduce `OutputSpender` trait and implement for `(Phantom)KeysManager`
Elias Rohrer [Tue, 16 Apr 2024 08:52:51 +0000 (10:52 +0200)]
Introduce `OutputSpender` trait and implement for `(Phantom)KeysManager`

.. we move `spend_spendable_outputs` to a new trait which we can easily
reuse in `OutputSweeper` later.

7 months agoAdd splicing feature flag (also triggers dual_funding)
optout [Thu, 18 Apr 2024 06:40:34 +0000 (08:40 +0200)]
Add splicing feature flag (also triggers dual_funding)

7 months agoUpdate docs for ChannelClosed Event
Keyue Bao [Wed, 17 Apr 2024 15:59:04 +0000 (08:59 -0700)]
Update docs for ChannelClosed Event

7 months agoAcquire `per_peer_state` `write` lock earlier in `ChannelManager::write`
Elias Rohrer [Wed, 17 Apr 2024 09:54:25 +0000 (11:54 +0200)]
Acquire `per_peer_state` `write` lock earlier in `ChannelManager::write`

Previously, we would hold the `per_peer_state` `read` lock during the
serialization of channel objects. While this might have reduced lock
congestion minimally, we also calculated the number of serializable
peers in this phase, only to use it later after dropping and reacquiring
the `per_peer_state` `write` lock.

This could potentially result in inconsistiencies if the
`serializable_peer_count` would change after we dropped the `read` lock
but before we acquired the `write` lock.

To mitigate the issue we just acquire the `write` lock ealier and hold
it for the remainder of `ChannelManager::write`.

7 months agoMerge pull request #2991 from optout21/txsigs-splicing
Matt Corallo [Tue, 16 Apr 2024 20:27:54 +0000 (13:27 -0700)]
Merge pull request #2991 from optout21/txsigs-splicing

Add tx_signatures.tlvs field (splicing-specific field in dual funding message)

7 months agoAdd tx_signatures.tlvs field (splicing-specific field in dual funding message)
optout [Tue, 16 Apr 2024 05:32:37 +0000 (07:32 +0200)]
Add tx_signatures.tlvs field (splicing-specific field in dual funding message)

7 months agoMerge pull request #2993 from wpaulino/handshake-complete-timer-tick-occurred-race
Matt Corallo [Mon, 15 Apr 2024 21:21:47 +0000 (21:21 +0000)]
Merge pull request #2993 from wpaulino/handshake-complete-timer-tick-occurred-race

Fix race between handshake_complete and timer_tick_occurred

7 months agoImplement Eq and Hash for Bolt12Invoice
Jeffrey Czyz [Mon, 11 Mar 2024 23:31:50 +0000 (18:31 -0500)]
Implement Eq and Hash for Bolt12Invoice

Bolt12Invoice will be added to a new Event::InvoiceGenerated variant.
These traits along with PartialEq are required to be implemented for any
type used in an Event.

7 months agoRefactor handling of Bolt12Invoice
Jeffrey Czyz [Mon, 11 Mar 2024 22:03:26 +0000 (17:03 -0500)]
Refactor handling of Bolt12Invoice

In order to provide an InvoiceGenerated event, it would be cleaner to
have one location where a Bolt12Invoice is successfully created.
Refactor the handling code to this end and clean-up line length by
making some of the type conversions more streamlined.

7 months agoRefactor handling of InvoiceRequest
Jeffrey Czyz [Sun, 10 Mar 2024 00:58:01 +0000 (18:58 -0600)]
Refactor handling of InvoiceRequest

In order to generate and InvoiceSent event, it would be cleaner to have
one location where a Bolt12Invoice is successfully generated. Refactor
the handling code to this end and clean-up line length by making some of
the type conversions more streamlined.

7 months agoMerge pull request #2961 from jkczyz/2024-03-compact-blinded-paths
Matt Corallo [Mon, 15 Apr 2024 17:56:29 +0000 (17:56 +0000)]
Merge pull request #2961 from jkczyz/2024-03-compact-blinded-paths

Compact blinded path handling

7 months agoFix typos
Jeffrey Czyz [Mon, 15 Apr 2024 16:00:28 +0000 (11:00 -0500)]
Fix typos

7 months agoResolve blinded path when creating onion message
Jeffrey Czyz [Sun, 7 Apr 2024 19:10:29 +0000 (21:10 +0200)]
Resolve blinded path when creating onion message

Add a version of the create_onion_message utility function that attempts
to resolved the introduction node of the destination's BlindedPath using
a ReadOnlyNetworkGraph`. Otherwise, if given a path using the compact
representation, using create_onion_message would fail. Keep the current
version for use internally and for external uses where the blinded path
is known to be resolved.

7 months agoCache introduction_node_id lookup in get_route
Jeffrey Czyz [Fri, 29 Mar 2024 16:24:54 +0000 (11:24 -0500)]
Cache introduction_node_id lookup in get_route

7 months agoLook up node id from scid in OnionMessenger
Jeffrey Czyz [Wed, 20 Mar 2024 19:31:30 +0000 (14:31 -0500)]
Look up node id from scid in OnionMessenger

When forwarding onion messages, the next node may be represented by a
short channel id instead of a node id. Parameterize OnionMessenger with
a NodeIdLookUp trait to find which node is the next hop. Implement the
trait for ChannelManager for forwarding to channel counterparties.

Also use this trait when advancing a blinded path one hop when the
sender is the introduction node.

7 months agoResolve IntroductionNode::DirectedShortChannelId
Jeffrey Czyz [Tue, 19 Mar 2024 02:58:04 +0000 (21:58 -0500)]
Resolve IntroductionNode::DirectedShortChannelId

When OnionMessenger creates an OnionMessage to a Destination, the latter
may contain an IntroductionNode::DirectedShortChannelId inside a
BlindedPath. Resolve these in DefaultMessageRouter and handle unresolved
ones in OnionMessenger.

7 months agoGeneralize BlindedPath::introduction_node_id field
Jeffrey Czyz [Fri, 15 Mar 2024 21:52:36 +0000 (16:52 -0500)]
Generalize BlindedPath::introduction_node_id field

Allow using either a node id or a directed short channel id in blinded
paths. This allows for a more compact representation of blinded paths,
which is advantageous for reducing offer QR code size.

Follow-up commits will implement handling the directed short channel id
case in OnionMessenger as it requires resolving the introduction node in
MessageRouter.

7 months agoAdd source reference to BlindedPathCandidate hop
Jeffrey Czyz [Wed, 20 Mar 2024 21:43:03 +0000 (16:43 -0500)]
Add source reference to BlindedPathCandidate hop

Blinded paths currently contain a node id for the introduction node.
However, a compact representation will allow a directed short channel id
instead. Update BlindedPathCandidate and OneHopBlindedPathCandidate to
store a NodeId reference from either the NetworkGraph or from the user-
provided first hops.

This approach avoids looking up the introduction node id on demand,
which may not be resolvable. Thus, that would require returning an
Option from CandidateRouteHop::source and handle None accordingly.

7 months agoMerge pull request #2987 from TheBlueMatt/2024-04-test-ser-bug
valentinewallace [Mon, 15 Apr 2024 15:23:09 +0000 (11:23 -0400)]
Merge pull request #2987 from TheBlueMatt/2024-04-test-ser-bug

Add test coverage for cc78b77c715d6ef62693d4c1bc7190da990ec0fa

7 months agoMerge pull request #2971 from jbesraa/review-club/2815
Matt Corallo [Sat, 13 Apr 2024 19:59:05 +0000 (19:59 +0000)]
Merge pull request #2971 from jbesraa/review-club/2815

Fix comparison in `get_dust_buffer_feerate`

7 months agoFix `cmp::max` execution in `ChannelContext::get_dust_buffer_feerate`
jbesraa [Tue, 26 Mar 2024 17:23:37 +0000 (19:23 +0200)]
Fix `cmp::max` execution in `ChannelContext::get_dust_buffer_feerate`

  The current `cmp::max` doesnt align with the function comment, ie its
  comparing 2530 and `feerate_plus_quarter` instead of `feerate_per_kw
  + 2530` and `feerate_plus_quarter` which is fixed in this commit

7 months agoFix race between handshake_complete and timer_tick_occurred
Wilmer Paulino [Fri, 12 Apr 2024 17:23:45 +0000 (10:23 -0700)]
Fix race between handshake_complete and timer_tick_occurred

The initial noise handshake on connection establishment must complete
within a single timer tick. This timeout is enforced via
`awaiting_pong_timer_tick_intervals` whenever a timer tick fires while
our handshake has yet to complete. Currently, on an inbound connection,
if a timer tick fires after we've sent act two of the noise handshake
along with our init message and before receiving the counterparty's init
message, we begin enforcing such timeout. Even if we immediately
continue to process the counterparty's init message to complete to
handshake, the timeout enforcement is not cleared. With the handshake
complete, `awaiting_pong_timer_tick_intervals` is now tracked to enforce
a pong timeout, except a ping was never actually sent. If a single timer
tick fires again without having received a message from the peer, or
enough timer ticks fire to trigger the
`MAX_BUFFER_DRAIN_TICK_INTERVALS_PER_PEER` logic, we'll end up
disconnecting the peer due to a timeout for a pong we'll never receive.

We fix this by always resetting `awaiting_pong_timer_tick_intervals`
upon processing our counterparty's init message.

7 months agoLog pending in-flight updates when we are missing a monitor
Matt Corallo [Thu, 11 Apr 2024 15:20:08 +0000 (15:20 +0000)]
Log pending in-flight updates when we are missing a monitor

If we are missing a `ChannelMonitor` for which the `ChannelManager`
has pending updates, it may be useful to print what the updates we
have actually are, at least useful in identifying the bug(s).

7 months agoAdd BlindedPath::introduction_node_id method
Jeffrey Czyz [Wed, 20 Mar 2024 21:42:30 +0000 (16:42 -0500)]
Add BlindedPath::introduction_node_id method

Blinded paths use a pubkey to identify the introduction node, but it
will soon allow using a directed short channel id instead. Add an
introduction_node_id method to BlindedPath to facilitate lookup in the
latter case.

7 months agoAdd IndexedMap::get_key_value
Jeffrey Czyz [Tue, 12 Dec 2023 20:51:22 +0000 (14:51 -0600)]
Add IndexedMap::get_key_value

Useful for applying Option::map when needing both the key and value for
when needing a reference to the key with a longer lifetime.

7 months agoGeneralize onion message ForwardTlvs::next_node_id
Jeffrey Czyz [Sat, 2 Mar 2024 18:28:20 +0000 (12:28 -0600)]
Generalize onion message ForwardTlvs::next_node_id

Allow either using a node id or a short channel id when forwarding an
onion message. This allows for a more compact representation of blinded
paths, which is advantageous for reducing offer QR code size.

Follow-up commits will implement handling the short channel id case as
it requires looking up the destination node id.

7 months agoMerge pull request #2910 from tnull/2024-02-rustfmt-sign-mod
Matt Corallo [Wed, 10 Apr 2024 20:50:46 +0000 (20:50 +0000)]
Merge pull request #2910 from tnull/2024-02-rustfmt-sign-mod

`rustfmt`:  Format `sign` module

7 months agoAdd test coverage for cc78b77c715d6ef62693d4c1bc7190da990ec0fa 2024-04-test-ser-bug
Valentine Wallace [Fri, 29 Mar 2024 21:48:26 +0000 (17:48 -0400)]
Add test coverage for cc78b77c715d6ef62693d4c1bc7190da990ec0fa

cc78b77c715d6ef62693d4c1bc7190da990ec0fa fixed an important
downgrade bug, but neglected to add test coverage. Here we recitfy
that by adding a few simple tests of common cases.

Tests heavily tweaked by Matt Corallo <git@bluematt.me>.

7 months agoRemove `no-std-check/src/lib.rs` from `rustfmt` exclusion list
Elias Rohrer [Fri, 23 Feb 2024 11:12:50 +0000 (12:12 +0100)]
Remove `no-std-check/src/lib.rs` from `rustfmt` exclusion list

.. now continously checking its formatting in CI.

7 months agoRemove `msrv-no-dev-deps-check/src/lib.rs` from `rustfmt` exclusion list
Elias Rohrer [Fri, 23 Feb 2024 11:11:50 +0000 (12:11 +0100)]
Remove `msrv-no-dev-deps-check/src/lib.rs` from `rustfmt` exclusion list

.. now continously checking its formatting in CI.

7 months agoRun `rustfmt` on `msrv-no-dev-deps-check/src/lib.rs`
Elias Rohrer [Fri, 23 Feb 2024 11:12:19 +0000 (12:12 +0100)]
Run `rustfmt` on `msrv-no-dev-deps-check/src/lib.rs`

7 months agoRemove `sign/type_resolver.rs` from `rustfmt` exclusion list
Elias Rohrer [Fri, 23 Feb 2024 10:45:47 +0000 (11:45 +0100)]
Remove `sign/type_resolver.rs` from `rustfmt` exclusion list

.. now continously checking its formatting in CI.

7 months agoRun `rustfmt` on `sign/type_resolver.rs`
Elias Rohrer [Wed, 27 Mar 2024 11:14:50 +0000 (12:14 +0100)]
Run `rustfmt` on `sign/type_resolver.rs`

7 months agoRemove `sign/taproot.rs` from `rustfmt` exclusion list
Elias Rohrer [Fri, 23 Feb 2024 10:43:44 +0000 (11:43 +0100)]
Remove `sign/taproot.rs` from `rustfmt` exclusion list

.. now continously checking its formatting in CI.

7 months agoRun `rustfmt` on `sign/taproot.rs`
Elias Rohrer [Wed, 27 Mar 2024 11:14:24 +0000 (12:14 +0100)]
Run `rustfmt` on `sign/taproot.rs`

7 months agoRemove `sign/mod.rs` from `rustfmt` exclusion list
Elias Rohrer [Fri, 23 Feb 2024 10:41:53 +0000 (11:41 +0100)]
Remove `sign/mod.rs` from `rustfmt` exclusion list

.. now continously checking its formatting in CI.

7 months agoRun `rustfmt` on `sign/mod.rs`
Elias Rohrer [Tue, 9 Apr 2024 11:09:37 +0000 (13:09 +0200)]
Run `rustfmt` on `sign/mod.rs`