]> git.bitcoin.ninja Git - rust-lightning/log
rust-lightning
6 months agoMerge pull request #3073 from tnull/2024-05-bump-nits
Matt Corallo [Tue, 21 May 2024 13:08:35 +0000 (06:08 -0700)]
Merge pull request #3073 from tnull/2024-05-bump-nits

Fix minor nits in `BumpTransactionEventHandler`

6 months agoMerge pull request #3068 from toxeus/main
Elias Rohrer [Tue, 21 May 2024 10:18:53 +0000 (12:18 +0200)]
Merge pull request #3068 from toxeus/main

Re-export bitcoin crate

6 months agoMerge pull request #3069 from TheBlueMatt/2024-06-log-chan-count
Elias Rohrer [Mon, 20 May 2024 12:13:18 +0000 (14:13 +0200)]
Merge pull request #3069 from TheBlueMatt/2024-06-log-chan-count

Log how many nodes/channels we have synced when we try to route

6 months agoLog how many nodes/channels we have synced when we try to route 2024-06-log-chan-count
Matt Corallo [Sun, 19 May 2024 18:35:04 +0000 (18:35 +0000)]
Log how many nodes/channels we have synced when we try to route

A common issue in LN is not having fully synced the network graph
when we attempt to send a payment. This should be improved
substantially with gossip v1.5, but for now we should improve our
debugability by logging how many nodes we have in our graph when
we attempt to find a route.

6 months agoRe-export bitcoin crate
Filip Gospodinov [Fri, 17 May 2024 15:00:44 +0000 (17:00 +0200)]
Re-export bitcoin crate

For the same reason the `bitcoin` crate is re-exporting
the `secp256k1` crate the `lightning` crate should
re-export the `bitcoin` crate: to ease the burden on
calling code to maintain compatible `bitcoin` versions.

The `lightning` crate makes heavy use of types defined in
(or re-exported by) the `bitcoin` crate. Compilation will
fail if e.g. comparisons or `match` expressions are done with
types from `bitcoin` crate versions with a non-equal minor
version. This forces calling code to depend on a `bitcoin`
crate with a compatible version. This becomes a maintenance
nightmare once two or more crates, that use `bitcoin` types
in their public API, are used in calling code simultaneously.

6 months agoFix minor nits in `BumpTransactionEventHandler`
Elias Rohrer [Fri, 17 May 2024 07:04:30 +0000 (09:04 +0200)]
Fix minor nits in `BumpTransactionEventHandler`

6 months agoMerge pull request #3036 from TheBlueMatt/2024-05-filter-color
valentinewallace [Tue, 14 May 2024 23:23:30 +0000 (16:23 -0700)]
Merge pull request #3036 from TheBlueMatt/2024-05-filter-color

Provide more color in filter registration methods

6 months agoMerge pull request #3061 from TheBlueMatt/2024-05-bindings-upstream
valentinewallace [Tue, 14 May 2024 16:44:25 +0000 (09:44 -0700)]
Merge pull request #3061 from TheBlueMatt/2024-05-bindings-upstream

Minor bindings tweaks

6 months agoAllow any `Deref` to an `EntropySource` in `BlindedPath` building 2024-05-bindings-upstream
Matt Corallo [Mon, 13 May 2024 18:01:20 +0000 (18:01 +0000)]
Allow any `Deref` to an `EntropySource` in `BlindedPath` building

This matches our normal API semantics and allows, for example,
`Arc`s to `EntropySource`s.

6 months agoimpl `Clone` on various public (mostly BOLT12) types
Matt Corallo [Mon, 13 May 2024 14:36:01 +0000 (14:36 +0000)]
impl `Clone` on various public (mostly BOLT12) types

This is required for bindings as passing types from Rust to GC'd
languages can't map the concept of a type that has a lifetime of
the called function but instead needs to clone for safety.

6 months agoExpose `ChannelManager` offer constructors in bindings
Matt Corallo [Mon, 13 May 2024 14:35:34 +0000 (14:35 +0000)]
Expose `ChannelManager` offer constructors in bindings

6 months agoMark `io_extras` as no-bindings-export as its not for public use
Matt Corallo [Sun, 12 May 2024 00:26:19 +0000 (00:26 +0000)]
Mark `io_extras` as no-bindings-export as its not for public use

6 months agoMake `offers::Amount` `Copy` and export it in bindings
Matt Corallo [Sat, 11 May 2024 18:51:48 +0000 (18:51 +0000)]
Make `offers::Amount` `Copy` and export it in bindings

`Amount` is less than two pointers long, so there's no reason it
shouldn't be `Copy`. Further, because its an enum, bindings can't
map a reference to it in an `Option`. Thus, here, we simply make it
`Copy` and return it in `Option`s rather than a reference to it.

6 months agoUse prelude by universal import, rather than single import
Matt Corallo [Sat, 11 May 2024 15:55:36 +0000 (15:55 +0000)]
Use prelude by universal import, rather than single import

This avoids the bindings trying to figure out what a
`lightning::prelude::Vec` is rather than matching it as a `Vec`.

6 months agoExport `ChannelId` in bindings rather than `[u8; 32]`
Matt Corallo [Sat, 11 May 2024 16:16:12 +0000 (16:16 +0000)]
Export `ChannelId` in bindings rather than `[u8; 32]`

Now that `ChannelId` has useful constructors and methods we need
to start exposing it to bindings users rather than relying on using
`[u8; 32]`.

6 months agoSkip `BestBlock::new` in bindings as we already have one
Matt Corallo [Sat, 11 May 2024 16:10:56 +0000 (16:10 +0000)]
Skip `BestBlock::new` in bindings as we already have one

6 months agoMerge pull request #3058 from benthecarman/deref-empty-nod-id-lookup
Matt Corallo [Mon, 13 May 2024 13:09:31 +0000 (06:09 -0700)]
Merge pull request #3058 from benthecarman/deref-empty-nod-id-lookup

impl Deref for EmptyNodeIdLookUp

6 months agoMerge pull request #3059 from jkczyz/2024-05-drop-writeable-signer
Matt Corallo [Sat, 11 May 2024 12:57:28 +0000 (05:57 -0700)]
Merge pull request #3059 from jkczyz/2024-05-drop-writeable-signer

Remove `WriteableEcdsaChannelSigner` trait

6 months agoRemove WriteableEcdsaChannelSigner trait
Jeffrey Czyz [Fri, 10 May 2024 19:32:48 +0000 (14:32 -0500)]
Remove WriteableEcdsaChannelSigner trait

WriteableEcdsaChannelSigner is no longer needed now that
EcdsaChannelSigner isn't written in OnchainTxHandler.

6 months agoStop writing EcdsaChannelSigner
Jeffrey Czyz [Fri, 10 May 2024 18:58:41 +0000 (13:58 -0500)]
Stop writing EcdsaChannelSigner

EcdsaChannelSigner is no longer deserialized as of version 0.0.113 and
downgrades before version 0.0.113 are no longer supported as of version
0.0.119.

6 months agoMerge pull request #2930 from jbesraa/Add-PaymentHash-to-Record
Matt Corallo [Fri, 10 May 2024 16:55:55 +0000 (09:55 -0700)]
Merge pull request #2930 from jbesraa/Add-PaymentHash-to-Record

Add `PaymentHash` to `Record`

6 months agoMerge pull request #2973 from valentinewallace/2024-03-om-mailbox
Arik [Thu, 9 May 2024 22:27:49 +0000 (15:27 -0700)]
Merge pull request #2973 from valentinewallace/2024-03-om-mailbox

Support intercepting onion messages for offline peers

6 months agoimpl Deref for EmptyNodeIdLookUp
benthecarman [Thu, 9 May 2024 17:16:40 +0000 (12:16 -0500)]
impl Deref for EmptyNodeIdLookUp

6 months agoFill in top-level docs for onion message offline peer interception.
Valentine Wallace [Wed, 27 Mar 2024 15:52:10 +0000 (11:52 -0400)]
Fill in top-level docs for onion message offline peer interception.

6 months agoLimit OnionMessenger event buffer size.
Valentine Wallace [Wed, 27 Mar 2024 14:09:47 +0000 (10:09 -0400)]
Limit OnionMessenger event buffer size.

6 months agoManually implement Debug for onion message packets.
Valentine Wallace [Wed, 27 Mar 2024 15:06:33 +0000 (11:06 -0400)]
Manually implement Debug for onion message packets.

Previously we derived Debug, but that caused a lot of unreadable encrypted
bytes to be printed.

6 months agoTest offline peer onion message interception.
Valentine Wallace [Wed, 27 Mar 2024 15:05:21 +0000 (11:05 -0400)]
Test offline peer onion message interception.

6 months agoFix outdated comment in onion message functional test.
Valentine Wallace [Mon, 25 Mar 2024 17:23:00 +0000 (13:23 -0400)]
Fix outdated comment in onion message functional test.

6 months agoRefactor MessengerNode test util construction to take config.
Valentine Wallace [Mon, 25 Mar 2024 17:14:29 +0000 (13:14 -0400)]
Refactor MessengerNode test util construction to take config.

Will be used in the next commit when another config parameter is added.

6 months agoSupport forwarding prebuilt onion messages in OnionMessenger.
Valentine Wallace [Mon, 25 Mar 2024 15:42:13 +0000 (11:42 -0400)]
Support forwarding prebuilt onion messages in OnionMessenger.

6 months agoOnionMessenger: support generating peer connection events.
Valentine Wallace [Fri, 22 Mar 2024 19:58:33 +0000 (15:58 -0400)]
OnionMessenger: support generating peer connection events.

Useful if we are in the mode of interception OMs for offline peers, so
users know when to re-inject intercepted OMs.

6 months agoSupport generating events when an OM for an offline peer is received.
Valentine Wallace [Thu, 21 Mar 2024 17:56:54 +0000 (13:56 -0400)]
Support generating events when an OM for an offline peer is received.

Docs will be added in upcoming commits.

6 months agoMerge pull request #3041 from G8XSU/followup-2957
Matt Corallo [Thu, 9 May 2024 16:47:41 +0000 (09:47 -0700)]
Merge pull request #3041 from G8XSU/followup-2957

Followups to #2957

6 months agoAdd `payment_hash` to `WithChannelMonitor`
jbesraa [Sun, 24 Mar 2024 05:07:09 +0000 (07:07 +0200)]
Add `payment_hash` to `WithChannelMonitor`

6 months agoAdd `PaymentHash` to `Record`
esraa [Tue, 12 Mar 2024 14:23:00 +0000 (14:23 +0000)]
Add `PaymentHash` to `Record`

    Adding the `payment_hash` to `Record` so we are able to track it
    in logs.

6 months agoMerge pull request #2907 from shaavan/issue2882
Jeffrey Czyz [Wed, 8 May 2024 22:32:41 +0000 (17:32 -0500)]
Merge pull request #2907 from shaavan/issue2882

Introduce ResponseInstructions for OnionMessage Handling

6 months agoMerge pull request #3012 from TheBlueMatt/2024-04-0.0.123-rl
Matt Corallo [Wed, 8 May 2024 20:35:52 +0000 (13:35 -0700)]
Merge pull request #3012 from TheBlueMatt/2024-04-0.0.123-rl

Add draft release notes for 0.0.123

6 months agoMerge pull request #3054 from TheBlueMatt/2024-04-fuzz-bolt11
Matt Corallo [Wed, 8 May 2024 20:24:31 +0000 (13:24 -0700)]
Merge pull request #3054 from TheBlueMatt/2024-04-fuzz-bolt11

Add fuzzing coverage for BOLT11 invoice deserialization

6 months agoBump `possiblyrandom` to 0.2 2024-04-0.0.123-rl
Matt Corallo [Fri, 19 Apr 2024 15:33:58 +0000 (15:33 +0000)]
Bump `possiblyrandom` to 0.2

I'd uploaded `possiblyrandom` 0.1 to reserve the crate name but
with a dummy library so now we need ot use 0.2 for the release.

6 months agoAdd changelog entries for 0.0.123
Matt Corallo [Fri, 19 Apr 2024 15:24:32 +0000 (15:24 +0000)]
Add changelog entries for 0.0.123

6 months agoUse consistent byte/char offsets when parsing invoice HRPs 2024-04-fuzz-bolt11
Matt Corallo [Tue, 30 Apr 2024 17:11:54 +0000 (17:11 +0000)]
Use consistent byte/char offsets when parsing invoice HRPs

When parsing lightning-invoice HRPs we want to read them
char-by-char, tracking at which offset different fields were. Prior
to this commit this was done first by reading char-by-char and then
by indexing using the byte offset which works for ASCII strings but
fails on multi-byte characters.

This commit fixes this issue by simply always walking byte-by-byte
and rejecting multi-byte characters which don't belong in HRPs.

6 months agoSubstantially increase coverage in BOLT11 deserialization fuzzer
Matt Corallo [Tue, 30 Apr 2024 14:31:57 +0000 (14:31 +0000)]
Substantially increase coverage in BOLT11 deserialization fuzzer

6 months agoMove existing BOLT11 fuzz test to the `fuzz` crate
Matt Corallo [Tue, 30 Apr 2024 13:58:21 +0000 (13:58 +0000)]
Move existing BOLT11 fuzz test to the `fuzz` crate

6 months agoMerge pull request #3046 from TheBlueMatt/2024-03-fees-are-dust
Matt Corallo [Wed, 8 May 2024 19:24:04 +0000 (12:24 -0700)]
Merge pull request #3046 from TheBlueMatt/2024-03-fees-are-dust

Fix the `full_stack_target` breakage test and doc feerate requests

6 months agoImplement ResponseInstruction Usage in OnionMessage Handling
shaavan [Thu, 18 Apr 2024 11:31:52 +0000 (17:01 +0530)]
Implement ResponseInstruction Usage in OnionMessage Handling

This commit integrates the newly introduced ResponseInstruction structs
and enums into the codebase for handling OnionMessage responses.

6 months agoFix the `full_stack_target` breakage test and doc feerate requests 2024-03-fees-are-dust
Matt Corallo [Tue, 7 May 2024 16:34:36 +0000 (16:34 +0000)]
Fix the `full_stack_target` breakage test and doc feerate requests

When we added the additional deust exposure checks in
702196819e6445048b803574fcacef77d5ce8c9c we added several
additional feerate fetches which broke the `full_stack_target`
change-detection test.

This updates the hard-coded test to support the new feerate fetches
and also includes a comment on `FeeEstimator` to indicate that
users really need to be caching feerates as otherwise they'll slow
us down.

6 months agoMerge pull request #3045 from TheBlueMatt/2024-03-fees-are-dust
Matt Corallo [Tue, 7 May 2024 15:50:46 +0000 (08:50 -0700)]
Merge pull request #3045 from TheBlueMatt/2024-03-fees-are-dust

Include excess counterparty commitment transaction fees in dust exposure

6 months agoAdd a simple test of the new excess-fees-are-dust behavior
Matt Corallo [Sun, 5 May 2024 02:00:42 +0000 (02:00 +0000)]
Add a simple test of the new excess-fees-are-dust behavior

6 months agoUpdate default dust exposure limit and the documentation thereof
Matt Corallo [Sun, 5 May 2024 00:44:07 +0000 (00:44 +0000)]
Update default dust exposure limit and the documentation thereof

Now that we're including excess counterparty commitment transaction
fees in our dust calculation, we need to update the docs
accordingly. We do so here, describing some of the considerations
and risks that come with the new changes.

We also take this opportunity to double the default value, as users
have regularly complained that non-anchor channels fail to send
HTLCs with the default settings with some feerates.

Fixes #2922

6 months agoInclude excess commitment transaction fees in dust exposure
Matt Corallo [Tue, 30 Apr 2024 20:42:36 +0000 (20:42 +0000)]
Include excess commitment transaction fees in dust exposure

Transaction fees on counterparty commitment transactions are
ultimately not our money and thus are really "dust" from our PoV -
they're funds that may be ours during off-chain updates but are not
ours once we go on-chain.

Thus, here, we count any such fees in excess of our own fee
estimates towards dust exposure. We don't bother to make an
inbound/outbound channel distinction here as in most cases users
will use `MaxDustExposure::FeeRateMultiplier` which will scale
with the fee we set on outbound channels anyway.

Note that this also enables the dust exposure checks on anchor
channels during feerate updates. We'd previously elided these as
increases in the channel feerates do not change the HTLC dust
exposure, but now do for the fee dust exposure.

6 months agoStop tracking chain_sync_monitor_persistences in TestPersister
Gursharan Singh [Mon, 6 May 2024 20:00:52 +0000 (13:00 -0700)]
Stop tracking chain_sync_monitor_persistences in TestPersister

6 months agoMake ChannelMonitor chain-sync log a trace log
Gursharan Singh [Mon, 6 May 2024 18:06:13 +0000 (11:06 -0700)]
Make ChannelMonitor chain-sync log a trace log

6 months agoMinor Doc fixes after #2957
Gursharan Singh [Mon, 6 May 2024 18:04:50 +0000 (11:04 -0700)]
Minor Doc fixes after #2957

6 months agoMerge pull request #3039 from valentinewallace/2024-04-invoice-amt-msats-overflow
Matt Corallo [Mon, 6 May 2024 19:20:37 +0000 (12:20 -0700)]
Merge pull request #3039 from valentinewallace/2024-04-invoice-amt-msats-overflow

Fix overflow in invoice amount setter.

6 months agoMerge pull request #2957 from G8XSU/pause-events
Matt Corallo [Mon, 6 May 2024 19:08:10 +0000 (12:08 -0700)]
Merge pull request #2957 from G8XSU/pause-events

Don't pause events for chainsync persistence

6 months agoFix overflow in invoice amount setter.
Valentine Wallace [Tue, 30 Apr 2024 17:01:03 +0000 (13:01 -0400)]
Fix overflow in invoice amount setter.

6 months agoProvide more color in filter registration methods 2024-05-filter-color
Matt Corallo [Sun, 5 May 2024 19:52:58 +0000 (19:52 +0000)]
Provide more color in filter registration methods

A few years ago we had repeated user confusion dealing with the
`Filter` methods and exactly how they differ. Here we try to add a
bit more color in several ways as suggested by users in a few
places - listing examples of why the methods are used as well as
ensuring its clearly communicated that not all parameters need be
used.

Fixes #1069

6 months agoMerge pull request #3035 from TheBlueMatt/2024-04-upstream-123-bindings
Matt Corallo [Sat, 4 May 2024 00:55:25 +0000 (17:55 -0700)]
Merge pull request #3035 from TheBlueMatt/2024-04-upstream-123-bindings

6 months agoKeep newlines between releases in CHANGELOG consistent
Matt Corallo [Tue, 9 Apr 2024 14:39:33 +0000 (14:39 +0000)]
Keep newlines between releases in CHANGELOG consistent

6 months agoAdd release note for 0.0.122 with just three PRs.
Matt Corallo [Mon, 8 Apr 2024 16:16:03 +0000 (16:16 +0000)]
Add release note for 0.0.122 with just three PRs.

6 months agoMerge pull request #3018 from jkczyz/2024-04-optional-description
Matt Corallo [Fri, 3 May 2024 19:55:17 +0000 (12:55 -0700)]
Merge pull request #3018 from jkczyz/2024-04-optional-description

Optional description for `Offer` and `Refund`

6 months agoMerge pull request #3029 from TheBlueMatt/2024-04-fix-batch-funding-failures
Matt Corallo [Fri, 3 May 2024 19:17:58 +0000 (12:17 -0700)]
Merge pull request #3029 from TheBlueMatt/2024-04-fix-batch-funding-failures

Add error handling for channels which fail to be created in `funding_transaction_generated_intern`

6 months agoIntroduce ResponseInstructions for OnionMessage Handling
shaavan [Mon, 25 Mar 2024 08:42:47 +0000 (14:12 +0530)]
Introduce ResponseInstructions for OnionMessage Handling

- Currently, handle_message (or handle_custom_message) only exposes
  the generated response for an OnionMessage, lacking the necessary
  reply_path for asynchronous responses.

- This commit introduces a new flow for OnionMessage handling.

- Instead of solely taking the message as input, handle_message now accepts
  an Optional `responder`, returning a `ResponseInstruction` containing both
  the response and the reply_path.

- `ResponseInstruction` utilizes different enum variants to indicate how
  `handle_onion_message_response` should handle the response.

- This enhancement enables exposing the reply_path alongside the response
  and allows for more complex response mechanisms, such as responding with
  an added reply_path.

- The commit introduces the foundational framework (structs & enums) for this new flow.

6 months agoOnly require description when offer has an amount
Jeffrey Czyz [Thu, 2 May 2024 16:43:04 +0000 (11:43 -0500)]
Only require description when offer has an amount

The spec was changed to allow excluding an offer description if the
offer doesn't have an amount. However, it is still required when the
amount is set.

6 months agoSwap `UserConfig::default()` for `test_default_channel_config`
Matt Corallo [Wed, 1 May 2024 21:56:04 +0000 (21:56 +0000)]
Swap `UserConfig::default()` for `test_default_channel_config`

As LDK changes, `UserConfig::default()` may imply marginally
different behavior, whereas `test_default_channel_config` is
intended to tweak defaults to provide a stable behavior for test
contexts.

This commit changes a few uses of `UserConfig::default()` to
`test_default_channel_config` in cases that will fail over the
coming commits due to dust changes.

6 months agoCorrect indentation in `get_pending_htlc_stats`
Matt Corallo [Wed, 27 Mar 2024 02:21:40 +0000 (02:21 +0000)]
Correct indentation in `get_pending_htlc_stats`

The previous commit left indentation in `get_pending_htlc_stats`
deliberately wrong, to ease reviewability. This commit fixes the
indentation.

6 months agoUnify `get_{inbound,outbound}_pending_htlc_stats`
Matt Corallo [Wed, 27 Mar 2024 02:14:50 +0000 (02:14 +0000)]
Unify `get_{inbound,outbound}_pending_htlc_stats`

In most cases we already call both in a pair, and in fact always
consolidate some of the returned values across both accessors, so
there's not much reason to have them be separate methods.

Here we merge them.

6 months agoMerge pull request #3033 from TheBlueMatt/2024-04-notify-bp-on-blocks
Matt Corallo [Wed, 1 May 2024 21:21:28 +0000 (14:21 -0700)]
Merge pull request #3033 from TheBlueMatt/2024-04-notify-bp-on-blocks

Wake `background-processor` from `ChainMonitor` on new blocks

6 months agoWake `background-processor` from `ChainMonitor` on new blocks 2024-04-notify-bp-on-blocks
Matt Corallo [Tue, 30 Apr 2024 21:30:26 +0000 (21:30 +0000)]
Wake `background-processor` from `ChainMonitor` on new blocks

When we receive a new block we may generate
`Event::SpendableOutputs` in `ChannelMonitor`s which then need to
be processed by the background processor. While it will do so
eventually when its normal loop goes around, this may cause user
tests to be delayed in finding events, so we should notify the BP
immediately to wake it on new blocks.

We implement that here, unconditionally notifying the
`background-processor` whenever we receive a new block or confirmed
transactions.

6 months agoUpdate documentation on `[u8; 32]` wrappers for clarity 2024-04-upstream-123-bindings
Matt Corallo [Wed, 1 May 2024 16:04:13 +0000 (16:04 +0000)]
Update documentation on `[u8; 32]` wrappers for clarity

6 months agoMove `[u8; 32]` wrapper types to a common module
Matt Corallo [Wed, 1 May 2024 15:49:59 +0000 (15:49 +0000)]
Move `[u8; 32]` wrapper types to a common module

The `PaymentHash`, `PaymentSecret`, `PaymentPreimage`, and
`ChannelId` types are all small wrappers around `[u8; 32]` and are
used throughout the codebase but were defined in the top-level
`ln/mod.rs` file and the relatively sparsely-populated
`ln/channel_id.rs` file.

Here we move them to a common `types` module and go ahead and
update all our in-crate `use` statements to refer to the new
module for bindings. We do, however, leave a `pub use` alias for
the old paths to avoid upgrade hassle for users.

6 months agoAdd bindings no-export tags to doc test types
Matt Corallo [Wed, 1 May 2024 15:19:20 +0000 (15:19 +0000)]
Add bindings no-export tags to doc test types

We don't actually intend these to be public as they're just for
docs but the bindings don't currently parse `#[doc(hidden)]` as
"no-export" so we add manual no-export tags as well.

6 months agoAdd derives where they make sense and the bindings require them
Matt Corallo [Wed, 1 May 2024 15:18:29 +0000 (15:18 +0000)]
Add derives where they make sense and the bindings require them

6 months agoRename and expose message-specific `NextHop`
Matt Corallo [Tue, 23 Apr 2024 15:56:13 +0000 (15:56 +0000)]
Rename and expose message-specific `NextHop`

`onion::message::messenger::PeeledOnion` is a public enum which
included the private enum `NextHop`, which is not acceptable. Thus,
we here expose `NextHop` but rename it `NextMessageHop` to make
clear that it is specific to messages.

6 months agoMerge pull request #3032 from valentinewallace/2024-04-pico-btc-overflow
Matt Corallo [Wed, 1 May 2024 13:08:45 +0000 (06:08 -0700)]
Merge pull request #3032 from valentinewallace/2024-04-pico-btc-overflow

Fix overflow in lightning-invoice `amount_pico_btc`

6 months agoMerge pull request #3031 from TheBlueMatt/2024-04-new-rustc-warning
valentinewallace [Tue, 30 Apr 2024 17:16:11 +0000 (13:16 -0400)]
Merge pull request #3031 from TheBlueMatt/2024-04-new-rustc-warning

Fix new rustc `#[macro_export]` warning in doctests

6 months agoFix new rustc `#[macro_export]` warning in doctests 2024-04-new-rustc-warning
Matt Corallo [Tue, 30 Apr 2024 13:45:45 +0000 (13:45 +0000)]
Fix new rustc `#[macro_export]` warning in doctests

rustc now warns any time a `#[macro_export]` is used inside a
function as it generates surprising results. Because doctests are
run inside implicit test functions this means any use of
`#[macro_export]` inside a doctest will now warn. We do this in
`lightning-custom-message` to demonstrated how to use the crate,
which now fails to compile.

Here we fix this by adding an `fn main() {}` to the doctest, which
causes doctests to be compiled as freestanding code rather than
inside a test function.

Note that while discussing this upstream it came up that rustc is
also planning on changing the way doctests are compiled to compile
an entire crate's doctests in one go rather than in separate
crates, causing doctests to have a shared namespace which may
generate future surprising outcomes.

6 months agoFix overflow in lightning-invoice amount_pico_btc.
Valentine Wallace [Tue, 30 Apr 2024 14:05:35 +0000 (10:05 -0400)]
Fix overflow in lightning-invoice amount_pico_btc.

6 months agoSend peers error messages for failures due to invalid batch funding 2024-04-fix-batch-funding-failures
Matt Corallo [Mon, 29 Apr 2024 21:05:52 +0000 (21:05 +0000)]
Send peers error messages for failures due to invalid batch funding

If we fail to fund a batch open we'll force-close all channels in
the batch, however would previously fail to send error messages to
our peers for any channels we were due to test after the one that
failed.

This commit fixes that issue, sending the required error messages
to allow our peers to clean up their state.

6 months agoClose channels when `find_funding_output` fails to find an output
Matt Corallo [Mon, 29 Apr 2024 18:12:59 +0000 (18:12 +0000)]
Close channels when `find_funding_output` fails to find an output

In `funding_transaction_generated_intern`, if `find_funding_output`
fails (e.g. due to the require output not being present in the
provided funding transaction) we'd previously not generated a
`ChannelClosed` event which leaves users possibly in a confused
state.

Here we fix this, also fixing the relevant tests to check for the
new event.

Fixes #2843.

6 months agoMerge pull request #3017 from jkczyz/2024-04-optional-pubkey
Matt Corallo [Mon, 29 Apr 2024 19:05:30 +0000 (12:05 -0700)]
Merge pull request #3017 from jkczyz/2024-04-optional-pubkey

Sending to `Offer` without `signing_pubkey`

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 agoRemove ChainMonitor::sync_persistence_id
Gursharan Singh [Fri, 12 Apr 2024 06:35:54 +0000 (23:35 -0700)]
Remove ChainMonitor::sync_persistence_id

It was used earlier for generating unique MonitorUpdateId for
UpdateOrigin::ChainSync monitor updates.

6 months agoRemove MonitorUpdateId from persist trait
Gursharan Singh [Fri, 12 Apr 2024 06:31:30 +0000 (23:31 -0700)]
Remove MonitorUpdateId from persist trait

MonitorUpdateId was an opaque abstraction for id's generated by
UpdateOrigin:Offchain and UpdateOrigin::ChainSync monitor updates.
It was mainly needed to map calls made to
ChainMonitor::channel_monitor_updated. We no longer track
UpdateOrigin::ChainSync MonitorUpdates and can directly use
ChannelMonitor::get_latest_update_id() for tracking
UpdateOrigin::Offchain monitor updates.

6 months agoDon't require Refund::description in API
Jeffrey Czyz [Wed, 24 Apr 2024 18:59:01 +0000 (13:59 -0500)]
Don't require Refund::description in API

Refunds currently require a description, though this may change to be
optional. Remove the description requirement from the API, setting and
empty string by default.

6 months agoDon't require Offer::description in API
Jeffrey Czyz [Wed, 24 Apr 2024 17:40:22 +0000 (12:40 -0500)]
Don't require Offer::description in API

Offers currently require a description, though this may change to be
optional. Remove the description requirement from the API, setting and
empty string by default.

6 months agoBolt12Invoice for Offer without signing_pubkey
Jeffrey Czyz [Tue, 23 Apr 2024 23:35:05 +0000 (18:35 -0500)]
Bolt12Invoice for Offer without signing_pubkey

When parsing a Bolt12Invoice use both the Offer's signing_pubkey and
paths to determine if it is for an Offer or a Refund. Previously, an
Offer was required to have a signing_pubkey. But now that it is
optional, the Offers paths can be used to make the determination.
Additionally, check that the invoice matches one of the blinded node ids
from the paths' last hops.

6 months agoAdd InvoiceRequestTlvStream::paths
Jeffrey Czyz [Tue, 23 Apr 2024 23:30:59 +0000 (18:30 -0500)]
Add InvoiceRequestTlvStream::paths

Instead of reusing OfferTlvStream::paths, add a dedicated paths TLV to
InvoiceRequestTlvStream such that it can be used in Refund. This allows
for an Offer without a signing_pubkey and still be able to differentiate
whether an invoice is for an offer or a refund.

6 months agoAllow parsing Offer without signing_pubkey
Jeffrey Czyz [Wed, 24 Apr 2024 14:03:56 +0000 (09:03 -0500)]
Allow parsing Offer without signing_pubkey

If an offer has at least one path, it may omit the signing pubkey and
use the blinded node id of the last hop of a path to sign an invoice.
Allow parsing such offers but not yet creating them.

6 months agoOptional OfferContents::signing_pubkey
Jeffrey Czyz [Tue, 23 Apr 2024 22:38:13 +0000 (17:38 -0500)]
Optional OfferContents::signing_pubkey

If an Offer contains a path, the blinded_node_id of the path's final hop
can be used as the signing pubkey. Make Offer::signing_pubkey and
OfferContents::signing_pubkey return an Option to support this. Upcoming
commits will implement this behavior.

6 months agoStop tracking MonitorUpdates from ChainSync in pending_monitor_updates
Gursharan Singh [Wed, 27 Mar 2024 15:16:14 +0000 (16:16 +0100)]
Stop tracking MonitorUpdates from ChainSync in pending_monitor_updates

We no longer need to track them since we no longer hold events for
pending MonitorUpdates resulting from ChainSync.

6 months agoStop storing last_chain_persist_height
Gursharan Singh [Wed, 27 Mar 2024 11:18:31 +0000 (12:18 +0100)]
Stop storing last_chain_persist_height

We only used to store last_chain_persist_height to release
events held for more than LATENCY_GRACE_PERIOD_BLOCKS due to
pending monitor update with UpdateOrigin::ChainSync. Since we no
longer pause events for ChainSync persistence, we no longer need to
store last_chain_persist_height.

6 months agoDon't pause events for chainsync persistence
Gursharan Singh [Thu, 7 Mar 2024 19:00:41 +0000 (11:00 -0800)]
Don't pause events for chainsync persistence

We used to wait on ChannelMonitor persistence to avoid
duplicate payment events. But this can still happen in cases where
ChannelMonitor handed the event to ChannelManager and we did not persist
ChannelManager after event handling.
It is expected to receive payment duplicate events and clients should handle these
events in an idempotent manner. Removing this hold-up of events simplifies
the logic and makes it easier to not persist ChannelMonitors on every block connect.

7 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

7 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

7 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.