rust-lightning
12 months agoMerge pull request #1841 from ariard/2022-11-revoked-balance-non-aggregable
Matt Corallo [Thu, 18 May 2023 19:24:55 +0000 (19:24 +0000)]
Merge pull request #1841 from ariard/2022-11-revoked-balance-non-aggregable

Post-anchor: do not aggregate claim of revoked output

12 months agoRemove aggregable flag from PackageTemplate constructor
Antoine Riard [Wed, 30 Nov 2022 01:48:22 +0000 (20:48 -0500)]
Remove aggregable flag from PackageTemplate constructor

12 months agoAnchor: do not aggregate claim of revoked output
Antoine Riard [Wed, 9 Nov 2022 00:12:22 +0000 (19:12 -0500)]
Anchor: do not aggregate claim of revoked output

See https://github.com/lightning/bolts/pull/803

This protect the justice claim of counterparty revoked output. As
otherwise if the all the revoked outputs claims are batched in a
single transaction, low-feerate HTLCs transactions can delay our
honest justice claim transaction until BREAKDOWN_TIMEOUT expires.

12 months agoMerge pull request #2288 from wpaulino/rust-bitcoin-30-prereqs
Matt Corallo [Mon, 15 May 2023 18:42:38 +0000 (18:42 +0000)]
Merge pull request #2288 from wpaulino/rust-bitcoin-30-prereqs

12 months agoMerge pull request #2271 from tnull/2023-04-fix-onion-panic
Matt Corallo [Thu, 11 May 2023 21:52:47 +0000 (21:52 +0000)]
Merge pull request #2271 from tnull/2023-04-fix-onion-panic

Return error when failing onion packet construction

12 months agoMerge pull request #2286 from benthecarman/spendable-outputs-psbt
Matt Corallo [Thu, 11 May 2023 21:41:07 +0000 (21:41 +0000)]
Merge pull request #2286 from benthecarman/spendable-outputs-psbt

Create and Sign PSBTs for spendable outputs

12 months agoReturn error when failing to construc onion messages
Elias Rohrer [Wed, 5 Apr 2023 15:08:49 +0000 (17:08 +0200)]
Return error when failing to construc onion messages

Previously, we would panic when failing to construct onion messages in
certain circumstances. Here we opt to always rather error out and don't
panic if something goes wrong during OM packet construction.

12 months agoMerge pull request #2237 from henghonglee/issue-2189-score-params
Matt Corallo [Thu, 11 May 2023 05:27:14 +0000 (05:27 +0000)]
Merge pull request #2237 from henghonglee/issue-2189-score-params

[#2189] Score Fee Params as a passed in parameter

12 months agoCreate and Sign PSBTs for spendable outputs
benthecarman [Tue, 9 May 2023 18:29:51 +0000 (13:29 -0500)]
Create and Sign PSBTs for spendable outputs

12 months agoMove functions around to colocate impl of FeeParams and DecayParams
henghonglee [Wed, 10 May 2023 05:13:42 +0000 (22:13 -0700)]
Move functions around to colocate impl of FeeParams and DecayParams

12 months agoScore's FeeParams as passed-in params on Routefinding functions
henghonglee [Sat, 6 May 2023 18:01:22 +0000 (11:01 -0700)]
Score's FeeParams as passed-in params on Routefinding functions

This PR aims to create a "stateless" scorer. Instead of passing
in fee params at construction-time, we want to parametrize the
scorer with an associated "parameter" type, which is then
passed to the router function itself, and allows passing
different parameters per route-finding call.

12 months agoFix test_restored_packages_retry serialized monitor payload
Wilmer Paulino [Wed, 10 May 2023 17:39:19 +0000 (10:39 -0700)]
Fix test_restored_packages_retry serialized monitor payload

The purpose of this payload is to ensure we retry restored packages on a
`ChannelMonitor` that has upgraded from a version that previously did
not have such retry logic. We can verify this works by checking whether
a restored package has a `height_timer` of `None` upon deserializing the
monitor payload.

In the previous commit, we added a helper that constructs blocks
whenever tests demand blocks be connected. This helper moved towards
having all connected blocks have a version of 0x2000_0000 (also known as
NO_SOFT_FORK_SIGNALLING). However, previously, it was possible for some
blocks to be connected with a slighty different version: 0x0200_0000,
resulting in different block hashes.

This block hash divergence prompted a failure in this test when
`ConnectStyle::HighlyRedundantTransactionsFirstSkippingBlocks` is used
for `nodes[0]`, since this block connection style reconfirms
transactions redundantly and the serialized monitor payload kept a
reference to the hash of the block with version 0x0200_0000, when it
should be expecting one with version 0x2000_0000.

12 months agoUse helper to create dummy blocks
Wilmer Paulino [Thu, 27 Apr 2023 20:31:04 +0000 (13:31 -0700)]
Use helper to create dummy blocks

`rust-bitcoin v0.30.0` introduces concrete variants for data members of
block `Header`s. To avoid having to update these across every use, we
introduce new helpers to create dummy blocks and headers, such that the
update process is a bit more straight-forward.

12 months agoCheck difficulty transition against `Target` instead of `Work`
Wilmer Paulino [Fri, 28 Apr 2023 09:06:23 +0000 (02:06 -0700)]
Check difficulty transition against `Target` instead of `Work`

`rust-bitcoin v0.30.0` made some changes in this area that no longer
allow us to work with the previously exposed `U256` type. While `Work`
and `Target` (they're inverses of each other) essentially represent the
same concept, it makes more sense from their API's perspective to only
expose difficulty transitions and adjustments on `Target`s.

12 months agoIgnore lightning-transaction-sync build output
Wilmer Paulino [Thu, 27 Apr 2023 21:29:04 +0000 (14:29 -0700)]
Ignore lightning-transaction-sync build output

12 months agoMerge pull request #2279 from benthecarman/ord-invoice
Wilmer Paulino [Wed, 10 May 2023 18:24:00 +0000 (11:24 -0700)]
Merge pull request #2279 from benthecarman/ord-invoice

Impl PartialOrd and Ord for Invoice

12 months agoMerge pull request #2287 from TheBlueMatt/2023-05-no-background-event-dup-persist
Matt Corallo [Wed, 10 May 2023 00:02:31 +0000 (00:02 +0000)]
Merge pull request #2287 from TheBlueMatt/2023-05-no-background-event-dup-persist

Stop persisting background shutdown monitor updates

12 months agoRename ClosingMonitorUpdate MonitorUpdateRegeneratedOnStartup 2023-05-no-background-event-dup-persist
Matt Corallo [Tue, 9 May 2023 21:24:56 +0000 (21:24 +0000)]
Rename ClosingMonitorUpdate MonitorUpdateRegeneratedOnStartup

This makes much clearer at sites generating such events that they
will be lost on restart, to reduce risk of bugs creeping in due to
lost monitor updates.

12 months agoStop persisting background shutdown monitor updates
Matt Corallo [Tue, 9 May 2023 21:02:01 +0000 (21:02 +0000)]
Stop persisting background shutdown monitor updates

In d4810087c1 we added logic to apply `ChannelMonitorUpdate`s which
were a part of a channel closure async via a background queue to
address some startup issues. When we did that we persisted those
updates to ensure we replayed them when starting next time.

However, there was no reason to - if we persisted and then
restarted even without those monitor updates we'd find a monitor
without a channel, which we'd tell to broadcast the latest
commitment transaction to force-close.

Since adding that logic, we've used the same background queue for
several purposes.

12 months agoImpl PartialOrd and Ord for Invoice
benthecarman [Tue, 9 May 2023 00:02:05 +0000 (19:02 -0500)]
Impl PartialOrd and Ord for Invoice

12 months agoMerge pull request #2281 from dunxen/2023-05-dfmsgfollowups
Matt Corallo [Tue, 9 May 2023 17:10:38 +0000 (17:10 +0000)]
Merge pull request #2281 from dunxen/2023-05-dfmsgfollowups

Dual funding message follow-ups

12 months agoMerge pull request #2270 from tnull/2023-05-improve-tx-sync-compat-notice
Matt Corallo [Tue, 9 May 2023 17:06:43 +0000 (17:06 +0000)]
Merge pull request #2270 from tnull/2023-05-improve-tx-sync-compat-notice

Make `lightning-transaction-sync` compat notice a bit more explicit

12 months agoMerge pull request #2278 from benthecarman/faster-u16-check
Wilmer Paulino [Tue, 9 May 2023 16:53:12 +0000 (09:53 -0700)]
Merge pull request #2278 from benthecarman/faster-u16-check

Check too many tx outputs upfront when verifying funding tx

12 months agoMerge pull request #2277 from valentinewallace/2023-05-fix-big-oms
valentinewallace [Tue, 9 May 2023 12:50:28 +0000 (08:50 -0400)]
Merge pull request #2277 from valentinewallace/2023-05-fix-big-oms

Fix large onion message packet generation

12 months agoMake `lightning-transaction-sync` compat notice a bit more explicit
Elias Rohrer [Fri, 5 May 2023 09:26:50 +0000 (11:26 +0200)]
Make `lightning-transaction-sync` compat notice a bit more explicit

As `lightning-transaction-sync` was introduced with 0.0.114 and depended
on prior changes in the same release cycle we deemed it reasonable to
omit the implicitly limited backwards compatibility.

It however turns out this might be confusing to users copy/pasting the
codebase. Here we therefore spell out the implicit dependency on 0.0.114
and above.

12 months agoEnforce that no bytes remain for TransactionU16LenLimited read
Duncan Dean [Tue, 9 May 2023 06:37:58 +0000 (08:37 +0200)]
Enforce that no bytes remain for TransactionU16LenLimited read

12 months agoMove TransactionU16LenLimited to ser.rs
Duncan Dean [Tue, 9 May 2023 06:19:32 +0000 (08:19 +0200)]
Move TransactionU16LenLimited to ser.rs

12 months agoMerge pull request #2258 from valentinewallace/2023-04-blinded-pathfinding-groundwork-2
Matt Corallo [Mon, 8 May 2023 23:17:42 +0000 (23:17 +0000)]
Merge pull request #2258 from valentinewallace/2023-04-blinded-pathfinding-groundwork-2

Prefactor `PaymentParameters` for blinded recipients

12 months agoCheck too many tx outputs upfront when verifying funding tx
benthecarman [Mon, 8 May 2023 22:49:05 +0000 (17:49 -0500)]
Check too many tx outputs upfront when verifying funding tx

12 months agoMove final_cltv_expiry_delta from PaymentParams to Payee::Clear
Valentine Wallace [Thu, 27 Apr 2023 21:37:38 +0000 (17:37 -0400)]
Move final_cltv_expiry_delta from PaymentParams to Payee::Clear

Since blinded pay params won't have this value.

12 months agoAdd BOLT 12 features to PaymentParams
Valentine Wallace [Wed, 3 May 2023 18:05:20 +0000 (14:05 -0400)]
Add BOLT 12 features to PaymentParams

12 months agoMove BOLT11 features from top level PaymentParams to Payee::Clear
Valentine Wallace [Wed, 3 May 2023 17:04:25 +0000 (13:04 -0400)]
Move BOLT11 features from top level PaymentParams to Payee::Clear

Since blinded payees don't have this.

12 months agoError if BOLT 11 features are provided for blinded payment params
Valentine Wallace [Sat, 29 Apr 2023 19:37:51 +0000 (15:37 -0400)]
Error if BOLT 11 features are provided for blinded payment params

12 months agoMove payee node id from top level PaymentParams to Payee::Clear
Valentine Wallace [Sat, 29 Apr 2023 21:13:02 +0000 (17:13 -0400)]
Move payee node id from top level PaymentParams to Payee::Clear

Since blinded payees don't have one

12 months agoFix onion messages of size BIG_PACKET_HOP_DATA_LEN
Valentine Wallace [Mon, 8 May 2023 18:23:56 +0000 (14:23 -0400)]
Fix onion messages of size BIG_PACKET_HOP_DATA_LEN

This was previously broken and would result in an invalid HMAC error, because
we had a hardcoded assumption that OM hop data would always be of size 1300.

12 months agoFix broken test utils in OnionMessenger and stop asserting on logs
Valentine Wallace [Fri, 5 May 2023 17:33:08 +0000 (13:33 -0400)]
Fix broken test utils in OnionMessenger and stop asserting on logs

12 months agoMerge pull request #1794 from dunxen/2022-10-dualfunding-act-1
Wilmer Paulino [Mon, 8 May 2023 17:47:51 +0000 (10:47 -0700)]
Merge pull request #1794 from dunxen/2022-10-dualfunding-act-1

Dual funding and interactive tx construction wire messages

12 months agoMerge pull request #2269 from TheBlueMatt/2023-05-doc-events-present
Matt Corallo [Mon, 8 May 2023 16:39:15 +0000 (16:39 +0000)]
Merge pull request #2269 from TheBlueMatt/2023-05-doc-events-present

Document when event fields are `Some`

12 months agoMerge pull request #2265 from wpaulino/channel-force-closed-update-err
Matt Corallo [Mon, 8 May 2023 16:33:14 +0000 (16:33 +0000)]
Merge pull request #2265 from wpaulino/channel-force-closed-update-err

Prevent ChannelForceClosed monitor update error after detecting spend

12 months agoMerge pull request #2267 from TheBlueMatt/2023-05-better-scb-err
Matt Corallo [Sat, 6 May 2023 00:58:18 +0000 (00:58 +0000)]
Merge pull request #2267 from TheBlueMatt/2023-05-better-scb-err

Mention lnd's SCB feature in the corresponding error message

12 months agoAdd & generate dual-funding message fuzzing
Duncan Dean [Mon, 13 Mar 2023 09:44:31 +0000 (11:44 +0200)]
Add & generate dual-funding message fuzzing

12 months agoAdd new wire messaging and events but don't handle them
Duncan Dean [Tue, 1 Nov 2022 14:12:06 +0000 (16:12 +0200)]
Add new wire messaging and events but don't handle them

12 months agoAdd message structs required for dual-funded channels
Duncan Dean [Thu, 20 Oct 2022 20:56:37 +0000 (22:56 +0200)]
Add message structs required for dual-funded channels

This is the first of a set of PRs to enable the experimental dual-funded
channels feature using interactive transaction construction. This allows
both the channel initiator and channel acceptor to contribute funds
towards the channel.

12 months agoDocuemnt when `PaymentPathFailed::payment_id` is `Some` 2023-05-doc-events-present
Matt Corallo [Fri, 5 May 2023 04:08:55 +0000 (04:08 +0000)]
Docuemnt when `PaymentPathFailed::payment_id` is `Some`

The `PaymentPathFailed::payment_id` field has been `Some` since
the field was added in
73f601fd3d1c9defe553392264ca6dbcc53e4334.

12 months agoDocument when `PaymentPathSuccessful::payment_hash` is filled in.
Matt Corallo [Fri, 5 May 2023 03:33:54 +0000 (03:33 +0000)]
Document when `PaymentPathSuccessful::payment_hash` is filled in.

The `payment_hash` field in `PaymentPathSuccessful` is always
`Some` as long as the pening payment tracker has a `payment_hash`,
which is true for all `Pending` payments as well as all `Fulfilled`
payments starting with the commit which added
`PaymentPathSuccessful` -
3b5c370b404e2f5a8f3c35093b97406f149a9340c177c05252574083d68df0da.

12 months agoImprove logging around redundant force close monitor updates
Wilmer Paulino [Thu, 4 May 2023 22:37:25 +0000 (15:37 -0700)]
Improve logging around redundant force close monitor updates

12 months agoMention lnd's SCB feature in the corresponding error message 2023-05-better-scb-err
Matt Corallo [Fri, 5 May 2023 00:13:25 +0000 (00:13 +0000)]
Mention lnd's SCB feature in the corresponding error message

It's a bit confusing when we see only "Peer sent a garbage
channel_reestablish" when a peer uses lnd's SCB feature to ask us
to broadcast the latest state. This updates the error message to be
a bit clearer.

12 months agoPrevent ChannelForceClosed monitor update error after detecting spend
Wilmer Paulino [Thu, 4 May 2023 22:16:17 +0000 (15:16 -0700)]
Prevent ChannelForceClosed monitor update error after detecting spend

If we detected a spend for a channel onchain prior to handling its
`ChannelForceClosed` monitor update, we'd log a concerning error
message and return an error unnecessarily. The channel has already been
closed, so handling the `ChannelForceClosed` monitor update at this
point should be a no-op.

12 months agoMerge pull request #2111 from TheBlueMatt/2023-03-sent-persist-order-prep
Matt Corallo [Thu, 4 May 2023 21:26:44 +0000 (21:26 +0000)]
Merge pull request #2111 from TheBlueMatt/2023-03-sent-persist-order-prep

Setup Support for delaying `ChannelMonitorUpdate` flight until an `Event` completes

12 months agoMerge pull request #2262 from Kixunil/remove-serde-error-allocation
Wilmer Paulino [Thu, 4 May 2023 17:30:32 +0000 (10:30 -0700)]
Merge pull request #2262 from Kixunil/remove-serde-error-allocation

Remove unneeded allocation

12 months agoError if clear hints are provided for blinded PaymentParams
Valentine Wallace [Sat, 29 Apr 2023 18:47:59 +0000 (14:47 -0400)]
Error if clear hints are provided for blinded PaymentParams

12 months agoGroundwork for refactoring PaymentParams::Hints to ::Payee
Valentine Wallace [Wed, 26 Apr 2023 19:15:19 +0000 (15:15 -0400)]
Groundwork for refactoring PaymentParams::Hints to ::Payee

Minor changes in preparation for supporting route blinding in
PaymentParameters. In the next commit, we'll be moving more
unblinded-payee-specific fields from the top level parameters into the clear
enum variant.

12 months agoRemove unneeded allocation
Martin Habovstiak [Thu, 4 May 2023 09:21:04 +0000 (11:21 +0200)]
Remove unneeded allocation

`<E as serde::de::Error>::custom()` accepts any `T: Display`, not just
`String`. Therefore it accepts `Arguments<'_>` too so we can use
`format_args!()` instead of `format!()`.

See https://github.com/lightningdevkit/rust-lightning/pull/2187#discussion_r1168781355

12 months agoMerge pull request #2246 from arik-so/2023-04-sign-module
Matt Corallo [Wed, 3 May 2023 16:53:36 +0000 (16:53 +0000)]
Merge pull request #2246 from arik-so/2023-04-sign-module

Move keysinterface.rs to a directory-level module called sign

12 months agoMerge pull request #2219 from benthecarman/custom-closing-address
Matt Corallo [Wed, 3 May 2023 16:33:57 +0000 (16:33 +0000)]
Merge pull request #2219 from benthecarman/custom-closing-address

Add ability to set shutdown script when closing channel

13 months agoMove keysinterface.rs to a directory-level module called sign.
Arik Sosman [Fri, 28 Apr 2023 19:11:37 +0000 (14:11 -0500)]
Move keysinterface.rs to a directory-level module called sign.

13 months agoMerge pull request #2249 from TheBlueMatt/2023-04-less-pm-bounds
Matt Corallo [Wed, 3 May 2023 01:41:17 +0000 (01:41 +0000)]
Merge pull request #2249 from TheBlueMatt/2023-04-less-pm-bounds

Trivial PeerManager cleanups

13 months agoExpose a trait impl'd for all `PeerManager` for use as a bound 2023-04-less-pm-bounds
Matt Corallo [Sat, 29 Apr 2023 18:45:59 +0000 (18:45 +0000)]
Expose a trait impl'd for all `PeerManager` for use as a bound

A while back, in tests, we added a `AChannelManager` trait, which
is implemented for all `ChannelManager`s, and can be used as a
bound when we need a `ChannelManager`, rather than having to
duplicate all the bounds of `ChannelManager` everywhere.

Here we do the same thing for `PeerManager`, but make it public and
use it to clean up `lightning-net-tokio` and
`lightning-background-processor`.

We should likely do the same for `AChannelManager`, but that's left
as a followup.

13 months agoMerge pull request #2253 from dunxen/2023-05-removeoptionalfield
Matt Corallo [Tue, 2 May 2023 22:02:04 +0000 (22:02 +0000)]
Merge pull request #2253 from dunxen/2023-05-removeoptionalfield

Remove `OptionalField` and make `DataLossProtect` fields mandatory

13 months agoAdd ability to set shutdown script when closing channel
benthecarman [Sun, 23 Apr 2023 07:14:26 +0000 (02:14 -0500)]
Add ability to set shutdown script when closing channel

13 months agoMerge pull request #2244 from benthecarman/signature-size
Wilmer Paulino [Tue, 2 May 2023 19:01:51 +0000 (12:01 -0700)]
Merge pull request #2244 from benthecarman/signature-size

Incorporate low-R values into estimate signature size

13 months agoSet data_loss_protect_required
Duncan Dean [Tue, 2 May 2023 18:26:46 +0000 (20:26 +0200)]
Set data_loss_protect_required

13 months agoStore + process pending `ChannelMonitorUpdate`s in `Channel` 2023-03-sent-persist-order-prep
Matt Corallo [Fri, 17 Mar 2023 04:55:30 +0000 (04:55 +0000)]
Store + process pending `ChannelMonitorUpdate`s in `Channel`

The previous commits set up the ability for us to hold
`ChannelMonitorUpdate`s which are pending until we're ready to pass
them to users and have them be applied. However, if the
`ChannelManager` is persisted while we're waiting to give the user
a `ChannelMonitorUpdate` we'll be confused on restart - seeing our
latest `ChannelMonitor` state as stale compared to our
`ChannelManager` - a critical error.

Luckily the solution is trivial, we simply need to store the
pending `ChannelMonitorUpdate` state and load it with the
`ChannelManager` data, allowing stale monitors on load as long as
we have the missing pending updates between where we are and the
latest `ChannelMonitor` state.

13 months agoHandle `EventCompletionAction`s after events complete
Matt Corallo [Thu, 16 Mar 2023 03:33:20 +0000 (03:33 +0000)]
Handle `EventCompletionAction`s after events complete

This adds handling of the new `EventCompletionAction`s after
`Event`s are handled, letting `ChannelMonitorUpdate`s which were
blocked fly after a relevant `Event`.

13 months agoTrack an `EventCompletionAction` for after an `Event` is processed
Matt Corallo [Fri, 28 Apr 2023 04:24:25 +0000 (04:24 +0000)]
Track an `EventCompletionAction` for after an `Event` is processed

This will allow us to block `ChannelMonitorUpdate`s on `Event`
processing in the next commit.

Note that this gets dangerously close to breaking forwards
compatibility - if we have an `Event` with an
`EventCompletionAction` tied to it, we persist a new, even, TLV in
the `ChannelManager`. Hopefully this should be uncommon, as it
implies an `Event` was delayed until after a full round-trip to a
peer.

13 months agoAllow holding `ChannelMonitorUpdate`s until later, completing one
Matt Corallo [Wed, 15 Mar 2023 23:16:06 +0000 (23:16 +0000)]
Allow holding `ChannelMonitorUpdate`s until later, completing one

In the coming commits, we need to delay `ChannelMonitorUpdate`s
until future actions (specifically `Event` handling). However,
because we should only notify users once of a given
`ChannelMonitorUpdate` and they must be provided in-order, we need
to track which ones have or have not been given to users and, once
updating resumes, fly the ones that haven't already made it to
users.

To do this we simply add a `bool` in the `ChannelMonitorUpdate` set
stored in the `Channel` which indicates if an update flew and
decline to provide new updates back to the `ChannelManager` if any
updates have their flown bit unset.

Further, because we'll now by releasing `ChannelMonitorUpdate`s
which were already stored in the pending list, we now need to
support getting a `Completed` result for a monitor which isn't the
only pending monitor (or even out of order), thus we also rewrite
the way monitor updates are marked completed.

13 months agoMerge pull request #2213 from benthecarman/error-sign-provider-addrs
Matt Corallo [Tue, 2 May 2023 17:48:05 +0000 (17:48 +0000)]
Merge pull request #2213 from benthecarman/error-sign-provider-addrs

Allow get_shutdown_scriptpubkey and get_destination_script to return an Error

13 months agoRemove `OptionalField` and move `shutdown_scriptpubkey` into TLV stream
Duncan Dean [Mon, 1 May 2023 20:52:30 +0000 (22:52 +0200)]
Remove `OptionalField` and move `shutdown_scriptpubkey` into TLV stream

As pointed out in https://github.com/lightning/bolts/pull/754/commits/6656b70,
we can move the `shutdown_scriptpubkey` field into the TLV streams of
`OpenChannel` and `AcceptChannel` without affecting the resulting encoding.

We use `WithoutLength` encoding here to ensure that we do not encode a
length prefix along with `Script` as is normally the case.

13 months agoAllow get_shutdown_scriptpubkey and get_destination_script to return an error
benthecarman [Sat, 22 Apr 2023 05:48:28 +0000 (00:48 -0500)]
Allow get_shutdown_scriptpubkey and get_destination_script to return an error

13 months agoIncorporate low-R values into estimate signature size
benthecarman [Tue, 2 May 2023 07:01:37 +0000 (02:01 -0500)]
Incorporate low-R values into estimate signature size

13 months agoMake `DataLossProtect` fields required and remove wrappers
Duncan Dean [Mon, 1 May 2023 20:23:20 +0000 (22:23 +0200)]
Make `DataLossProtect` fields required and remove wrappers

The fields provided by `DataLossProtect` have been mandatory since
https://github.com/lightning/bolts/pull/754/commits/6656b70, regardless
of whether `option_dataloss_protect` or `option_remote_key` feature bits
are set.

We move the fields out of `DataLossProtect` to make encoding definitions
more succinct with `impl_writeable_msg!` and to reduce boilerplate.

This paves the way for completely removing `OptionalField` in subsequent
commits.

13 months agoMove the `CustomMessageHandler` into the `MessageHandler` struct
Matt Corallo [Sat, 29 Apr 2023 17:58:15 +0000 (17:58 +0000)]
Move the `CustomMessageHandler` into the `MessageHandler` struct

`PeerManager` takes a `MessageHandler` struct which contains all
the known message handlers for it to pass messages to. It then,
separately, takes a `CustomMessageHandler`. This makes no sense, we
should simply include the `CustomMessageHandler` in the
`MessageHandler` struct for consistency.

13 months agoMerge pull request #2245 from TheBlueMatt/2023-04-ping-count-overflow
Wilmer Paulino [Fri, 28 Apr 2023 19:15:02 +0000 (12:15 -0700)]
Merge pull request #2245 from TheBlueMatt/2023-04-ping-count-overflow

Fix overflow in `awaiting_pong_timer...` with too many peers

13 months agoMerge pull request #2217 from alecchendev/2023-04-expose-hash-in-balance
Wilmer Paulino [Fri, 28 Apr 2023 18:11:01 +0000 (11:11 -0700)]
Merge pull request #2217 from alecchendev/2023-04-expose-hash-in-balance

Expose `PaymentHash` and `PaymentPreimage` in `Balance`

13 months agoMerge pull request #2239 from valentinewallace/2023-04-remove-redundant-final-cltv...
Wilmer Paulino [Fri, 28 Apr 2023 17:46:51 +0000 (10:46 -0700)]
Merge pull request #2239 from valentinewallace/2023-04-remove-redundant-final-cltv-param

Remove redundant `final_cltv_delta` param from `get_route`

13 months agoFix overflow in `awaiting_pong_timer...` with too many peers 2023-04-ping-count-overflow
Matt Corallo [Fri, 28 Apr 2023 16:19:04 +0000 (16:19 +0000)]
Fix overflow in `awaiting_pong_timer...` with too many peers

If we have more than
127 / `MAX_BUFFER_DRAIN_TICK_INTERVALS_PER_PEER` (31) peers,
`awaiting_pong_timer_tick_intervals` can overflow before we hit
the limit. This isn't super harmful, we'll still disconnect peers
as long as they don't send *any* messages between two pings, but it
does cause us to not disconnect peers which are extremely slow in
responding to messages, e.g. because they are overloaded.

13 months agoMerge pull request #2230 from freddiekrugerrand/2228-validatechainhash
Matt Corallo [Thu, 27 Apr 2023 23:00:42 +0000 (23:00 +0000)]
Merge pull request #2230 from freddiekrugerrand/2228-validatechainhash

Check chain hash for channel announcement and update

13 months agoMerge pull request #2044 from freddiekrugerrand/1782-limitchannelhints
Matt Corallo [Thu, 27 Apr 2023 22:02:16 +0000 (22:02 +0000)]
Merge pull request #2044 from freddiekrugerrand/1782-limitchannelhints

Limit route hints to three channels

13 months agoRemove redundant final_cltv_delta param from get_route
Valentine Wallace [Thu, 27 Apr 2023 20:49:02 +0000 (16:49 -0400)]
Remove redundant final_cltv_delta param from get_route

PaymentParameters already includes this value.

This set us up to better support route blinding, since there is no known
final_cltv_delta when paying to a blinded route.

13 months agoMerge pull request #2234 from dunxen/2023-04-bpteststemp
Matt Corallo [Wed, 26 Apr 2023 17:49:52 +0000 (17:49 +0000)]
Merge pull request #2234 from dunxen/2023-04-bpteststemp

Use `env::temp_dir()` for BP tests

13 months agoMerge pull request #2229 from TheBlueMatt/2023-04-115-bindings-upstream-2
Matt Corallo [Wed, 26 Apr 2023 17:34:18 +0000 (17:34 +0000)]
Merge pull request #2229 from TheBlueMatt/2023-04-115-bindings-upstream-2

Trivial Bindings Updates

13 months agoMerge pull request #2233 from TheBlueMatt/2023-04-fix-future-leak
Wilmer Paulino [Wed, 26 Apr 2023 17:27:29 +0000 (10:27 -0700)]
Merge pull request #2233 from TheBlueMatt/2023-04-fix-future-leak

Fix a leak in FutureState when a Notifier is dropped un-woken

13 months agoCheck chain hash for channel announcement and update
Fred Walker [Wed, 26 Apr 2023 12:58:05 +0000 (08:58 -0400)]
Check chain hash for channel announcement and update

13 months agoUse `env::temp_dir()` for BP tests
Duncan Dean [Wed, 26 Apr 2023 12:57:18 +0000 (14:57 +0200)]
Use `env::temp_dir()` for BP tests

Currently `BackgroundProcessor` tests create persister directories in the
current working directory and rely on cleaning up in a `Drop` implementation.

Unfortunately, it seems that in the async tests that nodes are not
`drop()`ed for some reason and so the directories created by those
tests remain behind in the current working directory.

This commit at least ensures that these test directories are created in
a temporary location for the OS using `temp_dir()`. It doesn't aim to
solve the lack of cleanup in the async tests.

Partial fix for #2224 but I believe it's enough to resolve it as these
temp directories that do remain will be purged by the OS at some stage
and are overwritten by subsequent tests if there is a conflict.

13 months agoFix a leak in `FutureState` when a `Notifier` is dropped un-woken 2023-04-fix-future-leak
Matt Corallo [Wed, 26 Apr 2023 05:01:13 +0000 (05:01 +0000)]
Fix a leak in `FutureState` when a `Notifier` is dropped un-woken

If a `Notifier` has an internal `FutureState` which gathers some
sleeper callbacks, but is never actaully woken, those callbacks
will leak due to a circular `Arc` reference when the `Notifier` is
`drop`'d.

Because `Notifier`s are rarely `drop`'d in production this isn't a
huge deal, but shows up materially in bindings tests as they spawn
many nodes over the course of a short test.

Fixes #2232

13 months agoHold a reference to the `Arc<FutureState>` when completing futures
Matt Corallo [Wed, 26 Apr 2023 04:29:59 +0000 (04:29 +0000)]
Hold a reference to the `Arc<FutureState>` when completing futures

This will allow us to pass in that state to the callbacks in the
next commit.

13 months agoAdd a bindings constructor for `lightning-invoice`'s `Sha256` wrapper 2023-04-115-bindings-upstream-2
Matt Corallo [Tue, 25 Apr 2023 17:35:24 +0000 (17:35 +0000)]
Add a bindings constructor for `lightning-invoice`'s `Sha256` wrapper

13 months ago[bindings] Disable BOLT12 builders which require move semantics
Matt Corallo [Tue, 25 Apr 2023 06:10:05 +0000 (06:10 +0000)]
[bindings] Disable BOLT12 builders which require move semantics

13 months agoLimit phantom invoice hints to 3
Fred Walker [Thu, 2 Mar 2023 19:37:16 +0000 (14:37 -0500)]
Limit phantom invoice hints to 3

13 months agoMove phantom route hint selection into its own function
Fred Walker [Thu, 2 Mar 2023 19:34:13 +0000 (14:34 -0500)]
Move phantom route hint selection into its own function

13 months agoMerge pull request #2222 from benthecarman/pub-utxo-resolver
Matt Corallo [Tue, 25 Apr 2023 02:01:06 +0000 (02:01 +0000)]
Merge pull request #2222 from benthecarman/pub-utxo-resolver

13 months agoMerge pull request #2211 from TheBlueMatt/2023-04-0.0.115-cut v0.0.115
Matt Corallo [Tue, 25 Apr 2023 00:20:18 +0000 (00:20 +0000)]
Merge pull request #2211 from TheBlueMatt/2023-04-0.0.115-cut

Cut 0.0.115

13 months agoAdd 0.0.115 CHANGELOG entries 2023-04-0.0.115-cut
Matt Corallo [Fri, 21 Apr 2023 23:28:25 +0000 (23:28 +0000)]
Add 0.0.115 CHANGELOG entries

13 months agoBump crate versions to 0.0.115/invoice 0.23
Matt Corallo [Fri, 21 Apr 2023 23:36:43 +0000 (23:36 +0000)]
Bump crate versions to 0.0.115/invoice 0.23

13 months agoMerge pull request #2004 from tnull/2023-02-add-async-bp-example
Matt Corallo [Mon, 24 Apr 2023 22:38:40 +0000 (22:38 +0000)]
Merge pull request #2004 from tnull/2023-02-add-async-bp-example

Add Tokio example to `process_events_async` docs

13 months agoMerge pull request #2209 from TheBlueMatt/2023-04-better-discon-err-msg
Matt Corallo [Mon, 24 Apr 2023 21:22:06 +0000 (21:22 +0000)]
Merge pull request #2209 from TheBlueMatt/2023-04-better-discon-err-msg

Clarify the error message when we disconnect a peer

13 months agoMerge pull request #2220 from TheBlueMatt/2023-04-dont-ban-cln
Matt Corallo [Mon, 24 Apr 2023 21:15:08 +0000 (21:15 +0000)]
Merge pull request #2220 from TheBlueMatt/2023-04-dont-ban-cln

Don't remove nodes if there's no channel_update for a temp failure

13 months agoAdd Tokio example to `process_events_async` docs
Elias Rohrer [Thu, 2 Feb 2023 20:55:58 +0000 (14:55 -0600)]
Add Tokio example to `process_events_async` docs

13 months agoAdd function for updating network graph with announcement with no UTXO resolver
benthecarman [Mon, 24 Apr 2023 13:10:25 +0000 (08:10 -0500)]
Add function for updating network graph with announcement with no UTXO resolver

13 months agoDon't remove nodes if there's no channel_update for a temp failure 2023-04-dont-ban-cln
Matt Corallo [Sun, 23 Apr 2023 16:17:29 +0000 (16:17 +0000)]
Don't remove nodes if there's no channel_update for a temp failure

Previously, we were requiring any `UPDATE` onion errors to include
a `channel_update`, as the spec mandates[1]. If we see an onion
error which is missing one we treat it as a misbehaving node that
isn't behaving according to the spec and simply remove the node.

Sadly, it appears at least some versions of CLN are such nodes, and
opt to not include `channel_update` at all if they're returning a
`temporary_channel_failure`. This causes us to completely remove
CLN nodes from our graph after they fail to forward our HTLC.

While CLN is violating the spec here, there's not a lot of reason
to not allow it, so we go ahead and do so here, treating it simply
as any other failure by letting the scorer handle it.

[1] The spec says `Please note that the channel_update field is
mandatory in messages whose failure_code includes the UPDATE flag`
however doesn't repeat it in the requirements section so its not
crazy that someone missed it when implementing.