rust-lightning
16 months agoMerge pull request #1956 from TheBlueMatt/2023-01-ser-cleanups
Matt Corallo [Wed, 18 Jan 2023 21:31:07 +0000 (21:31 +0000)]
Merge pull request #1956 from TheBlueMatt/2023-01-ser-cleanups

Trivial Serialization Tweaks

16 months agoMerge pull request #1968 from lexe-tech/max/net-tokio-no-arc
Jeffrey Czyz [Wed, 18 Jan 2023 16:26:39 +0000 (10:26 -0600)]
Merge pull request #1968 from lexe-tech/max/net-tokio-no-arc

lightning-net-tokio: Don't require `Arc<PeerManager>`

16 months agolightning-net-tokio: Don't require `Arc<PeerManager>`
Max Fang [Wed, 18 Jan 2023 04:37:10 +0000 (20:37 -0800)]
lightning-net-tokio: Don't require `Arc<PeerManager>`

16 months agoMerge pull request #1962 from TheBlueMatt/2023-01-bp-no-std
Matt Corallo [Tue, 17 Jan 2023 23:48:48 +0000 (23:48 +0000)]
Merge pull request #1962 from TheBlueMatt/2023-01-bp-no-std

Use the user-provided `SleepFuture` for interval checks in `background-processor`

16 months agoMerge pull request #1960 from tnull/2023-01-deref-router-in-invoicepayer
Matt Corallo [Tue, 17 Jan 2023 23:21:22 +0000 (23:21 +0000)]
Merge pull request #1960 from tnull/2023-01-deref-router-in-invoicepayer

Make `InvoicePayer`'s `Router` `Deref`

16 months agoMerge pull request #1957 from TheBlueMatt/2022-01-mon-ref-lockorder
Matt Corallo [Tue, 17 Jan 2023 23:09:05 +0000 (23:09 +0000)]
Merge pull request #1957 from TheBlueMatt/2022-01-mon-ref-lockorder

Pass MonitorUpdates by ref and tweak manager lockorder

16 months agoUse a variable-length integer for many serialization wrappers 2023-01-ser-cleanups
Matt Corallo [Mon, 28 Nov 2022 01:00:38 +0000 (01:00 +0000)]
Use a variable-length integer for many serialization wrappers

The lightning protocol uses u16s for lengths in most cases. As our
serialization framework primarily targets that, we must as well.
However, because we may serialize objects that have  more than 65K
entries, we want to be able to store larger values. Thus, we define
a variable length integer here which is backwards-compatible but
treats 0xffff as "read eight more bytes".

This doesn't address any specific known issue, but feels like good
practice just in case.

16 months agoMake `background-processor` no-std-friendly (ish) 2023-01-bp-no-std
Matt Corallo [Tue, 17 Jan 2023 00:16:48 +0000 (00:16 +0000)]
Make `background-processor` no-std-friendly (ish)

This makes `background-processor` build without `std` at all. This
isn't particularly useful in the general no-std case as
`background-processor` is only useful with the `futures` feature,
and async will generally need `std` in some way or another. Still,
it ensures we don't end up reintroducing a dependency on the
current time, which breaks `wasm` use-cases.

16 months agoMerge pull request #1955 from TheBlueMatt/2023-01-1950-message-text
Matt Corallo [Tue, 17 Jan 2023 17:49:29 +0000 (17:49 +0000)]
Merge pull request #1955 from TheBlueMatt/2023-01-1950-message-text

Fix link text in `reply_short_channel_ids_end`

16 months agoMerge pull request #1963 from lexe-tech/max/derive-debug
Matt Corallo [Tue, 17 Jan 2023 17:03:13 +0000 (17:03 +0000)]
Merge pull request #1963 from lexe-tech/max/derive-debug

derive `Debug` for `ConfirmationTarget`

16 months agoderive `Debug` for `ConfirmationTarget`
Max Fang [Tue, 17 Jan 2023 04:15:01 +0000 (20:15 -0800)]
derive `Debug` for `ConfirmationTarget`

16 months agoMerge pull request #1959 from danielgranhao/stop-passing-init-features-in-msg-handlers
Matt Corallo [Tue, 17 Jan 2023 01:26:31 +0000 (01:26 +0000)]
Merge pull request #1959 from danielgranhao/stop-passing-init-features-in-msg-handlers

Stop passing `InitFeatures` in msg handlers

16 months agoMerge pull request #1939 from TheBlueMatt/2022-01-fuzz-hashbrown
Matt Corallo [Tue, 17 Jan 2023 00:55:37 +0000 (00:55 +0000)]
Merge pull request #1939 from TheBlueMatt/2022-01-fuzz-hashbrown

Misc fuzzing tweaks

16 months agoUse the user-provided `SleepFuture` for interval checks in BP
Matt Corallo [Tue, 17 Jan 2023 00:03:43 +0000 (00:03 +0000)]
Use the user-provided `SleepFuture` for interval checks in BP

`background-processor` does a number of jobs on various timers.
Instead of doing those by interrogating `std::time::Instant`, this
change swaps to using the existing user-provided sleep future.

Fixes #1864.

16 months agoUse flexible timer types in background processor's regular jobs
Matt Corallo [Mon, 16 Jan 2023 23:47:11 +0000 (23:47 +0000)]
Use flexible timer types in background processor's regular jobs

`background-processor` does a number of jobs on various timers.
Currently, those are all done by checking the timers every 100ms
by interrogating `std::time::Instant`. This is fine for the
threaded version, but we'd like more flexibility in the `futures`-
based `background-processor`.

Here we swap the `std::time::Instant` interrogation for a lambda
which we will switch out to the user-provided sleeper in the next
commit.

16 months agoMake `InvoicePayer`'s `Router` `Deref`
Elias Rohrer [Mon, 16 Jan 2023 22:54:53 +0000 (16:54 -0600)]
Make `InvoicePayer`'s `Router` `Deref`

As of HEAD the `ChannelManager` is parametrized by a `Router`, while
`InvoicePayer` also owns a `Router`. In order to allow for a single
object being reused, we make the `InvoicePayer` side `Deref`.

16 months agoStop passing `InitFeatures` in msg handlers
Daniel Granhão [Mon, 16 Jan 2023 20:34:59 +0000 (20:34 +0000)]
Stop passing `InitFeatures` in msg handlers

16 months agoSwap per_peer_state lock order 2022-01-mon-ref-lockorder
Matt Corallo [Thu, 12 Jan 2023 02:14:20 +0000 (02:14 +0000)]
Swap per_peer_state lock order

16 months agoPass monitor updates by reference, not owned
Matt Corallo [Sat, 12 Nov 2022 18:26:38 +0000 (18:26 +0000)]
Pass monitor updates by reference, not owned

In the next commit(s) we'll start holding `ChannelMonitorUpdate`s
that are being persisted in `Channel`s until they're done
persisting. In order to do that, switch to applying the updates by
reference instead of value.

16 months agoUse `ChannelUnavailable` for a peer disconnecting not `MisuseError` 2022-01-fuzz-hashbrown
Matt Corallo [Sun, 15 Jan 2023 23:37:00 +0000 (23:37 +0000)]
Use `ChannelUnavailable` for a peer disconnecting not `MisuseError`

This fixes a crash in the `full_stack_target` fuzz test (found by
Chaincode's generous fuzzing infrastructure!) but ultimately is a
better error code - a peer disconnecting before we can fund a
channel isn't a "misuse error" its an unavailable channel.

16 months agoMake fuzz assertions explicit in Cargo.toml
Matt Corallo [Fri, 6 Jan 2023 20:11:27 +0000 (20:11 +0000)]
Make fuzz assertions explicit in Cargo.toml

16 months agoDo not rely on auto-deref'ing when aaccessing a `Hash{Map,Set}`
Matt Corallo [Fri, 6 Jan 2023 20:05:07 +0000 (20:05 +0000)]
Do not rely on auto-deref'ing when aaccessing a `Hash{Map,Set}`

In newer versions of `hashbrown` this code would be broken. While
we aren't updating `hashbrown` any time soon (as it requires an
MSRV bump), it is useful to swap for a newer `hashbrown` when
fuzzing, which this makes easier.

16 months agoSwitch to hashbrown in fuzzing
Matt Corallo [Fri, 6 Jan 2023 19:53:47 +0000 (19:53 +0000)]
Switch to hashbrown in fuzzing

hashbrown by default uses ahash, which may be a bit faster, but
more importantly, if we upgrade to hashbrown 0.13/ahash 0.8 we can
make it use a constant randomization factor, making fuzzers happier.

16 months agoBump fuzz `afl` dependency to latest upstream version
Matt Corallo [Fri, 6 Jan 2023 19:52:24 +0000 (19:52 +0000)]
Bump fuzz `afl` dependency to latest upstream version

16 months agoConvert `Vec` de/serialization impl to a macro and impl for tuples
Matt Corallo [Mon, 28 Nov 2022 00:42:15 +0000 (00:42 +0000)]
Convert `Vec` de/serialization impl to a macro and impl for tuples

...to make it easier to add new implementations and implement it
for all tuples which implement `Readabe` + `Writeable`. Note that
we don't want to just convert to a blanket implementation as we'd
really like to keep our optimized `Vec<u8>` wrapper or we'll end
up spinning way too much when writing vecs of bytes.

16 months agoAdd support for including `ignorable` types in enum de/ser macros
Matt Corallo [Tue, 22 Nov 2022 22:41:13 +0000 (22:41 +0000)]
Add support for including `ignorable` types in enum de/ser macros

An enum implements de/serialization via
`impl_writeable_tlv_based_enum_upgradable` currently cannot contain
an object that only implements `MaybeReadable`.

This solves that by implementing the required blocks for
`ignorable`, opting to return `Ok(None)` in the top-level read in
cases where the inner field read returns `Ok(None)`.

16 months agoImplement (de)serialization for BTreeMap same as HashMap
Matt Corallo [Tue, 22 Nov 2022 21:55:39 +0000 (21:55 +0000)]
Implement (de)serialization for BTreeMap same as HashMap

16 months agoFix link text in `reply_short_channel_ids_end` 2023-01-1950-message-text
Matt Corallo [Sun, 15 Jan 2023 07:01:30 +0000 (07:01 +0000)]
Fix link text in `reply_short_channel_ids_end`

16 months agoMerge pull request #1950 from tnull/2023-01-fix-doc-warnings-and-nits
Matt Corallo [Sun, 15 Jan 2023 07:03:14 +0000 (07:03 +0000)]
Merge pull request #1950 from tnull/2023-01-fix-doc-warnings-and-nits

Fix doc warnings and doc cleanup in `msgs.rs`/`ser.rs`

16 months agoMerge pull request #1946 from wpaulino/init-features-user-config
Matt Corallo [Sun, 15 Jan 2023 04:00:11 +0000 (04:00 +0000)]
Merge pull request #1946 from wpaulino/init-features-user-config

Use UserConfig to determine advertised InitFeatures by ChannelManager

16 months agoMerge pull request #1953 from arik-so/2023-01-debug-gossip-heisenbug
Matt Corallo [Sat, 14 Jan 2023 22:43:26 +0000 (22:43 +0000)]
Merge pull request #1953 from arik-so/2023-01-debug-gossip-heisenbug

16 months agoAllow manually passing a timestamp to `channel_failed`. Fixes #1914.
Arik Sosman [Sat, 14 Jan 2023 16:22:50 +0000 (08:22 -0800)]
Allow manually passing a timestamp to `channel_failed`. Fixes #1914.

16 months agoAdd error messages to stale gossip cleanup assertions.
Arik Sosman [Sat, 14 Jan 2023 15:17:12 +0000 (07:17 -0800)]
Add error messages to stale gossip cleanup assertions.

Should help debug #1914.

16 months agoUse UserConfig to determine advertised InitFeatures by ChannelManager
Wilmer Paulino [Wed, 11 Jan 2023 18:21:29 +0000 (10:21 -0800)]
Use UserConfig to determine advertised InitFeatures by ChannelManager

This is purely a refactor that does not change the InitFeatures
advertised by a ChannelManager. This allows users to configure which
features should be advertised based on the values of `UserConfig`. While
there aren't any existing features currently leveraging this behavior,
it will be used by the upcoming anchors_zero_fee_htlc_tx feature.

The UserConfig dependency on provided_init_features caused most
callsites of the main test methods responsible for opening channels to
be updated. This commit foregos that completely by no longer requiring
the InitFeatures of each side to be provided to these methods. The
methods already require a reference to each node's ChannelManager to
open the channel, so we use that same reference to obtain their
InitFeatures. A way to override such features was required for some
tests, so a new `override_init_features` config option now exists on
the test harness.

16 months agoMerge pull request #1930 from arik-so/2022-12-remove-keysinterface
Matt Corallo [Sat, 14 Jan 2023 04:59:27 +0000 (04:59 +0000)]
Merge pull request #1930 from arik-so/2022-12-remove-keysinterface

Remove KeysInterface

16 months agoFix misc. warnings from `--document-private-items`
Elias Rohrer [Fri, 13 Jan 2023 22:02:41 +0000 (16:02 -0600)]
Fix misc. warnings from `--document-private-items`

16 months agoFix docs and export `impl_tlv_based_enum` variants
Elias Rohrer [Fri, 13 Jan 2023 21:54:14 +0000 (15:54 -0600)]
Fix docs and export `impl_tlv_based_enum` variants

16 months agoFix misc doc warnings.
Elias Rohrer [Fri, 13 Jan 2023 15:18:34 +0000 (09:18 -0600)]
Fix misc doc warnings.

16 months agoFix doc warnings and cleanup in `msgs.rs`
Elias Rohrer [Fri, 13 Jan 2023 15:18:26 +0000 (09:18 -0600)]
Fix doc warnings and cleanup in `msgs.rs`

16 months agoFix doc warnings and cleanup in `ser.rs`
Elias Rohrer [Fri, 13 Jan 2023 13:16:18 +0000 (07:16 -0600)]
Fix doc warnings and cleanup in `ser.rs`

16 months agoDecouple lifetimes for trait implementations that used to comprise KeysInterface.
Arik Sosman [Fri, 13 Jan 2023 00:10:44 +0000 (16:10 -0800)]
Decouple lifetimes for trait implementations that used to comprise KeysInterface.

16 months agoSplit up generic parameters that used to comprise KeysInterface.
Arik Sosman [Tue, 20 Dec 2022 22:46:08 +0000 (14:46 -0800)]
Split up generic parameters that used to comprise KeysInterface.

16 months agoRemove KeysInterface trait.
Arik Sosman [Tue, 20 Dec 2022 22:46:08 +0000 (14:46 -0800)]
Remove KeysInterface trait.

16 months agoMerge pull request #1823 from mariocynicys/expose-tlv-macros2
Matt Corallo [Wed, 11 Jan 2023 21:02:25 +0000 (21:02 +0000)]
Merge pull request #1823 from mariocynicys/expose-tlv-macros2

Expose `impl_writeable_tlv_based` macro

16 months agoMerge pull request #1507 from ViktorTigerstrom/2022-05-store-channels-per-peer
Matt Corallo [Tue, 10 Jan 2023 19:19:35 +0000 (19:19 +0000)]
Merge pull request #1507 from ViktorTigerstrom/2022-05-store-channels-per-peer

Store `channels` per-peer

16 months agoMerge pull request #1944 from TheBlueMatt/2022-01-lockorder-windows-robust
Matt Corallo [Tue, 10 Jan 2023 19:19:25 +0000 (19:19 +0000)]
Merge pull request #1944 from TheBlueMatt/2022-01-lockorder-windows-robust

Make `debug_sync` regex more robust

16 months agoMerge pull request #1943 from andrei-21/feature/handle-read-dir-errors
Matt Corallo [Tue, 10 Jan 2023 17:23:31 +0000 (17:23 +0000)]
Merge pull request #1943 from andrei-21/feature/handle-read-dir-errors

Handle `read_dir()` errors in persister

16 months agoMake `debug_sync` regex more robust 2022-01-lockorder-windows-robust
Matt Corallo [Tue, 10 Jan 2023 06:37:39 +0000 (06:37 +0000)]
Make `debug_sync` regex more robust

On windows the symbol names appear to sometimes be truncated,
which causes the symbol name to not include the `::new` at the end.
This causes the regex to mis-match and track the wrong location
for the mutex construction, leading to bogus lockorder violations.

For example, in testing the following symbol name appeared on
Windows, without the function name itself:

`lightning::debug_sync::RwLock<std::collections::hash::map::HashMap<lightning::chain::transaction::OutPoint,lightning::chain::chainmonitor::MonitorHolder<lightning::util::enforcing_trait_impls::EnforcingSigner>,std::collections::hash::map::RandomState> >::`

16 months agoMove tests from debug_sync to a new submodule
Matt Corallo [Tue, 10 Jan 2023 06:34:30 +0000 (06:34 +0000)]
Move tests from debug_sync to a new submodule

This will allow us to change the module regex match in debug_sync
to make it more robust.

16 months agoMove `debug_sync` to the new `sync` folder
Matt Corallo [Tue, 10 Jan 2023 06:29:58 +0000 (06:29 +0000)]
Move `debug_sync` to the new `sync` folder

16 months agoMove `no-std` sync implementations to a folder to clean up
Matt Corallo [Tue, 10 Jan 2023 06:26:46 +0000 (06:26 +0000)]
Move `no-std` sync implementations to a folder to clean up

16 months agoHandle read_dir() errors in persister
Andrei [Tue, 10 Jan 2023 00:00:00 +0000 (00:00 +0000)]
Handle read_dir() errors in persister

16 months agoRemove the `ChannelManager::channel_state`
Viktor Tigerström [Fri, 6 Jan 2023 23:31:10 +0000 (00:31 +0100)]
Remove the `ChannelManager::channel_state`

16 months agoExpect `pending_msg_events` to be in random peer order in tests
Viktor Tigerström [Tue, 3 Jan 2023 09:52:10 +0000 (10:52 +0100)]
Expect `pending_msg_events` to be in random peer order in tests

16 months agoStore `pending_msg_events` per peer
Viktor Tigerström [Mon, 19 Dec 2022 19:51:07 +0000 (20:51 +0100)]
Store `pending_msg_events` per peer

16 months agoUse correct node in `test_invalid_upfront_shutdown_script`
Viktor Tigerström [Tue, 3 Jan 2023 09:52:41 +0000 (10:52 +0100)]
Use correct node in `test_invalid_upfront_shutdown_script`

16 months agoAvoid unnecessary looping over all peers' channels
Viktor Tigerström [Sat, 10 Dec 2022 22:02:00 +0000 (23:02 +0100)]
Avoid unnecessary looping over all peers' channels

16 months agoUpdate `id_to_peer` docs with consistency guarantees info
Viktor Tigerström [Sat, 10 Dec 2022 21:20:05 +0000 (22:20 +0100)]
Update `id_to_peer` docs with consistency guarantees info

16 months agoRemove one tab level when accessing a `peer_state`
Viktor Tigerström [Sat, 10 Dec 2022 17:54:01 +0000 (18:54 +0100)]
Remove one tab level when accessing a `peer_state`

16 months agoRemove unnecessary channel counterparty checks
Viktor Tigerström [Sat, 10 Dec 2022 17:03:22 +0000 (18:03 +0100)]
Remove unnecessary channel counterparty checks

16 months agoAdd handle unkown peer test
Viktor Tigerström [Mon, 13 Jun 2022 19:24:51 +0000 (21:24 +0200)]
Add handle unkown peer test

16 months agoAdd duplicate temporary_channel_id for 2 peers test
Viktor Tigerström [Tue, 31 May 2022 19:20:55 +0000 (21:20 +0200)]
Add duplicate temporary_channel_id for 2 peers test

16 months agoUnify failure to query `Channel` error messages
Viktor Tigerström [Mon, 6 Jun 2022 21:57:24 +0000 (23:57 +0200)]
Unify failure to query `Channel` error messages

16 months agoAvoid unnecessary immediate retake `per_peer_state` lock
Viktor Tigerström [Thu, 8 Dec 2022 23:59:21 +0000 (00:59 +0100)]
Avoid unnecessary immediate retake `per_peer_state` lock

16 months agoRemove unnecessary `per_peer_state` branch
Viktor Tigerström [Fri, 10 Jun 2022 00:01:36 +0000 (02:01 +0200)]
Remove unnecessary `per_peer_state` branch

After `channels` are now stored in the `per_peer_state`, some logic can
be simplified and extra accessing of the `per_peer_state` can be
removed.

16 months agoStore channels per peer
Viktor Tigerström [Sat, 26 Nov 2022 08:02:20 +0000 (09:02 +0100)]
Store channels per peer

16 months agoMerge pull request #1941 from andrei-21/feature/rework-unwrap
Matt Corallo [Mon, 9 Jan 2023 19:35:57 +0000 (19:35 +0000)]
Merge pull request #1941 from andrei-21/feature/rework-unwrap

Rework `unwrap()` call in persistence

16 months agoFix an incorrect assertion in tlv stream encoding
Omer Yacine [Wed, 2 Nov 2022 15:32:47 +0000 (17:32 +0200)]
Fix an incorrect assertion in tlv stream encoding

Types must be unique and monotonically increasing (using < instead of <=)

16 months agoExpose `impl_writeable_tlv_based` macro
Omer Yacine [Fri, 6 Jan 2023 08:18:26 +0000 (10:18 +0200)]
Expose `impl_writeable_tlv_based` macro

Every exported macro needed to have all the macros used inside it:
1- to be exported as well.
2- be called from the `$crate` namespace so it works in other crates.

Some structs in `lightning::util::ser` needed to be made public as they were used inside the exported macros.

Use the macros like this:
```Rust
lightning::impl_writeable_tlv_based!(...)
```

16 months agoMerge pull request #1940 from TheBlueMatt/2023-01-nostd-try-lock
Matt Corallo [Mon, 9 Jan 2023 16:22:34 +0000 (16:22 +0000)]
Merge pull request #1940 from TheBlueMatt/2023-01-nostd-try-lock

16 months agoRework unwrap() call in persistence
Andrei [Sun, 8 Jan 2023 00:00:00 +0000 (00:00 +0000)]
Rework unwrap() call in persistence

16 months agoMake the no-std `RwLockGuard` `try_lock` actually try 2023-01-nostd-try-lock
Matt Corallo [Sat, 7 Jan 2023 20:11:05 +0000 (20:11 +0000)]
Make the no-std `RwLockGuard` `try_lock` actually try

There doesn't appear to be any reason to have `try_lock` fail, and
future work shouldn't need to check for std to use `try_lock`.

16 months agoAdd `try_write` function to `FairRwLock`
Viktor Tigerström [Thu, 8 Dec 2022 21:40:54 +0000 (22:40 +0100)]
Add `try_write` function to `FairRwLock`

16 months agoAdd `ChannelManager::PeerState::latest_features` docs
Viktor Tigerström [Sat, 26 Nov 2022 07:47:11 +0000 (08:47 +0100)]
Add `ChannelManager::PeerState::latest_features` docs

16 months agoAdd `counterparty_node` to test macros
Viktor Tigerström [Fri, 27 May 2022 18:14:19 +0000 (20:14 +0200)]
Add `counterparty_node` to test macros

16 months agoMerge pull request #1927 from jkczyz/2022-12-invoice-rework
valentinewallace [Fri, 6 Jan 2023 16:07:17 +0000 (11:07 -0500)]
Merge pull request #1927 from jkczyz/2022-12-invoice-rework

Pre-work for BOLT 12 invoices

16 months agoDefine blinded hop features for use in BOLT 12
Jeffrey Czyz [Fri, 16 Dec 2022 20:06:33 +0000 (14:06 -0600)]
Define blinded hop features for use in BOLT 12

BOLT 12 invoices may contain blinded_payinfo for each hop in a blinded
path. Each blinded_payinfo contains features, whose length must be
encoded since there may be multiple hops.

Note these features are also needed in the BOLT 4 encrypted_data_tlv
stream. But since they are a single TLV record, the length must *not* be
encoded there.

16 months agoDefine BOLT 12 invoice features with MPP support
Jeffrey Czyz [Thu, 15 Dec 2022 03:18:13 +0000 (21:18 -0600)]
Define BOLT 12 invoice features with MPP support

16 months agoUse explicit WithoutLength for BOLT 12 features
Jeffrey Czyz [Fri, 16 Dec 2022 19:35:50 +0000 (13:35 -0600)]
Use explicit WithoutLength for BOLT 12 features

Most BOLT 12 features are used as the value of a TLV record and thus
don't use an explicit length. One exception is the features inside the
blinded payinfo subtype since the TLV record contains a list of them.
However, these features are also used in the BOLT 4 encrypted_data_tlv
TLV stream as a single record, where the length is implicit.

Implement Readable and Writeable for Features wrapped in WithoutLength
such that either serialization can be used where required.

16 months agoRemove Option from InvoiceRequest::signature
Jeffrey Czyz [Wed, 14 Dec 2022 23:51:04 +0000 (17:51 -0600)]
Remove Option from InvoiceRequest::signature

Refunds don't have signatures and now use their own abstraction.
Therefore, signatures can be required in invoice requests as per the
spec.

16 months agoCorrect documentation about Refund::payer_id
Jeffrey Czyz [Tue, 20 Dec 2022 04:33:01 +0000 (22:33 -0600)]
Correct documentation about Refund::payer_id

The docs incorrectly stated that Refund::payer_id is for signing, where
it is only used for identifying a node if Refund::paths is not present.

16 months agoMerge pull request #1812 from valentinewallace/2022-10-chanman-router-param
Matt Corallo [Thu, 5 Jan 2023 22:09:35 +0000 (22:09 +0000)]
Merge pull request #1812 from valentinewallace/2022-10-chanman-router-param

Parameterize `ChannelManager` by a `Router`

16 months agoTest utils: allow queueing >2 persistence update results
Valentine Wallace [Wed, 21 Dec 2022 20:45:57 +0000 (15:45 -0500)]
Test utils: allow queueing >2 persistence update results

16 months agoser_macros: rename check_tlv_order
Valentine Wallace [Fri, 30 Dec 2022 23:50:26 +0000 (18:50 -0500)]
ser_macros: rename check_tlv_order

.. to disamgibutate from check_encoded_tlv_order

16 months agoProvide a `static_value` TLV field serialization type
Matt Corallo [Thu, 20 Oct 2022 19:41:38 +0000 (19:41 +0000)]
Provide a `static_value` TLV field serialization type

This is useful in the type serialization definition macros to avoid
writing or reading a field at all, simply using a static value on
each reload.

16 months agoParameterize Simple*ChannelManager with DefaultRouter and ProbScorer
Valentine Wallace [Thu, 22 Dec 2022 01:43:02 +0000 (20:43 -0500)]
Parameterize Simple*ChannelManager with DefaultRouter and ProbScorer

16 months agoTake in-flight HTLCs by reference in Router::find_route
Valentine Wallace [Mon, 19 Dec 2022 05:26:58 +0000 (00:26 -0500)]
Take in-flight HTLCs by reference in Router::find_route

Useful in upcoming work when for payment retries.

16 months agoImplement routing against the netgraph in tests
Valentine Wallace [Tue, 29 Nov 2022 20:16:47 +0000 (15:16 -0500)]
Implement routing against the netgraph in tests

16 months agoMerge pull request #1935 from TheBlueMatt/2022-12-no-non-time-panic
Matt Corallo [Tue, 3 Jan 2023 22:02:04 +0000 (22:02 +0000)]
Merge pull request #1935 from TheBlueMatt/2022-12-no-non-time-panic

Ensure derive_channel_keys doesn't panic if per-run seed is high

16 months agoParameterize ChannelManager by a Router trait
Valentine Wallace [Fri, 28 Oct 2022 15:31:24 +0000 (11:31 -0400)]
Parameterize ChannelManager by a Router trait

This will be used in upcoming work to fetch routes on-the-fly for payment
retries, which will no longer be the responsibility of InvoicePayer.

16 months agoEnsure the per-channel key derivation counter doesn't role over 2022-12-no-non-time-panic
Matt Corallo [Wed, 28 Dec 2022 18:12:29 +0000 (18:12 +0000)]
Ensure the per-channel key derivation counter doesn't role over

Previously, the `derive_channel_keys` derivation ID asserted that
the high bit of the per-channel key derivation counter doesn't
role over as it checked the 31st bit was zero. As we no longer do
that, we should ensure the assertion in `generate_channel_keys_id`
asserts that we don't role over.

16 months agoMerge pull request #1934 from TheBlueMatt/2022-12-113-bindings-upstream
Matt Corallo [Tue, 3 Jan 2023 17:06:37 +0000 (17:06 +0000)]
Merge pull request #1934 from TheBlueMatt/2022-12-113-bindings-upstream

Trivial Bindings Updates

16 months agoMerge pull request #1936 from TheBlueMatt/2023-01-in-flight-clone
Matt Corallo [Tue, 3 Jan 2023 16:43:18 +0000 (16:43 +0000)]
Merge pull request #1936 from TheBlueMatt/2023-01-in-flight-clone

`#[derive(Clone)]` for `InFlightHtlcs`

16 months ago`#[derive(Clone)]` for `InFlightHtlcs` 2023-01-in-flight-clone
Matt Corallo [Mon, 2 Jan 2023 01:07:59 +0000 (01:07 +0000)]
`#[derive(Clone)]` for `InFlightHtlcs`

This is useful for bindings, and generally isn't a bad thing for
users to have access to.

17 months agoEnsure `derive_channel_keys` doesn't panic if per-run seed is high
Matt Corallo [Wed, 28 Dec 2022 17:44:33 +0000 (17:44 +0000)]
Ensure `derive_channel_keys` doesn't panic if per-run seed is high

b04d1b868fe28bea2e4c711e6e6d2470d2b98d77 changed the way we
calculate the `channel_keys_id` to include the 128-bit
`user_channel_id` as well, shifting the counter up four bytes and
the `starting_time_nanos` field up into the second four bytes.

In `derive_channel_keys` we hash the full `channel_keys_id` with an
HD-derived key from our master seed. Previously, that key was
derived with an index of the per-restart counter, re-calculated by
pulling the second four bytes out of the `user_channel_id`. Because
the `channel_keys_id` fields were shifted up four bytes, that is
now a reference to the `starting_time_nanos` value. This should be
fine, the derivation doesn't really add any value here, its all
being hashed anyway, except that derivation IDs must be below 2^31.
This implies that we panic if the user passes a
`starting_time_nanos` which has the high bit set. For those using
the nanosecond part of the current time this isn't an issue - the
value cannot exceed 1_000_000, which does not have the high bit
set, however, some users may use some other per-run seed.

Thus, here we simply drop the high bit from the seed, ensuring we
don't panic. Note that this is backwards compatible as it only
changes the key derivation in cases where we previously panicked.

Ideally we'd drop the derivation entirely, but that would break
backwards compatibility of key derivation.

17 months agoNo-export `&self` methods on non-cloneable enum(s) 2022-12-113-bindings-upstream
Matt Corallo [Fri, 23 Dec 2022 20:44:24 +0000 (20:44 +0000)]
No-export `&self` methods on non-cloneable enum(s)

Specifically, `OnionMessageContents` is a non-cloneable enum, which
isn't stored opaque so we cannot call `&self` methods on it.
Because its methods aren't critical to the API for now, we simply
no-export them rather than trying to work out an alternative
approach.

17 months agoStore an owned `Score` in `ScorerAccountingForInFlightHtlcs`
Matt Corallo [Thu, 22 Dec 2022 21:58:53 +0000 (21:58 +0000)]
Store an owned `Score` in `ScorerAccountingForInFlightHtlcs`

`ScorerAccountingForInFlightHtlcs` generally stores a `Score`
reference generated by calling `LockableScore::lock`, which
actually returns an arbitrary `Score`. Given `Score` is implemented
directly on lock types, it makes sense to simply hold a fully owned
`Score` in `ScorerAccountingForInFlightHtlcs` rather than a mutable
reference to one.

17 months agoMerge pull request #1929 from valentinewallace/2022-12-outbound-payment-mod-followup
Matt Corallo [Wed, 21 Dec 2022 23:08:58 +0000 (23:08 +0000)]
Merge pull request #1929 from valentinewallace/2022-12-outbound-payment-mod-followup

Outbound payment module follow-up

17 months agooutbound_payment: put method signature closing paren on next line
Valentine Wallace [Tue, 20 Dec 2022 23:20:53 +0000 (18:20 -0500)]
outbound_payment: put method signature closing paren on next line

in long method signatures

17 months agoMerge pull request #1931 from TheBlueMatt/2022-12-1910-followups
Arik [Wed, 21 Dec 2022 19:05:09 +0000 (11:05 -0800)]
Merge pull request #1931 from TheBlueMatt/2022-12-1910-followups

Trivial #1910 Followups